Add proper stage running

master
Marrub 2017-09-28 13:51:14 -04:00
parent cc8f9f21bc
commit 67307e300a
9 changed files with 62 additions and 20 deletions

View File

@ -1,4 +1,5 @@
// Copyright © 2017 Project Golan, all rights reserved. // Copyright © 2017 Project Golan, all rights reserved.
include "objdefs/player.dod" include "objdefs/player.dod"
include "objdefs/testobj.dod"
// EOF // EOF

View File

@ -1,12 +1,8 @@
// Copyright © 2017 Project Golan, all rights reserved. // Copyright © 2017 Project Golan, all rights reserved.
entity Shootable entity Player
{ {
health 1 health 1
} subtype Player
entity Player < Shootable
{
task G_Player_Think
size 4 size 4
drawsize 16 drawsize 16
friction 0.9 friction 0.9

10
data/objdefs/testobj.dod Normal file
View File

@ -0,0 +1,10 @@
// Copyright © 2017 Project Golan, all rights reserved.
entity TestObj
{
health 1
size 10
drawsize 16
sprite "ent/testobj"
}
// EOF

View File

@ -2,7 +2,10 @@
font "base" = "fonts/base.ttf", 24pt font "base" = "fonts/base.ttf", 24pt
texture "gui/border" = "textures/Border.png" texture "gui/border" = "textures/Border.png"
texture "ent/player" = "sprites/Particle3_Pointer.png"
texture "ent/player" = "sprites/Particle3_Pointer.png"
texture "ent/testobj" = "sprites/Particle3.png"
texture "box" = "textures/Box.png" texture "box" = "textures/Box.png"
texture "empty" = "textures/Empty.png" texture "empty" = "textures/Empty.png"

5
maps/stage1.gmf9 Normal file
View File

@ -0,0 +1,5 @@
// Copyright © 2017 Project Golan, all rights reserved.
{50 TestObj -200 0 16}
{50 TestObj -200 100 16}
// EOF

View File

@ -13,7 +13,8 @@
// Extern Objects ------------------------------------------------------------| // Extern Objects ------------------------------------------------------------|
char const *G_Place = u8"地球軌道・朝"; char const *G_Place = u8"地球軌道・朝";
unsigned long G_Time;
// Static Functions ----------------------------------------------------------| // Static Functions ----------------------------------------------------------|
@ -95,6 +96,8 @@ G_stage G_Stage_LoadMap(char const *fname)
} }
while(!feof(fp)); while(!feof(fp));
printf("Stage: Done loading stage '%s'.\n", fname);
done: done:
free(name); free(name);
fclose(fp); fclose(fp);
@ -103,22 +106,42 @@ done:
} }
// //
// G_Stage_Begin // G_Stage_LoadBase
// //
void G_Stage_Begin(unsigned stagenum) void G_Stage_LoadBase(void)
{ {
printf("Stage: Beginning stage %u.\n", stagenum); printf("Stage: Loading base map.\n");
G_stage s = G_Stage_LoadMap("maps/base.gmf0"); G_stage s = G_Stage_LoadMap("maps/base.gmf0");
for(int i = 0; i < s.mapC; i++) for(size_t i = 0; i < s.mapC && s.mapV[i].time == 0; i++)
s.mapV[i].proc(&s.mapV[i].data); s.mapV[i].proc(&s.mapV[i].data);
M_Vec_clear(s.map); printf("Stage: Splitting blockmap.\n");
printf("Stage: Done loading, splitting blockmap.\n");
DGE_BlockMap_Split(16, 1); DGE_BlockMap_Split(16, 1);
printf("Stage: Done loading stage %u.\n", stagenum); M_Vec_clear(s.map);
}
//
// G_Stage_Run
//
void G_Stage_Run(unsigned stagenum)
{
printf("Stage: Beginning stage %u.\n", stagenum);
G_stage s = G_Stage_LoadMap(M_StrFmt("maps/stage%u.gmf0", stagenum));
size_t i;
for(G_Time = 0;; G_Time++)
{
for(; i < s.mapC && s.mapV[i].time == G_Time; i++)
s.mapV[i].proc(&s.mapV[i].data);
DGE_Task_Sleep(0, 1);
}
M_Vec_clear(s.map);
} }
// EOF // EOF

View File

@ -41,11 +41,13 @@ typedef struct G_stage
// Extern Objects ------------------------------------------------------------| // Extern Objects ------------------------------------------------------------|
extern char const *G_Place; extern char const *G_Place;
extern long unsigned G_Time;
// Extern Functions ----------------------------------------------------------| // Extern Functions ----------------------------------------------------------|
G_stage G_Stage_LoadMap(char const *fname); G_stage G_Stage_LoadMap(char const *fname);
void G_Stage_Begin(unsigned stagenum); void G_Stage_LoadBase(void);
void G_Stage_Run(unsigned stagenum);
#endif #endif

View File

@ -47,7 +47,8 @@ void GInit(char const *resdecl)
void main(void) void main(void)
{ {
GInit("resdecl.rd"); GInit("resdecl.rd");
G_Stage_Begin(1); G_Stage_LoadBase();
G_Stage_Run(1);
} }
// EOF // EOF

View File

@ -19,7 +19,8 @@ static void R_drawHitboxes(void)
unsigned head = DGE_Thinker_Head(); unsigned head = DGE_Thinker_Head();
DGE_Point2 vp = DGE_Renderer_GetViewpoint(); DGE_Point2 vp = DGE_Renderer_GetViewpoint();
for(DGE_Thinker th = {head}; (th.id = th.next) != head;) { for(DGE_Thinker th = {head}; (th.id = th.next) != head;)
{
DGE_PhysicsThinker pth; DGE_PhysicsThinker pth;
if((pth.id = DGE_Object_Cast(th.id, DGE_OT_PhysicsThinker))) { if((pth.id = DGE_Object_Cast(th.id, DGE_OT_PhysicsThinker))) {
fixed tx = pth.x - vp.x, ty = pth.y - vp.y; fixed tx = pth.x - vp.x, ty = pth.y - vp.y;