Skip to content
halva6Public

About

a small PacMan-like game using JavaFX

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

42 Commits

Folders and files

Repository files navigation

Snackman

Snackman is a small JavaFX game inspired by Pacman.
This project mainly serves as a technical demonstration of a simple game loop, animation handling in JavaFX and Maven.

Overview

The game is built around a tile-based map.
A player entity moves through the map, collects food dots, and avoids enemy entities.
The game ends when all dots are collected or when the player collides with an enemy.

Installation

Run mvn clean javafx:jlink to create a distribution packed with a standalone jre.

Game Loop and Animation

The game loop is implemented using JavaFX’s AnimationTimer.

  • Each frame calculates the elapsed time (deltaTime).
  • A fixed time step is used (FIXED_DELTA_TIME) to update game logic at constant intervals.
  • The fixedUpdate() method handles movement logic for the player and enemies.
  • The updateGame() method is executed every frame and is responsible for:
    • Input handling
    • Sprite movement
    • Collision checks
    • Rendering

This separation ensures that game logic is not directly dependent on the frame rate.

Structure and Responsibilities

  • Map generation
    The map is generated once at startup and converted into static tile sprites.

  • Entities
    Player and enemies are represented by logic classes (position, direction, movement) and visual sprite classes used for rendering.

  • Rendering
    The canvas is cleared every frame and all tiles, entities, and UI elements (score, pause view) are rendered again.

  • Collision handling
    Collisions are checked between:

    • Player and food tiles (score increase, win condition)
    • Player and enemies (game over)

About

a small PacMan-like game using JavaFX

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages