Fixed rotation when moving
This commit is contained in:
parent
843719b433
commit
1886bd7f16
File diff suppressed because it is too large
Load Diff
1437
src/arenaEngine.c
1437
src/arenaEngine.c
File diff suppressed because it is too large
Load Diff
@ -70,6 +70,7 @@ int isMoveCorrect(ARENA_H_TILE* arena, TILE *t_list, int coord_x, int coord_y, i
|
||||
int getRelativeDirection(SDL_Rect pos1, SDL_Rect pos2);
|
||||
|
||||
int NumberPlayerAlive(PLAYER *Head);
|
||||
int canAttackPlayer(PLAYER *p1, PLAYER *p2);
|
||||
void AttackPlayer(PLAYER *player1, PLAYER *player2);
|
||||
void ActionPlayer(ARENA_H_TILE* arena,TILE *t_list,PLAYER * player, int action);
|
||||
|
||||
|
@ -68,16 +68,18 @@ int updateArena(SDL_Window* window, ARENA_H_TILE* arena, TILE *tiles, PLAYER *pl
|
||||
ActionPlayer(arena,tiles,p1,4); //Déplacement vers la gauche
|
||||
} else if(action == 5) {
|
||||
//Regarder le perso en face, le plus près
|
||||
AttackPlayer(p1,p2); //Voir quel player on choisit d'attaquer
|
||||
if (canAttackPlayer(p1,p2)==1) {
|
||||
AttackPlayer(p1,p2); //Voir quel player on choisit d'attaquer
|
||||
}
|
||||
}
|
||||
|
||||
// On place le joueur à la bonne position
|
||||
position.x = p1->PositionX * TILE_SIZE;
|
||||
position.y = p1->PositionY * TILE_SIZE;
|
||||
|
||||
//SDL_BlitSurface(p1->texture[getRelativeDirection(oldposition, position)], NULL, SDL_GetWindowSurface(window), &position);
|
||||
SDL_BlitSurface(getTileSurfaceFromID(tiles,getTileTypeID(arena,(oldposition.x)/TILE_SIZE,(oldposition.y)/TILE_SIZE)), NULL, SDL_GetWindowSurface(window), &oldposition);
|
||||
SDL_BlitSurface(p1->texture[DOWN], NULL, SDL_GetWindowSurface(window), &position);
|
||||
//SDL_BlitSurface(p1->texture[DOWN], NULL, SDL_GetWindowSurface(window), &position);
|
||||
SDL_BlitSurface(p1->texture[getRelativeDirection(oldposition, position)], NULL, SDL_GetWindowSurface(window), &position);
|
||||
|
||||
|
||||
|
||||
@ -96,9 +98,9 @@ int updateArena(SDL_Window* window, ARENA_H_TILE* arena, TILE *tiles, PLAYER *pl
|
||||
IAposition.x = p2->PositionX * TILE_SIZE;
|
||||
IAposition.y = p2->PositionY * TILE_SIZE;
|
||||
|
||||
//SDL_BlitSurface(p2->texture[getRelativeDirection(oldIAposition, IAposition)], NULL, SDL_GetWindowSurface(window), &IAposition);
|
||||
SDL_BlitSurface(getTileSurfaceFromID(tiles,getTileTypeID(arena,(oldIAposition.x)/TILE_SIZE,(oldIAposition.y)/TILE_SIZE)), NULL, SDL_GetWindowSurface(window), &oldIAposition);
|
||||
SDL_BlitSurface(p2->texture[DOWN], NULL, SDL_GetWindowSurface(window), &IAposition);
|
||||
//SDL_BlitSurface(p2->texture[DOWN], NULL, SDL_GetWindowSurface(window), &IAposition);
|
||||
SDL_BlitSurface(p2->texture[getRelativeDirection(oldIAposition, IAposition)], NULL, SDL_GetWindowSurface(window), &IAposition);
|
||||
|
||||
SDL_UpdateWindowSurface(window);
|
||||
|
||||
|
48
src/main.h
48
src/main.h
@ -1,24 +1,24 @@
|
||||
#ifndef MAIN_H_
|
||||
#define MAIN_H_
|
||||
|
||||
#define A_WIDTH 30
|
||||
#define A_HEIGHT 30
|
||||
|
||||
#define TILE_SIZE 32
|
||||
#define WINDOWS_WIDTH TILE_SIZE * A_WIDTH
|
||||
#define WINDOWS_HEIGHT TILE_SIZE * A_HEIGHT
|
||||
|
||||
/*
|
||||
* Generator tiles spawn rate (in percent)
|
||||
*/
|
||||
#define ROCK_GEN_RATE 30
|
||||
#define TREE_GEN_RATE 25
|
||||
#define WATER_GEN_RATE 8
|
||||
#define GOLD_GEN_RATE 10
|
||||
|
||||
enum {DOWN, UP, LEFT, RIGHT};
|
||||
enum {GRASS, ROCK, TREE, WATER, GOLD, SPAWN};
|
||||
|
||||
int random_lim(int max);
|
||||
|
||||
#endif
|
||||
#ifndef MAIN_H_
|
||||
#define MAIN_H_
|
||||
|
||||
#define A_WIDTH 30
|
||||
#define A_HEIGHT 30
|
||||
|
||||
#define TILE_SIZE 32
|
||||
#define WINDOWS_WIDTH TILE_SIZE * A_WIDTH
|
||||
#define WINDOWS_HEIGHT TILE_SIZE * A_HEIGHT
|
||||
|
||||
/*
|
||||
* Generator tiles spawn rate (in percent)
|
||||
*/
|
||||
#define ROCK_GEN_RATE 30
|
||||
#define TREE_GEN_RATE 25
|
||||
#define WATER_GEN_RATE 8
|
||||
#define GOLD_GEN_RATE 10
|
||||
|
||||
enum {DOWN, UP, LEFT, RIGHT};
|
||||
enum {GRASS, ROCK, TREE, WATER, GOLD, SPAWN};
|
||||
|
||||
int random_lim(int max);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user