forked from ssine/airport-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassenger.cpp
More file actions
73 lines (60 loc) · 1.64 KB
/
Copy pathpassenger.cpp
File metadata and controls
73 lines (60 loc) · 1.64 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
#include "stdafx.h"
#include "passenger.h"
#include <cstdlib>
#include <cstdio>
#include "view.h"
#include <iostream>
using namespace std;
float width = 0.08, height = 0.25;
// 动画步长
float step = 0.02;
// 距离终点多远时停止
float stopEps = 0.05;
extern float CPInterval;
extern float CPBaseX, CPBaseY;
extern float CPWidth, CPHeight;
inline float sym(float a, float b) {
if(std::abs(a - b) < stopEps) return 0.0f;
else if(a - b > 0) return -1.0f;
else return 1.0f;
}
int Passenger::count = 0;
Passenger::Passenger(int arriveTime, int checkTime, bool giveid, bool isMuslim) {
if(giveid) id = count++;
this->arriveTime = arriveTime;
this->checkTime = checkTime;
this->isMuslim = isMuslim;
texId = getPassengerTexId();
this->width = ::width;
this->height = ::height;
pos.x = pos.y = -1.0;
//routeId = curFreeRtp;
}
Passenger::Passenger() {
}
void Passenger::move() {
if(isMuslim) {
pos.x += sym(pos.x, CPBaseX + 10*CPInterval) * step;
pos.y += sym(pos.y, CPBaseY) * step;
} else {
pos.x += sym(pos.x, route[routeId].x) * step;
pos.y += sym(pos.y, route[routeId].y) * step;
}
}
void Passenger::nextPoint() {
if(routeId > 0) routeId--;
}
void Passenger::draw(bool showNum) {
if(isMuslim) {
drawObject(muslim, pos, 0.2, 0.4);
} else {
Glyph::draw();
}
if(showNum) {
char s[100];
glColor3f(1.0f, 1.0f, 1.0f); //设置字体颜色
glRasterPos2f(pos.x, pos.y + height);
sprintf(s, "%d", id);
drawString(s);
}
}