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

2017/7/6

whats going on???!!!!

Williamli Williamli

2017/7/6

#
Im making a flappy bird game and whenever I try to put a new bird into the background, a terminal window pops up. But, I cant even open the terminal window and I dont know why, so I don't know what the problem is. Here's my code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)import greenfoot;


/**
 * Write a description of class bird here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class bird extends Actor
{
    int gravity = 10;
    boolean wingflap = false;
    int x = getX();
    int y = getY();
    int a = 10;
    /**
     * Act - do whatever the bird wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        upAndDown();
    }   
    public void upAndDown(){
        if(Greenfoot.isKeyDown("up")){
            setLocation(x,y+a);
        }
    }
}
danpost danpost

2017/7/7

#
You are trying to add a new bird into the world and 'addObject' is a World class method. Providing your World subclass code would seem to be what is needed.
Williamli Williamli

2017/7/7

#
How do you do the "addobject code?"
danpost danpost

2017/7/7

#
Williamli wrote...
How do you do the "addobject code?"
In your World subclass:
addObject(new bird(), intX, intY);
where the location (intX, intY) is where you want the bird to be placed into the world at.
Williamli Williamli

2017/7/9

#
Now a terminal window pops up and when I close one, another one pops up but I cant even open the terminal window so I don't know what to do
danpost danpost

2017/7/9

#
In the bird class, cut lines 14 and 15 and paste them at line 28.
You need to login to post a reply.