Oolite
Loading...
Searching...
No Matches
OOPlasmaBurstEntity.m
Go to the documentation of this file.
1
/*
2
3
OOPlasmaBurstEntity.m
4
5
6
Oolite
7
Copyright (C) 2004-2013 Giles C Williams and contributors
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
MA 02110-1301, USA.
23
24
*/
25
26
#import "
OOPlasmaBurstEntity.h
"
27
#import "
Universe.h
"
28
29
#define kPlasmaBurstInitialSize 64.0f
30
#define kPlasmaBurstGrowthRate 64.0f
31
#define kPlasmaBurstDuration 2.0f
32
33
@implementation
OOPlasmaBurstEntity
34
35
- (id)initWithPosition:(
HPVector
)inPosition
36
{
37
if
((
self
= [super initWithDiameter:
kPlasmaBurstInitialSize
])) {
38
[
self
setPosition
:inPosition];
39
[
self
setCollisionRadius
:2.0];
40
41
[
self
setColor
:[
OOColor
redColor
]];
42
}
43
44
return
self
;
45
}
46
47
- (void)update:(
double
)delta_t
48
{
49
[
super
update
:delta_t];
50
51
OOTimeDelta
lifeTime = [
self
timeElapsedSinceSpawn
];
52
float
attenuation =
OOClamp_0_1_f
(1.0f - lifeTime /
kPlasmaBurstDuration
);
53
54
_diameter
=
kPlasmaBurstInitialSize
+ lifeTime *
kPlasmaBurstGrowthRate
;
55
56
_colorComponents
[3] = attenuation;
57
58
if
(lifeTime >
kPlasmaBurstDuration
)
59
[UNIVERSE removeEntity:
self
];
60
}
61
62
@end
OOClamp_0_1_f
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
Definition
OOFastArithmetic.h:65
OOPlasmaBurstEntity.h
kPlasmaBurstDuration
#define kPlasmaBurstDuration
Definition
OOPlasmaBurstEntity.m:31
kPlasmaBurstGrowthRate
#define kPlasmaBurstGrowthRate
Definition
OOPlasmaBurstEntity.m:30
kPlasmaBurstInitialSize
#define kPlasmaBurstInitialSize
Definition
OOPlasmaBurstEntity.m:29
OOTimeDelta
double OOTimeDelta
Definition
OOTypes.h:193
Universe.h
-[Entity timeElapsedSinceSpawn]
GLfloat timeElapsedSinceSpawn()
Definition
Entity.m:985
-[Entity update:]
void update:(OOTimeDelta delta_t)
Definition
Entity.m:850
-[Entity setCollisionRadius:]
void setCollisionRadius:(GLfloat amount)
Definition
Entity.m:840
-[Entity setPosition:]
void setPosition:(HPVector posn)
Definition
Entity.m:608
OOColor
Definition
OOColor.h:41
+[OOColor redColor]
OOColor * redColor()
Definition
OOColor.m:259
OOLightParticleEntity::_diameter
float _diameter
Definition
OOLightParticleEntity.h:35
-[OOLightParticleEntity setColor:]
void setColor:(OOColor *color)
Definition
OOLightParticleEntity.m:79
OOLightParticleEntity::_colorComponents
GLfloat _colorComponents[4]
Definition
OOLightParticleEntity.h:34
OOPlasmaBurstEntity
Definition
OOPlasmaBurstEntity.h:29
HPVector
Definition
OOHPVector.h:35
src
Core
Entities
OOPlasmaBurstEntity.m
Generated by
1.15.0