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

2024/3/19

How do i make my character jump?

zehbi-tracker zehbi-tracker

2024/3/19

#
I want my character to jump and fall down but every time i look at a yt tutorial or one of the examples ocdes here i cant get it working. I am making a 2d fighter game for school and am a newbee to greenfoot. Could anybody give me advise on how to make my character jump. (Snelheid is dutch and it means speed)
public class Joker extends Actor {
    public int snelheid = 4;
    /**
     * Act - do whatever the Joker wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        checkKeys(); 
    }    
    
    public void checkKeys()
    { 
        if(Greenfoot.isKeyDown("d"))
        {
        setLocation(getX() + snelheid, getY());
        }
        
        if(Greenfoot.isKeyDown("a"))
        {
        setLocation(getX() - snelheid, getY());
        }
    }
}
danpost danpost

2024/3/19

#
zehbi-tracker wrote...
I want my character to jump and fall down but every time i look at a yt tutorial or one of the examples ocdes here i cant get it working.
You might want to check out my Jump and Run Demo w/Moving Platform scenario.
zehbi-tracker zehbi-tracker

2024/3/21

#
thx it worked btw
You need to login to post a reply.