-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
66 lines (58 loc) · 1.44 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <gb/gb.h>
#include "background.c"
#include "simplebackground.c"
#include <stdio.h>
#include "Dinosaurio.c"
void main(){
UINT8 currentspriteindex = 0;
//To calculate the position of the character
int xAxis = 40, yAxis = 120;
//Show the sprite of the Dinosaur
set_sprite_data(0, 2, Dinosaurio);
set_sprite_tile(0, 0);
move_sprite(0, 40, 120);
SHOW_SPRITES;
//Show background
set_bkg_data(0, 12, backgroundtiles);
set_bkg_tiles(0, 0, 40, 18, backgroundmap);
SHOW_BKG;
DISPLAY_ON;
//Principal loop
while(1){
scroll_bkg(1,0);
if(currentspriteindex==0){
currentspriteindex = 1;
}
else{
currentspriteindex = 0;
}
set_sprite_tile(0, currentspriteindex);
switch(joypad()){
case J_LEFT:
if (xAxis > 12){
scroll_sprite(0,-5,0);
xAxis -= 5;
}
break;
case J_RIGHT:
if (xAxis < 155){
scroll_sprite(0,5,0);
xAxis += 5;
}
break;
case J_UP:
if (yAxis > 65){
scroll_sprite(0,0,-5);
yAxis -= 5;
}
break;
case J_DOWN:
if (yAxis < 150){
scroll_sprite(0,0,5);
yAxis += 5;
}
break;
}
delay(100);
}
}