Tile Map Editor

Libraries, utilities, bootloaders...

Re: Tile Map Editor

Postby albertinjo » Sat Jul 25, 2015 11:53 am

This project is great!
I plan using this in my further game development.
Keep up the good work!
User avatar
albertinjo
 
Posts: 98
Joined: Wed Mar 26, 2014 2:26 pm

Re: Tile Map Editor

Postby Summoner123 » Sat Jul 25, 2015 7:52 pm

hehe... Thanks all.


I'm trying to implement the "bitmap encoder" inside my Software, that's work for 8x8 or smaller (monochromatic 's)
sprites, after that it bug (if width go over 8 pixel's, in Height over 8 lines I thinks that work fine), this routine need to be optimized in the future.

I have made a video to demonstrate the implementation of "bitmap Encoder" on the code generator, and it working with arduino IDE and Simbuino:

https://www.youtube.com/watch?v=5CQx2Olnsng

At the final of video it's possible to see a little bug, it's occurs when I try save the new .gtm file
over the loaded file (overwrite), the Error Log say: It's not possible access the file why it still in use for other process
But the "other Process" is in the same Program. I was told to try the .dispose() but I haven't tried yet.
If you save with other file name (no Overwrite) it work very Well.

ps: The program don't Crash!, if you click "Continue" it go on without any apparent problem

When I fix this Bug I will put here to Download the program and Source Code commented, in this way someone who wants give me some help with this routine's (or modify then) can start where I Stoped...huehuehue
User avatar
Summoner123
 
Posts: 26
Joined: Fri Mar 20, 2015 12:35 am

Re: Tile Map Editor

Postby Marcus » Sat Jul 25, 2015 8:52 pm

That looks great, I'm looking forward to it!
This'll save a lot of work.
Marcus
 
Posts: 143
Joined: Fri Jan 09, 2015 6:51 pm

Re: Tile Map Editor

Postby Summoner123 » Mon Jul 27, 2015 12:21 am

One little more Update:

- Overwrite Save Bug Fixed (I forget the use of system.IO.streamWriter.close() to end the "load" process)
- Add "Replace Sprite" Button, it change the current Sprite (in all tileMap) to other, so it's possible to
change all the trees or all the floor with two click's.
- Add "Remove Sprite" button, it can remove from all tile map the current sprite (replace with void tile)
- Add "Draw Selected Tiles" button, with it, you can select one area (linear or no) holding "Ctrl", when you click
in this button, the current sprite will be placed in the selected area (useful to draw the floor... rsrs)


It's all for now...
In this software still have a several things to do, but I will give a break in the "improvement" of this program (busy at this time).

The last Version you can download here:


Source (comented):TileMapSource BETA V1.02.rar
Executable in the "Bin->Release" Folder


One pic of a 30x30 tilemap (tile 8x8) than I have made:


Image



the result (without any collision routine):

Image
(I'm really bad to draw sprite... XD)
User avatar
Summoner123
 
Posts: 26
Joined: Fri Mar 20, 2015 12:35 am

Re: Tile Map Editor

Postby Sorunome » Mon Jul 27, 2015 9:30 am

Looking awesome!

Also, you'll have to adjust the output as I changed a bit on how drawTIlemap is working, more about that here: viewtopic.php?f=12&t=3213#p10002
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Tile Map Editor

Postby Summoner123 » Thu Jul 30, 2015 5:24 pm

Sorunome wrote:Looking awesome!

Also, you'll have to adjust the output as I changed a bit on how drawTIlemap is working, more about that here: viewtopic.php?f=12&t=3213#p10002



Hi Sorunome.

Yes, I will do it, thanks for warn me.


Edit:

Software update to the new data layout of drawtilemap()
It "get" the size of first tile loaded, so is important the use of same size in all tiles.

This tile Map.

Image

Resulted in this code generated.

Code: Select all
  const byte tilemap[] PROGMEM = {10,10,
 8, 8,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0,77,77, 0, 0, 0, 0,
 0, 0, 0,77,77,77,77, 0, 0, 0,
 0, 0,77,77, 1, 1,77,77, 0, 0,
 0,77,77, 1, 1, 1, 1,77,77, 0,
 0,77,77, 1, 1, 1, 1,77,77, 0,
 0, 0,77,77, 1, 1,77,77, 0, 0,
 0, 0, 0,77,77,77,77, 0, 0, 0,
 0, 0, 0, 0,77,77, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ;

const byte arvore[] PROGMEM = {   
B00010000,
B00101000,
B01000100,
B10000010,
B10000010,
B01101100,
B00101000,
B01010100 } ;

const byte grass1[] PROGMEM = {   
B00000000,
B01000100,
B00100010,
B00011001,
B01000000,
B00000100,
B00100010,
B00000000 } ;


const byte *spritesheet[] = {   arvore,grass1 } ;
 


77 is the voidtile, take care about it, It may appear some garbage on the screen if the drawtilemap() try to render a void tile.
It occurs why the index of a matriz is one point of reference in the memory adress, so Spritesheet[77] can refer to a memory location where is saved other thing.
I would not recommend leave voidtiles


Download:TileMapBeta V1.02.rar
Executable in the Bin->Release



A little OFF-Topic coment (about drawTilemap())

I have a take a look at the gb.display.drawtilemap, and I tried to add some list of sprites drawn in the display,
My idea is use this "mapping" for colision (example), so I have add two variables in the display.h:

Code: Select all
   typedef struct{         //line 171 "Public Variables
  int x;                    //X coordinate
  int y;                    //Y coordinate
  const byte *spritecol;    //Sprite of object
  }object;
  object solid[60];

  byte numcolision = 0;    //count of solid objects


So now I have access to gb.display.numcolision (number of sprites on the display)
and access to gb.display.solid[index].x (or y, or the sprite of index object)

And I add this lines to display.cpp:

Code: Select all
   numcolision = 0;                                 //Line 735 - clear numcolision
    for(uint8_t ddy = startDdy;ddy < maxDdy;ddy++){
        for(uint8_t ddx = startDdx;ddx < maxDdx;ddx++){
            int8_t drawX = ddx*tile_width + x + dx;
            int8_t drawY = ddy*tile_height + y + dy;
            uint8_t tile = pgm_read_byte(tilemap + ddy*tilemap_width + ddx);
            if(drawX >= dx && drawY >= dy && drawX <= (ddw-tile_width) && drawY <= (ddh-tile_height)){
                drawBitmap(drawX,drawY,spritesheet[tile]);
            
            solid[numcolision].x = drawX;                     //Save X coordinate
            solid[numcolision].y = drawY;                     //Save Y coordinate
            solid[numcolision].spritecol = spritesheet[tile]; //Save Sprite of tile
            numcolision++;                                    //Increment numcolision
            
            }else{ // we need to draw a partial bitmap
                drawBitmap(drawX,drawY,spritesheet[tile],dx,dy,dw,dh);
            }
        }
    }


With this routine I can save the X,y and sprites of all tiles rendered (non partial), I think is possible to concat this with
physics (collide) library, to add some collision to drawTilemap() (it's possible?).

I checked the data received from each tile, and appear to be right, but I can't get the collideBitmapBitmap() to work... :?

EDIT:

I got it! Collision working with tilemapDraw()...

Revising the collideBitmapBitmap() code I can see the problem, it get the Width and Heigth of Bitmap using the two initial bytes of sprites,
this bytes was removed in update of Drawtilemap(), so it did not work, I have changed to gb.collideRectRect() and it Work.

Take a look:

Code: Select all
for(i=0; i < gb.display.numcolision + 1; i++)
   {
    if(gb.collideRectRect(player.posx,player.posy,8,8,gb.display.solid[i].x,gb.display.solid[i].y,8,8))
    {
          if(gb.display.solid[i].spritecol == floor1); //Do nothing because it's floor
else      if(gb.display.solid[i].spritecol == arvore)gb.popup(F("Tree"),10);
else      if(gb.display.solid[i].spritecol == agua2 )gb.popup(F("Water"),10);
else      if(gb.display.solid[i].spritecol == agua3 )gb.popup(F("Water"),10);
else      if(gb.display.solid[i].spritecol == tijolo)gb.popup(F("Brick"),10);

      }   
  } 
   
    if(gb.buttons.repeat(BTN_B,1))
    {
      gb.display.print("CPU Load: ");
      gb.display.print(gb.getCpuLoad());
      gb.display.cursorX = 0;
    }


The result:

Image
User avatar
Summoner123
 
Posts: 26
Joined: Fri Mar 20, 2015 12:35 am

Re: Tile Map Editor

Postby Zvoc47 » Tue Oct 06, 2015 3:43 pm

Wow! Awesome!

Can you please make a download link outside of 4shared like MediaFire or Dropbox? I'm not comfortable with having to log in to my social networks in order to download.
Zvoc47
 
Posts: 56
Joined: Mon Oct 05, 2015 10:03 pm

Re: Tile Map Editor

Postby Summoner123 » Thu Oct 15, 2015 1:09 pm

Zvoc47 wrote:Wow! Awesome!

Can you please make a download link outside of 4shared like MediaFire or Dropbox? I'm not comfortable with having to log in to my social networks in order to download.



Hi Guy...

There is a link to Media Fire download.

http://www.mediafire.com/download/1wc8du99c1ucc38/TileMapBeta_V1.02.rar

If you will try to use this on a "serious" project, take care about the several Bug's, especially with the "save" option, never leave a void sprite between two other sprites, or it will bug when you try to load the MAP.

Image
User avatar
Summoner123
 
Posts: 26
Joined: Fri Mar 20, 2015 12:35 am

Previous

Return to Software Development

Who is online

Users browsing this forum: No registered users and 22 guests

cron