Sprite flipping, face in direction of movement

This commit is contained in:
stevenhowes
2021-05-13 20:56:36 +01:00
parent 3c0a6d25e9
commit 74faf7f89b
6 changed files with 72 additions and 5 deletions
Binary file not shown.
Binary file not shown.
+8 -4
View File
@@ -40,14 +40,18 @@ Squeezeflags = -o $@
# Dynamic dependencies: # Dynamic dependencies:
o.Graphics: c.Graphics
o.Graphics: C:h.swis
o.Graphics: C:h.kernel
o.Graphics: C:h.kernel
o.Input: c.Input o.Input: c.Input
o.Input: C:h.swis o.Input: C:h.swis
o.Input: C:h.kernel o.Input: C:h.kernel
o.Input: C:h.kernel o.Input: C:h.kernel
o.Graphics: c.Graphics
o.Graphics: C:h.swis
o.Graphics: C:h.kernel
o.Graphics: C:h.kernel
o.Graphics: c.Graphics
o.Graphics: C:h.swis
o.Graphics: C:h.kernel
o.Graphics: C:h.kernel
o.CTheEscape: c.CTheEscape o.CTheEscape: c.CTheEscape
o.CTheEscape: C:h.swis o.CTheEscape: C:h.swis
o.CTheEscape: C:h.kernel o.CTheEscape: C:h.kernel
BIN
View File
Binary file not shown.
+36
View File
@@ -139,6 +139,42 @@ void draw_sprite(char* spritename,int x, int y)
_kernel_swi(OS_SpriteOp,&inreg,&outreg); _kernel_swi(OS_SpriteOp,&inreg,&outreg);
} }
void draw_sprite_flippedh(char* spritename,int x, int y)
{
// SpriteOp 32
inreg.r[0] = 256+33;
inreg.r[1] = (int) buffer;
inreg.r[2] = (int) spritename;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
draw_sprite(spritename,x,y);
// SpriteOp 32
inreg.r[0] = 256+33;
inreg.r[1] = (int) buffer;
inreg.r[2] = (int) spritename;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
}
void draw_sprite_flippedv(char* spritename,int x, int y)
{
// SpriteOp 47
inreg.r[0] = 256+47;
inreg.r[1] = (int) buffer;
inreg.r[2] = (int) spritename;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
draw_sprite(spritename,x,y);
// SpriteOp 47
inreg.r[0] = 256+47;
inreg.r[1] = (int) buffer;
inreg.r[2] = (int) spritename;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
}
void draw_letter(char* spritename,int x, int y) void draw_letter(char* spritename,int x, int y)
{ {
// SpriteOp 34 to put sprite at a location // SpriteOp 34 to put sprite at a location
+27
View File
@@ -37,6 +37,11 @@ struct Area_s {
struct Area_s Areas[AREAS]; struct Area_s Areas[AREAS];
#define DIRECTION_DOWN 0
#define DIRECTION_UP 1
#define DIRECTION_LEFT 2
#define DIRECTION_RIGHT 3
struct TilePlayer_s { struct TilePlayer_s {
struct EntityLocation_s location; struct EntityLocation_s location;
struct EntityLocation_s lastlocation; struct EntityLocation_s lastlocation;
@@ -48,6 +53,7 @@ struct TilePlayer_s {
struct EntityLocation_s lastmapoffset; struct EntityLocation_s lastmapoffset;
struct EntityLocation_s localtile; struct EntityLocation_s localtile;
int rawtile; int rawtile;
unsigned char direction;
}; };
struct TilePlayer_s TilePlayer; struct TilePlayer_s TilePlayer;
@@ -270,6 +276,8 @@ void game2_setup()
TilePlayer.drawbox_tr.X = 80; TilePlayer.drawbox_tr.X = 80;
TilePlayer.drawbox_tr.Y = 80; TilePlayer.drawbox_tr.Y = 80;
TilePlayer.direction = DIRECTION_DOWN;
memset(map[0],0xFF,100); memset(map[0],0xFF,100);
memset(map[1],0xFF,100); memset(map[1],0xFF,100);
memset(map[2],0xFF,100); memset(map[2],0xFF,100);
@@ -329,6 +337,7 @@ void game2_tick_input()
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y); game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
} }
movedy = 1; movedy = 1;
TilePlayer.direction = DIRECTION_UP;
} }
else if(input_readkey(41))// Down arrow else if(input_readkey(41))// Down arrow
{ {
@@ -344,6 +353,7 @@ void game2_tick_input()
TilePlayer.location.Y = TilePlayer.lastlocation.Y; TilePlayer.location.Y = TilePlayer.lastlocation.Y;
} }
} }
TilePlayer.direction = DIRECTION_DOWN;
movedy = 1; movedy = 1;
} }
@@ -373,6 +383,7 @@ void game2_tick_input()
TilePlayer.mapoffset.X += 10; TilePlayer.mapoffset.X += 10;
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y); game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
} }
TilePlayer.direction = DIRECTION_RIGHT;
} }
else if(input_readkey(25))// Left arrow else if(input_readkey(25))// Left arrow
{ {
@@ -388,6 +399,7 @@ void game2_tick_input()
TilePlayer.location.X = TilePlayer.lastlocation.X; TilePlayer.location.X = TilePlayer.lastlocation.X;
} }
} }
TilePlayer.direction = DIRECTION_LEFT;
} }
if(game2_check_collide()) if(game2_check_collide())
@@ -475,7 +487,22 @@ int game2_tick()
game2_tick_input(); game2_tick_input();
if(TilePlayer.direction == DIRECTION_DOWN)
{
draw_sprite("man",TilePlayer.location.X,TilePlayer.location.Y); draw_sprite("man",TilePlayer.location.X,TilePlayer.location.Y);
}
else if(TilePlayer.direction == DIRECTION_UP)
{
draw_sprite_flippedh("man",TilePlayer.location.X,TilePlayer.location.Y);
}
else if(TilePlayer.direction == DIRECTION_RIGHT)
{
draw_sprite("manrot",TilePlayer.location.X,TilePlayer.location.Y);
}
else if(TilePlayer.direction == DIRECTION_LEFT)
{
draw_sprite_flippedv("manrot",TilePlayer.location.X,TilePlayer.location.Y);
}
#ifdef M2_DEBUG_HITBOXES #ifdef M2_DEBUG_HITBOXES
draw_rectangle( draw_rectangle(