116 lines
2.2 KiB
C
116 lines
2.2 KiB
C
// Copyright © 2017 Project Golan, all rights reserved.
|
|
// See COPYING for more information.
|
|
#include "g_object.h"
|
|
|
|
#include "g_stage.h"
|
|
|
|
#include <Doominati.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
// Extern Functions ----------------------------------------------------------|
|
|
|
|
//
|
|
// G_RenderThinker_Animate
|
|
//
|
|
void G_RenderThinker_Animate(unsigned id)
|
|
{
|
|
G_renderth th = {id};
|
|
|
|
if(th.ftime > 0)
|
|
th.ftime = th.ftime - 1;
|
|
|
|
else if(th.ftime == 0 && th.curanim)
|
|
{
|
|
if(th.frame < th.curanim->count)
|
|
{
|
|
G_frame const *const fr = &th.curanim->frame[th.frame];
|
|
th.sprite = fr->sprite;
|
|
th.ftime = fr->time;
|
|
th.frame = th.frame + 1;
|
|
}
|
|
else
|
|
th.sprite = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
// G_RenderThinker_AnimSet
|
|
//
|
|
void G_RenderThinker_AnimSet(unsigned id, G_anim const *anim)
|
|
{
|
|
G_renderth th = {id};
|
|
|
|
if(anim && th.curanim != anim)
|
|
{
|
|
th.curanim = anim;
|
|
th.frame = 0;
|
|
th.ftime = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
// G_RenderThinker_AnimSetForced
|
|
//
|
|
void G_RenderThinker_AnimSetForced(unsigned id, G_anim const *anim)
|
|
{
|
|
G_renderth th = {id};
|
|
|
|
th.curanim = anim;
|
|
th.frame = 0;
|
|
th.ftime = 0;
|
|
}
|
|
|
|
//
|
|
// G_Entity_Create
|
|
//
|
|
void G_Entity_Create(G_mapdata *info)
|
|
{
|
|
G_enttype const *type = G_ObjDef_GetType(info->ent.name);
|
|
|
|
G_entity ent = {DGE_Entity_Create(type ? type->ext : 0)};
|
|
|
|
ent.x = info->ent.x;
|
|
ent.y = info->ent.y;
|
|
ent.z = info->ent.z;
|
|
|
|
ent.gx = 1;
|
|
ent.gy = 1;
|
|
ent.gz = 1;
|
|
ent.mass = 1;
|
|
ent.friction = 0.875ulr;
|
|
|
|
if(type) {
|
|
G_ObjDef_setupEntity(type, ent);
|
|
G_ObjDef_createTask (type, ent.id);
|
|
}
|
|
}
|
|
|
|
//
|
|
// G_Sector_Create
|
|
//
|
|
void G_Sector_Create(G_mapdata *info)
|
|
{
|
|
DGE_Sector sec = {DGE_Sector_Create(4, 0)};
|
|
|
|
DGE_Object_RefAdd(sec.id);
|
|
|
|
sec.friction = 0.9lr;
|
|
sec.gz = -2;
|
|
sec.zl = info->sec.f;
|
|
sec.zu = info->sec.c;
|
|
|
|
fixed xl = info->sec.x , yl = info->sec.y;
|
|
fixed xu = info->sec.w + xl, yu = info->sec.h + yl;
|
|
|
|
DGE_Sector_PointSet(sec.id, 0, (DGE_Point2){xl, yl});
|
|
DGE_Sector_PointSet(sec.id, 1, (DGE_Point2){xl, yu});
|
|
DGE_Sector_PointSet(sec.id, 2, (DGE_Point2){xu, yu});
|
|
DGE_Sector_PointSet(sec.id, 3, (DGE_Point2){xu, yl});
|
|
|
|
DGE_Sector_CalcBounds(sec.id);
|
|
DGE_Sector_Block(sec.id);
|
|
}
|
|
|
|
// EOF
|