forked from nickidebruyn/Galago2D
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NideBruyn
committed
Jul 26, 2022
1 parent
86396d1
commit fba6dca
Showing
49 changed files
with
186 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+2.44 KB
out/production/classes/com/galago/sprite/SingleSpriteAnimationControl.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.01 KB
out/production/classes/com/galago/sprite/SpriteAnimationControl.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.3 KB
out/production/classes/com/galago/sprite/physics/BoxCollisionShapeSorter.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+330 Bytes
out/production/classes/com/galago/sprite/physics/DefaultFilter.class
Binary file not shown.
Binary file added
BIN
+917 Bytes
out/production/classes/com/galago/sprite/physics/Dyn4jAppState$1.class
Binary file not shown.
Binary file added
BIN
+1.32 KB
out/production/classes/com/galago/sprite/physics/Dyn4jAppState$2.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+349 Bytes
out/production/classes/com/galago/sprite/physics/PhysicsCollisionListener.class
Binary file not shown.
Binary file added
BIN
+441 Bytes
out/production/classes/com/galago/sprite/physics/PhysicsControl.class
Binary file not shown.
Binary file added
BIN
+1.84 KB
out/production/classes/com/galago/sprite/physics/PhysicsSpace$1.class
Binary file not shown.
Binary file added
BIN
+1000 Bytes
out/production/classes/com/galago/sprite/physics/PhysicsSpace$2.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+239 Bytes
out/production/classes/com/galago/sprite/physics/PhysicsTickListener.class
Binary file not shown.
Binary file added
BIN
+16.6 KB
out/production/classes/com/galago/sprite/physics/RigidBodyControl2D.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.73 KB
...uction/classes/com/galago/sprite/physics/characters/PlatformerCharacterControlState.class
Binary file not shown.
Binary file added
BIN
+285 Bytes
...production/classes/com/galago/sprite/physics/characters/PlatformerCharacterListener.class
Binary file not shown.
Binary file added
BIN
+2.16 KB
out/production/classes/com/galago/sprite/physics/joint/DistanceJoint.class
Binary file not shown.
Binary file added
BIN
+1.85 KB
out/production/classes/com/galago/sprite/physics/joint/FrictionJoint.class
Binary file not shown.
Binary file added
BIN
+2.44 KB
out/production/classes/com/galago/sprite/physics/joint/HingeJoint.class
Binary file not shown.
Binary file added
BIN
+1.03 KB
out/production/classes/com/galago/sprite/physics/joint/PhysicsJoint.class
Binary file not shown.
Binary file added
BIN
+2.28 KB
out/production/classes/com/galago/sprite/physics/joint/RopeJoint.class
Binary file not shown.
Binary file added
BIN
+1.86 KB
out/production/classes/com/galago/sprite/physics/shape/BoxCollisionShape.class
Binary file not shown.
Binary file added
BIN
+1.87 KB
out/production/classes/com/galago/sprite/physics/shape/CapsuleCollisionShape.class
Binary file not shown.
Binary file added
BIN
+1.62 KB
out/production/classes/com/galago/sprite/physics/shape/CircleCollisionShape.class
Binary file not shown.
Binary file added
BIN
+2.02 KB
out/production/classes/com/galago/sprite/physics/shape/CollisionShape.class
Binary file not shown.
Binary file added
BIN
+1.87 KB
out/production/classes/com/galago/sprite/physics/shape/EllipseCollisionShape.class
Binary file not shown.
Binary file added
BIN
+3.95 KB
out/production/classes/com/galago/sprite/physics/shape/LineCollisionShape.class
Binary file not shown.
Binary file added
BIN
+2.16 KB
out/production/classes/com/galago/sprite/physics/shape/PyramidCollisionShape.class
Binary file not shown.
Binary file added
BIN
+2.42 KB
out/production/classes/com/galago/sprite/physics/shape/TriangleCollisionShape.class
Binary file not shown.
Binary file added
BIN
+4.32 KB
out/production/classes/com/galago/sprite/physics/vehicle/Vehicle.class
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package com.galago.sprite.examples; | ||
|
||
import com.galago.sprite.Sprite; | ||
import com.galago.sprite.camera.Camera2DState; | ||
import com.galago.sprite.physics.Dyn4jAppState; | ||
import com.galago.sprite.physics.RigidBodyControl2D; | ||
import com.galago.sprite.physics.characters.PlatformerCharacterControlState; | ||
import com.galago.sprite.physics.shape.BoxCollisionShape; | ||
import com.galago.sprite.physics.shape.CircleCollisionShape; | ||
import com.jme3.app.SimpleApplication; | ||
import com.jme3.asset.TextureKey; | ||
import com.jme3.material.Material; | ||
import com.jme3.material.RenderState; | ||
import com.jme3.math.Vector2f; | ||
import com.jme3.renderer.queue.RenderQueue; | ||
import com.jme3.scene.Geometry; | ||
import com.jme3.texture.Texture; | ||
|
||
/** | ||
* This example will show you how to create simple sprites for the background, | ||
* floor and player. | ||
* | ||
* | ||
* @author NickideBruyn | ||
*/ | ||
public class Example1 extends SimpleApplication { | ||
|
||
private Geometry player; //The player spatial object | ||
private Geometry background; //The background spatial | ||
private Geometry floor; //The floor | ||
|
||
private Dyn4jAppState dyn4jAppState; | ||
private PlatformerCharacterControlState platformerCharacterControlState; | ||
private Camera2DState camera2DState; | ||
|
||
/** | ||
* The main method for this java app when we run it. | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
Example1 app = new Example1(); | ||
app.start(); | ||
} | ||
|
||
@Override | ||
public void simpleInitApp() { | ||
|
||
dyn4jAppState = new Dyn4jAppState(); | ||
stateManager.attach(dyn4jAppState); | ||
|
||
//Load the background | ||
Sprite backgroundSprite = new Sprite(20, 10); | ||
background = new Geometry("background", backgroundSprite); | ||
Material material = loadMaterial("Textures/colored_desert.png"); | ||
background.setMaterial(material); | ||
backgroundSprite.scaleTextureCoordinates(new Vector2f(2, 1)); | ||
rootNode.attachChild(background); | ||
background.move(0, 0, -1); | ||
|
||
//Load the floor | ||
Sprite floorSprite = new Sprite(20, 1); | ||
floor = new Geometry("floor", floorSprite); | ||
material = loadMaterial("Textures/dirtMid.png"); | ||
floor.setMaterial(material); | ||
floorSprite.scaleTextureCoordinates(new Vector2f(20, 1)); | ||
rootNode.attachChild(floor); | ||
floor.move(0, -4f, 0); | ||
|
||
//For the floor sprite it will be a static body with 0 mass | ||
RigidBodyControl2D rbcFloor = new RigidBodyControl2D(new BoxCollisionShape(floorSprite.getWidth(), floorSprite.getHeight()), 0); | ||
//Attach the control to the spatial | ||
floor.addControl(rbcFloor); | ||
//Add the rigid body to the physics space | ||
dyn4jAppState.getPhysicsSpace().add(rbcFloor); | ||
//Move the rigid body to the desired position | ||
rbcFloor.move(0, -4f); | ||
|
||
|
||
//Load the player | ||
Sprite playerSprite = new Sprite(1, 1); | ||
player = new Geometry("player", playerSprite); | ||
material = loadMaterial("Textures/slimeBlock.png"); | ||
player.setMaterial(material); | ||
player.setQueueBucket(RenderQueue.Bucket.Transparent); | ||
rootNode.attachChild(player); | ||
player.move(0, 3f, 0); | ||
|
||
//The player rigid body will have mass so that it can be affected by gravity | ||
RigidBodyControl2D rbcPlayer = new RigidBodyControl2D(new CircleCollisionShape(0.5f), 1); | ||
//Add the control to the player spatial | ||
player.addControl(rbcPlayer); | ||
//Add it to the physics space | ||
dyn4jAppState.getPhysicsSpace().add(rbcPlayer); | ||
//Now we can move it to a start position | ||
rbcPlayer.move(0, 3); | ||
//Adjust the player's gravity | ||
rbcPlayer.setGravityScale(2); | ||
|
||
|
||
platformerCharacterControlState = new PlatformerCharacterControlState(dyn4jAppState, player); | ||
stateManager.attach(platformerCharacterControlState); | ||
|
||
//Example4-Step1: Create the camera2Dstate and give it a distance and movement interpolation amount | ||
camera2DState = new Camera2DState(player, 6, 0.01f); | ||
//Set camera clipping which will block the camera from moving a certain min and max value on the x and y axis | ||
camera2DState.setCameraClipping(new Vector2f(-2f, 0), new Vector2f(2f, 1)); | ||
//You can also set a camera to player offset. Move the camera to stick above the player 2f in the y axis | ||
camera2DState.setTargetOffset(new Vector2f(0, 2)); | ||
//Attach the camera2Dstate to the state manager | ||
stateManager.attach(camera2DState); | ||
|
||
} | ||
|
||
/** | ||
* Local method for reuse of loading a texture as an unshaded material | ||
* | ||
* @param file | ||
* @return | ||
*/ | ||
protected Material loadMaterial(String file) { | ||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); | ||
Texture tex = assetManager.loadTexture(new TextureKey(file, false)); | ||
tex.setWrap(Texture.WrapMode.Repeat); | ||
mat.setTexture("ColorMap", tex); | ||
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); | ||
return mat; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/galago/sprite/physics/characters/PlatformerCharacterListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.galago.sprite.physics.characters; | ||
|
||
public interface PlatformerCharacterListener { | ||
|
||
public void doCharacterIdleEvent(); | ||
|
||
public void doCharacterWalkEvent(float direction); | ||
|
||
public void doCharacterJumpEvent(int count); | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.