×
Create a new article
Write your page title here:
We currently have 210 articles on Open Eggbert. Type your article name above or click on one of the titles below and start writing!



Open Eggbert
210Articles

Gravity: Difference between revisions

No edit summary
m Robertvokac moved page Development of Open Eggbert to Gravity without leaving a redirect
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:


== Multiplatform ==
== Implementing jumping ==
Open Eggbert is multiplatform (desktop, Android, web).
To implement a jump mechanic, you can follow these steps:


* We should assure continuously, that the latest version (snapshot) runs correctly on all the 3 supported platforms.
1. **Define Variables:**


This means some limitations like:
   - Create variables for the player's velocity, gravity, and whether the player is on the ground.


# Method '''String.lines(String string)''' is not present in GWT.
   ```java
#* How to fix: Use method '''OpenEggbertUtils.lines(String string)'''


== Inspiration ==
   float velocityY = 0;
https://github.com/libgdx/libgdx-demo-cuboc


== Requirements for Development ==
   final float gravity = -0.5f;
Java 17 must be installed. Newer versions may work only for the desktop.


== Sound + Midi support ==
   boolean onGround = true;
https://github.com/mgsx-dev/gdx-pd


== Graphics ==
   ```
How to scale graphics - ?


https://github.com/leonbloy/pngj
2. **Jump Logic:**


https://www.nayuki.io/page/png-library
   - Implement the jump by applying an upward velocity when the jump key is pressed and the player is on the ground.


   ```java


   if (Gdx.input.isKeyPressed(Input.Keys.SPACE) && onGround) {


https://github.com/nayuki/BMP-IO?tab=readme-ov-file
       velocityY = 10;  // Jump strength


https://www.nayuki.io/page/bmp-io-library-java
       onGround = false;


https://github.com/PyroSamurai/JBL
   }


   ```


3. **Apply Gravity:**


https://github.com/nayuki/PNG-library
   - Continuously apply gravity to the player's vertical velocity.


https://image4j.sourceforge.net/
   ```java


   velocityY += gravity;


https://libgdxinfo.wordpress.com/basic_image/
   ```


== Animation ==
4. **Update Player Position:**
https://github.com/WinterAlexander/gdx-animation


https://libgdx.com/wiki/graphics/2d/2d-animation
   - Update the player's Y position using the current velocity.


https://gamefromscratch.com/libgdx-tutorial-3b-simple-animation/
   ```java


https://gamefromscratch.com/libgdx-video-tutorial-sprite-animation/
   player.y += velocityY;


https://www.pixnbgames.com/blog/libgdx/frame-by-frame-animations-in-libgdx/
   ```


https://www.codeandweb.com/texturepacker/tutorials/libgdx-sprite-sheet-tutorial
5. **Ground Detection:**


https://www.reddit.com/r/libgdx/comments/18bghen/how_can_i_get_an_animation_to_be_timed_correctly/
   - Check if the player has landed back on the ground to reset the jump.


https://gamedev.stackexchange.com/questions/138324/libgdx-animation-sequence
   ```java


<blockquote>       boxes = new Texture(Gdx.files.internal("boxes.png")); //** loading boxes **//
   if (player.y <= groundLevel) {


       box1 = new TextureRegion(boxes,0,0,180,320);
       player.y = groundLevel;


       box2 = new TextureRegion(boxes,200,0,480-200,320);
       velocityY = 0;


       box3 = new TextureRegion(boxes,0,330,127,511-330);
       onGround = true;


       box4 = new TextureRegion(boxes,180,325,511-180,511-320);</blockquote>
   }


== Generating GIFs in Open Eggbert ==
   ```
https://github.com/Anuken/GDXGifRecorder


== Videos ==
By following these steps, you create a basic jumping mechanic where the player can jump when on the ground, and gravity pulls them back down. This can be expanded with more complex mechanics like double jumps or variable jump heights.
https://github.com/libgdx/gdx-video


== Sprite Tools ==
== Gravity ==
Generating sprite animations to gifs
https://gamedev.stackexchange.com/questions/111314/writing-my-own-gravity
 
https://genuinecoder.com/how-to-create-gif-from-multiple-images-in-java/
 
Detection of sprite positions.
 
https://github.com/mapeditor/tiled/tree/master/util/java/libtiled-java
 
https://www.mapeditor.org/
 
== Support for web and mobile platforms (Android, iPhone) ==
It is a good idea to ensure, that Open Eggbert is runnable on web and mobile platforms.
 
 
 
https://stackoverflow.com/questions/2590850/threading-in-gwt-client
 
https://stackoverflow.com/questions/57735039/how-framwork-such-as-libgdx-handle-threading-for-web-target
 
https://stackoverflow.com/questions/28267316/libgdx-not-work-on-android-api-21
 
== Networking ==
https://www.reddit.com/r/libgdx/comments/4rtdph/what_are_some_networking_options_for_libgdx/
 
== Screens ==
https://www.gamedevelopment.blog/full-libgdx-game-tutorial-loading-screen/
 
https://www.slideshare.net/slideshow/libgdx-screens-fonts-and-preferences/44430118
 
== Controls ==
 
=== Mouse ===
 
=== Keyboard ===
 
=== Touch screen ===
 
=== Gamepad ===
https://github.com/libgdx/Jamepad
 
== 2D physics engines ==
https://github.com/erincatto/box2d-lite
 
https://github.com/jbox2d/jbox2d
 
http://www.jbox2d.org/
 
https://box2d.org/documentation/
 
https://github.com/dyn4j/dyn4j
 
https://slick.ninjacave.com/
 
https://github.com/jwvhewitt/Slick2d-Game-Engine
 
https://github.com/implicit-invocation/jbump
 
== How to create a Java Platformer game ==
https://longbaonguyen.github.io/courses/platformer/platformer.html
 
== Design patterns ==
https://gameprogrammingpatterns.com/command.html
 
== Books ==
https://gameprogrammingpatterns.com/contents.html
 
== Wikipedia ==
[[wikipedia:Game_design|Game design - Wikipedia]]
 
[[wikipedia:Video_game_development|Video game development - Wikipedia]]
 
[[wikipedia:Gameplay|Gameplay - Wikipedia]]
 
== Platforms ==
 
=== Desktop ===
 
=== Android ===
 
=== Web ===
https://libgdx.com/wiki/html5-backend-and-gwt-specifics
 
== External links ==
https://gamedev.stackexchange.com/questions/109047/how-to-close-an-app-correctly-on-desktop
 
https://gamefromscratch.com/speeding-up-gwt-compilation-speeds-in-a-libgdx-project/

Latest revision as of 14:54, 19 April 2025

Implementing jumping

To implement a jump mechanic, you can follow these steps:

1. **Define Variables:**

   - Create variables for the player's velocity, gravity, and whether the player is on the ground.

   ```java

   float velocityY = 0;

   final float gravity = -0.5f;

   boolean onGround = true;

   ```

2. **Jump Logic:**

   - Implement the jump by applying an upward velocity when the jump key is pressed and the player is on the ground.

   ```java

   if (Gdx.input.isKeyPressed(Input.Keys.SPACE) && onGround) {

       velocityY = 10;  // Jump strength

       onGround = false;

   }

   ```

3. **Apply Gravity:**

   - Continuously apply gravity to the player's vertical velocity.

   ```java

   velocityY += gravity;

   ```

4. **Update Player Position:**

   - Update the player's Y position using the current velocity.

   ```java

   player.y += velocityY;

   ```

5. **Ground Detection:**

   - Check if the player has landed back on the ground to reset the jump.

   ```java

   if (player.y <= groundLevel) {

       player.y = groundLevel;

       velocityY = 0;

       onGround = true;

   }

   ```

By following these steps, you create a basic jumping mechanic where the player can jump when on the ground, and gravity pulls them back down. This can be expanded with more complex mechanics like double jumps or variable jump heights.

Gravity

https://gamedev.stackexchange.com/questions/111314/writing-my-own-gravity