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.

Quick Explain

  • ▸jMonkeyEngine uses Java and supports desktop, Android, and web (via WebGL) platforms.
  • ▸It provides a scene graph architecture, built-in physics (Bullet Physics), shader support, and tools for 3D asset management.
  • ▸Used by indie developers, educational institutions, and hobbyists for 3D game development and simulations.

Core Features

  • ▸Scene graph and spatial objects
  • ▸3D model loading (OBJ, glTF, etc.)
  • ▸Camera and lighting control
  • ▸Physics and collision system
  • ▸Audio, input, and GUI integration

Learning Path

  • ▸Learn Java and OOP principles
  • ▸Understand scene graph architecture
  • ▸Practice physics integration
  • ▸Implement custom shaders and lighting
  • ▸Deploy to desktop and Android

Practical Examples

  • ▸3D first-person shooter
  • ▸Physics-based puzzle game
  • ▸Virtual reality prototype
  • ▸3D racing game
  • ▸Interactive 3D visualization

Comparisons

  • ▸jME vs Unity: Java code-centric vs editor-based
  • ▸jME vs MonoGame: Java 3D vs C# 2D/3D
  • ▸jME vs Godot: Java 3D vs GUI-friendly multi-language
  • ▸jME vs Unreal: lightweight Java engine vs AAA engine
  • ▸jME vs LibGDX: full 3D engine vs 2D/3D hybrid framework

Strengths

  • ▸Full-featured 3D engine in Java
  • ▸Open-source and free
  • ▸Integrated physics and shader support
  • ▸Active developer community
  • ▸Cross-platform for desktop and mobile

Limitations

  • ▸Primarily 3D; 2D support is minimal
  • ▸Requires good understanding of Java and OOP
  • ▸No visual editor included by default (SceneComposer optional)
  • ▸Smaller asset marketplace than Unity or Unreal
  • ▸Limited built-in networking; third-party needed for multiplayer

When NOT to Use

  • ▸2D-only casual games
  • ▸Rapid drag-and-drop prototyping
  • ▸AAA visual fidelity projects
  • ▸Projects needing extensive asset marketplace
  • ▸Non-Java developers

Cheat Sheet

  • ▸SimpleApplication = main class
  • ▸Node = container object
  • ▸Spatial = 3D object
  • ▸Control = attach behavior
  • ▸AppState = modular game logic

FAQ

  • ▸Is jMonkeyEngine free?
  • ▸Yes - fully open-source.
  • ▸Does it support 2D?
  • ▸Minimal; mainly 3D engine.
  • ▸Which platforms are supported?
  • ▸Windows, macOS, Linux, Android, Web (WebGL).
  • ▸Is it beginner-friendly?
  • ▸Moderate; requires Java knowledge.
  • ▸Does it have visual editor?
  • ▸Optional SceneComposer; core engine is code-driven.

30-Day Skill Plan

  • ▸Week 1: Java basics and Hello jME
  • ▸Week 2: Scene graph and Spatials
  • ▸Week 3: Physics and collision handling
  • ▸Week 4: Shaders, lighting, and post-processing
  • ▸Week 5: Cross-platform builds and optimization

Final Summary

  • ▸jMonkeyEngine is a Java-based 3D game engine with scene graph architecture and integrated physics.
  • ▸It supports desktop, Android, and WebGL deployment.
  • ▸Best suited for Java developers creating 3D games, simulations, and interactive applications.
  • ▸Offers flexibility, open-source community support, and robust rendering and physics systems.
  • ▸Less suitable for 2D-only projects or rapid drag-and-drop prototyping.

Project Structure

  • ▸Main.java - entry point
  • ▸Assets/ - models, textures, sounds
  • ▸AppStates/ - game logic modules
  • ▸Controls/ - object behaviors
  • ▸Shaders/ - custom rendering shaders

Monetization

  • ▸Paid PC/Android games
  • ▸In-app purchases via Android
  • ▸Educational software licensing
  • ▸Ad integrations via Android SDK
  • ▸VR/AR commercial applications

Productivity Tips

  • ▸Leverage SceneComposer for faster setup
  • ▸Reuse Controls and AppStates
  • ▸Profile performance early
  • ▸Use Level-of-Detail (LOD) for models
  • ▸Batch static geometries

Basic Concepts

  • ▸Scene graph: hierarchical object structure
  • ▸Spatial: basic 3D object
  • ▸Node: container for Spatials
  • ▸Control: attach behavior to objects
  • ▸AppState: modular game/application logic

Official Docs

  • ▸https://jmonkeyengine.org/
  • ▸https://jmonkeyengine.github.io/
  • ▸https://github.com/jMonkeyEngine/jmonkeyengine

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