-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharactor.cpp
More file actions
36 lines (31 loc) · 876 Bytes
/
Copy pathCharactor.cpp
File metadata and controls
36 lines (31 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "Charactor.h"
#include "global.h"
//#include <allegro5/allegro.h>
//#include <allegro5/allegro_primitives.h>
const char direction_name[][10] = {"LEFT", "RIGHT", "UP", "DOWN"};
// set counter frequency of drawing moving animation
const int draw_frequency = 10;
void Charactor::Draw(){
/*TODO*/
}
void Charactor::load_move()
{
/*TODO*/
}
bool Charactor::valid_move(int dx,int dy)
{
return this->width/2 + get_posx()+dx*speed > -25
&& this->width/2 + get_posx()+dx*speed < field_width-50
&& this->height/2 + get_posy()+dy*speed > -50
&& this->height/2 + get_posy()+dy*speed < field_height-80;
}
void Charactor::step(double dx,double dy)
{
set_posx(get_posx()+dx);
set_posy(get_posy()+dy);
set_gridx( (int)(get_posy() / grid_width+1) );
set_gridy( (int)(get_posx() / grid_height+1) );
}
Charactor::~Charactor()
{
}