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 ¯\ _ (ツ) _ /¯
- Extensible Entity-Component system
- A
GameObject
is an entity that can be extended to make custom entitiesGameObjects
maintain a set ofComponent
objects
- Behaviours of a
GameObject
can be described by addingComponent
objects- Some standard components are
Renderer
,Transform
,Animator
, andCollider
- Custom components can be made by extending the
Component
class - Allows for easy reusability of behaviours among numerous
GameObjects
- Some standard components are
- A
- Observer pattern
- Using Java's
Runnable
andConsumer
, listeners can be created for global/local events that are invoked. - Events can be created by instantiating a new
EventSource
orEventSource.WithArgs<T>
and adding any listeners- Mitigates callback hell that I've experienced in other javax.swing projects
- Using Java's
- Object lifecycle
- For any classes implementing
IEntity
(includingGameObject
andComponent
):- The
awake()
method is called when an entity is first instantiated. Overridingawake()
allows you to run a custom startup. - The
update()
method is called on afixedUpdate
. Overridingupdate()
allows you to run custom frame-to-frame logic - The
onDestroy()
method is called when an entity is removed or destroyed. OverridingonDestroy()
allows you to implement customonDestroy
behaviours
- The
- For any classes implementing
- Serialization utilities
- Use the
Serializer
andDeserializer
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
- Use the
- Collision?
- No physics are implemented but intersection detection between
Collider
components is supported- The
onCollision(Collider other)
method of aGameObject
with aCollider
component will be called on intersection
- The
- No physics are implemented but intersection detection between
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
}