omi-eikyo/src/main.c

111 lines
2.6 KiB
C
Raw Normal View History

2017-09-20 08:42:57 -07:00
// Copyright © 2017 Project Golan, all rights reserved.
#include "g_object.h"
2017-09-21 10:53:20 -07:00
#include "m_str.h"
2017-09-20 08:42:57 -07:00
#include <Doominati.h>
#include <stdio.h>
2017-09-21 18:55:22 -07:00
// Extern Objects ------------------------------------------------------------|
char const *G_place = u8"地球軌道・朝";
2017-09-20 08:42:57 -07:00
// Static Functions ----------------------------------------------------------|
2017-09-21 18:55:22 -07:00
//
// R_drawHitboxes
//
static void R_drawHitboxes(void)
{
DGE_Texture_Bind(0);
DGE_Draw_SetColor(1lr, 0, 0, 0.5lr);
unsigned head = DGE_Thinker_Head();
DGE_Point2 vp = DGE_Renderer_GetViewpoint();
for(DGE_Thinker th = {head}; (th.id = th.next) != head;) {
DGE_PhysicsThinker pth;
if((pth.id = DGE_Object_Cast(th.id, DGE_OT_PhysicsThinker))) {
fixed tx = pth.x - vp.x, ty = pth.y - vp.y;
DGE_Draw_Rectangle(tx - pth.sx, ty - pth.sy, tx + pth.sx, ty + pth.sy);
}
}
DGE_Draw_SetColor();
}
//
// R_Draw
//
static DGE_Callback void R_Draw(ulfra delta)
{
DGE_Shader_Bind(DGE_Shader_Get(s"plasma"));
DGE_Texture_Bind(0);
DGE_Draw_Rectangle(0, 0, 960, 720);
DGE_Shader_Bind(0);
}
2017-09-20 08:42:57 -07:00
//
2017-09-21 10:53:20 -07:00
// R_DrawPost
2017-09-20 08:42:57 -07:00
//
2017-09-21 10:53:20 -07:00
static DGE_Callback void R_DrawPost(ulfra delta)
2017-09-20 08:42:57 -07:00
{
2017-09-21 18:55:22 -07:00
DGE_Texture_Bind(DGE_Texture_Get(s"gui/border"));
2017-09-21 10:53:20 -07:00
DGE_Draw_Rectangle(0, 0, 960, 720);
2017-09-21 18:55:22 -07:00
DGE_Font_Bind(DGE_Font_Get(s"base"));
2017-09-21 10:53:20 -07:00
DGE_Draw_SetTextAlign(DGE_Align_Center);
2017-09-21 18:55:22 -07:00
DGE_Draw_Text(760, 20, G_place);
2017-09-21 10:53:20 -07:00
DGE_Draw_SetTextAlign(DGE_Align_Left);
2017-09-21 18:55:22 -07:00
DGE_Draw_Text(585, 70, u8"ハイスコア\nスコア\n\n残り再試行回");
2017-09-21 10:53:20 -07:00
DGE_Draw_SetTextAlign(DGE_Align_Right);
DGE_Draw_Text(945, 70, M_StrFmt("%.15i\n%.15i\n\n%i", 0, 0, 5));
2017-09-21 18:55:22 -07:00
R_drawHitboxes();
2017-09-20 08:42:57 -07:00
}
2017-09-21 10:53:20 -07:00
//
// G_Stage_Begin
//
static void G_Stage_Begin(unsigned stagenum)
{
G_Player_Create(-200, 250);
}
2017-09-20 08:42:57 -07:00
2017-09-21 10:53:20 -07:00
// Extern Functions ----------------------------------------------------------|
2017-09-20 19:36:30 -07:00
2017-09-21 18:55:22 -07:00
void R_ResDec_Load(char const *fname);
2017-09-20 08:42:57 -07:00
//
// main
//
[[__extern("asm")]] DGE_Callback
void main(void)
{
printf("\n=====================\n"
u8"オミ:影響の目 1.0\n"
u8"Copyright © 2017 Project Golan, all rights reserved.\n\n");
2017-09-21 10:53:20 -07:00
DGE_Renderer_SetVirtualRes(960, 720);
2017-09-20 08:42:57 -07:00
2017-09-21 18:55:03 -07:00
printf("Loading resource declarations...\n");
R_ResDec_Load("resdecl.rd");
2017-09-20 08:42:57 -07:00
printf("Loading object function table...\n");
G_ObjDef_Init();
G_ObjDef_loadFunc(G_Player_Think);
printf("Loading object definitions...\n");
G_ObjDef_Load("objdefs.dod");
2017-09-20 19:36:30 -07:00
printf("Registering callbacks...\n");
2017-09-21 18:55:22 -07:00
DGE_Callback_Register(DGE_CB_Draw, (DGE_CallbackType)R_Draw);
2017-09-21 10:53:20 -07:00
DGE_Callback_Register(DGE_CB_DrawPost, (DGE_CallbackType)R_DrawPost);
2017-09-20 08:42:57 -07:00
2017-09-20 19:36:30 -07:00
printf("Ready.\n");
2017-09-21 10:53:20 -07:00
G_Stage_Begin(1);
2017-09-20 08:42:57 -07:00
}
// EOF