Fix missing sdl3game.pc for pkg-config, change sprite speed and character movement values to long int expressed in nanoseconds for better compatibility with SDL_Time and locking against game clock, still expressed as milliseconds in json
This commit is contained in:
18
src/actor.c
18
src/actor.c
@@ -76,7 +76,7 @@ akerr_ErrorContext *actor_automatic_face(actor *obj)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *actor_logic_changeframe(actor *obj, sprite *curSprite, SDL_Time curtimems)
|
||||
akerr_ErrorContext *actor_logic_changeframe(actor *obj, sprite *curSprite, SDL_Time curtime)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
FAIL_ZERO_RETURN(errctx, obj, AKERR_NULLPOINTER, "Null actor reference");
|
||||
@@ -111,7 +111,7 @@ akerr_ErrorContext *actor_logic_changeframe(actor *obj, sprite *curSprite, SDL_T
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *actor_logic_movement(actor *obj, SDL_Time curtimems)
|
||||
akerr_ErrorContext *actor_logic_movement(actor *obj, SDL_Time curtime)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
FAIL_ZERO_RETURN(errctx, obj, AKERR_NULLPOINTER, "Null actor reference");
|
||||
@@ -139,7 +139,6 @@ akerr_ErrorContext *actor_update(actor *obj)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
SDL_Time curtime = 0;
|
||||
SDL_Time curtimems = 0;
|
||||
sprite *curSprite = NULL;
|
||||
|
||||
FAIL_ZERO_RETURN(errctx, obj, AKERR_NULLPOINTER, "NULL actor reference");
|
||||
@@ -147,12 +146,11 @@ akerr_ErrorContext *actor_update(actor *obj)
|
||||
|
||||
ATTEMPT {
|
||||
SDL_GetCurrentTime(&curtime);
|
||||
curtimems = curtime / 1000000;
|
||||
CATCH(errctx, obj->facefunc(obj));
|
||||
// is it time to apply movement logic?
|
||||
if ( (curtimems - obj->logictimer) >= obj->basechar->movementspeed ) {
|
||||
CATCH(errctx, obj->movementlogicfunc(obj, curtimems));
|
||||
obj->logictimer = curtimems;
|
||||
if ( (curtime - obj->logictimer) >= obj->basechar->movementspeed ) {
|
||||
CATCH(errctx, obj->movementlogicfunc(obj, curtime));
|
||||
obj->logictimer = curtime;
|
||||
}
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
@@ -161,9 +159,9 @@ akerr_ErrorContext *actor_update(actor *obj)
|
||||
ATTEMPT {
|
||||
CATCH(errctx, character_sprite_get(obj->basechar, obj->state, &curSprite));
|
||||
// is it time to change frames?
|
||||
if ( (curtimems - obj->curSpriteFrameTimer) >= curSprite->speed ) {
|
||||
CATCH(errctx, obj->changeframefunc(obj, curSprite, curtimems));
|
||||
obj->curSpriteFrameTimer = curtimems;
|
||||
if ( ((curtime) - obj->curSpriteFrameTimer) >= curSprite->speed) {
|
||||
CATCH(errctx, obj->changeframefunc(obj, curSprite, curtime));
|
||||
obj->curSpriteFrameTimer = curtime;
|
||||
}
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
|
||||
Reference in New Issue
Block a user