-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter2D.cpp
67 lines (57 loc) · 1.31 KB
/
Character2D.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "stdafx.h"
#include "Bitmap.h"
#include "Character2D.h"
#include "Input_State.h"
#include "Keyboard.h"
#include "Scroller.h"
Character2D::Character2D ()
{
Set_Defaults ();
}
Character2D::Character2D (int ID, int character_width, int character_height, bool Controllable)
{
Set_Defaults ();
width = character_width;
height = character_height;
controllable = Controllable;
}
Character2D::Character2D (int ID, Bitmap loaded_bitmap, bool Controllable)
{
Set_Defaults ();
bitmap = &loaded_bitmap;
bitmap->get_size (bitmap->sprite, width, height);
controllable = Controllable;
}
Character2D::Character2D (int ID, Bitmap &loaded_bitmap, int character_width, int character_height, bool Controllable)
{
Set_Defaults ();
bitmap = &loaded_bitmap;
width = character_width;
height = character_height;
controllable = Controllable;
spritesheet = true;
}
Character2D::~Character2D () {}
void Character2D::Set_Defaults ()
{
x = 200;
y = 200;
move_speed = 1;
spritesheet = false;
}
void Character2D::Update ()
{
position_rect ();
}
void Character2D::position_rect ()
{
render_rect.left = x - width / 2;
render_rect.right = x + width / 2;
render_rect.top = y - height;
render_rect.bottom = y;
}
void Character2D::set_position (int X, int Y)
{
x = X;
y = Y;
}