Tiles

SGDK only sub forum

Moderator: Stef

Post Reply
User avatar
Staffan
Very interested
Posts: 55
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 :)

User avatar
Stef
Very interested
Posts: 2619
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 :)

User avatar
Staffan
Very interested
Posts: 55
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.

User avatar
Stef
Very interested
Posts: 2619
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.

User avatar
Staffan
Very interested
Posts: 55
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?

User avatar
Stef
Very interested
Posts: 2619
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 :)

User avatar
Staffan
Very interested
Posts: 55
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?

User avatar
Staffan
Very interested
Posts: 55
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.

User avatar
Stef
Very interested
Posts: 2619
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.

User avatar
Staffan
Very interested
Posts: 55
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....

User avatar
Staffan
Very interested
Posts: 55
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 11 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest