Tiles

SGDK only sub forum

Moderator: Stef

Post Reply
Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Tiles

Post by Staffan » Tue Jul 04, 2017 7:08 am

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 :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Tiles

Post by Stef » Tue Jul 04, 2017 9:22 am

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 :)

Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Re: Tiles

Post by Staffan » Wed Jul 05, 2017 8:22 am

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.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Tiles

Post by Stef » Wed Jul 05, 2017 2:28 pm

How are you declaring it ? TILESET ? or IMAGE ?
The easiest way to display it is to use IMAGE resource then use VDP_drawImage(..) method.

Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Re: Tiles

Post by Staffan » Thu Jul 06, 2017 2:46 pm

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?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Tiles

Post by Stef » Thu Jul 06, 2017 2:52 pm

Of course :) IMAGE contains a TileSet and and Map internally so you can use all those functions with it :)

Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Re: Tiles

Post by Staffan » Thu Jul 20, 2017 6:24 am

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?

Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Re: Tiles

Post by Staffan » Fri Aug 11, 2017 8:56 am

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.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Tiles

Post by Stef » Fri Aug 11, 2017 9:11 am

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.

Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Re: Tiles

Post by Staffan » Fri Aug 11, 2017 3:01 pm

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....

Staffan
Very interested
Posts: 57
Joined: Wed Jun 14, 2017 2:33 pm

Re: Tiles

Post by Staffan » Fri Aug 11, 2017 3:03 pm

... and I will also show what I got so far.
rom.zip
(43.62 KiB) Downloaded 250 times

Post Reply