~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to restricted/app-fortress/fortress/DustCloudObject.hx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package fortress;
 
2
 
 
3
import mathx.Point2;
 
4
 
 
5
/**
 
6
 * Creates dust effects for cannon ball hits land.
 
7
 */
 
8
class DustCloudObject extends LiveObject
 
9
{
 
10
        var curAlpha : Float;
 
11
        static var numClouds : Int = 10;
 
12
        
 
13
        public function new( gd : GameDriver, atMP : Point2, size : Point2 )
 
14
        {
 
15
                super( gd );
 
16
                this.at = atMP.clone();
 
17
                this.size = size.clone();
 
18
                curAlpha = 1;
 
19
                actMode = LiveObject.actInvisible;
 
20
        }
 
21
        
 
22
        override function draw()
 
23
        {       
 
24
                //leave old drawing there to add to quality (though perhaps too many circles?)
 
25
                
 
26
                //needs to be adjusted to frequency if odl items are not removed...
 
27
                for( i in 0...numClouds )
 
28
                {
 
29
                        var c = draw.Color.int( 0x9e4c00 ).adjustBrightness( 0.5 + Math.random() ).asInt();
 
30
                        var x = Math.random() * size.x - size.x/2;
 
31
                        var y = Math.random() * size.y - size.y/2;
 
32
                        var cx = Math.random() * size.x / 2;
 
33
                        var cy = Math.random() * size.y / 2;
 
34
                        
 
35
                        graphics.beginFill( c, Math.random() * 0.5 + 0.5 );
 
36
                        graphics.drawEllipse( x * GConst.gridSizeX, y * GConst.gridSizeY, 
 
37
                                cx * GConst.gridSizeX, cy * GConst.gridSizeY );
 
38
                        graphics.endFill();
 
39
                }
 
40
        }
 
41
        
 
42
        override public function step( elapsed : Float ) : StepResult
 
43
        {
 
44
                curAlpha -= elapsed;    //1 second for display
 
45
                if( curAlpha <= 0 )
 
46
                        return StepResult.Remove;
 
47
                        
 
48
                alpha = curAlpha;
 
49
                size = size.mul( 1 + elapsed * 2 );     //slowly increase size
 
50
                draw();
 
51
                
 
52
                return StepResult.Changed;
 
53
        }
 
54
}
 
 
b'\\ No newline at end of file'