Coder Social home page Coder Social logo

swing-lite-engine's Introduction

Swing-Lite-Engine

A small framework I built to help with basic game development using Java's javax.swing library. In no way should this ever be used for larger games (use OpenGL, Unity, etc for that). The syntax is Unity-like, and implements some of its core concepts.

I mainly made this to refresh my Java knowledge before I take ICS4U ¯\ _ (ツ) _ /¯

Current Features

  • Extensible Entity-Component system
    • A GameObject is an entity that can be extended to make custom entities
      • GameObjects maintain a set of Component objects
    • Behaviours of a GameObject can be described by adding Component objects
      • Some standard components are Renderer, Transform, Animator, and Collider
      • Custom components can be made by extending the Component class
      • Allows for easy reusability of behaviours among numerous GameObjects
  • Observer pattern
    • Using Java's Runnable and Consumer, listeners can be created for global/local events that are invoked.
    • Events can be created by instantiating a new EventSource or EventSource.WithArgs<T> and adding any listeners
      • Mitigates callback hell that I've experienced in other javax.swing projects
  • Object lifecycle
    • For any classes implementing IEntity (including GameObject and Component):
      • The awake() method is called when an entity is first instantiated. Overriding awake() allows you to run a custom startup.
      • The update() method is called on a fixedUpdate. Overriding update() allows you to run custom frame-to-frame logic
      • The onDestroy() method is called when an entity is removed or destroyed. Overriding onDestroy() allows you to implement custom onDestroy behaviours
  • Serialization utilities
    • Use the Serializer and Deserializer classes to save Java objects in your game (save games, playerprefs, etc) to a byte .txt file
    • Make sure your object implements java.io.Serializable
  • Collision?
    • No physics are implemented but intersection detection between Collider components is supported
      • The onCollision(Collider other) method of a GameObject with a Collider component will be called on intersection

Some Boilerplate to Get Started

public static void main(String[] args) {
    //Custom startup initialization goes here
    Game.init(new ViewSettings(new Vector2(900, 600), null, "Hello Game!")); //start the update loop and create window
}

swing-lite-engine's People

Contributors

nathanwong1106 avatar

Watchers

 avatar

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.