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