mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2025-03-11 15:39:41 -04: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
|
#define SFG_LEVEL_ELEMENT_ACTIVE_DISTANCE 8
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Time in ms after which AI will be recomputing its state (which also affects
|
Time interval in ms after which AI will be updating (which also affects
|
||||||
how quickly death animation plays etc).
|
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
|
#endif // guard
|
||||||
|
28
main.c
28
main.c
@ -290,6 +290,13 @@ typedef struct
|
|||||||
#define SFG_AI_UPDATE_FRAME_INTERVAL 1
|
#define SFG_AI_UPDATE_FRAME_INTERVAL 1
|
||||||
#endif
|
#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
|
GLOBAL VARIABLES
|
||||||
===============================================================================
|
===============================================================================
|
||||||
@ -644,10 +651,8 @@ void SFG_blitImage(
|
|||||||
sY++;
|
sY++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u++;
|
u++;
|
||||||
}
|
}
|
||||||
|
|
||||||
v++;
|
v++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,9 +983,9 @@ void SFG_playerRotateWeapon(uint8_t next)
|
|||||||
SFG_player.weapon %= 3;
|
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;
|
SFG_currentLevel.checkedMonsterIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t recomputeAIState = ((SFG_gameFrame - SFG_currentLevel.frameStart) %
|
if (((SFG_gameFrame - SFG_currentLevel.frameStart) %
|
||||||
SFG_AI_UPDATE_FRAME_INTERVAL) == 0;
|
SFG_AI_UPDATE_FRAME_INTERVAL) == 0)
|
||||||
|
for (uint8_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i)
|
||||||
for (uint8_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i)
|
if (SFG_currentLevel.monsterRecords[i].stateType !=
|
||||||
if (SFG_currentLevel.monsterRecords[i].stateType !=
|
SFG_MONSTER_STATE_INACTIVE)
|
||||||
SFG_MONSTER_STATE_INACTIVE)
|
SFG_monsterPerformAI(
|
||||||
SFG_monsterPerformAI(
|
&(SFG_currentLevel.monsterRecords[i]));
|
||||||
&(SFG_currentLevel.monsterRecords[i]),recomputeAIState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SFG_clearScreen(uint8_t color)
|
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
|
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
|
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
|
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
|
#define SFG_FPS 60
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user