A simple 2D game library made using Java Swing for Java Swing. In contrast to other 2D game libraries in Java this does not use OpenGL and instead uses Swing components/methodologies only. The allows you to be able to leverage existing knowledge of Java Swing components, layouts, UIs and design patterns in order to create a functional 2D game.
The projects nomenclature might seem familiar if you have ever used cocos2dx and thats because it is what inspired me to write this.
TODO (before beta release):
- Remove
Scene
reference fromGameLoop
- Iterate sprites using iterator or synchronized block in places that access sprite list
-
Scene
to render black background and not white - Add a
INode
interface whichScene
will accept andSprite
will implement - Add a
ICollidable
interface which will allow automatic collision detections - Allow debug details/masks to be shown/drawn i.e FPS, objects rendered and red rectangles around all nodes when enabled
- Implement
AudioEngine
-
INode
should be able to be added to anotherINode
and rendered -
Scene
should be nothing more then anINode
with aDirector
which extendsJPanel
running the game loop and switching betweenScene
s -
Node
co-ordinates should be relative to parent.Scene
node should default by obtaining width and height from theDirector
. - Implement
Animation
loops as currently all animations run indefinitely -
ImageScaler
to be first class citizen built intoDirector
/Scene
(so no point calcs for various screen widths are needed from a user perspective) -
parent
should be nulled whenNode#remove
is called. - Checking for collisions should use a copy of the nodes as to avoid concurrent modification issues (when adding inside the
onCollision
method) - Add z-order to
Node
as well as fix Node size counts -
Node
should haveonEnter
/onExit
callbacks for when aNode
is made visible or removed from the scene/parent. - Remove any unnecessary synchronized blocks
- Rename all getters with world in to omit the world part for readability
- Add Spritesheet support for
SpriteFrameCache
- Allow
Sprite
to be created with a singleSpriteFrame
as opposed to animation - Implement
setRestrictMovementToParent(boolean enable, long flags)
,setRestrictMovementToNode(INode node, long flags)
andonMovementRestricted()
forSprite
, defaults to no restriction. - Implement
setFlippedY
onSprite
- Implement
setScale
forNode
- Implement
setScaleX
andsetScaleY
- Allow
Scene
background to be set with aSpriteFrame
and SpriteFrame name similar toSprite
- Add
MouseListener
ability toNode
s usingShape
/Ellipses2D
- Add
onCollisionStart
andonCollisionEnd
methodsICollidable
- Investigate adding only necessary apache commons libraries
- Add
Camera
which can be used for side scrolling/infinite background game types -
Scene
should only render visible sprites in the camera view - Implement assets search paths (SD,HD,HDR)
- Allow
Director
to use variable or fixed time step game loop, as well as control FPS to 30 or 60. In fixed stepelapsedTime
will become 0 and interpolation in Node render will be >= 0 and vice versa. - Implement some type of
ActionManager
/Actionable
class onNode
whichSprite
will use to switch out animations on the fly. Animate, MoveTo, Follow etc. - Allow more support of plist and TexturePacker formats like cropping and trimming of sprites, and rotated sprites as well as multi packed sheets
- Add Tileset/Tilemap support, which is used in its own sample (sample-2)
- Add physics capabilities using dyn4j
- Document classes and methods
Requirements:
Examples:
Special thanks to: