-
Notifications
You must be signed in to change notification settings - Fork 0
/
Object2D.h
52 lines (47 loc) · 1.78 KB
/
Object2D.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
47
48
49
50
51
52
#ifndef OBJECT2D_H
#define OBJECT2D_H
#pragma once
#include "SDL.h"
#include "SDL_opengl.h"
#include "Image.h"
#define NO2DHIST 5
// Stores an Image along with position and rotation information
class Object2D
{
private:
Image* image;
GLfloat xpos;
GLfloat ypos;
GLfloat xhist[NO2DHIST];
GLfloat yhist[NO2DHIST];
GLfloat xvel;
GLfloat yvel;
GLfloat angle;
GLfloat sizex;
GLfloat sizey;
//GLint drawOn;
public:
// i is the image to be displayed
Object2D(Image* i);
~Object2D() { }
GLfloat GetWidth() const; // Gets the default width (meters) of the image
GLfloat GetHeight() const; // Gets the default height (meters) of the image
GLfloat GetX() const; // Gets the X position (meters) of the object
GLfloat GetY() const; // Gets the Y position (meters) of the object
GLfloat GetLastX(); //returns the last x position
GLfloat GetLastY(); //returns the last y position
GLfloat GetXVel(); //returns the actual x hand velocity, non-distorted
GLfloat GetYVel(); //returns the actual y hand velocity, non-distorted
GLfloat GetVel(); //returns the actual 2D hand velocity, non-distorted
GLfloat GetAngle() const; // Gets the counterclockwise rotation (radians) of the object
void SetPos(GLfloat x, GLfloat y); // Sets the position (meters) of the object
void SetAngle(GLfloat theta); // Sets the counterclockwise rotation (radians) of the object
void Draw(); // Draw the object
void Draw(GLfloat width, GLfloat height); // Draw the object
float Distance(Object2D* ob1, Object2D* ob2); // Gets the distance between two objects (meters)
float Distance(Object2D* ob1, GLfloat x, GLfloat y); // Gets the distance between an object and a position (meters)
void On(); //set the draw flag on
void Off(); //set the draw flag off
int DrawState(); //return the draw flag
};
#endif