Movement fixes

This commit is contained in:
stevenhowes
2021-05-13 20:25:16 +01:00
parent dfeedc95f3
commit 3c0a6d25e9
2 changed files with 13 additions and 11 deletions
Binary file not shown.
+13 -11
View File
@@ -311,14 +311,15 @@ int game2_check_collide()
void game2_tick_input() void game2_tick_input()
{ {
char movedy = 0;
// Store in case we have a vertical collide // Store in case we have a vertical collide
TilePlayer.lastlocation.X = TilePlayer.location.X; TilePlayer.lastlocation.X = TilePlayer.location.X;
TilePlayer.lastlocation.Y = TilePlayer.location.Y; TilePlayer.lastlocation.Y = TilePlayer.location.Y;
TilePlayer.lastmapoffset.X = TilePlayer.mapoffset.X; TilePlayer.lastmapoffset.X = TilePlayer.mapoffset.X;
TilePlayer.lastmapoffset.Y = TilePlayer.mapoffset.Y; TilePlayer.lastmapoffset.Y = TilePlayer.mapoffset.Y;
// Up arrow if(input_readkey(57))// Up arrow
if(input_readkey(57))
{ {
TilePlayer.location.Y += 3 * (tick - lasttick); TilePlayer.location.Y += 3 * (tick - lasttick);
if(TilePlayer.location.Y > (910)) if(TilePlayer.location.Y > (910))
@@ -327,10 +328,9 @@ void game2_tick_input()
TilePlayer.mapoffset.Y += 10; TilePlayer.mapoffset.Y += 10;
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y); game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
} }
movedy = 1;
} }
else if(input_readkey(41))// Down arrow
// Down arrow
if(input_readkey(41))
{ {
TilePlayer.location.Y -= 3 * (tick - lasttick); TilePlayer.location.Y -= 3 * (tick - lasttick);
if(TilePlayer.location.Y < (10)) if(TilePlayer.location.Y < (10))
@@ -344,6 +344,7 @@ void game2_tick_input()
TilePlayer.location.Y = TilePlayer.lastlocation.Y; TilePlayer.location.Y = TilePlayer.lastlocation.Y;
} }
} }
movedy = 1;
} }
@@ -355,12 +356,15 @@ void game2_tick_input()
TilePlayer.mapoffset.Y = TilePlayer.lastmapoffset.Y; TilePlayer.mapoffset.Y = TilePlayer.lastmapoffset.Y;
} }
// Dont allow horizontal and vertical - makes movement sketchy
if(movedy == 1)
return;
// Store in case we have a horizontal collide // Store in case we have a horizontal collide
TilePlayer.lastlocation.X = TilePlayer.location.X; TilePlayer.lastlocation.X = TilePlayer.location.X;
TilePlayer.lastlocation.Y = TilePlayer.location.Y; TilePlayer.lastlocation.Y = TilePlayer.location.Y;
// Right arrow if(input_readkey(121))// Right arrow
if(input_readkey(121))
{ {
TilePlayer.location.X += 3 * (tick - lasttick); TilePlayer.location.X += 3 * (tick - lasttick);
if(TilePlayer.location.X > (910)) if(TilePlayer.location.X > (910))
@@ -370,9 +374,7 @@ void game2_tick_input()
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y); game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
} }
} }
else if(input_readkey(25))// Left arrow
// Left arrow
if(input_readkey(25))
{ {
TilePlayer.location.X -= 3 * (tick - lasttick); TilePlayer.location.X -= 3 * (tick - lasttick);
if(TilePlayer.location.X < (10)) if(TilePlayer.location.X < (10))