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
|
package fortress;
import mathx.Point2;
/**
* Creates dust effects for cannon ball hits land.
*/
class DustCloudObject extends LiveObject
{
var curAlpha : Float;
static var numClouds : Int = 10;
public function new( gd : GameDriver, atMP : Point2, size : Point2 )
{
super( gd );
this.at = atMP.clone();
this.size = size.clone();
curAlpha = 1;
actMode = LiveObject.actInvisible;
}
override function draw()
{
//leave old drawing there to add to quality (though perhaps too many circles?)
//needs to be adjusted to frequency if odl items are not removed...
for( i in 0...numClouds )
{
var c = draw.Color.int( 0x9e4c00 ).adjustBrightness( 0.5 + Math.random() ).asInt();
var x = Math.random() * size.x - size.x/2;
var y = Math.random() * size.y - size.y/2;
var cx = Math.random() * size.x / 2;
var cy = Math.random() * size.y / 2;
graphics.beginFill( c, Math.random() * 0.5 + 0.5 );
graphics.drawEllipse( x * GConst.gridSizeX, y * GConst.gridSizeY,
cx * GConst.gridSizeX, cy * GConst.gridSizeY );
graphics.endFill();
}
}
override public function step( elapsed : Float ) : StepResult
{
curAlpha -= elapsed; //1 second for display
if( curAlpha <= 0 )
return StepResult.Remove;
alpha = curAlpha;
size = size.mul( 1 + elapsed * 2 ); //slowly increase size
draw();
return StepResult.Changed;
}
}
|