Skip to content

Java-Game-Maker/JavaGameEngine

Repository files navigation


com.javagamemaker.javagameengine

An awesome Game Engine to jumpstart your game projects!
Explore the docs »

View Demo · Report Bug · Request Feature

Logo
Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

Examples

About The Project

When creating fun game projects there is a lot of code just to get you going so we created this awsome game engine to let you go directly to the fun of gamemaking.

Here's why:

  • Your time should be focused on creating something amazing. A game that is very fun with great features
  • You shouldn't be doing the same tasks over and over like creating all the hideous game making code
  • You should implement DRY principles to the rest of your life 😄

(back to top)

Built With

The com.javagamemaker.javagameengine is built with vanila java 1.8 using the swing framework for the input and drawing aspects

(back to top)

Getting Started

It is very easy to start

Prerequisites

Be sure yoy have the jre installed

  • check java
    java -version
    If you get some sort of error message please visit https://www.java.com/sv/ and download java

Installation

You can clone this repo and play around with the Testing package where we test the engine and then build the artifact and import the jar to your own project. Or you can download the jar file in the output folder and import the jar to your project.

  1. Clone the repo
    git clone https://github.com/Java-Game-Maker/com.javagamemaker.javagameengine.git

(back to top)

Usage

For more examples, please refer to the Documentation

To get started create a main.java file where you extend the com.javagamemaker.javagameengine class In your public static void main(String[] args){} method

init();

start(null);

And a windows named Java Game Engine will appear with a blue background To change the window just create a new JFrame and add the configuration you want to it and pass it in the start method

init();

JFrame frame = new JFrame();
frame.setTitle("My example Title");

start(frame);

REMEMBER that when you do this your frame is a totaly new frame and have to set size and so on

To change the background (skybox), you can access the GAMEWORLD.setBackground(new Color(0,0,0)); GAMEWORLD is the JPanel where we draw everyting to

A example on how to use it

package example;


import javax.swing.*;
import java.awt.*;


public class Main extends JavaGameEngine{

    public static Ob parent;
    public static Ob child;


    public static void main(String[] args)
    {
        Scene scene = new Scene();

        Ob ob1 = new Ob(new Vector2(100,100));
        Ob ob2 = new Ob(new Vector2(200,400));
        Ob ob3 = new Ob(new Vector2(400,400));

        scene.add(ob1);
        scene.add(ob2);
        scene.add(ob3);
        
        //set the selected scene
        setSelectecScene(scene);
        start();
    }

    static class Ob extends GameObject{
        public Ob con;

        public Ob(Vector2 pos){
            setPosition(pos);
        }

        @Override
        public void onMousePressed() {
            if(Main.parent==null){
                Main.parent = this;
            }
            else{
                Main.parent.con = this;
                Main.parent = null;

            }
        }

        @Override
        public void onMouseEntered() {
            setScale(getScale().multiply(1.1f));
        }
        @Override
        public void onMouseExit() {
            setScale(getScale().devide(1.1f));
        }
        @Override
        public void render(Graphics g) {
            super.render(g);
            if(con!=null){
                g.drawLine((int) getPosition().getX(), (int) getPosition().getY(), (int) con.getPosition().getX(), (int) con.getPosition().getY());
            }
        }
    }

}

(back to top)

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Alfred Roos - alfred@stensatter.se

Project Link: https://github.com/Java-Game-Maker/com.javagamemaker.javagameengine

(back to top)

Acknowledgments

Thanks to every on who has helped with this project. I want to special thanks to the following

(back to top)