This site requires JavaScript, please enable it in your browser!
Greenfoot back
-nic-
-nic- wrote ...

2012/10/8

Getting a random falling shell

1
2
3
4
-nic- -nic-

2012/10/10

#
ive changed it sow the shell fly backwards and down :D
Game/maniac Game/maniac

2012/10/11

#
I have made your shell class even better now so it creates a little pile on the floor, try it out:
import greenfoot.*;       
public class shell extends Animal    
{  
    int gravity=1;  
    int vSpeed=4;  
    int i=0;  
    int d=200; 
    public void act()  
    {
        eject();  
        delay();
    }
    public void eject()  
    {
        if(!atWorldEdge())
        {
            turn(20);
            setLocation(getX()+Greenfoot.getRandomNumber(8)-4,getY()-vSpeed);
        }else{
            setRotation(0);
        }
        timer(2);
    }  
    public void timer(int time)    
    {    
        i++;    
        if(i==time)    
        vSpeed-=gravity;    
        if(i==time+1)    
        i=0;    
    }  
    public void delay()
    {
        if(d<0){getWorld().removeObject(this);d=200;}else{d-=1;}
    }
    
}
Game/maniac Game/maniac

2012/10/12

#
I have now also improved the code for tanks and planes:
    public int t;
    public static boolean hit=false;
    public int health=100;
    public void act() 
    {
     move(-0.5);
     if(hit==true)
     {
         Actor Bullet;
         Bullet = getOneIntersectingObject(Bullet.class);
         World world;
         world = getWorld();
         world.removeObject(Bullet);
         move(0.25);hit=false;
         health-=Counter.getValue();
     }
     if(health<0)
     {
         Gold.add(5);
         Counter.add(1);
         getWorld().removeObject(this);
     } 
    }
    public static void mov(){hit=true;}
-nic- -nic-

2012/10/12

#
thanks illl try it when i get home
-nic- -nic-

2012/10/12

#
i like the randomised shell you created i ahd somthing a bit like it but it wasent random thanks
Game/maniac Game/maniac

2012/10/12

#
Your welcome :)
You need to login to post a reply.
1
2
3
4