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

Report as inappropriate.

danpost presents ...


Jump and Run Demo w/Moving Platform

I tried to make the code as simple as possible for what it does. It has well documented code which can be viewed by clicking the button obstacles across the bottom edge of the world. Use the escape (ESC) key to return to the demo.

Left (<) and right (>) arrows to move.
Up (^) arrow to jump.

8944 views / 1685 in the last 7 days

9 votes | 1 in the last 7 days

Tags: demo jump platform danpost moving_platform source-text

This scenario is a member of: Demos by danpost

Your browser does not support the canvas tag.
A new version of this scenario was uploaded on 2017-12-19 17:46:13 UTC
A new version of this scenario was uploaded on 2017-12-19 17:52:51 UTC
A new version of this scenario was uploaded on 2017-12-19 18:11:32 UTC


Now, updated for HTML 5.


Is it just me or is the escape button not working with HTML 5? For example in this scenario, I can't leave the code view with escape. (x works). Not sure if this was always the case, but right now, it doesn't seem to work.


@Hippo, escape works for me in HTML5.


Okay, maybe that's only a problem with Edge and Internet Explorer then.
Nice Game! I like how the code is as simple as possible for a very common game type. Thank you!


Why is he not jumping? import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Dante here. * * @author (your name) * @version (a version number or a date) */ public class Dante extends Actor { /** * Act - do whatever the Dante wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ static final int gravity = 2; static final int jumpForce = 30; int xSpeed = 4; int ySpeed = 0; public void act() { // Add your action code here. moveHorizontal(); } public void moveHorizontal() { int worldWidth = getWorld().getWidth(); int myWidth = getImage().getWidth(); int dx = 0; if(Greenfoot.isKeyDown("a")) dx--; if(Greenfoot.isKeyDown("d")) dx++; setLocation(getX()+dx*xSpeed, getY()); } private void moveVertically() { int worldHeight = getWorld().getHeight(); int myHeight = getImage().getHeight(); boolean onGround = false; ySpeed += gravity; setLocation(getX(), getY()+ySpeed); if(getY() > worldHeight-myHeight/2) { ySpeed = 0; onGround = true; } if(onGround && Greenfoot.isKeyDown("w")) { ySpeed =-jumpForce; } } }


ah i know why

See all comments

Want to leave a comment? You must first log in.

Who likes this?

AbdulrazaqAS Dlantz JBanyer JoyBajwa madflac fejfo JeppDev herusaputra Arthur114