1. Home
  2. /
  3. Jmonkeyengine
  4. /
  5. Jumping Sphere Example

Jumping Sphere Example - Jmonkeyengine Typing CST Test

Loading…

Jumping Sphere Example — Jmonkeyengine Code

A sphere jumps up and falls down simulating gravity.

import com.jme3.app.SimpleApplication;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Sphere;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;

public class JumpingSphereApp extends SimpleApplication {
	private Geometry sphere;
	private float vy = 0;
	private float y = 1;
	private float gravity = -9.8f;

	public static void main(String[] args) {
		new JumpingSphereApp().start();
	}

	@Override
	public void simpleInitApp() {
		Sphere s = new Sphere(16,16,1);
		sphere = new Geometry("Sphere", s);
		Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
		mat.setColor("Color", ColorRGBA.Green);
		sphere.setMaterial(mat);
		sphere.setLocalTranslation(0,y,0);
		rootNode.attachChild(sphere);
	}

	@Override
	public void simpleUpdate(float tpf) {
		vy += gravity * tpf;
		y += vy * tpf;
		if (y < 1) { y = 1; vy = 5; } // bounce
		sphere.setLocalTranslation(0, y, 0);
	}
}

Jmonkeyengine Language Guide

jMonkeyEngine (jME) is an open-source, cross-platform 3D game engine written in Java. It allows developers to create 3D games and interactive applications with full control over rendering, physics, and scene management.

Primary Use Cases

  • ▸3D PC games
  • ▸Android 3D games
  • ▸Educational simulations
  • ▸Virtual reality prototypes
  • ▸Interactive 3D visualizations

Notable Features

  • ▸Java-based development
  • ▸Cross-platform deployment (desktop, Android, Web via WebGL)
  • ▸Scene graph architecture
  • ▸Bullet Physics integration
  • ▸Shader support (GLSL/HLSL via OpenGL)

Origin & Creator

jMonkeyEngine was created in 2003 by Mark Powell and a group of open-source contributors to provide a Java-based 3D game engine for hobbyists and developers.

Industrial Note

jME is popular among Java developers seeking a full-featured 3D engine with a scene graph system, built-in physics, and a flexible rendering pipeline, particularly for desktop and Android targets.

More Jmonkeyengine Typing Exercises

jMonkeyEngine Simple Counter ExamplejMonkeyEngine Moving Box ExamplejMonkeyEngine Rotating Cube ExamplejMonkeyEngine Camera Follow ExamplejMonkeyEngine Color Changing BoxjMonkeyEngine Spinning TorusjMonkeyEngine Physics Falling BoxjMonkeyEngine Orbit Camera Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher