A Java-based recreation of the classic game Lemmings, focusing on implementing core programming concepts and providing a user-friendly interface for level creation and gameplay.
- Usage: Construction and editing of levels through reading and writing files.
- Implementation: Levels are constructed by reading from files, and users can edit levels, which triggers file writing. This allows for the dynamic setup of the game state based on text file content.
- Usage: Management of background images through a
BufferedImage
, representing the image as a 2D array for efficient color and position management. - Implementation: Utilizes
getRGB()
for reading andsetRGB()
for editing pixels, aiding in collision detection and environment manipulation without redundancy.
- Usage: Dynamic tracking of lemmings using an
ArrayList<BaseLemmings>
. - Implementation: Lemmings are added and removed in real-time. Iterators facilitate safe removal of entities, ensuring encapsulation and order maintenance.
- Usage: Diverse lemming behavior and abilities through a structured hierarchy.
- Implementation: An interface
Lemming
and abstract classBaseLemming
lay the groundwork for specialized lemmings (WalkerLemming
,BomberLemming
,BlockerLemming
), showcasing polymorphism and dynamic dispatch.
-
Lemming: An interface defining generic lemming behavior.
BaseLemming
: Common functionality for all lemmings.WalkerLemming
: Default movement and falling.BlockerLemming
: Blocking capabilities.BomberLemming
: Explosion and termination.
-
Level: Manages level state, including load/save functionality and movement checks.
-
AnimationCycle: Manages sequences of sprites.
-
CsvReader: Facilitates level data reading.
-
DrawContext: Centralizes drawing state.
-
GameCourt: Manages game state, including lemming interactions and UI elements.
-
RunLemmings: Main game UI for level selection.
-
LevelEditor: UI for level property editing.
-
Direction & LemmingType: ENUMs for movement and lemming categorization.
- Movement Detection: Initial pixel-by-pixel checks were replaced by simpler, more reliable methods.
- Color Handling: Discovery and adaptation to ARGB format for accurate color representation.
- Explosion Visualization: Adjustments to alpha channel settings for visible craters.
- Animation Padding: Custom padding to correct sprite spacing and animation alignment.
- Functionality Separation: Good, with the potential for improvement in
BlockerLemming
's external list access. - Encapsulation: Mostly adhered to, with minor exceptions.
- Refactoring Opportunities:
WalkerLemming.canMove()
for unified falling behavior.
- Sprite Sheets: Lemmings Forums
- Tutorials: