Tutorial #3 OUT


Rico

Certified Guru
Joined
Apr 4, 2003
Messages
5,649
Age
39
Location
England, UK
Website
Visit site
Get it here

http://www.thaworx.co.uk/ninja/tut3.htm

Head here to get a listing of all tutorial files/etc

http://www.thaworx.co.uk/ninja/

I cover: getting sprites, converting sprites, making custom maps, loading and blitting sprites, using the maps in your code (using Mappy and GP32Converter). Also some general notes on my previous tutorials.

Enjoy, Rico

P.S. I have not had a chance to test all the code yet. If anything in the tutorial doesn't work, please tell me ASAP so I can fix it! :p
 
Hey, nice work.

Your tutorials may just be the spur I need to make me buy a GP32. I've been undecided as to whether to buy one or not, but I'd love the chance to put my (very basic) c++ skills to some use! Please keep up the excellent work!
 
P.S. I have not had a chance to test all the code yet. If anything in the tutorial doesn't work, please tell me ASAP so I can fix it! :p
Rico, it looks really good. It is pretty clear and all.

I am only having one slight problem and I know it HAS to do with the palette. When it runs, the colors are ugly/not right. I am not sure how I fix this. I followed the steps, it is 256 colors, bmp and I know what index is transparent. I used GPConvert and made the .h file. It has my palette (which I renamed to npal). I added the Initialising the global palette code. Only difference is I have a grid of tiles, not a strip like you have.

I know it has to be something I am missing...

Screenshot of it running:
Screenshot
 
Last edited by a moderator:
That's not a palette problem - some of the tiles render fine.

Firstly make sure your map[][] values are valid... obviously rand() % 255 won't work.
Secondly if you're using a grid, you'll need to change sx and sy - something like sx = (tilenum % 8) * 32 + 32, sy = (tilenum / 8) * 32

(Assuming width of grid is 8, tilesize 32x32)
 
The garbage tiles are where it's tried to draw memory locations as tiles, indicating either - illegal map value, or - illegal sx and/or sy values. (or both)
 
The garbage tiles are where it's tried to draw memory locations as tiles, indicating either - illegal map value, or - illegal sx and/or sy values. (or both)
Hmm, I thought I had done that correctly and just assumed it was a palette problem. I'll double check it. In the meantime, let me see if I am grasping things so far.

First, the tileset.h file is basically a pixel-by-pixel representation of the tileset bmp file. The palette portion is the color values (how do those translate to RGB or some other value?) of the palette. The sprite_tileset char array are the tiles themselves. And, if our tilesize is 32x32 then if you took the first (32*32) 1024 values, that would be tile 0 with each set of 32 values representing a row of pixels in the tile?

Second, the map. Looking at the .h file, if our map size is 100x100 then the first 100 values (testmap[0][0-99]) tell what tiles go in the first row of the map (0,0 to 100,0)? So, let us say that the value 26 is at testmap[5][12]. Then if I wanted to find the actual tile in the tileset.h file, I would find the 25th (assuming the first set is 0) group of 32*32 values?

If that is all correct, then this makes much more sense to me. :) If it is all incorrect then I am a dunce. :(

Thanks for the help and patience, Rico!
 
Last edited by a moderator:
The sprite_tileset char array are the tiles themselves. And, if our tilesize is 32x32 then if you took the first (32*32) 1024 values, that would be tile 0 with each set of 32 values representing a row of pixels in the tile?

Second, the map. Looking at the .h file, if our map size is 100x100 then the first 100 values (testmap[0][0-99]) tell what tiles go in the first row of the map (0,0 to 100,0)? So, let us say that the value 26 is at testmap[5][12]. Then if I wanted to find the actual tile in the tileset.h file, I would find the 25th (assuming the first set is 0) group of 32*32 values?

If that is all correct, then this makes much more sense to me. :) If it is all incorrect then I am a dunce. :(

Thanks for the help and patience, Rico!
The actual format of sprite_tileset is meaningless since you are blitting.

If we use testmap[5][12] = 26 as an example, that means tile (12, 5) is #26.

If you had a strip, you would need dy = 0, dx = 26 * 32, sy = 0, sx = 26 * 32 + 32.

Why? Cos if the tile # is 0, then x value is 0 * 32 = 0
If tile # is 1, x value is 32, and so on.
 
Last edited by a moderator:
Back
Top