-
Notifications
You must be signed in to change notification settings - Fork 0
/
cItemList.cpp
72 lines (67 loc) · 1.54 KB
/
cItemList.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
70
71
72
#include "cItemList.h"
cItemList::cItemList()
{
items.clear();
}
cItemList::cItemList(const char *fn)
{
items.clear();
LoadRoom(fn);
}
cItemList::~cItemList()
{
items.clear();
}
void cItemList::Draw()
{
vector<cTexture>::iterator iter = items.begin();
while (iter != items.end()) {
if (iter->getLive()) {
glPushMatrix();
if (iter->getId() > 1) {
if (!iter->getRemoved()) {
glTranslatef(step * (iter->getPlaceHolder() - 2), 0.0, 0.0);
} else {
float x = iter->getXtarget();
if (iter->getXslide() > x) {
iter->setXslide(iter->getXslide() - iter->getXinc());
glTranslatef(iter->getXslide(), 0.0, 0.0);
} else
if (iter->getXslide() <= iter->getXtarget()) {
glTranslatef(step * (iter->getPlaceHolder() - 2), 0.0, 0.0);
iter->setRemoved(false);
}
}
}
iter->drawQuad(false);
glPopMatrix();
}
iter++;
}
}
void cItemList::pickItem(const int hit)
{
vector<cTexture>::iterator iter = items.begin();
while (iter != items.end()) {
if (iter->getId() == hit && iter->getLive()
&& iter->getId() > 1 && iter < items.end()) {
iter->setLive(false);
while (iter != items.end()) {
++iter;
if (iter != items.end() && iter->getLive()) break;
}
while (iter != items.end()) {
float x = (iter->getPlaceHolder()-2) * step - step;
iter->setXslide((iter->getPlaceHolder()-2) * step);
iter->setXtarget(x);
iter->setRemoved(true);
iter->setPlaceHolder(iter->getPlaceHolder() - 1);
iter++;
}
goto stop;
}
iter++;
}
stop :
int i = 0;//stuff
}