Controls handling, tick reset after intro and player movement

This commit is contained in:
stevenhowes
2021-03-19 23:19:29 +00:00
parent 4fd5fa0123
commit 1bd787e8a8
4 changed files with 55 additions and 13 deletions
BIN
View File
Binary file not shown.
+8 -8
View File
@@ -30,14 +30,6 @@ o.Sound: C:h.swis
o.Sound: C:h.kernel
o.Sound: C:h.kernel
o.Sound: h.Sound
o.Input: c.Input
o.Input: C:h.swis
o.Input: C:h.kernel
o.Input: C:h.kernel
o.Input: c.Input
o.Input: C:h.swis
o.Input: C:h.kernel
o.Input: C:h.kernel
o.Graphics: c.Graphics
o.Graphics: C:h.swis
o.Graphics: C:h.kernel
@@ -56,3 +48,11 @@ o.CTheEscape: C:h.swis
o.CTheEscape: C:h.kernel
o.CTheEscape: C:h.kernel
o.CTheEscape: h.Sound
o.Input: c.Input
o.Input: C:h.swis
o.Input: C:h.kernel
o.Input: C:h.kernel
o.Input: c.Input
o.Input: C:h.swis
o.Input: C:h.kernel
o.Input: C:h.kernel
+45 -3
View File
@@ -19,7 +19,7 @@ extern int current_element;
#define DISPLAY_Y 960
#define PLAYER_Y_START 100
#define PLAYER_X_SPEED 10
#define MAX_NPCS 5
#define MAX_STARS 49
@@ -168,22 +168,64 @@ void game_setup_stars()
}
}
void game_setup_input()
{
/*
inreg.r[0] = 4;
inreg.r[1] = 1;
_kernel_swi(OS_Byte,&inreg,&outreg);
*/
}
void game_input_tick()
{
// Right arrow
if(input_readkey(121))
{
Player.location.X += PLAYER_X_SPEED * (tick - lasttick);
Player.sprite = player_shipr;
// TODO: SHIP WIDTH
if(Player.location.X > DISPLAY_X)
{
Player.location.X = DISPLAY_X;
Player.sprite = player_ship;
}
}
// Left arrow
if(input_readkey(25))
{
Player.location.X -= PLAYER_X_SPEED * (tick - lasttick);
Player.sprite = player_shipl;
if(Player.location.X < 0)
{
Player.location.X = 0;
Player.sprite = player_ship;
}
}
}
void game_setup()
{
game_setup_input();
game_setup_stars();
game_setup_player();
tick = clock();
}
void game_tick()
{
lasttick = tick;
tick = clock();
screen_flipbuffer();
screen_clear();
game_tick_stars();
game_input_tick();
game_draw_stars();
game_draw_player();
printf("%i - %i",tick - lasttick,screen);
}
int main(int argc, char *argv[])
@@ -193,7 +235,7 @@ int main(int argc, char *argv[])
display_mode(DISPLAY_MODE);
load_sprites("Spr");
//intro();
intro();
display_mode(DISPLAY_MODE);