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

2017/2/8

How to make my character jump?

AntoniaPopa AntoniaPopa

2017/2/8

#
This is the code that I use now on my character "nigga" import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class nigga here. * * @author (your name) * @version (a version number or a date) */ public class nigga extends Actor { /** * Act - do whatever the nigga 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. if(Greenfoot.isKeyDown("left")) { move(-5); } if(Greenfoot.isKeyDown("right")) { move(5); } if(Greenfoot.isKeyDown("up")) { turn(-5); }if(Greenfoot.isKeyDown("down")) { turn(5); } Actor jucator; jucator = getOneObjectAtOffset(0,0,jucator.class); if(jucator != null) { World world; world = getWorld(); world.removeObject(jucator); scoreboard scoreboard = (scoreboard) (getWorld().getObjects(scoreboard.class).get(0)); scoreboard.score = scoreboard.score + 1; } } } How can I make him jump when I press Space?
Super_Hippo Super_Hippo

2017/2/8

#
1. There is probably some rule which permits using that name for the character. 2. Try to search for your problem here on the website. There are plenty of discussions around making a character jump.
You need to login to post a reply.