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 Slick2D, but operates at a higher level of abstraction.

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
  • Support for the free map editor Tiled
  • Simple management of graphics, music, and sound effects
  • Image manipulation

Download

  • Cell2D (version 2.1.1) with dependencies, source, and javadoc included
    • Changelog
      • Version 2.1.1
        • Updated to TiledReader version 1.1.0, for Tiled 1.4.x.
          • Added layer tint color support to TiledArea.
          • Made TiledConverter into an instantiable class, each instance of which interfaces with an instance of the FileSystemTiledReader class.
        • Added the getTransColor() method to TiledArea.
        • Made it so the List that TiledConverter.getSprites() returns in response to an image collection tileset is unmodifiable.
        • Added the ColorMultiplyFilter class.
        • Exposed Filter.getFilteredImage(), allowing for custom subclasses of Filter.
        • (Celick) Added Image.getBlankCopy().
        • Added semantic equals() and hashCode() methods to ColorFilter and ColorMapFilter.
        • Made methods that take a set of Filters as a parameter take them as varargs.
        • Added Animatable.getSprites() and Animatable.getFilteredCopy(), replacing Sprite's Sprite+Filter constructor.
        • Made Hitbox subclasses' getCopy() methods all final, and made their return types subclass-specific.
        • Made the equals() and hashCode() methods of Control subclasses final.
        • Removed Cell2D's dependency on JavaFX.
        • Sprites created from Celick Images can now have applicable Filters, as their constructors previously promised.
        • Fixed a bug in which Filtered images with transparency would come out more transparent than they should be.
        • Fixed a bug in which animated TiledArea tiles would animate at a speed of 0 by default.
        • Various internal code tweaks and documentation improvements
      • Version 2.1.0
        • Added the org.cell2d.space.map package, designed primarily for instantiating level maps in SpaceStates. As part of this package, Cell2D can now read information from files created with the map editor Tiled, using the new dependency TiledReader.
        • Added the classes ColorSpaceLayer, DrawableSpaceLayer, BasicEventGroup, BasicSpaceEventGroup, and BasicArea.
        • Added the Loadable interface, uniting the loading/unloading features of Sprites, SpriteSheets, Sounds, and Music tracks.
        • Filters can now be applied to Sprites created from Celick Images.
        • Added a parameter to SpriteSheet for the width of the margin around all of the Sprites on the image.
        • Added getSpriteWidth(), getSpriteHeight(), getSpacing(), and getMargin() getter methods to SpriteSheet.
        • Made SpriteSheet implement Iterable<Sprite>.
        • Added the method Animatable.getInstance().
        • Made getWidth() and getHeight() methods of Hitbox and SpaceObject instead of only RectangleHitbox.
        • Made it possible for AnimationInstances to be assigned to SpaceObjects without integer IDs.
        • Removed the Viewport edge parameters from SpaceObject.draw() and added Drawable.getRenderableRegion() to replace them.
        • Made DrawMode a public internal class of SpaceState.
        • Dropped AIF(F) file support (which may not have been working anyway).
        • Added a constructor to Color that takes a java.awt.Color as input.
        • Changed Area.load() to return an Iterable<SpaceObject> instead of the excessively specific Collection<SpaceObject>.
        • Changed ColorMapFilter to replace a pixel's RGB value if and only if it had a Map key with the same RGB value and an alpha value of 1. Previously, ColorMapFilter would only replace a pixel's RGB value if it had a Map key with the exact same RGBA value as the pixel.
        • Added a singleton-map constructor to ColorMapFilter.
        • Renamed Frac.toInt() to Frac.intRound() for consistency with intCeil() and intFloor().
        • Tweaked the way SpaceState calculates where on the screen to draw SpaceObjects.
        • (Celick) Removed the useless "clip" feature from the Graphics class (but left the useful "world clip" feature intact).
        • Made Animatable and AnimationInstance getter and setter methods throw IndexOutOfBoundsException in response to out-of-range indices, instead of returning default values or doing nothing.
        • Made SpriteSheet.getSprite() throw IndexOutOfBoundsException in response to out-of-bounds coordinates.
        • Added Exceptions for invalid constructor parameters in SpriteSheet.
        • Tweaked some Exception messages to make them more informative.
        • Removed an odd behavior in which a Sprite drawn "cropped" to be larger than before would repeat within the cropped area.
        • Fixed a null pointer bug that prevented PolygonHitboxes from being constructed.
        • Fixed a bug in which Sprites that were both rotated and flipped were drawn at the wrong positions.
        • Fixed a bug with the drawing of Sprites that are both cropped and flipped.
        • Fixed a bug in which an AnimationInstance added to a GameState with an integer ID could be removed from that state as if it did not have an ID.
        • Fixed a bug in which a SpriteSheet's width and height in Sprites would be erroneously set to 0 after unloading.
        • Fixed edge-case bugs in which two overlapping Line/Polygon/RectangleHitboxes would not be detected as such.
        • Various internal code tweaks and documentation improvements
      • Version 2.0.1
        • Added ArrayMap and ArraySet.
        • During a GameState transition with a visual fade-out, the current GameState's leftActions() method is now called after the fade-out has completed, rather than as it begins.
        • ThinkerObject's getTimerValue() and setTimerValue() methods now correctly accept only an Event with the appropriate generic type parameters.
        • The Iterators returned by SpaceState's objectIterator() and mobileObjectIterator() methods now correctly throw IllegalStateException in their remove() methods.
        • Fixed a bug in which the window of a game in fullscreen mode would not actually take up the entire screen.
        • Fixed a bug in which a MobileObject's followers would not follow it when it moved without being assigned to a SpaceState.
        • Various internal code tweaks and documentation improvements
      • Version 2.0.0
        • The names of Cell2D packages are now prefixed with "org.cell2d" instead of simply "cell2d".
        • Cell2D no longer uses Slick2D as a dependency. Instead, it incorporates code adapted from Slick2D, largely in the form of back-end "Celick" classes in packages prefixed with "org.cell2d.celick".
        • The org.cell2d.control package has been added, replacing Cell2D's use of Slick2D's input system.
        • The CellGameState class has been renamed to GameState.
        • ThinkerGroup's functionality has been folded into Thinker, and as a result, a GameState is now a type of Thinker. On the other hand, a Thinker's functionality of being assigned to another Thinker has been separated into its new child class SubThinker.
        • The org.cell2d.space package's generic type system has been reworked. Similarly to ordinary GameStates and Thinkers, SpaceStates and SpaceThinkers now have generic type parameters for subtypes of SpaceState and SpaceThinker that they interact with. On the other hand, Hitboxes and SpaceObjects have had their generic type parameters removed.
        • A ThinkerObject now inherits its SpaceThinker-like properties from a particular SpaceThinker that must be assigned to it. This allows ThinkerObjects to mimic any subtype of SpaceThinker.
        • Events and EventGroups have been added to generalize the relationship between the time-dependent actions of Thinkers and those of their SubThinkers. TimedEvent has been removed and its functionality given to Event.
        • The org.cell2d.basic and org.cell2d.space.basic packages have been added. They contain simpler but less flexible versions of certain classes for situations in which their full versatility would be excessive.
        • Direction is now in the package org.cell2d instead of org.cell2d.space, and its opposite(), clockwise(), and counterclockwise() methods have been added.
        • Getter methods that once returned copies of data structures such as Maps and Sets now return unmodifiable views of those data structures.
        • Many constructors that once required array parameters now also support varargs.
        • A CellGame no longer updates while its window is out of focus.
        • Area is now an interface instead of an abstract class.
        • PolygonHitboxes with no vertices are now unable to overlap other Hitboxes.
        • Some Exception messages have been tweaked.
        • Fixed a bug in which Sprites and SpriteSheets would not properly dispose of their resources when unloaded.
        • Various internal code tweaks and documentation improvements
      • 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

Links

Contributors

Alex Heyman

Alex Heyman

  • Programming
  • Documentation
  • Website design

Charlie Flocke

  • Logo design