-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDebris.cpp
More file actions
112 lines (105 loc) · 3.12 KB
/
Debris.cpp
File metadata and controls
112 lines (105 loc) · 3.12 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
#include "Debris.h"
#include "Engine.h"
Debris::Debris()
{
}
//================================================================================================//
/*******************
** Debris spawn **
********************/
//================================================================================================//
void Debris::Spawn(Vec2 pos)
{
IsActive = true;
oPos = Pos = pos;
fLife = fStartLife = (float)(rand()%4)+1;
frame = (float)(rand()%8);
fRotation = (float)(rand()%10)+1;
fRot = (float)(rand()%360);
rand()%2? bRotation = true: bRotation = false;
mSphere = Sphere(15,pos+Vec2(16,16));
iTakeDamageTicks = 0;
mWaterticks = 0;
}
//================================================================================================//
/*******************
** Debris Clone **
********************/
//================================================================================================//
Debris* Debris::Clone()const
{
return new Debris(*this);
}
//================================================================================================//
/********************
** Debris update **
*********************/
//================================================================================================//
void Debris::Update()
{
iTakeDamageTicks--;
oPos = Pos;
InWater();
bRotation?
fRot += fRotation:
fRot -= fRotation;
fLife-=0.1f;
if(fLife<=0)
IsActive = false;
Vel*=0.992f;
Pos+=Vel;
}
//================================================================================================//
/******************
** Debris draw **
*******************/
//================================================================================================//
void Debris::Draw(const float interp)
{
if(iTakeDamageTicks>0)
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
glColor4f(1,1,0,1);
}
else
{
float a = fLife;
if(a>1)a=1;
if(a<0)a=0;
glColor4f(1,1,1,a);
}
Vec2 p = UTIL_Misc::Interpolate(Pos,oPos,interp);
UTIL_GL::SetBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderRotatedSprite(gpEngine->sprTrash,(int)frame,p.x+16,p.y+16,4,4,fRot);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
/* glDisable(GL_TEXTURE_2D);
glColor4f(1,1,0,1);
GeoDraw2D::DrawSphere(mSphere, 10);//*/
}
//================================================================================================//
/*********************************
** if it goes offscreen kill it **
**********************************/
//================================================================================================//
void Debris::NeedsToBeRemoved()
{
}
//================================================================================================//
/****************
** Take damage **
*****************/
//================================================================================================//
bool Debris::CheckCollided(Sphere s, float damage)
{
return false;
}
void Debris::LoadFromFile(CFileIO &fIO)
{
}
void Debris::WriteToFile(CFileIO &fIO)
{
}
int Debris::InWater()
{
return 0;
}