Code Monkey home page Code Monkey logo

starfighter-gosu-tutorial's Introduction

This is another ruby tutorial for the awesome Gosu game library. (http://www.libgosu.org)

This tutorial builds on the Ruby Tutorial example that is included in the game library. As a project to help teach my teenage son Ruby programming, we dissected the original Gosu Ruby Tutorial and put it back to together in steps to learn the basics of game programming and to make a game of our own. This tutorial borrows heavily from the media assets of the Gosu examples.

Running
=======

First, you need to install the gosu gem:
$ gem install gosu

Run the Main.rb file to see the final game:
$ ruby Main.rb


Background
==========

The original Ruby Tutorial featured Asteroids-style navigation where left and right arrow keys rotate the ship, and the up and down keys control thrust and brake. The objective of the tutorial was to fly around the screen collecting stars.

This tutorial features "Galaga-style" fixed-angle navigation, where left and right move the ship along the x-axis and up and down move the ship along the y-axis. 

More importantly we added weapons! The weapons include single-shot (Space Key) and double-shot (Option/Alt Key) lasers, a "super shot" cannon (Control Key) that fires slowly but destroys anything in its path, and finally a nuke (N Key) that clears all obstacles from the screen when detonated. The nuke is only available if the ship's power level is full.

While in the original tutorial flying over a star would "collect" the star, in this tutorial hitting a star with your ship destroys the ship with an appropriately gratuitous explosion. To protect your ship you have a shield (Shift Key) that can be activated provided the ship's energy tank is not empty.

Pressing 'P' will pause the game and display the various controls. There are cheat codes available on the pause screen, but you will have to look through the source code to discover what those are.

This tutorial is broken into 6 steps:
  
  01_basic_window.rb -- demonstrates Gosu::Window and its update/draw loop
  02_graphics.rb -- demonstrates loading images and drawing to the window
  03_basic_control.rb -- demonstrates input with a Ship that can fly around the screen
  04_sounds_and_weaponry.rb -- adds weapons and sounds to 03_basic_control
  05_collisions.rb -- add Stars as obstacles with simple collision detection
  Main.rb -- complete game with user interface, life counting, pause, etc. 
      Classes are organized into separate files in lib directory

starfighter-gosu-tutorial's People

Contributors

masonhale avatar

Stargazers

Daniel Hedrick avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.