Guide to Developing 2D Grid-Based Games

Nov 17, 2024

CS-107 : Game Engine Elements

Instructors

  • J. Berdat, B. Chtelain, Q. Juppet, J. Sam
  • Version 1.0.0

Overview

  • The tutorial provides an introduction to a basic game engine for creating 2D grid-based games.
  • The examples include adaptations of games like Pokémon Emerald and Super Pacman.
  • The toolkit helps in understanding object-oriented programming by working with existing code.

1. Introduction

  • The document outlines the use of a simple toolkit for implementing a mini-project in the course.
  • The toolkit helps in creating 2D games and understanding game engine architecture.

2. Overview of the Toolkit's Architecture

  • The toolkit is divided into several packages: io, math, window, engine, areagame, and signal.
  • Packages:
    • io: Handles file-based I/O, e.g., images.
    • math: Offers mathematical models like vectors and transformations.
    • window: Models graphical interfaces with elements like windows and canvases.
    • engine: Contains abstract game engine elements.
    • areagame: Builds on engine for grid-based games.
    • signal: Includes signal-related components.

3. Setting Up

  • Instructions for setting up the tutorial in IntelliJ or Eclipse.
  • Important to set IDE to UTF-8 to avoid rendering issues.
  • game-engine and tutos are the main folders; exercises are done in subpackages.

4. Tutorial I: Basics of a Grid Game

4.1 Playable

  • Abstract concept of a playable element in the engine.
  • Key methods: update, begin, end.

4.2 Simulation Loop

  • Launching a game involves creating a game instance, file system, and graphical context.
  • The game and window update at a rate determined by the refresh rate.

4.3 Grid Games

  • Advantages: Simplified management of interactions and collisions.
  • Key classes: AreaGame, Area, AreaBehavior.

4.4 Play Areas: Class Area

  • Models a playable game area on a grid.
  • Methods: begin, update, draw, registerActor, unregisterActor, end.

4.5 Games with Areas: Class AreaGame

  • Models games with multiple areas.
  • Important methods: addArea, setCurrentArea.

4.6 Generic Actors

  • Toolkit allows programming games with diverse actors.
  • Actor concept modeled by engine.actor.Actor.

4.7 Exercise 1: First Game with Areas

  • Code a basic game using the toolkit elements.
  • Create a SimpleGhost actor and define basic methods.

5. Tutorial II: Interfaces and Grid-Specific Actors

5.1 Interfaces

  • Explains the importance of interfaces in encapsulation and abstraction.

5.2 Grid and Cells

  • AreaBehavior models a grid with an array of Cell objects.
  • Visual behavior defined by a behavior map image.

5.3 Actor for Wallpaper

  • Backgrounds are coded as actors, similar to SimpleGhost.

5.4 Exercise 2: First Grid Game

  • Create a variant with specific grids and cells.
  • Implement Tuto2Behavior with Tuto2CellType enumeration.

6. Tutorial III: Interactions and Nested Classes

6.1 Refactoring with Nested Classes

  • Improves design by enhancing encapsulation of Cell class.

6.2 Tutorial Solution

  • Provides a complete solution for the tutorial exercises.

6.3 Interactions Between Actors

  • Manages interactions using Interactor and Interactable interfaces.
  • Handles interactions at the grid level.

6.4 Generic Interactions

  • Uses a visitor design pattern for interaction management.

6.5 Class AreaGraph

  • Associates a connected graph with a game grid for actor movement.

6.6 Classes RPGSprite and Animation

  • Offers advanced graphical representations of game objects.

6.7 Signals

  • Models signals as entities with intensity, influencing game decisions.

7. Appendices

7.1 Positionable Objects

  • Describes the positioning of graphical objects in the game.

7.2 Useful Data Structures

  • Overview of data structures like associative tables and sets.

7.3 Graphic Resources and Level Editor

  • Provides resources and a level editor for creating game assets.

This tutorial serves as an extensive guide to developing 2D grid-based games using a provided toolkit, fostering understanding of game engine architecture and programming concepts.