Phaser locations, debug framework

This commit is contained in:
stevenhowes
2021-03-20 17:47:49 +00:00
parent 3463d84a58
commit ce042dbefd
4 changed files with 118 additions and 18 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: C:h.kernel o.Sound: C:h.kernel
o.Sound: h.Sound 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.Graphics
o.Graphics: C:h.swis o.Graphics: C:h.swis
o.Graphics: C:h.kernel o.Graphics: C:h.kernel
@@ -46,6 +38,14 @@ o.Graphics: c.Graphics
o.Graphics: C:h.swis o.Graphics: C:h.swis
o.Graphics: C:h.kernel o.Graphics: C:h.kernel
o.Graphics: C:h.kernel o.Graphics: C:h.kernel
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.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
+93 -3
View File
@@ -30,10 +30,13 @@ char hudbuffer[63];
enum font_e{sys_12_8,font_max}; enum font_e{sys_12_8,font_max};
enum colour_e{lcars_black,lcars_violet1,hotpink,stargrey1,stargrey2,stargrey3}; enum colour_e{lcars_black,lcars_violet1,debugpink,stargrey1,stargrey2,stargrey3,debuggreen};
int colours[] = {0x11111100,0xc4727200,0xcc00ff00,0x66666600,0x22222200,0x44444400}; int colours[] = {0x11111100,0xc4727200,0xcc00ff00,0x66666600,0x22222200,0x44444400,0x00ff0000};
int font[font_max]; int font[font_max];
enum debugs_e{dbbase,dbhitbox,dbweapons,dbinput,dbmax};
int debugs[dbmax];
struct EntityLocation_s { struct EntityLocation_s {
short int X,Y; short int X,Y;
}; };
@@ -60,6 +63,8 @@ struct Player_s {
int remainingdistance; int remainingdistance;
struct EntityLocation_s hitbox_bl; struct EntityLocation_s hitbox_bl;
struct EntityLocation_s hitbox_tr; struct EntityLocation_s hitbox_tr;
struct EntityLocation_s phaser1;
struct EntityLocation_s phaser2;
}; };
struct NPC_s NPCS[MAX_NPCS]; struct NPC_s NPCS[MAX_NPCS];
@@ -148,7 +153,9 @@ void game_draw_player()
{ {
draw_sprite(sprites[Player.sprite], Player.location.X, Player.location.Y); draw_sprite(sprites[Player.sprite], Player.location.X, Player.location.Y);
graphics_colour(colours[hotpink]); if(debugs[dbhitbox])
{
graphics_colour(colours[debugpink]);
// Bounding box debug // Bounding box debug
draw_rectangle( draw_rectangle(
@@ -157,6 +164,38 @@ void game_draw_player()
Player.location.X + Player.hitbox_tr.X, Player.location.X + Player.hitbox_tr.X,
Player.location.Y + Player.hitbox_tr.Y Player.location.Y + Player.hitbox_tr.Y
); );
}
if(debugs[dbweapons])
{
graphics_colour(colours[debuggreen]);
// Draw phaser banks
draw_line(
Player.location.X + Player.phaser1.X,
Player.location.Y + Player.phaser1.Y -5,
Player.location.X + Player.phaser1.X,
Player.location.Y + Player.phaser1.Y + 5
);
draw_line(
Player.location.X + Player.phaser1.X -5,
Player.location.Y + Player.phaser1.Y,
Player.location.X + Player.phaser1.X +5,
Player.location.Y + Player.phaser1.Y
);
draw_line(
Player.location.X + Player.phaser2.X,
Player.location.Y + Player.phaser2.Y -5,
Player.location.X + Player.phaser2.X,
Player.location.Y + Player.phaser2.Y + 5
);
draw_line(
Player.location.X + Player.phaser2.X -5,
Player.location.Y + Player.phaser2.Y,
Player.location.X + Player.phaser2.X +5,
Player.location.Y + Player.phaser2.Y
);
}
} }
void game_draw_stars() void game_draw_stars()
{ {
@@ -184,6 +223,11 @@ void game_setup_player()
Player.hitbox_bl.Y = 0; Player.hitbox_bl.Y = 0;
Player.hitbox_tr.X = 60; Player.hitbox_tr.X = 60;
Player.hitbox_tr.Y = 81; Player.hitbox_tr.Y = 81;
Player.phaser1.X = 20;
Player.phaser1.Y = 75;
Player.phaser2.X = 41;
Player.phaser2.Y = 75;
} }
void game_tick_stars() void game_tick_stars()
@@ -223,8 +267,53 @@ void game_setup_input()
*/ */
} }
void game_draw_debugmenu()
{
if(debugs[dbbase])
{
font_colour(colours[debuggreen],colours[lcars_black],font[sys_12_8]);
draw_text("Debug List",DISPLAY_X-200,DISPLAY_Y-40,font[sys_12_8]);
font_colour(colours[debugs[dbhitbox]?debugpink:stargrey1],colours[lcars_black],font[sys_12_8]);
draw_text("1: hitbox",DISPLAY_X-200,DISPLAY_Y-60,font[sys_12_8]);
font_colour(colours[debugs[dbweapons]?debugpink:stargrey1],colours[lcars_black],font[sys_12_8]);
draw_text("2: weapons",DISPLAY_X-200,DISPLAY_Y-80,font[sys_12_8]);
font_colour(colours[debugs[dbinput]?debugpink:stargrey1],colours[lcars_black],font[sys_12_8]);
draw_text("3: input",DISPLAY_X-200,DISPLAY_Y-100,font[sys_12_8]);
}
}
void game_input_tick() void game_input_tick()
{ {
if(debugs[dbbase])
{
if(input_readkey(17))
{
debugs[dbinput] = 1;
}
if(input_readkey(48))
{
debugs[dbhitbox] = 1;
}
if(input_readkey(49))
{
debugs[dbweapons] = 1;
}
}
if(debugs[dbinput])
{
font_colour(colours[debuggreen],colours[lcars_black],font[sys_12_8]);
sprintf(hudbuffer,"Keycode: %i",input_readanykey());
draw_text(hudbuffer,DISPLAY_X-500,DISPLAY_Y-40,font[sys_12_8]);
}
if(input_readkey(16))
{
debugs[dbbase] = 1;
}
// Right arrow // Right arrow
if(input_readkey(121)) if(input_readkey(121))
{ {
@@ -317,6 +406,7 @@ void game_tick()
game_draw_player(); game_draw_player();
game_draw_hud(); game_draw_hud();
game_draw_debugmenu();
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
+10
View File
@@ -18,3 +18,13 @@ int input_readkey(int key)
return 0; return 0;
} }
int input_readanykey()
{
inreg.r[0] = 129;
inreg.r[1] = 123 + 255;
inreg.r[2] = 255;
_kernel_swi(OS_Byte,&inreg,&outreg);
return outreg.r[1];
}