-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobject.h
More file actions
117 lines (108 loc) · 2.57 KB
/
object.h
File metadata and controls
117 lines (108 loc) · 2.57 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef OBJECT_H
#define OBJECT_H
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <iostream>
#include <SDL_ttf.h>
#include <cmath>
#include <ctime>
#include "screen.h"
#include "character.h"
class money
{
friend class mapobject;
public:
//check if money is valid in this map
int isvalid;
//Shows the dot on the screen
void render();
//check if trump reach money
void checkcollision(Dot&);
//Moves the dot
void move(int &);
private:
//The X and Y offsets of the dot
int mPosX, mPosY;
//The velocity of the dot
int mVelX, mVelY;
};
class obstacle
{
friend class mapobject;
private:
//The X and Y offsets of the dot
int mPosX, mPosY;
//The velocity of the dot
int mVelX, mVelY;
//which building to show
int buildingtype;
public:
obstacle(){isvalid = mVelX = mVelY = mPosX = mPosY = 0; buildingtype = rand()%2;}
//whether to show the obstacle
int isvalid;
//Shows the dot on the screen
void render();
//Moves the dot
void move(int &);
//check if trump reach money
void checkcollision(Dot&);
};
class people
{
friend class mapobject;
private:
//The X and Y offsets of the dot
int mPosX, mPosY;
//The velocity of the dot
int mVelX, mVelY;
//which building to show
int peopletype;
public:
people(){isvalid = mVelX = mVelY = mPosX = mPosY = 0; peopletype = rand()%3+1; append = false; apporder = 0;}
//whether to show the obstacle
int isvalid;
//Shows the dot on the screen
void render(Dot&);
//Moves the dot
void move(int &);
//check if trump reach money
void checkcollision(Dot&);
//check if should append
bool append;
//append order
int apporder;
};
class mapobject
{
private:
int m, o, p;
public:
mapobject(){m=o=p=mapcount=0;}
void arrayinit(int , int , int , int );
//state objects' x position
int objectpositionx[25]={0};
//state objects' y position
int objectpositiony[25]={0};
//state object's type
int objecttype[20]={0};
//check
bool checkobjectrepeat(int, int);
void move(int &);
void render(Dot&);
void reset();
money mapmoney[25];
obstacle mapobstacle[25];
people mappeople[25];
//check if trump reach money
void checkcollision(Dot&);
//append and move
void appmove(Dot&);
//render stack
void renderstack(Dot&);
protected:
int mapcount;
};
#endif