Cell2D

Cell2D is a free, open-source Java library for making 2D games, designed to simplify and speed up development by handling common organizational tasks. It is based on and incorporates Slick2D.

Features

  • Convenient and precise event scheduling
  • Compartmentalization of object and game state behaviors into modular thinkers
  • Object-level control of the flow of time
  • Efficient organization of objects in 2D space
  • Overlap detection between points, lines, circles, and polygons
  • Built-in basic solid-object collision system
  • Simple management of graphics, music, and sound effects
  • Image manipulation

Download

  • Cell2D (version 1.5.4) with source and Slick2D included
    • Changelog
      • Version 1.5.4
        • Added parameters for the position of the camera on the screen to SpaceLayer's renderActions() method.
        • Added Sound and Music's getGlobalVolume() and setGlobalVolume() methods.
        • Capped the volumes of Sounds and Music tracks at 1, as volumes greater than 1 did not increase their effective volumes anyway.
        • Similarly to CellVector, all AnimationInstance operations now return the AnimationInstance itself.
        • Added new constructors for SpaceObject and its subclasses that create SpaceObjects with locator Hitboxes that are new PointHitboxes at specified positions.
        • CellVector's equals() and hashCode() methods now consider two CellVectors equal if they represent the same point.
        • "Ties" between Thinkers with equal action priorities, SpaceObjects with equal draw priorities, and MobileObjects with equal movement priorities are now broken by comparing the objects' identity hash codes rather than hidden numerical IDs that are greater for more recently created objects.
        • Made the Frac class final, as it consists only of static information and cannot be instantiated anyway.
        • Various internal code tweaks and documentation improvements
      • Version 1.5.3
        • Added a parameter to CellGame's constructor that allows the client to specify an icon for the game's program window.
        • Added CellGame's getIconPath() method.
        • Added a formerly missing parameter description in the javadoc.
      • Version 1.5.2
        • Removed the SpaceObject constructor in which a "creator" SpaceObject was specified, as it was broken for MobileObjects and not very useful to begin with.
        • For consistency with its other bulk removal methods, SpaceState's removeAllObjects() method no longer calls clearEmptyCells() at the end.
        • Tweaked the behavior of the Over and Under DrawModes to match that of the Flat DrawMode for SpaceObjects with the same draw priority and y-coordinate.
        • Fixed a bug with the standard collision detection behavior.
        • Fixed a bug in which commands would be erroneously considered held after the game window changed size.
        • Various internal code tweaks and documentation improvements
      • Version 1.5.1
        • ThinkerObject's movement functionality has been separated into its new parent class MobileObject, and SpaceState's methods that used ThinkerObjects now use MobileObjects.
        • SpaceState's rendering system has been adjusted to prevent illusory jittering in the positions of objects that are moving together with the camera. As a result, methods such as Viewport's get...Edge() methods, getScreenPoint(), getSpacePoint(), and rectangleIsVisible() behave slightly differently.
        • Added CellGameState's bindFinishedActions() method.
        • Removed CellGame's finishTypingString() method.
        • A CellGame now throws a RuntimeException instead of letting itself crash the game if it does not enter its first CellGameState during its initActions().
        • Fixed a bug in which the game would crash if certain methods were called on a CellGame that had not entered its first CellGameState.
        • Fixed a bug in which MobileObjects would reset their step vectors immediately before moving instead of immediately after.
        • Fixed a bug in which stationary CompositeHitboxes would fail to update their boundaries accordingly when a new component was added.
        • Various internal code tweaks and documentation improvements
      • Version 1.5.0
        • The audio system in general has been revamped. CellGame's music stack can now accommodate multiple Music tracks per priority level, which means that multiple Music tracks can play at once.
        • All manipulation of Music tracks not related to their placements on the Music stack is now performed through methods of Music objects.
        • Music tracks can now be initialized with loop points.
        • Pitch in an audio context has been renamed to speed, and the speed of a Music track can now be faded in a similar manner to its volume.
        • Sound's loop() methods have been removed. Instead, whether or not to loop a Sound when playing it is specified with an optional parameter in the play() methods.
        • Sprites with limited functionality can now be created from Slick2D Images.
        • Loading images have been replaced with CellGame's new renderLoadingVisuals() method.
        • Added CellGame's getControlName() and getControl() methods.
        • Removed CellGame's getCurrentStateID() method.
        • Fixed a bug in which manually setting an AnimationInstance's index at a level other than its highest one would result in an error.
        • Fixed bugs in which Hitbox overlaps involving CircleHitboxes, LineHitboxes, or PolygonHitboxes would escape detection in specific situations.
        • Fixed a bug in which rotated Sprites were sometimes positioned incorrectly when drawn.
        • Various internal code tweaks and documentation improvements
      • Version 1.4.1
        • Updated to LWJGL 2.9.3 and JInput build #2841.
        • Added CellGame's isShowingFPS() and setShowFPS() methods.
        • Added SpaceState's getSpacePoint() method.
        • Added Viewport's getSpacePoint() and getScreenPoint() methods.
        • Added Viewport's getLeft(), getRight(), getTop(), and getBottom() methods.
        • PolygonHitbox's addRelVertex() methods have been renamed to variants of addVertex().
        • ColorFilter now allows color blending as well as replacement.
        • SpaceState's frameActions() and updateThinkerListActions() are no longer final.
        • Viewport's getLeftEdge(), getRightEdge(), getTopEdge(), and getBottomEdge() methods now have accurate documentation and provide their return values in fracunits.
        • Viewports' cameras must now be instances of SpaceObject<T> rather than just SpaceObject.
        • Fixed SpaceState's rectangleIsVisible() method.
        • Fixed Viewport's getWidth() and getHeight() methods.
        • Fixed a bug that prevented certain native libraries from being loaded.
        • Fixed a bug that prevented AnimationInstances from properly updating their indices on levels with speeds of 0.
        • Fixed a bug that caused commands to be pressed after arbitrary controls were bound to them.
        • Various internal code tweaks and documentation improvements
      • Version 1.4.0
        • CellGameStates now take their frameActions() before their Thinkers do. As a result, SpaceStates move their assigned ThinkerObjects before their SpaceThinkers' frameActions() are taken, and SpaceThinkers' afterMovementActions() have accordingly been removed and replaced with beforeMovementActions().
        • ThinkerGroups have been added, and both CellGameState and Thinker now extend ThinkerGroup.
        • ThinkerStates have been removed. Instead, Thinkers can be assigned to other Thinkers.
        • TimedEvent now has no generic type fields, and its eventActions() method has no parameters. Those attributes had problems before, and implementing them properly would increase generic type complexity for the sake of only a little convenience.
        • SpaceObject's draw() method now has parameters for the edges of the rendering region, just like SpaceLayer's and HUD's renderActions() methods do.
        • Viewport's constructor's HUD parameter has been removed.
        • Fixed a bug with Viewport rendering.
      • Version 1.3.1
        • Added a version of SpaceObject's getAnimInstance() method with no parameters.
        • The Exception that is thrown when a CellGame's loading image fails to load has been made more descriptive.
      • Version 1.3.0
        • The Assets class has been removed, as its function is performed more effectively by custom static variables in other classes.
        • Support for MOD and XM audio files has been removed, as it was limited and unreliable to begin with.
        • Cell2D's methods no longer throw SlickExceptions.
        • Fixed a bug that prevented Viewports from rendering SpaceObjects despite having them in their field of view.
        • Fixed a bug with the Sound class' stop() method.
      • Version 1.2.0
        • Cell2D now uses fixed-point numbers in the form of fracunits to represent "continuous" length and time. See the Frac class for more details.
        • SpaceThinkers no longer have beforeMovementActions(), as the existence of frameActions() makes them redundant.
      • Version 1.1.1
        • Added Viewport's getWidth() and getHeight() methods.
        • Viewport's edge setter methods return success or failure instead of throwing an exception if they fail.
      • Version 1.1.0
        • Added SpaceState and its associated classes.
        • Added CellVector.
        • Added generic type slots for subclasses of CellGame in CellGameState, Thinker, and ThinkerState.
        • Added more getter methods for the sizes of hidden collections.
      • Version 1.0.1
        • Useless instances of the Assets class can no longer be created.
        • Cell2D's version number is now printed to the console when a game starts.
      • Version 1.0.0
        • Initial release.
    • Older versions
    • Known issues
      • The javadoc sometimes refers to the movement of ThinkerObjects in particular, when in reality ThinkerObjects move identically to all other MobileObjects. Fixed in the GitHub version.
      • The explanation in Thinker's javadoc of the order of time-dependent actions among Thinkers assigned to other Thinkers is misleading. Fixed in the GitHub version and the online javadoc.

Links

Contributors

Andrew Heyman

Andrew Heyman

  • Programming
  • Documentation
  • Website design

Charlie Grimm

  • Logo design