X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fplayer.c;h=6c97e38dd2fad2338034c3cff83453c5e646b5c2;hb=79c636931d1f9bf844196e91be171b17bbe9c04f;hp=ebaef3e0d7f38aa418bbd7fb4c2da1c67f4b5fd5;hpb=21d9c58231cf7e1bdd95574e579c9c99a4cd1e9c;p=gbajam22 diff --git a/src/player.c b/src/player.c index ebaef3e..6c97e38 100644 --- a/src/player.c +++ b/src/player.c @@ -1,9 +1,32 @@ +#include +#include "game.h" #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) { +#ifndef BUILD_GBA + p->theta = (p->theta + view_dtheta) % X_2PI; + if(p->theta < 0) p->theta += X_2PI; + p->phi += view_dphi; + if(p->phi > X_HPI) p->phi = X_HPI; + if(p->phi < -X_HPI) p->phi = -X_HPI; + + view_dtheta = 0; + view_dphi = 0; +#endif + if(bnstate & KEY_UP) { p->phi += 0x800; if(p->phi > X_HPI) p->phi = X_HPI;