// Copyright © 2017 Project Golan, all rights reserved. #define _GNU_SOURCE // Required for sincos(3). See feature_test_macros(7) #include "g_object.h" #include #include #include // Static Functions ----------------------------------------------------------| // // G_Player_applyVelocity // static void G_Player_applyVelocity(DGE_Entity ent) { DGE_Point2R ax = DGE_Input_GetAxis(1); accum vx = (accum)ax.x, vy = (accum)ax.y; float mag = sqrtf(vx * vx + vy * vy); float ang = atan2f(vy, vx); float s, c; sincosf(ang, &s, &c); ent.vx = ent.vx + c * mag * 1.1; ent.vy = ent.vy - s * mag * 1.1; // TODO: apply animation based on X velocity here } // 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; G_Player_applyVelocity(ent); DGE_Task_Sleep(0, 1); } DGE_Object_RefSub(ent.id); } // EOF