Une-realite-trop-belle-pour.../src/main.c

56 lines
1.7 KiB
C

#include "game.h"
/* The Game struct is defined in game.h. */
Game game;
void slocate_int(int x, int y, int n) {
char buffer[20];
itoa(n, buffer);
slocate(x, y, buffer);
}
int main(void) {
int ticks;
/* Wait that all keys are released before starting the game. */
while(kisdown());
/* Init game */
game.screen = S_GAME;
/* Some dirty stuff to try out animations */
MMap map;
map.px = 32;
map.py = 8;
game.map = ↦
pinit(&game);
while(!kcheck(KCEXIT)){
sclear();
treset();
ticks = tgetticks();
switch(game.screen){
case S_GAME:
aframe_done(&game.player.anim);
/* Change the action that the player does when SHIFT is
pressed. */
if(kcheck(KCSHIFT)){
if(game.player.action+1 >= A_AMOUNT) pset_action(&game, 0);
else pset_action(&game, game.player.action+1);
while(kcheck(KCSHIFT));
}
/* Change the skin of the player when ALPHA is pressed. */
if(kcheck(KCALPHA)){
game.player.skin++;
if(game.player.skin >= L_AMOUNT) game.player.skin = 0;
while(kcheck(KCALPHA));
}
slocate_int(1, 1, game.player.anim.anim_frame);
slocate_int(1, 2, game.player.anim.delay_elapsed);
pdraw(&game);
break;
default:
game.screen = S_GAME; /* TODO: change this to S_TITLE ... */
}
supdate();
while(!tiselapsed(ticks, 20));
}
return 1;
}