So basically, you have an object the same size as your frame, with two textures:
* a map image representing your game level, with 1 pixel per tile.
* a tileset image with the individual tiles, in a 16x16 tile grid.
The color of each pixel in the map image determines which tile from the tileset to draw at that position.
The tileset image must be 16x16 tiles in size. Tiles are indexed from 0-255 (ordered left-to-right and top-to-bottom), using the red component from the map image only (unlike the example above which uses red and green).
btw: I realize there are many other ways to do the same thing, besides a pixel shader, but it just seemed like an interesting experiment. I really ought to add scrolling...
I made another new pixel shader - this one is for auto-tiling.
You give your object 2 textures - one acts as a map (1 pixel per tile), and the other holds the tile graphics. All the maths for selecting which tile to draw, according to the tiles around it, is done by the shader (proper area tiling requires two objects; linear tiling or walls etc only needs one).
I'm always amazed that you make these awesome code examples and just give them away. Have you considered setting up a small website with all of your examples so far? I know they're all on skydrive but I mean something more like nivram's site.
Originally Posted by nim I'm always amazed that you make these awesome code examples and just give them away. Have you considered setting up a small website with all of your examples so far? I know they're all on skydrive but I mean something more like nivram's site.
No kidding!
Sketchy, do you have some sort of job doing this stuff or is it a hobby? You and Pixelthief come up with some ulta-amazing stuff and it never ceases to amaze.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Thanks very much - and no, I don't do any of this for a job (I'm actually an outdoor activities guide - sea kayaking, rock climbing, coasteering, etc). It would be nice to eventually release a commercial game though, if I can ever be bothered to finish one...
To be honest, none of it's really that innovative - I mostly just find interesting ideas on other programming sites, and then try to replicate them in MMF2, so someone else has already done the hard work.
I think I enjoy just tinkering and solving problems more than I enjoy actually making games (mainly because graphics are so much hassle), and since I never finish games myself, I may as well share what I do make.
You've always been very helpful to everybody either here or on Clickteam's site.
I for one don't think you'll have any trouble getting help for any commercial game you decide to eventually make!
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!