Git Product home page Git Product logo

doodle's Introduction

#What is Doodle? Doodle is a framework meant for creating games in Java. It wraps JavaFX for rendering, input handling, collisions and more.

It provides you with classes like Entity, Room, KeyEventListener,.. to put your game together in an easier way.

The structure of Doodle is based off of Game Maker (Rooms, Sprites,..).

A better documentation is planned in the future.

#Reasons to use and not use Doodle

Doodle was created for rapid prototyping of games in Java. It is not a thoroughly production-tested framework.

Use Doodle if you want:

  • Rapid prototyping
  • An easy to understand framework
  • A starting point to write your own game engine in JavaFX
  • To spend more time developing your game and less time handling low-level stuff
  • A native Java solution for writing a game engine

DON'T use Doodle if you need:

  • An optimized game engine that can perform at high stress (1000+ moving sprites)
  • More advanced 3D operations
  • Control at the low-level of things
  • A professional framework (seriously, use something like LibGDX instead)

#How do I use Doodle in my project? Here's an example of how your program might look. Note: A better documentation is on the way

In your main class

    public static void main(String[] args) {
        settings.setTitle("Doodle Sample");
        NodeBasedRenderer renderer = new NodeBasedRenderer();
        //renderer.setEffect(new Bloom(0.2));
        settings.setRenderer(renderer);
        //settings.setDebugMode(true);

        /*settings.setDebugMode(false);
        settings.setFullscreen(true);*/

        launch(args);
    }

    @Override
    public void onApplicationReady()
    {
        Room myRoom = new Room(4096, 4096);
        setCurrentRoom(myRoom);
        
        Entity player = new PlayerEntity(64, 64);
        myRoom.addEntity(player);
    }

You may of course delegate the room creation to another class and even create a class that extends room for the entity creation. Note that launch(args) is blocking, so any statements after launch(args) will only get called when the main window is closed. After Doodle is ready setting up, onApplicationReady() is called.

PlayerEntity class

public class PlayerEntity extends Entity implements KeyEventListener
{
    public PlayerEntity(int x, int y)
    {
        super(new Sprite("ship.png"), x, y);
    }

    @Override
    public void onKeyEvent(KeyEvent keyEvent, KeyState keyState)
    {
        if (keyState == KeyState.HOLDING) {
            switch (keyEvent.getCode()) {
                case UP:
                    getPosition().translate(0, -5);
                    break;
                case DOWN:
                    getPosition().translate(0, 5);
                    break;
                case LEFT:
                    getPosition().translate(-5, 0);
                    break;
                case RIGHT:
                    getPosition().translate(5, 0);
                    break;
            }
        }
    }
}

Whenever you're interested in receiving certain net.digaly.doodle.events from the application, such as keyboard input or frame updates, your class can implement one of the following:

  • MouseEventListener
    Use when you want to know about mouse clicks, presses, releases and more
  • KeyEventListener
    Use when you want to know about button presses, releases and holds
  • FrameUpdateListener
    Use when you want to know when a new frame starts
  • FrameDrawListener
    Use when you want to know when a new frame is drawn, and maybe add custom draw code for your entity
  • CollisionEventListener
    Use when you want to know when an entity Enters, Exits or Stays in collision with another entity. (Note that your entity must have a collider assigned by using setCollider(new BoxCollider(this, 0, 0, getWidth(), getHeight()) for example)

When an entity is added to a room, it will automatically subscribe to the events that it needs and receive updates in the respective methods like you see above.

doodle's People

Watchers

 avatar

Forkers

yannisdejonghe

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.