mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-28 04:23:42 +01:00
Corrected bug regarding interactions with items in maps - used local coordinates instead of world coordinates :(
This commit is contained in:
parent
9d8464e0d5
commit
ad525b8693
1 changed files with 10 additions and 2 deletions
12
src/game.c
12
src/game.c
|
@ -13,14 +13,22 @@
|
|||
extern bopti_image_t SignAction_img;
|
||||
|
||||
|
||||
#define MAX_INTERACTION_DISTANCE 16
|
||||
|
||||
|
||||
void game_logic(Game *game) {
|
||||
|
||||
/* we check if interactions are possible close to the player */
|
||||
for( int i=0; i<game->map_level->nbextradata; i++ )
|
||||
{
|
||||
/* simple distance check along X and Y axis */
|
||||
if ( (abs((int) game->player.x - (int) game->map_level->extradata[i].x*PXSIZE) < 8*PXSIZE)
|
||||
&& (abs((int) game->player.y - (int) game->map_level->extradata[i].y*PXSIZE) < 8*PXSIZE))
|
||||
/* Be careful to use world coordinates, not local (i.e.map) ones */
|
||||
if ( (abs((int) game->player.wx -
|
||||
(int) game->map_level->extradata[i].x*PXSIZE )
|
||||
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
||||
&& (abs((int) game->player.wy -
|
||||
(int) game->map_level->extradata[i].y*PXSIZE )
|
||||
< MAX_INTERACTION_DISTANCE*PXSIZE) )
|
||||
{
|
||||
/* the player can do something */
|
||||
game->player.canDoSomething = true;
|
||||
|
|
Loading…
Reference in a new issue