I am trying to make a attack with the name "ice" the plan is to make the movement speed of "enemy" nad "dog"my enemies 0 but i dont know how to do it can someone tell me how to do this


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 | import greenfoot.*; public class Enemies extends Actor { public int W; //gives the movement speed, put this as "move(W);" public int Freezing = 0 ; //Countdown for freezing public boolean frozen1 = false ; //Is the enemy frozen then it's true, if the enemy is not frozen then it's false public void act() { Frozen(); if (frozen1 == true ) { W = 0 ; } else { W = ...; //put your own value here } move(W); } public void Frozen() { if (frozen1 == true ) { Freezing++; } if (Freezing >= 100 ) { frozen1 = false ; Freezing = 0 ; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import greenfoot.*; public class Freezing extends PlayerBullet { public void act() { Freeze(); } public void Freeze() { Enemies enem = (Enemies)getOneIntersectingObject(Enemies. class ); if (enem != null && enem.frozen1 == false ) { enem.frozen1 = true ; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /** * Write a description of class villian here. * * @author (your name) * @version (a version number or a date) */ public class enemy extends Actor { /** * Act - do whatever the enemy wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(- 3 ); } } |
1 | if ( ! isTouching(ice. class )) move(- 3 ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /** * */ public class ice extends Actor { /** * Act - do whatever the ice wants to do. This method is called whenever the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move( 5 ); dog d = (dog) getOneIntersectingObject(dog. class ); enemy v = (enemy) getOneIntersectingObject(enemy. class ); if (v != null ) { if ( ! isTouching(enemy. class )) move( 0 ); } if (d != null ) { move( 0 ); } } } |
1 2 3 4 5 6 7 8 9 | import greenfoot.*; public class ice extends Actor { public void act() { move( 5 ); } } |
1 2 3 4 5 | public void act() { move( 5 ); if (isAtEdge()) getWorld().removeObject( this ); } |