Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

GabTux/diamond-heist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diamond Heist

Diamond Heist is a 2D game in which two players try to steal a diamond and bring it to their base. The players are invisible by default (both to themselves and their opponents) but make sounds that can give them away.

About the environment

The game is written in Ruby using the Gosu library. Gosu is a multiplatform library that allows you to create 2D games. It uses OpenGL and SDL2 internally. Read more here: https://www.libgosu.org/.

The game was developed on Linux (Kubuntu), but has also been tested on Windows 10.

About the game

Diamond Heist is a 2D game in which two players try to steal a diamond and bring it to their base. Players are invisible by default (both to themselves and to their opponents). They only become visible when an event occurs:

  • a player fires a shot

  • a player hits an obstacle

  • the player is in his base or at the diamond

When any player moves, their footsteps are heard. There are two types of footsteps - on the grass and on the stairs. Also, the game has rich sound effects for other events (shot, impact, player spawning, etc).

The goal of the game is to steal the diamond and bring it to your base. If the player is shot, he is dead for a while and then reappears at his home location. If he is currently carrying the diamond, the diamond is returned to its original location.

More information about the game’s controls can be found in the About menu of the game itself.

Requirements

The game uses several libraries, all listed in the Gemfile file. They can be installed using the bundle install command. However, some gems require additional libraries installed on the system.

Before running bundle install you need to install SDL2 and ImageMagick.

SDL2

SDL2 is required for the Gosu library. It can be installed on Ubuntu using the command:

sudo apt-get install build-essential libsdl2-dev libgl1-mesa-dev libgmp-dev libfontconfig1-dev

ImageMagick

ImageMagick is required to install the rmagick gem. On Ubuntu it can be installed using the command:

sudo apt install build-essential imagemagick libmagickcore-dev libmagickwand-dev

Launch

Execute from src directory:

ruby main.rb

Implementation

This section describes some interesting parts of the implementation. More information can be found in the documentation itself in the doc directory.

Gosu

The typical approach is to inherit from Gosu::Window and implement your own Window, i.e. mainly the update, draw, needs_redraw, button_down methods, or other methods as needed and according to the documentation. These methods are then called repeatedly, this is handled by the Gosu library.

This is exactly the approach I have taken, the very topmost object is the GameWindow which contains the GameState object and the update, draw etc methods are called on this object. Subsequent changes to the scene are then just replacing the state variable.

Hierarchy of classes

I’ve tried to keep a reasonable structure according to the general rules for writing games: https://gameprogrammingpatterns.com/. This way, for example, I can elegantly have all game objects in one array and simply iterate over them. The most important skeleton of the hiearchy itself is shown in doc/diamond_heist_graph.pdf:

diamond heist graph

TexturePacker a Tiled

TexturePacker is a tool that allows you to combine multiple textures into a single png image and create a json file that contains information about each texture. I used this tool to create textures for individual game objects.

Tiled is a tool that allows you to create maps, and I used this tool to create a game map.

I used the gosu-texture-packer and gosu-tiled libraries to conveniently load the resulting files.

Credits

I downloaded most of the sound effects from freesound.org and further edited them using Audacity. I created most of the graphic elements with inspiration from the top-down-basic pack and edited them with GIMP.

The following book by Mr. Tomas Varaneckas was a very valuable resource for me in the actual implementation: https://leanpub.com/developing-games-with-ruby/read

Screenshots

main menu
base
shot
death
about
main menu2

Video

Youtube video: maxresdefault

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages