Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Showcase / The Lost Battle - arcade game with PS3 controller support
- - By dreasgrech Date 2010-08-06 12:35
This is a arcade-style game I built to learn ruby in conjunction with Gosu and Chipmunk.  I had very limited time to build this game so it's features are quite limited.

Features
* Arcade-style shooter
* Multiplayer, 2-4 players
* PS3 joystick controller support
* Powerups (Triple Shot, Double Damage, Ship Helper and Health Packs)

For the moment, it only works on linux due to how the joystick support is implemented.  I also haven't packaged the game so you need to download (or checkout) the source and run it manually with the ruby interpreter.  The entry point of the game is main.rb

Prerequisites
* Ruby 1.9
* Gosu
* Chipmunk
* Joystick-Ruby
* RMagick

Source
The source of the game can be found at it's google code page here: http://code.google.com/p/the-lost-battle/

You can checkout using Mercurial with: hg clone https://the-lost-battle.googlecode.com/hg/ the-lost-battle

Running the game
After you click start game on the main screen, you will see the player selection, similar to the second screenshot above. If you do not have any joysticks connected, you will only be shown 1 player slot and the game will be unable to start since it requires 1 < players <= 4. Therefore, with a single joystick connected, you will be able to play a 2 player game...one player with the keyboard+mouse and the other player with the controller.

Make sure that the joysticks are connected before you go into the player selection screen because the amount of player slots that the screen will display depends on the number of connected controllers.

More information can be found at my blog post: http://blog.dreasgrech.com/2010/08/lost-battle-ruby-multiplayer-game-with.html and it's Google Code page
Parent - - By banister Date 2010-08-06 16:56
what are you using rmagick for?
Parent - - By dreasgrech Date 2010-08-06 17:05
For the Health bars.

This is the gist of the code to draw and update them:

@gc = Magick::Draw.new
@gc.fill_opacity(0)
@gc.stroke(@border)
@gc.stroke_width(1)

@gc.rectangle(0,0, @width, @height)

@gc.fill_opacity(1)
@gc.fill(@foreground)
@gc.stroke(@foreground)
@gc.stroke_width(1)
@gc.rectangle(1,1, (@fixed_width == nil ? bar_width - 1 : @fixed_width), @height - 1)

if @text.length > 0 then
        @gc.fill('black')
        @gc.stroke('black')
        @gc.text(25, 15, @text)
end
background = Magick::Image.new(@width + 1, @height + 1)
@gc.draw background
@bar = Gosu::Image.new(@window, background, true)

The full class is here http://code.google.com/p/the-lost-battle/source/browse/healthbar.rb
Parent - By banister Date 2010-08-06 23:03
you could achieve something like that with TexPlay :). The problem with rmagick is it's quite difficult to install and so a lot of people avoid it...
Parent - By jlnr (dev) Date 2010-08-06 23:40
As far as I can see you could just use Gosu::Image::from_text to render the name once, and then juse use a white and a red Gosu::Image#draw_quad call to draw the health bar. It would even be faster because you wouldn't create new images all the time :) That way you need to rely on neither RMagick nor TexPlay. (Not that relying on TexPlay is a bad thing, it will be included with the Mac deployment .app template starting in 0.7.23.)
Parent - By dreasgrech Date 2010-08-07 04:26
Thanks for the suggestions.

At some point in time, I'll try to rewrite the health bars without any dependencies.
Parent - - By jlnr (dev) Date 2010-08-06 23:43
Looks nice even though I obviously cannot play it. I still have multi-gamepad support scheduled for Gosu 0.8, but I fear it will only happen after I work on the Graphics part first. :(
Parent - - By dreasgrech Date 2010-08-07 04:27
The reason I used Josystick-Ruby instead of instead of Gosu's GamePad support is because I couldn't get any readings for my controller with Gosu. 

I only tried it on a Linux though, so I can't speak for Windows.
Parent - By jlnr (dev) Date 2010-08-07 04:36
Yeah—joystick support is stubbed out on Linux. I have two libraries on my To Do list that might help with implementing it, but I'll have to crunch on other platforms for this month first. :(
- - By ippa Date 2010-08-19 02:59
This looks very cool, sweet graphics ... too bad I don't have anyone easy available to play with ...
Parent - By dreasgrech Date 2010-08-19 06:01
Ah yes, due to the very limited time I had in working on this game, I didn't have the chance to build some AI

So for the moment, it requires 2-4 players (2 minimum)

Cheers for the compliment though! :-)
Up Topic Gosu / Gosu Showcase / The Lost Battle - arcade game with PS3 controller support

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill