/
Door.cpp
71 lines (65 loc) · 1.06 KB
/
Door.cpp
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
/*
* Door.cpp
*
*You need to get this thing to track the location
*of the observer within the virtual world and react
*to its proximity.
*
*You need to come up with a closing animation
*and an opening animation.
*
* COMP330 Assignment 3 - 2014
*
* Template by Matt Cabanag
*/
#include "Door.h"
Door::Door()
{
//todo:Fill this up with stuff you need
SceneObject();
open = 0;
maxOpen = 6;
}
void Door::Update()
{
//todo:Fill this up with stuff you need
if (nearby == true)
{
if (open <= maxOpen)
{
if (speed.x != 0)
{
open += speed.x;
}
else
{
open += maxOpen / 10;
}
}
}
else if (open >= 0)
{
if (speed.x != 0)
{
open -= speed.x;
}
else
{
open -= maxOpen / 10;
}
}
}
void Door::DrawModel()
{
//todo:Fill this up with stuff you need
glPushMatrix();
glTranslatef(height/4-open, height/2, 0.5);
glScalef(height/2, height, 1);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslatef(height/4+height/4+open, height/2, 0.5);
glScalef(height/2, height, 1);
glutSolidCube(1);
glPopMatrix();
}