~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to app-squix/squix/EdgeMonster.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
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright (c) edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package squix;
 
7
 
 
8
import mathx.Point2;
 
9
import mathx.MatPoint;
 
10
import ui.anim.lib.EyePair;
 
11
 
 
12
class EdgeMonster extends EdgeWalker
 
13
{
 
14
        public function new( game : Game, profile : Int )
 
15
        {
 
16
                //profile specifies where it starts and what direction it moves
 
17
                profile = profile % 8;
 
18
                var dir = (profile % 2 == 0) ? GridUtil.cClockwise : GridUtil.cCounterClockwise;
 
19
                if( profile >= 4 )
 
20
                        dir = GridUtil.reverseCW( dir );        //for second round of monster to go in opposite direction
 
21
                var start = switch( profile % 4 )
 
22
                        {
 
23
                                case 0: Point2.at( 0, 0 );
 
24
                                case 1: Point2.at( game.surface.width, 0 );
 
25
                                case 2: Point2.at( game.surface.width, game.surface.height );
 
26
                                case 3: Point2.at( 0, game.surface.height );
 
27
                        }
 
28
                
 
29
                super( game, 
 
30
                        dir, start,
 
31
                        new ui.anim.lib.EyePair(),
 
32
                        game.global.edgeMonsterSpeed,
 
33
                        game.global.edgeMonsterSize
 
34
                         );
 
35
                setMonster();
 
36
                //setup optional elements
 
37
                dieSeq = EyePair.seq.SadBlink;
 
38
                
 
39
                actor.actorSetSequence( EyePair.seq.SlowWake, ui.Action.bind( setAlive ) );
 
40
        }
 
41
                
 
42
        override function _afterStep( elapsed : Float )
 
43
        {               
 
44
                //set some actor traits
 
45
                if( game.cursor == null )
 
46
                        return;
 
47
                        
 
48
                var dist = sAt.distanceTo( cursorPosition() );
 
49
                if( dist < game.surface.width / 5 )
 
50
                        actor.actorSetTrait( EyePair.trait.Mood.Angry );
 
51
                else
 
52
                        actor.actorSetTrait( EyePair.trait.Mood.Normal );
 
53
                        
 
54
                if( dist < game.surface.width / 10 )
 
55
                        actor.actorSetTrait( EyePair.trait.Color.Red );
 
56
                else
 
57
                        actor.actorSetTrait( EyePair.trait.Color.White );
 
58
        }
 
59
}