-
Notifications
You must be signed in to change notification settings - Fork 8
/
Fire.cpp
114 lines (112 loc) · 3.83 KB
/
Fire.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
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
#include "Fire.h"
#include "Engine.h"
//================================================================================================//
/********************************************************
** Doesnt really do anything, more like a dummy entity **
*********************************************************/
//================================================================================================//
Fire::Fire()
{
}
void Fire::Spawn(Vec2 pos)
{
IsActive = true;
oPos = Pos = pos;
}
Fire* Fire::Clone()const
{
return new Fire(*this);
}
void Fire::Update()
{
}
void Fire::Draw(const float interp)
{
glColor4f(1,1,1,1);
UTIL_GL::SetBlend(GL_SRC_ALPHA,GL_ONE);
UTIL_GL::BindTexture(GL_TEXTURE_2D,gpEngine->imgSplashFire);
for(int f=0;f<1;f++)
{
float x = Pos.x;
float y = Pos.y;
float sinus=0.3f;
float fire;
float t=gpEngine->mTimer.GetTime();
if(f>0)
fire = sin(t*=1.5f)*10;
else
fire = sin(t*5)*10;
glBegin(GL_QUADS);
if(!bTop)
{
glTexCoord2f((float)(f?1:0),0); glVertex2f(x+fire, y);
glTexCoord2f((float)(f?0:1),0); glVertex2f(x+512+fire, y);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),0.25f); glVertex2f(x+512+fire*0.75f, y+32);
glTexCoord2f((float)(f?1:0),0.25f); glVertex2f(x+fire*0.75f, y+32);
glTexCoord2f((float)(f?1:0),0.25f); glVertex2f(x+fire*0.75f, y+32);
glTexCoord2f((float)(f?0:1),0.25f); glVertex2f(x+512+fire*0.75f, y+32);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),0.5f); glVertex2f(x+512+fire*0.5f, y+64);
glTexCoord2f((float)(f?1:0),0.5f); glVertex2f(x+fire*0.5f, y+64);
glTexCoord2f((float)(f?1:0),0.5f); glVertex2f(x+fire*0.5f, y+64);
glTexCoord2f((float)(f?0:1),0.5f); glVertex2f(x+512+fire*0.5f, y+64);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),0.75f); glVertex2f(x+512+fire*0.25f, y+96);
glTexCoord2f((float)(f?1:0),0.75f); glVertex2f(x+fire*0.25f, y+96);
glTexCoord2f((float)(f?1:0),0.75f); glVertex2f(x+fire*0.25f, y+96);
glTexCoord2f((float)(f?0:1),0.75f); glVertex2f(x+512+fire*0.25f, y+96);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),1); glVertex2f(x+512, y+128);
glTexCoord2f((float)(f?1:0),1); glVertex2f(x, y+128);
glEnd();
}
else
{
y=y+96;
glTexCoord2f((float)(f?1:0),0); glVertex2f(x+fire, y);
glTexCoord2f((float)(f?0:1),0); glVertex2f(x+512+fire, y);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),0.25f); glVertex2f(x+512+fire*0.75f, y-32);
glTexCoord2f((float)(f?1:0),0.25f); glVertex2f(x+fire*0.75f, y-32);
glTexCoord2f((float)(f?1:0),0.25f); glVertex2f(x+fire*0.75f, y-32);
glTexCoord2f((float)(f?0:1),0.25f); glVertex2f(x+512+fire*0.75f, y-32);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),0.5f); glVertex2f(x+512+fire*0.5f, y-64);
glTexCoord2f((float)(f?1:0),0.5f); glVertex2f(x+fire*0.5f, y-64);
glTexCoord2f((float)(f?1:0),0.5f); glVertex2f(x+fire*0.5f, y-64);
glTexCoord2f((float)(f?0:1),0.5f); glVertex2f(x+512+fire*0.5f, y-64);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),0.75f); glVertex2f(x+512+fire*0.25f, y-96);
glTexCoord2f((float)(f?1:0),0.75f); glVertex2f(x+fire*0.25f, y-96);
glTexCoord2f((float)(f?1:0),0.75f); glVertex2f(x+fire*0.25f, y-96);
glTexCoord2f((float)(f?0:1),0.75f); glVertex2f(x+512+fire*0.25f, y-96);
fire = sin((t+=sinus)*5)*10;
glTexCoord2f((float)(f?0:1),1); glVertex2f(x+512, y-128);
glTexCoord2f((float)(f?1:0),1); glVertex2f(x, y-128);
glEnd();
}
}
glDisable(GL_BLEND);
}
void Fire::NeedsToBeRemoved()
{
if(Pos.x+512<=gpEngine->Scroll)
IsActive = false;
}
bool Fire::CheckCollided(Sphere s, float damage)
{
return false;
}
void Fire::LoadFromFile(CFileIO &fIO)
{
fIO.ReadBinary(&bTop,1);
}
void Fire::WriteToFile(CFileIO &fIO)
{
fIO.WriteBinary(&bTop,1);
}
int Fire::InWater()
{
return 0;
}