projects
/
gbajam22
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pass the gdb init file explicitly where needed (gba debug rule)
[gbajam22]
/
src
/
player.c
diff --git
a/src/player.c
b/src/player.c
index
62c9813
..
5a39077
100644
(file)
--- a/
src/player.c
+++ b/
src/player.c
@@
-1,29
+1,40
@@
+#include <string.h>
#include "player.h"
#include "player.h"
+#include "level.h"
#include "gbaregs.h"
#include "xgl.h"
#include "gbaregs.h"
#include "xgl.h"
+void init_player(struct player *p, struct level *lvl)
+{
+ memset(p, 0, sizeof *p);
+ p->cx = lvl->orgx;
+ p->cy = lvl->orgy;
+ cell_to_pos(lvl, lvl->orgx, lvl->orgy, &p->x, &p->y);
+ p->cell = level_cell(lvl, lvl->orgx, lvl->orgy);
+}
+
void player_input(struct player *p, uint16_t bnstate)
{
if(bnstate & KEY_UP) {
void player_input(struct player *p, uint16_t bnstate)
{
if(bnstate & KEY_UP) {
- p->phi += 0x2000;
+ p->phi += 0x800;
if(p->phi > X_HPI) p->phi = X_HPI;
}
if(bnstate & KEY_DOWN) {
if(p->phi > X_HPI) p->phi = X_HPI;
}
if(bnstate & KEY_DOWN) {
- p->phi -= 0x2000;
+ p->phi -= 0x800;
if(p->phi < -X_HPI) p->phi = -X_HPI;
}
if(bnstate & KEY_LEFT) {
if(p->phi < -X_HPI) p->phi = -X_HPI;
}
if(bnstate & KEY_LEFT) {
- p->theta += 0x2000;
- if(p->theta > X_2PI) p->theta -= X_2PI;
+ p->theta += 0x800;
+ if(p->theta >= X_2PI) p->theta -= X_2PI;
}
if(bnstate & KEY_RIGHT) {
}
if(bnstate & KEY_RIGHT) {
- p->theta -= 0x2000;
- if(p->theta < X_2PI) p->theta += X_2PI;
+ p->theta -= 0x800;
+ if(p->theta < 0) p->theta += X_2PI;
}
if(bnstate & KEY_A) {
}
if(bnstate & KEY_A) {
- p->y += 0x1000;
+ p->y += 0x2000;
}
if(bnstate & KEY_B) {
}
if(bnstate & KEY_B) {
- p->y -= 0x1000;
+ p->y -= 0x2000;
}
}
}
}