X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fplayer.c;h=5a39077e9437248b2a9a3b5b2d6e83e3dfbff330;hb=d985165d0e156c785895a5272113ff477bebeeb8;hp=d025799cd91e91951960eb7e5f2ffdea5a2cab0e;hpb=5e41feadc19dbc9cda954543cf2b2649ced835b4;p=gbajam22 diff --git a/src/player.c b/src/player.c index d025799..5a39077 100644 --- a/src/player.c +++ b/src/player.c @@ -1,7 +1,18 @@ +#include #include "player.h" +#include "level.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) { @@ -14,11 +25,11 @@ void player_input(struct player *p, uint16_t bnstate) } if(bnstate & KEY_LEFT) { p->theta += 0x800; - if(p->theta > X_2PI) p->theta -= X_2PI; + if(p->theta >= X_2PI) p->theta -= X_2PI; } if(bnstate & KEY_RIGHT) { p->theta -= 0x800; - if(p->theta < X_2PI) p->theta += X_2PI; + if(p->theta < 0) p->theta += X_2PI; } if(bnstate & KEY_A) { p->y += 0x2000;