#3707 - phr0zn - Wed Mar 05, 2003 7:37 pm
Hey everyone. I am working on a "random map" generator for my GBA project. I coded it so that I would create a double scripted map array called "map[30][20]". I then set the entire array to equal zero, then "randomly" place 1s around the map in an organized fashion to create rooms and paths. However, my problem is converting this to the gba.
What I want to do is create two background tiles, both 8x8 (hence getting a 240x160 pixel screen if there are 30x8 + 20x8 tiles). However, I cannot load them as sprites (this wouldn't make sense anyway for a background) because it would create more than the max 128 sprites at a time.
So I am wondering if it is possible to do it like this (please note im fairly new to programming for the game boy advance): by loading them into the videobuffer for each tile.
I really doubt this will work but my goal was to draw the tile for each time the tile is 1 or 0, to create a random background.
Any help and direction would be much appreciated. I can post more code if you need it.
Thanks a lot.
shad0an@hotmail.com
What I want to do is create two background tiles, both 8x8 (hence getting a 240x160 pixel screen if there are 30x8 + 20x8 tiles). However, I cannot load them as sprites (this wouldn't make sense anyway for a background) because it would create more than the max 128 sprites at a time.
So I am wondering if it is possible to do it like this (please note im fairly new to programming for the game boy advance): by loading them into the videobuffer for each tile.
Code: |
//the two tiles #include "tile1.h" #include "tile2.h" u16 i,x,y; for(x=0; x<20; x++) for(y=0; y<30; y++) { if(map[x][y] == 1) { for(i = 0; i<256; i++) theScreenPalette[i] = tile1Palette[i]; u16* tempData = (u16*)tile1; for(x=0; x<8; x++) for(y=0; y<8; y++) theVideoBuffer[y*8+8] = tempData[y*8+8]; } else if(map[x][y] == 0) { for(i = 0; i<256; i++) theScreenPalette[i] = tile2Palette[i]; u16* tempData = (u16*)tile2; for(x=0; x<8; x++) for(y=0; y<8; y++) theVideoBuffer[y*8+8] = tempData[y*8+8]; } } |
I really doubt this will work but my goal was to draw the tile for each time the tile is 1 or 0, to create a random background.
Any help and direction would be much appreciated. I can post more code if you need it.
Thanks a lot.
shad0an@hotmail.com