Skip to content

davidkroukamp/SwingGameLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwingGameLibrary

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 from GameLoop
  • 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 which Scene will accept and Sprite 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 another INode and rendered
  • Scene should be nothing more then an INode with a Director which extends JPanel running the game loop and switching between Scenes
  • Node co-ordinates should be relative to parent. Scene node should default by obtaining width and height from the Director.
  • Implement Animation loops as currently all animations run indefinitely
  • ImageScaler to be first class citizen built into Director/Scene (so no point calcs for various screen widths are needed from a user perspective)
  • parent should be nulled when Node#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 have onEnter/onExit callbacks for when a Node 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 single SpriteFrame as opposed to animation
  • Implement setRestrictMovementToParent(boolean enable, long flags), setRestrictMovementToNode(INode node, long flags) and onMovementRestricted() for Sprite, defaults to no restriction.
  • Implement setFlippedY on Sprite
  • Implement setScale for Node
  • Implement setScaleX and setScaleY
  • Allow Scene background to be set with a SpriteFrame and SpriteFrame name similar to Sprite
  • Add MouseListener ability to Nodes using Shape/Ellipses2D
  • Add onCollisionStart and onCollisionEnd methods ICollidable
  • 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 step elapsedTime will become 0 and interpolation in Node render will be >= 0 and vice versa.
  • Implement some type of ActionManager/Actionable class on Node which Sprite 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:

See SwingGameLibrary-Samples

Special thanks to:

  • TinySound for the great library, which is the backbone of SwingGameLibrary's AudioEngine
  • jcabi-xml for the XML library used to read plist file format

Releases

No releases published

Packages

No packages published

Languages