 |
Jetzt bewegt sich was:
Lege als nächstes ein neues C-File an:
#include
<gb/gb.h>
#include "Tilemap.c"
#include "Tiles.c"
#define NIX 0
#define PILLE 1
#define PACMAN 2
#define MAUER 3
unsigned char tiles[] ={NIX,PILLE,PACMAN,MAUER};
void setze(int s_x,int s_y, UINT8 s_tile)
{
pacmantilemap[s_x+s_y*20]=s_tile; // Tile im
Speicher ändern
set_bkg_tiles(s_x,s_y,1,1,tiles+s_tile); // Tile
neu darstellen
}
void main()
{int x,y;
SHOW_BKG;
set_bkg_data(0,4,tiledata);
set_bkg_tiles(0,0,20,18,pacmantilemap); //ganze
Map anzeigen
x=10;y=9;
setze(x,y,PACMAN);
for(;;){
delay(100);
switch (joypad(0))
{
case (J_RIGHT):
if (pacmantilemap[(x+1)+y*20]!=MAUER) //rechts
keine Mauer ?
{
setze(x,y,NIX); // dann PacMan von aktuellem
Platznehmen...
x=x+1; // ... und 1 weiter rechts ...
setze(x,y,PACMAN);};break; // ...wieder hinsetzen
..
}
}
} |
|