mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-28 11:52:15 -05:00
Start AI
This commit is contained in:
parent
7a47d4768d
commit
eedec535e9
@ -54,4 +54,10 @@
|
|||||||
*/
|
*/
|
||||||
#define SFG_LEVEL_ELEMENT_ACTIVE_DISTANCE 8
|
#define SFG_LEVEL_ELEMENT_ACTIVE_DISTANCE 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
Time in ms after which AI will be recomputing its state (which also affects
|
||||||
|
how quickly death animation plays etc).
|
||||||
|
*/
|
||||||
|
#define SFG_AI_UPDATE_INTERVAL 500
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
21
main.c
21
main.c
@ -283,6 +283,13 @@ typedef struct
|
|||||||
|
|
||||||
#define SFG_MAX_MONSTERS 64
|
#define SFG_MAX_MONSTERS 64
|
||||||
|
|
||||||
|
#define SFG_AI_UPDATE_FRAME_INTERVAL \
|
||||||
|
(SFG_AI_UPDATE_INTERVAL / SFG_MS_PER_FRAME)
|
||||||
|
|
||||||
|
#if SFG_AI_UPDATE_FRAME_INTERVAL == 0
|
||||||
|
#define SFG_AI_UPDATE_FRAME_INTERVAL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GLOBAL VARIABLES
|
GLOBAL VARIABLES
|
||||||
===============================================================================
|
===============================================================================
|
||||||
@ -971,6 +978,11 @@ void SFG_playerRotateWeapon(uint8_t next)
|
|||||||
SFG_player.weapon %= 3;
|
SFG_player.weapon %= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SFG_monsterPerformAI(SFG_MonsterRecord *monster, int8_t recomputeState)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Performs one game step (logic, physics), happening SFG_MS_PER_FRAME after
|
Performs one game step (logic, physics), happening SFG_MS_PER_FRAME after
|
||||||
previous frame.
|
previous frame.
|
||||||
@ -1269,6 +1281,15 @@ void SFG_gameStep()
|
|||||||
SFG_currentLevel.monsterRecordCount)
|
SFG_currentLevel.monsterRecordCount)
|
||||||
SFG_currentLevel.checkedMonsterIndex = 0;
|
SFG_currentLevel.checkedMonsterIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t recomputeAIState = ((SFG_gameFrame - SFG_currentLevel.frameStart) %
|
||||||
|
SFG_AI_UPDATE_FRAME_INTERVAL) == 0;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i)
|
||||||
|
if (SFG_currentLevel.monsterRecords[i].stateType !=
|
||||||
|
SFG_MONSTER_STATE_INACTIVE)
|
||||||
|
SFG_monsterPerformAI(
|
||||||
|
&(SFG_currentLevel.monsterRecords[i]),recomputeAIState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SFG_clearScreen(uint8_t color)
|
void SFG_clearScreen(uint8_t color)
|
||||||
|
Loading…
Reference in New Issue
Block a user