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

Report as inappropriate.

icegecko11
icegecko11 presents ...

2010/12/17

asteroids-1

Made by Jordan. Press "space" to fire, "z" to use a proton wave, the up arrow key to boost and the left and right arrow keys to turn. Press the down arrow to turn endless mode on.

10548 views / 33 in the last 7 days

2 votes | 0 in the last 7 days

Tags: with-source

open in greenfoot
Your browser is ignoring the <APPLET> tag.
USER67USER67

2013/3/6

In the rocket class, you will find this private void. Adding the small pieces of code at the bottom which are accelerate(0.95); and move(); effectively introduce a degree of deceleration. This means the rocket won't keep drifting when you have stopped pressing "up"! private void ignite(boolean boosterOn) { int currentRotation = this.getRotation(); if (boosterOn == true) { this.setImage("rocketWithThrust.png"); this.addForce(new Vector(currentRotation, .3)); } else { this.setImage("rocket.png"); accelerate(0.95); } move(); }

Want to leave a comment? You must first log in.

Who likes this?

USER67 qnanqing