mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-12-21 23:08:49 -05:00
Continue AI
This commit is contained in:
parent
eedec535e9
commit
9a0f4f3a8e
11
constants.h
11
constants.h
@ -55,9 +55,14 @@
|
||||
#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).
|
||||
Time interval in ms after which AI will be updating (which also affects
|
||||
speed of monster animation etc).
|
||||
*/
|
||||
#define SFG_AI_UPDATE_INTERVAL 500
|
||||
#define SFG_AI_UPDATE_INTERVAL 300
|
||||
|
||||
/**
|
||||
Normal movement speed of monsters, in squares per second.
|
||||
*/
|
||||
#define SFG_MONSTER_MOVEMENT_SPEED 2
|
||||
|
||||
#endif // guard
|
||||
|
28
main.c
28
main.c
@ -290,6 +290,13 @@ typedef struct
|
||||
#define SFG_AI_UPDATE_FRAME_INTERVAL 1
|
||||
#endif
|
||||
|
||||
#define SFG_MONSTER_MOVE_UNITS_PER_FRAME \
|
||||
(((SFG_MONSTER_MOVEMENT_SPEED * SFG_AI_UPDATE_FRAME_INTERVAL * 4) / SFG_FPS))
|
||||
|
||||
#if SFG_MONSTER_MOVE_UNITS_PER_FRAME == 0
|
||||
#define SFG_MONSTER_MOVE_UNITS_PER_FRAME 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
GLOBAL VARIABLES
|
||||
===============================================================================
|
||||
@ -644,10 +651,8 @@ void SFG_blitImage(
|
||||
sY++;
|
||||
}
|
||||
}
|
||||
|
||||
u++;
|
||||
}
|
||||
|
||||
v++;
|
||||
}
|
||||
}
|
||||
@ -978,9 +983,9 @@ void SFG_playerRotateWeapon(uint8_t next)
|
||||
SFG_player.weapon %= 3;
|
||||
}
|
||||
|
||||
void SFG_monsterPerformAI(SFG_MonsterRecord *monster, int8_t recomputeState)
|
||||
void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
|
||||
{
|
||||
// TODO
|
||||
monster->coords[0] += SFG_MONSTER_MOVE_UNITS_PER_FRAME;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1282,14 +1287,13 @@ void SFG_gameStep()
|
||||
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);
|
||||
if (((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]));
|
||||
}
|
||||
|
||||
void SFG_clearScreen(uint8_t color)
|
||||
|
@ -21,7 +21,9 @@
|
||||
Target FPS (frames per second). This sets the game logic FPS and will try to
|
||||
render at the same rate. If such fast rendering can't be achieved, frames will
|
||||
be droped, but the game logic will still be forced to run at this speed, so
|
||||
the game may actually become slowed down if FPS is set too high.
|
||||
the game may actually become slowed down if FPS is set too high. Too high FPS
|
||||
can also negatively affect game speeds which are computed as integers and
|
||||
rounding errors can occur soon, so don't set this to extreme values.
|
||||
*/
|
||||
#define SFG_FPS 60
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user