Mentions légales du service

Skip to content
Snippets Groups Projects
action.h 1.60 KiB
#ifndef ACTION_H
#define ACTION_H

#include "agdbentures.h"

// the width of a screen, in tiles
#define SCREEN_WIDTH 60

// the height of the screen, in tiles
#define SCREEN_HEIGHT 8

#define UP 8
#define DOWN 2
#define LEFT 4
#define RIGHT 6

/**
 * pos_x : current x position of the character
 * pos_y : current y position of the character
 * dir : Defines the direction in which the player moves. 
 * Must be in [1..9], where 5 is no movement, 1 is down-left, 9 is top-right... Do you follow?
 * If dir is not in [1..9], it is treated as 5, so no movement occurs.
 */

void turn_right (void);
void turn_left (void);


/**
 * Computes the coordinates from (x,y) when moving 1 square in direction 'dir'
 * and stores the results in pointers (*cx, *cy).
 */
void coord_in_dir (int y, int x, int dir, int *cy, int *cx);

/**
 * Idem but when moving 'n' squares in direction 'dir'.
 */
void coord_in_dir_n (int y, int x, int dir, int *cy, int *cx, int n);

// Functions to move the character
void up();
void up_n(unsigned n);
void down();
void down_n(unsigned n);
void left();
void left_n(unsigned n);
void right();
void right_n(unsigned n);

void forward (void);
void forward_n (unsigned num_steps);

/**
 * Verifies if the player can move to tile (x, y).
 * Returns 0  if (x, y) is accessible
 * Returns 1  if (x, y) is no accessible because it's occupied by an obstacle
 * Returns -1 if (x, y) is outside the screen. In that case it's up to the game to decide
 * wether the player will transition to another screen or can't move anymore.
 */
int collision(int x, int y);

void talk(void);
void fight(equipment eq);

#endif//ACTION_H