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

2012/8/3

Rocket trouble

CrazyGamer1122 CrazyGamer1122

2012/8/3

#
(i feel like a noob since this is my second discussion today) i am trying to make a rocket game, where you are shooting at the enemies. i cannot figure out how to make the player shoot. heres my player code so far...
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Player here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Player extends MovingActors
{
    /**
     * Act - do whatever the Player wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if (Greenfoot.isKeyDown("right"))
        {
            move(5);
        }

        if (Greenfoot.isKeyDown("left"))
        {
            move(-5);
        }
        
        if (Greenfoot.isKeyDown("space"))
        {
          shoot();
        }
    }
    
    public void shoot()
     {
      // this is where the code to call the shot actor will be. 
     }

}

     
erdelf erdelf

2012/8/3

#
this discussion seems to be the same, look there
CrazyGamer1122 CrazyGamer1122

2012/8/3

#
oh....... sorry, i was just trying to be more specific about what i needed help on.
CrazyGamer1122 CrazyGamer1122

2012/8/3

#
just realized that the "this discussion" was a link.
You need to login to post a reply.