Page 1 of 1

Tiles

Posted: Tue Jul 04, 2017 7:08 am
by Staffan
Hello Again!
I was wondering if anyone have a tile example. Because I dont want to make sprites of everything :)

There iare some tile examples, but they are always hardcoded into memory. I was wondering if it was possible with a png image and some cool SGDK commands :)

Re: Tiles

Posted: Tue Jul 04, 2017 9:22 am
by Stef
Of course you can load GFX data from iamge (BMP or PNG).
Look at the "sprite" sample provided in SGDK :
https://github.com/Stephane-D/SGDK/tree ... ple/sprite
If you go into the "res" folder you will see some .res files declaring resources.
Rescomp tool will compile the resources into .s / .h file for you. you can read the rescomp.txt file (in the "bin" folder of SGDK) to see which kind of resource are supported :)

Re: Tiles

Posted: Wed Jul 05, 2017 8:22 am
by Staffan
Well, I have a tileset resource that exist as a resource in my code, but I dont know how to use it in any functions....
Havent found a single example that loads my tileset. Tried to use the same funktions as the hardcoded tileset in sprite example, but didnt work.

Re: Tiles

Posted: Wed Jul 05, 2017 2:28 pm
by Stef
How are you declaring it ? TILESET ? or IMAGE ?
The easiest way to display it is to use IMAGE resource then use VDP_drawImage(..) method.

Re: Tiles

Posted: Thu Jul 06, 2017 2:46 pm
by Staffan
Tiles are characters right? At the commodore 64 i used characters because they are so fast. If I use an image like you said, can I still load it
to the TILE_USERINDEX adress, and then use it with VDP_setTileMapXY?

Re: Tiles

Posted: Thu Jul 06, 2017 2:52 pm
by Stef
Of course :) IMAGE contains a TileSet and and Map internally so you can use all those functions with it :)

Re: Tiles

Posted: Thu Jul 20, 2017 6:24 am
by Staffan
Thanx again!
Now I can out tiles in the background as well.

Does anyone know how to see what tile im standing on?
I mean read the data and se what character is under a certain sprite?

Re: Tiles

Posted: Fri Aug 11, 2017 8:56 am
by Staffan
I solved the above by looking at my own Tile Array and doing some math. Feels like the wrong way but it works.

I was also wondering about the best way to animate tiles. Is the vdp_drawimage function fast enough?
I will have a water tile with waves or something.

Re: Tiles

Posted: Fri Aug 11, 2017 9:11 am
by Stef
About looking what map tile is behind your sprite, you should do it from your map data.
As you know the sprite position in the level so you should be able to find which background tile is behind the sprite just by using its coordinates / 8 or something like that ;)
Also about animating background, it's better to have a large image containing the different water animation and just use VDP_setMapEx(..) to refresh only a part of the tilemap with a specific region of your map image.

Re: Tiles

Posted: Fri Aug 11, 2017 3:01 pm
by Staffan
Are there any drawbacks with using VDP_drawImageEx? I dont have to learn the map structure then and it seems to work.

Besides rescomp.txt says map isnt implemented....

Re: Tiles

Posted: Fri Aug 11, 2017 3:03 pm
by Staffan
... and I will also show what I got so far.
rom.zip
(43.62 KiB) Downloaded 255 times