EnemyWatcher.emam 1006 Bytes
Newer Older
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
1
/* (c) https://github.com/MontiCore/monticore */
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
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
package de.rwth.supermario.haller.environment;


component EnemyWatcher {
    ports
    
        in Z EnemyDistX,
        in Z EnemyDistY,
        in Z EnemyVelocityX,
        in Z EnemyVelocityY,
        
        out Z movesTowardsPlayer,
        out Z inJumpRange;

    implementation Math {
        //Empirical distance values
        Z jumpRangeX = 200;
        
        //Enemy in Jumprange, and not above, not undefined, stopping to jump while we are over it, so we don't jump much too far. 
        if((abs(EnemyDistX) < jumpRangeX) && (EnemyDistY > -64) && (EnemyDistX != -1) && (EnemyDistX > 45))
            inJumpRange = 1;
        else
            inJumpRange = 0;
        end
        
        
        //Enemy moving in the opposite direction of the direction to it from mario
        if((EnemyVelocityX > 0) != (EnemyDistX > 0))
            movesTowardsPlayer = 1;
        else
            movesTowardsPlayer = 0;
        end
        
    }
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
36
}