Giter VIP home page Giter VIP logo

voodoo2d's Introduction

Voodoo 2D

A lightweight engine to easily build complex cross-platform 2D games in Java.

Build Status MIT License

Main Features

  • Basic Game Infrastructure (GameLoop, Configuration, ...)
  • 2D Render Engine (GUI Components, Spritesheet Animations, Ambient Lighting, Particle System, ...)
  • 2D Sound Engine (support for .ogg)
  • 2D Physics Engine
  • Support for Tile Maps in .tmx format (e.g. made with Tiled Editor)
  • Player input via Keyboard/Mouse

Code:

Mesh mesh = Mesh.loadMesh("textures/player.png", 64); // Create new mesh with size of 64x64 pixels
GameObject gameObject = new GameObject(mesh); // Makes a new gameObject from mesh
Animation run = new Animation(gameObject, 0, 3, 6); // Creates new animation with frames 0 - 3 at 6 fps
run.play(); // Play the animation!
INPUT
if(window.isKeyPressed(GLFW_KEY_D)) { // Checks if "D" key is down
    run.play(); // Plays our animation!
COLLISION
aabb = new AABB(); // Make a new collision box
aabb.setCenter(0.5f, 0.0875f); // Set the center point of the boundary
aabb.setDistance(0.5f, 0.0875f); // Set the distance from the center to the edges of the boundary

Maven Dependency

<dependency>
  <groupId>com.github.jacksonhoggard</groupId>
  <artifactId>voodoo2d</artifactId>
  <version>1.0-DEVBUILD</version>
</dependency>

CONTRIBUTING

If you'd like to make a contribution, please refer to CONTRIBUTING.md or read the wiki page on how to set up the project

TROUBLESHOOTING

A game object is not drawing to the screen!

  • Make sure you placed the game object in the gameObjects list that will be passed into the render method of the renderer.
  • Check to see if the object has been instantiated properly.

Animations are not diplaying properly

  • Ensure that you have given the proper range of sprites to be displayed from the spritesheet (i.e. 0 - 3).
  • Remember that, when playing an animation, all other animations attached to that game object will be stopped.

Something else isn't working properly

  • Open up an issue! Someone will get to it as soon as possible.

Current Version

  • 1.0-DEVBUILD (Development Version)

Areas for improvements / involvement

  • GUI
  • Particle System
  • Scenes
  • Lighting options
  • Batched Rendering

voodoo2d's People

Contributors

garrettbassen avatar jacksonhoggard avatar mariaadannies avatar plutone11011 avatar tim-day-387 avatar tinovasq avatar yash-punia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voodoo2d's Issues

GUI

Describe the feature you'd like
GUI features! There should be both static and dynamic elements that can be drawn onto the screen and the elements should remain in the same spot even if the camera moves.

image

GUI Elements to add:

  • Base gui element
  • Base gui interface
  • Text
  • Button

Additional context
This book contains a lot of information on lwjgl and how it works. Although it describes how to create a 3D engine, the HUD can be applied to Voodoo2D without any problems.

Improve Collision System

Update the collision system to make it similar to this tutorial:
Here

No need to add physics engine stuff just yet, just make sure the engine has all the components necessary to develop one.

Add method to Mesh class

Describe the feature you'd like
I want the following code to be added to the Mesh class:

public static Mesh loadMesh(String filename) {
    return new Mesh(
            new float[]{ // positions
                    -0.5f,  0.5f, 0.0f,
                    -0.5f, -0.5f, 0.0f,
                    0.5f, -0.5f, 0.0f,
                    0.5f,  0.5f, 0.0f,
            },
           new float[]{ // text coordinates
                    0.0f, 0.0f,
                    0.0f, 1.0f,
                    1.0f, 1.0f,
                    1.0f, 0.0f,
            },
            new int[]{
                    0, 1, 3, 3, 1, 2,
            },
            new SpriteSheet(filename)
    );
}

Add anti aliasing

Please replace the TODO comment in Window.java with the following code:

glfwWindowHint(GLFW_SAMPLES, 4);

If you are a beginner, you can start by just adding the above code. If you are maybe a little more experienced, try to add a boolean to allow anti aliasing to be turned on or off (look at how vSync is handled if you are confused on how to do this).

GameEngine runs init() twice upon startup

Describe the bug
GameEngine runs init() twice upon startup: not a 'game breaking' bug per se (ha), but does interfere with the map tileset parsing and construction, which is how I found it.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to src/main/.../voodoo2d/engine/GameEngine.java.
  2. Using either IDE breakpoints or a println(), mark the method call of init().
  3. notice the double run logic error.

Expected behavior
The method should be called once, as it is an initialization.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Win10 Home 64bit
  • Browser: N/A
  • Version N/A

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser N/A
  • Version N/A

Additional context
None.

Batch Rendering

I see that in this Project every single GameObject is rendered using a separate draw call. (Very Slow)

Batch Rendering is not hard to implement. Only thing is one has to overhaul the entire Renderer :(

Can't build using maven

Describe the bug
Can't build the project using maven and the /pom.xml file

To Reproduce
Steps to reproduce the behavior:

  1. clone the project
  2. run 'mvn clean install'

Expected behavior
Maven should build it without errors

Screenshots
Bildschirmfoto 2020-05-31 um 17 06 18

Desktop

  • OS: macOS
  • Version: 10.15.4

Additional context

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-shade-plugin is missing. @ line 146, column 21
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead. @ 
[WARNING] The expression ${version} is deprecated. Please use ${project.version} instead. @ 
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl:jar:${lwjgl.natives} is missing. @ line 94, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-assimp:jar:${lwjgl.natives} is missing. @ line 99, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-glfw:jar:${lwjgl.natives} is missing. @ line 104, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-openal:jar:${lwjgl.natives} is missing. @ line 109, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-opengl:jar:${lwjgl.natives} is missing. @ line 114, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-stb:jar:${lwjgl.natives} is missing. @ line 119, column 21
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.github.crembluray:voodoo2d:1.0-SNAPSHOT (/Users/edgelord/git/voodoo2d/pom.xml) has 6 errors
[ERROR]     'dependencies.dependency.version' for org.lwjgl:lwjgl:jar:${lwjgl.natives} is missing. @ line 94, column 21
[ERROR]     'dependencies.dependency.version' for org.lwjgl:lwjgl-assimp:jar:${lwjgl.natives} is missing. @ line 99, column 21
[ERROR]     'dependencies.dependency.version' for org.lwjgl:lwjgl-glfw:jar:${lwjgl.natives} is missing. @ line 104, column 21
[ERROR]     'dependencies.dependency.version' for org.lwjgl:lwjgl-openal:jar:${lwjgl.natives} is missing. @ line 109, column 21
[ERROR]     'dependencies.dependency.version' for org.lwjgl:lwjgl-opengl:jar:${lwjgl.natives} is missing. @ line 114, column 21
[ERROR]     'dependencies.dependency.version' for org.lwjgl:lwjgl-stb:jar:${lwjgl.natives} is missing. @ line 119, column 21
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

Lighting

Describe the feature you'd like
Lighting using spot and point lights. It should look like the screenshots below.

Screenshots
image
image

Additional links
lwjgl book has a great chapter on this

Loading a single texture as a GameObject throws an error

Describe the bug
When calling

Mesh.loadMesh("filename");

it tries to create a spritesheet for the mesh, but we only want to use one texture for our gameObject, meaning it throws an error
trying to do this.

To Reproduce
Steps to reproduce the behavior:

  1. Create a mesh using Mesh.loadMesh("filename");

Expected behavior
The texture should be loaded into the mesh and no error should be thrown.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • JDK: AdoptOpenJDK11

Cannot build SNAPSHOT.jar

Describe the bug
I did all the configuration and building steps on the wiki, but the IntelliJ IDEA just gave me a "DEVBUILD.jar", a single jar file, and it wouldn't run because it doesn't have a main class.

To Reproduce
Steps to reproduce the behavior:

  1. Clone repo
  2. Start IntelliJ IDEA
  3. Press green start button on the top menu line of the program right next to the button that says main after editing configuration to build a jar, with the command "clean install" as the wiki suggests
  4. Check the target folder

Expected behavior
Two .jar files, in which one of them would be named SNAPSHOT.jar, and it would start the engine.

Screenshots
image
image
image
image

Desktop (please complete the following information):

  • OS: Windows 10
  • JDK: AdoptOpenJDK11

Additional context
As shown in the screenshot, it also opens up the game screen. I'm not sure if that is supposed to happen or not.

Tile Mapping

Add tile mapping into the engine

Edit: thanks @tinovasq for laying the framework for tilemapping! Currently working on creating and combining the layers to be displayed.

Example:

TMX file

<map version="1.0" orientation="orthogonal" width="20" height="20" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="grass-tiles-2-small" tilewidth="32" tileheight="32">
  <image source="grass-tiles-2-small.png" width="384" height="192"/>
 </tileset>
 <tileset firstgid="73" name="tree2-final" tilewidth="32" tileheight="32">
  <image source="tree2-final.png" width="256" height="256"/>
 </tileset>
 <layer name="Background" width="20" height="20">
  <data>
   <tile gid="13"/>
   <tile gid="2"/>
   <tile gid="1"/>
   ...
  </data>
 </layer>
 <layer name="Top" width="20" height="20">
  <data>
   <tile gid="0"/>
   ...
  </data>
 </layer>
 <objectgroup name="Collision" width="20" height="20">
  <object x="287" y="354" width="127" height="60"/>
 </objectgroup>
</map>

In the Engine:

finalimage
Helpful link for reading TMX files!

Create a demo game

The demo game would use features from the engine to show off how the engine can be used.

Animations not working!

Describe the bug
For some reason animations get stuck on a single frame when played and aren't working anymore.

To Reproduce
Steps to reproduce the behavior:

  1. Make an animation.
  2. Play it.

Expected behavior
The animation plays as expected.

Screenshots
animerror

Desktop (please complete the following information):

  • OS: Windows 10
  • JDK: AdoptOpenJDK11

Metrics results for the project

I run some metrics to your project by Metrics Reloaded(Jet Brains) in contex of an academic project.

Some of the most important results :

1)Method measurement v(G) = 1.53%(in cyclomatic complexity) -> Generally, 1-4% is low complexity,
5-7% show moderate complexity, 8-10% have high complexity and 11+% are very high complexity.So the results are in good terms.

image

2)WMC Average = 10,35. WMC->number of methods defined in class.
The study suggests "optimal" use for WMC, but does not say what the optimal range is. In general it is good to range from 20-50 depending on the number of methods in a class.

image

3)CF Average = 17,66%. CF = Coupling Factor.

CF = Actual couplings / Maximum possible couplings
The coupling factor (CF alias COF) measures the actual connections between classes in relation to the maximum number of possible links.
It has been suggested that the CF should not exceed 12%, but we can not comment on whether this is a viable ceiling for all systems. In this project i found that the coupling factor is slightly increased based on the measurements.

image

Add anti aliasing variable to GameEngine constructor

Is your feature request related to a problem? Please describe.
No. Just an enhancement : )

Describe the feature you'd like
The current GameEngine constructor looks like this:

public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic)

It needs to look like this:

public GameEngine(String windowTitle, int width, int height, boolean vSync, boolean antiAliasing, IGameLogic gameLogic)

where it takes in a boolean telling it to turn on or off antialiasing. Not too hard, just not implemented yet. The window class already has the antiAliasing variable so all you would have to do is add antiAliasing to the Window constructor and the GameEngine constructor.

Windows specific hardcoded paths causes sample game to crush

Describe the bug
Windows specific hardcoded paths causes IO Exceptions during runtime.

  1. java.io.FileNotFoundException: /path/to/voodoo2d/src\main\resources\maps\example.tmx
    Probable cause is hardcoded path here:
    src/main/java/com/github/crembluray/voodoo2d/game/MapTree.java
  2. javax.imageio.IIOException: Can't read input file!
    Probable cause is hardcoded path here:
    src/main/java/com/github/crembluray/voodoo2d/engine/mapping/Layer.java

Changing the paths helped to run the demo.

To Reproduce
Steps to reproduce the behavior:

  1. Use any POSIX OS.
  2. Switch to 83c745.
  3. Add Maven exec plugin to pom.xml and specify com.github.crembluray.voodoo2d.game.Main as main class:
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <configuration>
    	<mainClass>com.github.crembluray.voodoo2d.game.Main</mainClass>
        </configuration>
    </plugin>
  4. Run $ mvn clean install exec:java

Expected behavior
Demo shouldn't crash.

Desktop (please complete the following information):

  • OS: Fedora 32
  • JDK: AdoptOpenJDK11

Update Wiki

Is your documentation update related to existing documentation? Please link it below
https://github.com/JacksonHoggard/voodoo2d/wiki

Describe the documentation update
The wiki is outdated and is for a much older version. Update the wiki to be more accurate to the current version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.