Skip to content

kim-minh/Jewel-Match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jewel Match

Simple Bejeweled/Match-3 game written in C++ and SDL 2.0.

This was built and tested on an M1 Mac with macOS Monterey, but should work on other platforms as well.

Jewel Match

Build Instruction

These instructions are for compilation with Visual Studio Code on macOS. This assumes you already have Homebrew installed.

You can look for other compile instructions on Lazy Foo' Productions.

Prerequisites

  • First, install SDL and extensions:

      brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer
    
  • Then clone the repo:

      git clone https://github.com/kim-minh/Jewel-Match.git
    

Configure Visual Studio Code:

Note: On Intel Macs, replace /opt/hombrew/ with /usr/local/homebrew/.

  • In tasks.jsons, add these to "args":

    "${workspaceFolder}/src/*.cpp",
    "-I/opt/homebrew/include",
    "-I${workspaceFolder}/include",
    "-lSDL2", "-lSDL2main", "-lSDL2_image", "-lSDL2_ttf", "-lSDL2_mixer",
    "-L/opt/homebrew/lib",
    
  • In c_cpp_properties.json, add these to "includePath":

    "/opt/homebrew/include",
    "/opt/homebrew/lib"
    

    Or press Command + SHIFT + P , select C/C++ Edit configurations (GUI) and add to Include path.

Finally, Run Build Task in the directory of the cloned repo.

Design Idea

Game state:

1. Initialize game's resources (texture, audio, ...)

  • If unable to initialize, quit program and output error to Terminal.
  • Move to state 2.

2. Start screen

  • Board is initialized with random tiles that does not have any existing matches. Board is not drawn yet.
  • Check if there are any possible moves. There is a chance that the board will be generated without any.
  • If no moves are available, recreate the board.

3. Ready

  • Board is ready to be played (key press)
  • Start timer (default is 120 seconds)

4. Idle detection

  • Check if player has matched any tiles.
  • Show hint after 7 seconds of idling.

5. Play

  • Select first tile, select second tile.
  • Swap selected tiles.
  • If there is at least one match, destroy those that matches, else swap back.

6. Drop new tiles from above

  • Drops a single row of new tiles
  • Check the board for matches.
  • If there are matching tiles, destroy those and repeat state 6.

7. Board is now stable

  • Check if there is time left. If not, move to state 8.
  • Check if exist moves to match tiles. If not, randomize the board.
  • Go back to state 4.

8. Game over screen

  • Show game over and final score.
  • Go back to state 3.

Copyrights

Most of this project's assets was taken from Freegemas (GNU GPL v2)

Background music Easy Lemon by Kevin MacLeod, licensed under Creative Commons: By Attribution 3.0

Sound Effects Game Start and Game Over are from Freesound, licensed under Creative Commons: By Attribution 3.0

Font Digital-7 by Style-7 (Free for personal use)

The rest of the project is licensed under GPLv3 (see LICENSE)