-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.cpp
More file actions
72 lines (58 loc) · 1.21 KB
/
GameObject.cpp
File metadata and controls
72 lines (58 loc) · 1.21 KB
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
68
69
70
71
72
/*
* GameObject.cpp
*
* Created on: Jan 24, 2011
* Author: Doug
*/
#include "GameObject.h"
GameObject::GameObject() {
// TODO Auto-generated constructor stub
}
GameObject::~GameObject() {
// TODO Auto-generated destructor stub
}
void GameObject::startup(int width, int height, BITMAP *bm, BITMAP *buff){
x_pos = -50; //start off screen
y_pos = -50;
shadow_x = -50;
shadow_y = -50;
sprite = bm;
buffer = buff;
shadow=create_bitmap_ex(32,width,height);
rectfill(shadow,0,0,width,height,makecol(0,0,0));
alive = 1;
}
void GameObject::setX(int x) {
if (alive == 0) return;
draw_sprite(buffer, shadow, shadow_x,shadow_y);
x_pos = x;
draw_sprite(buffer,sprite,x_pos,y_pos);
shadow_x=x_pos;
shadow_y=y_pos;
}
void GameObject::setY(int y){
if (alive == 0) return;
draw_sprite(buffer, shadow, shadow_x,shadow_y);
y_pos = y;
draw_sprite(buffer,sprite,x_pos,y_pos);
shadow_y=y_pos;
shadow_x=x_pos;
}
int GameObject::getX(){
return x_pos;
}
int GameObject::getY(){
return y_pos;
}
void GameObject::setSprite(BITMAP *bm){
sprite = bm;
}
void GameObject::setAlive(int al){
alive = al;
}
int GameObject::getAlive(){
return alive;
}
void GameObject::setShadow(BITMAP* sh){
shadow = sh;
}