-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawable.h
46 lines (37 loc) · 1.37 KB
/
drawable.h
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
#ifndef DRAWABLE__H
#define DRAWABLE__H
#include <SDL.h>
#include <iostream>
#include "vector2f.h"
// Drawable is an Abstract Base Class (ABC) that
// specifies the methods that derived classes may
// and must have.
class Drawable {
public:
Drawable(const Vector2f& pos, const Vector2f& vel, const Vector2f& mxv) :
position(pos), velocity(vel), maxVelocity(mxv) {}
Drawable(const Drawable& s) : position(s.position), velocity(s.velocity),
maxVelocity(s.maxVelocity) { }
virtual ~Drawable() {}
virtual void draw() const = 0;
virtual void update(Uint32 ticks) = 0;
float X() const { return position[0]; }
void X(float x) { position[0] = x; }
float Y() const { return position[1]; }
void Y(float y) { position[1] = y; }
float velocityX() const { return velocity[0]; }
void velocityX(float vx) { velocity[0] = vx; }
float velocityY() const { return velocity[1]; }
void velocityY(float vy) { velocity[1] = vy; }
const Vector2f& getPosition() const { return position; }
const Vector2f& getVelocity() const { return velocity; }
const Vector2f& getMaxVelocity() const { return maxVelocity; }
void setPosition(const Vector2f& pos) { position = pos; }
void setVelocity(const Vector2f& vel) { velocity = vel; }
void setMaxVelocity(const Vector2f& vel) { maxVelocity = vel; }
private:
Vector2f position;
Vector2f velocity;
Vector2f maxVelocity;
};
#endif