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

2012/4/18

Hey just looking for some help coding for a senior project due soon....

OGava OGava

2012/4/18

#
Hey so all's I need to do is throw together a basic program with 3 subclasses (paperball, recyclingBin, and User). I want the paperballs to fly around the screen and then the bins to just pick them up. The part of the code i dont understand is gettting the user to just hit the balls and force them toanother direction. If someone could throw me toward the way of coding this I'd appreciate that greatly! thanks everyone
IsVarious IsVarious

2012/4/18

#
I'm a bit confused about your questions. Is it that you're trying to make it so when the user clicks on the object, it is then pushed in a new direction? If this is the question, I would start with an if statement that checks to see if that object is clicked on, and then have a method that does what it is you're wanting done. For example, if you're wanting to push the ball in a new direction. You would write like this...
 

if (Greenfoot.mouseClicked(this)){
           PushBallInNewDirection();
 }

Then you would write the method that does the action you're wanting.
 

private void PushBallInNewDirection()
         {
            Do something to object
         }
If you're wanting the ball to respond to the user's click, and then push it in a new direction, I would look for other scenarios that do what you're wanting, look at the code, and model code after that.
You need to login to post a reply.