#726 - whodoo - Fri Jan 10, 2003 12:08 am
I got another simple question..I?ve made a snake-game for gba...and everything works fine and Im using the hardware to blir the "parts" of the snake as sprites..
but now I want a frame around the game(like walls)..only thin lines...how can I do that? I?s simple in mode 4 where I can draw them pixel by pixel but how do I do it in mode_1? I don?t wanna use sprites, just show some lines and stuff like that..
#729 - whodoo - Fri Jan 10, 2003 12:17 am
and I don?t wanna make a tile-map or something..I just want a square around the "snake-level" the best and fastes way...
#738 - sgeos - Fri Jan 10, 2003 2:24 am
I'd make a few simple tiles and put a BG map on top of everything else.
-Brendan
#755 - Quirky - Fri Jan 10, 2003 9:18 am
whodoo wrote: |
and I don?t wanna make a tile-map or something..I just want a square around the "snake-level" the best and fastes way... |
The best way to do it is with tiles though. You'd only need 6 of 'em; four for the corners, one for the vertical walls one for the horizontals. Then set the relevant parts of vram with the tile map info - horizontals along the top and bottom, verticals at the sides, and the four corners. Very quick (it's all drawn by hardware) and very simple.
#756 - Touchstone - Fri Jan 10, 2003 9:43 am
Could do with just three tiles, one corner, one vertical and one horizontal, and have the corner tiled flipped horizontally and/or vertically. If you have to save tile memory or whatever. :)
_________________
You can't beat our meat
#807 - whodoo - Fri Jan 10, 2003 7:46 pm
can I have tiles with the width of the entire GB-screen?.. I read somewhere that the limit was 64*64 pixels...
#817 - pulstar_3 - Fri Jan 10, 2003 9:05 pm
The maximum size of the tiles are 8x8. If you want anything bigger you just have to make it from 8x8 tiles.
#834 - ampz - Sat Jan 11, 2003 12:32 am
Touchstone wrote: |
Could do with just three tiles, one corner, one vertical and one horizontal, and have the corner tiled flipped horizontally and/or vertically. If you have to save tile memory or whatever. :) |
Three tiles?!? Are you crazy? You can't be that careless with video memory.
It can be done with just one tile actually.
Draw a tile with a cross on it, draw the center of the cross with one color, and the four lines leading from the center to the edges with four other colors.
Then just setup the BG to be a 16color one, and use the same tile for the entire frame (corner tiles flipped vertically/horizontally). Set up three different palettes for horizonatal lines, vertical lines and corners. Each palette should "activate" respective colors, the other colors shall remain black or transparent.
That's it! I just saved you at least 50bytes of video memory. (Simple, huh?) You don't even have to thank me. :-)
#837 - Touchstone - Sat Jan 11, 2003 1:31 am
ampz wrote: |
Touchstone wrote: | Could do with just three tiles, one corner, one vertical and one horizontal, and have the corner tiled flipped horizontally and/or vertically. If you have to save tile memory or whatever. :) |
Three tiles?!? Are you crazy? You can't be that careless with video memory.
It can be done with just one tile actually.
Draw a tile with a cross on it, draw the center of the cross with one color, and the four lines leading from the center to the edges with four other colors.
Then just setup the BG to be a 16color one, and use the same tile for the entire frame (corner tiles flipped vertically/horizontally). Set up three different palettes for horizonatal lines, vertical lines and corners. Each palette should "activate" respective colors, the other colors shall remain black or transparent.
That's it! I just saved you at least 50bytes of video memory. (Simple, huh?) You don't even have to thank me. :-) |
Well... If you look at the total amount of used resources instead of counting bytes you will find that using three tiles and one palette (3T/1P) instead of one tile and three palettes (1T/3P) will save you resources since 3T/1P use about 3.2% of the total amount of resources (tileram and paletteram) whereas 1T/3P use about 9.5%. :) I know, way to serious but I'm tired, okay. Besides, those numbers probably dont add up when I recheck them tomorrow. I like the way you're thinking Ampz.
_________________
You can't beat our meat
#845 - whodoo - Sat Jan 11, 2003 3:12 am
okey thanks!
#846 - Nessie - Sat Jan 11, 2003 3:27 am
[EDIT]: I could have sworn someone was asking a question on how to set this up...but maybe I misread it? Or maybe they edited their original post. Oh well... :)
If you have a single 8x8 tile ( say just a solid color if you really want to go simple )...then all you have to do is create a 32x32 tile BG ( background ) layer. This should give you enough area to cover the whole screen since 32(tiles) x 8(width of EACH tile) = 256....(remember that the GBA resolution is 240x160).
One thing I forgot about...you'll actually need TWO tiles...one of which is just a blank 8x8 tile. You can make this "blank"/ transparent tile by filling the 8x8 tile with color 0 out of either a 16 color palette or a 256 color palette. The GBA hardware just interprets that color as "don't plot any pixels here".
Anyway, now you just need to fill in your 32x32 tile BG map with either tile 0 ( your transparent one ) or tile 1 ( your solid one, for the walls ).
Since 8 goes into 240 an even 30 times....and 8 goes into 160 and even 20 times, you only really need 30x20 out of your regular 32x32 grid..
...whoops, I don't have time to finish the description since I have to leave... sorry, but hopefully this will get you started...
Later..
#861 - Splam - Sat Jan 11, 2003 1:09 pm
If you're going to go on a crusade to save a few bytes of vram, which in this situation really isn't needed, then you could use 1 16colour tile with a line down the side, flip it for the other side of the screen and use an interrupt to change colour 0 for the top and the bottom lines. 32bytes, 1 palette.
#873 - ampz - Sat Jan 11, 2003 7:25 pm
That doesn't acount for corners.
My version only uses 5 colors in 3 palettes, there are still 11 colors left in each palette for other purposes.
An interrupt could cut it down to only 2 palettes...
I wish it was possible to flip tiles 90 degrees... That would be quite useful sometimes...
#878 - Splam - Sat Jan 11, 2003 7:47 pm
The corners are created by the tile meeting the line, the tile would have a vertical line on the far left (flipped for right).
90 degree rotation of the tiles would be very useful, ahh well maybe gba 2 ;)
#997 - ampz - Mon Jan 13, 2003 3:24 am
That way you'll miss one pixel in each corner.... ;-)
#1003 - Splam - Mon Jan 13, 2003 7:40 am
No :P
Get a bit of graph paper, outline your "screen" draw a vertical line, draw a horizontal line across the top of it, missing anything? nope..
ie
2222222222
10000000
10000000
10000000
10000000
10000000
1 is the tile, 2 is the colour 0 line.
Admitedly this only works in this case, but a) that's all that was asked for and b) I was just pointing out there's really no point in going crazy over vram usage for a snake game :)