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

MatheMagician's Comments

Back to MatheMagician's profile

...vote sorry
Thanks ShoutToUS, yours is my one hundredth.
Neat! I would love to see how you did this though. Would you mind posting the source?
Yes Jrlowe, there are some bugs with boxes where the corners hit. I am not too worried about it though, since boxes can't intersect in real life. I might do something to stop the boxes from hitting like that though.
I won!
I think I fixed all bugs:)
@leaderchicken, if you look above, ledzep has already implemented the move() method and he already is using the setrotation methods. @ledzep, to answer your question about changing the direction of the bullet, just set move(-speed); instead of move(speed). Also, about the errors mentioned by leaderchicked, you can easily fix them following these steps: first, remove the checkBoundaries(); method from your act() method so it looks like this: public void act() { move(-speed); setRotation(getRotation()); destroyEnemies(); } second, change your destroyEnemies() code to this: public void destroyEnemies() { //"Enemy" can be any class that you want the Strel to destroy. Actor enemy = getOneIntersectingObject(Avion2.class); if(enemy !=null) { getWorld().removeObject(enemy); getWorld().removeObject(this); } else checkBoundaries(); } what I have done here is added an else block so the computer asks itself "have i hit anything?" if not, then he checks to see if he is at the end of the world. Also, on some of the walls, your bullet is not removing itself, so change your checkboundaries() code to this: public void checkBoundaries() { if(getX() > getWorld().getWidth() - 2) { getWorld().removeObject(this); } else if(getX() < 1) { getWorld().removeObject(this); } else if(getY() > getWorld().getHeight() - 2) { getWorld().removeObject(this); } else if(getY() < 1) { getWorld().removeObject(this); } } This might seem like a lot, but really I have barely changed your code.
Press m.
Instead of using the setLocation() method to move, use the move() method. You probably want to say something like move(-speed);