5
5
namespace invadersGame{
6
public SDL.Surface GameObjectImage;
8
7
class GameObject : Object{
9
protected SDL.Rect my_rect;
11
protected float speed;
12
protected float pos_x;
13
protected float pos_y;
14
protected uint32 last_frame;
9
16
public struct MovmentVector {
11
18
* Is used for storting a movement vector.
12
19
* IE: if it should move up (y < 0), up (y > 0), left (x < 0),
17
int Speed; /* Maximum movement over Time */
18
int Time; /* The time it takes to move */
22
int delta_x; /* The delta of the object can have thee states:
23
delta_x < 0, delta_x = 0 or delta_x > 0*/
24
int delta_y; /* See above */
25
int speed; /* Maximum movement over Time (in seconds) */
21
30
MovmentVector mMovmentVector;
24
GameObjectImage = SDLImage.load("media/images/null.png");
26
Game.getRandom(SCREEN_WIDTH),
27
Game.getRandom(SCREEN_HEIGHT),
31
stdout.printf("X: %i, Y: %i\n", mMovmentVector.x, mMovmentVector.y);
33
mMovmentVector.x = 10;
35
stdout.printf("New X: %i, Y: %i\n", mMovmentVector.x, mMovmentVector.y);
32
public GameObject(int16 x, int16 y, int delta_x, int delta_y,
33
int speed, int health){
35
my_rect = SDL.Rect ();
42
last_frame = SDL.Timer.get_ticks();
45
public virtual void draw(SDL.Screen screen) {
46
ResourceHandler.image_null.blit(null ,screen,my_rect);
49
public virtual void move() {