About | Rules and Guide | Sign In/Create Account | Write a Post
Construction1990’s Internet Montage? No!
Please excuse the site weirdness. Mike is fixing and making things.
Ludum Dare 31 — Coming December 5th-8th 2014!

  • ??? Begins: in 8 days, 23 hours, 50 minutes, 46 seconds
  • October Ends: in 10 days, 0 hours, 2 minutes, 46 seconds
  • Ludum Dare 31 begins: in 45 days, 0 hours, 50 minutes, 46 seconds
  • (FYI: Clock might be off) | Ludum Dare 31: Real World Gatherings (Now Open!)

    [ October Challenge 2014 | Resources | Submit/Edit | View All ]

    2D Tile Engine!

    Posted by
    April 30th, 2011 7:37 am


    Just a few demos using only 10×10 tiles:

    How it happens:
    A 10×10 tile is created using a boolean array:

    for(int i=0;i<10;i++){
    	for(int j=0;j<10;j++){
     		tiles[i,j] = (Random.Range(0.0f,1.0f)>=0.5f);

    Then each tile checks its surrounding tiles and records the environment status into a flag:

    byte getFlagsForTile(int i, int j){
    	byte result = 0;
    	int curPos = 0;
    	for(int k=-1;k<=1;k++){
    		for(int l=-1;l<=1;l++){
    	return result;

    Based on this flag system:

    So if the flag’s first bit is 1, that means there’s a tile on the lower right of this tile.

    Using the flag as a guide, the tile can then pick its graphics from this sprite sheet:


    That’s it … also I will use the flag information to generate collision.

    One Response to “2D Tile Engine!”

    1. snowyowl says:

      Wow. That is an awesome sprite sheet.

    Leave a Reply

    You must be logged in to post a comment.

    All posts, images, and comments are owned by their creators.

    [cache: storing page]