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

2015/12/20

How do i increase movement speed?

onlineragekiller onlineragekiller

2015/12/20

#
I dont know whats wrong with my code, i have made a variable for the speed (called s) and i have an if statement for if if pickup a speedUp, but it doesnt work. Here is my code:
 int s = 4;
        if (Greenfoot.isKeyDown("space")) {
            move(s);   
        }
                
        if (Greenfoot.isKeyDown("up")){
            turn(-s);
        }
        
        if (Greenfoot.isKeyDown("down")) {
            turn(s);
        }
        
        //ALS DE SPELER speedUP OPPAKT
        if (!getIntersectingObjects(speedUp.class).isEmpty()) {
            //WHY THIS DOESNT WORK?
            s = 8;
        }
Super_Hippo Super_Hippo

2015/12/20

#
Move line 1 outside methods.
fejfo fejfo

2015/12/22

#
or move
//ALS DE SPELER speedUP OPPAKT
       if (!getIntersectingObjects(speedUp.class).isEmpty()) {
           //WHY THIS DOESNT WORK?
           s = 8;
       }
to the front
Super_Hippo Super_Hippo

2015/12/22

#
With only this, the actor would be faster as long as it intersects with the power up, not after picking it up. (The power up is never removed there though.)
You need to login to post a reply.