Move Player functions to g_player.c
parent
1b78de537e
commit
7ca5c6275b
|
@ -1,8 +1,8 @@
|
||||||
bin/*.ir
|
bin/*.ir
|
||||||
codedefs/*.bin
|
codedefs/*.bin
|
||||||
src_crap
|
|
||||||
src_oldtest
|
|
||||||
doc
|
doc
|
||||||
|
fonts
|
||||||
sounds
|
sounds
|
||||||
sprites
|
sprites
|
||||||
textures
|
textures
|
||||||
|
src_crap
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright © 2017 Project Golan, all rights reserved.
|
||||||
|
#include "g_object.h"
|
||||||
|
|
||||||
|
#include <Doominati.h>
|
||||||
|
|
||||||
|
// Extern Functions ----------------------------------------------------------|
|
||||||
|
|
||||||
|
//
|
||||||
|
// G_Player_Think
|
||||||
|
//
|
||||||
|
DGE_Callback void G_Player_Think(DGE_Entity ent)
|
||||||
|
{
|
||||||
|
DGE_Object_RefAdd(ent.id);
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
if(ent.health <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
ent.vx = ent.vx + (fixed)DGE_GetInputAxis(0, DGE_Axis_X);
|
||||||
|
ent.vy = ent.vy - (fixed)DGE_GetInputAxis(0, DGE_Axis_Y);
|
||||||
|
|
||||||
|
DGE_Task_Sleep(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
DGE_Object_RefSub(ent.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// G_Player_Create
|
||||||
|
//
|
||||||
|
DGE_Entity G_Player_Create(fixed x, fixed y)
|
||||||
|
{
|
||||||
|
DGE_Entity ent = {DGE_Entity_Create(0)};
|
||||||
|
|
||||||
|
ent.x = x;
|
||||||
|
ent.y = y;
|
||||||
|
|
||||||
|
G_entty const *type;
|
||||||
|
if((type = G_ObjDef_GetType("Player"))) {
|
||||||
|
G_ObjDef_setupEntity(type, ent);
|
||||||
|
G_ObjDef_createTask (type, ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
// Types ---------------------------------------------------------------------|
|
// Types ---------------------------------------------------------------------|
|
||||||
|
|
||||||
|
typedef unsigned long fract ulfra;
|
||||||
typedef short accum fixed; // Fixed
|
typedef short accum fixed; // Fixed
|
||||||
typedef long fract lfrac; // Long Fractional
|
typedef long fract lfrac; // Long Fractional
|
||||||
typedef size_t msize; // Machine Size
|
typedef size_t msize; // Machine Size
|
||||||
|
|
50
src/main.c
50
src/main.c
|
@ -1,6 +1,5 @@
|
||||||
// Copyright © 2017 Project Golan, all rights reserved.
|
// Copyright © 2017 Project Golan, all rights reserved.
|
||||||
#include "g_object.h"
|
#include "g_object.h"
|
||||||
#include "m_types.h"
|
|
||||||
|
|
||||||
#include <Doominati.h>
|
#include <Doominati.h>
|
||||||
|
|
||||||
|
@ -9,44 +8,21 @@
|
||||||
// Static Functions ----------------------------------------------------------|
|
// Static Functions ----------------------------------------------------------|
|
||||||
|
|
||||||
//
|
//
|
||||||
// G_Player_Think
|
// Draw
|
||||||
//
|
//
|
||||||
DGE_Callback static void G_Player_Think(DGE_Entity ent)
|
static void Draw(ulfra delta)
|
||||||
{
|
{
|
||||||
DGE_Object_RefAdd(ent.id);
|
DGE_Font_Bind(DGE_Font_Get(s"myfont"));
|
||||||
|
DGE_Draw_Text(20, 20,
|
||||||
for(;;)
|
u8"hello, world!? こんにちは、世界さん!?\n"
|
||||||
{
|
u8"¿¡hola, mundo!? 你好,世界!?\n"
|
||||||
if(ent.health <= 0)
|
u8"γειά σου κόσμε!? hej verden!?");
|
||||||
break;
|
|
||||||
|
|
||||||
ent.vx = ent.vx + (fixed)DGE_GetInputAxis(0, DGE_Axis_X);
|
|
||||||
ent.vy = ent.vy - (fixed)DGE_GetInputAxis(0, DGE_Axis_Y);
|
|
||||||
|
|
||||||
DGE_Task_Sleep(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
DGE_Object_RefSub(ent.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// G_Player_Create
|
|
||||||
//
|
|
||||||
static DGE_Entity G_Player_Create(fixed x, fixed y)
|
|
||||||
{
|
|
||||||
DGE_Entity ent = {DGE_Entity_Create(0)};
|
|
||||||
ent.x = x;
|
|
||||||
ent.y = y;
|
|
||||||
G_entty const *type;
|
|
||||||
if((type = G_ObjDef_GetType("Player"))) {
|
|
||||||
G_ObjDef_setupEntity(type, ent);
|
|
||||||
G_ObjDef_createTask (type, ent);
|
|
||||||
}
|
|
||||||
return ent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extern Functions ----------------------------------------------------------|
|
// Extern Functions ----------------------------------------------------------|
|
||||||
|
|
||||||
|
extern void G_Player_Think(DGE_Entity);
|
||||||
|
|
||||||
//
|
//
|
||||||
// main
|
// main
|
||||||
//
|
//
|
||||||
|
@ -66,9 +42,13 @@ void main(void)
|
||||||
printf("Loading object definitions...\n");
|
printf("Loading object definitions...\n");
|
||||||
G_ObjDef_Load("objdefs.dod");
|
G_ObjDef_Load("objdefs.dod");
|
||||||
|
|
||||||
printf("Ready.\n");
|
printf("Creating fonts...\n");
|
||||||
|
DGE_Font_Create(s"myfont", "fonts/base.ttf", 24);
|
||||||
|
|
||||||
G_Player_Create(32, 32);
|
printf("Registering callbacks...\n");
|
||||||
|
DGE_Callback_Register(DGE_CB_Draw, (DGE_CallbackType)Draw);
|
||||||
|
|
||||||
|
printf("Ready.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
Loading…
Reference in New Issue