Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Extending Gosu / Chingu - A game framework for Ruby / Gosu
- By ippa Date 2009-10-07 21:20
I've been working on a framework for Ruby/Gosu for a couple of months now.

After ~10 game prototypes in both Rubygame and Gosu and some small full games I noticed what I constantly repeated in my projects.
Then I decided to start build some reusable base code. Chingu is the result of that history + 4 different games being developed and common patterns abstracted out.

The core of Chingu:
- Pretty input-handling:   @player.input = { :left => :go_left, :right => :go_right, :space => :fire }   (main window and game states can also have input)
- Deployment safe asset handling: Image["player.png"]   Sound["woff.wav"].play  etc
- A stack based (push/pop), robust game state system
- Automatic tracking, drawing and updating of game objects if you use Enemy.create  (instead of Enemy is inherited from Chingu::GameObject)
- Base classes (BasicGameObject, GameObject) which will provide the most common functionality for 2D game objects
- Traits - simple but effective way of extending your game classes to provide physics, effects, timers and basic collision-detection etc
- Useful helper classes like: Animation, Parallax, Text and Rect

I know nobody will even look at a framework if it's not documented so I've taken some time to do just that:

Big readme:

I've bundled ~11 commented examples with Chingu since I myself love learning from examples. Examples show off game states, input-handling, the parallax-class, traits like collision_detect and velocity, particles and more.

There's 1 full game finished in Chingu so far: The Eternally Grey. See for more info.
It's a 48-compo game so it's not the best code ever :P. But it's decent and it depends on Chingu.

I got 4 more (very different) games in the works which I hope to be able to release during the coming months.
They're deliberately very different so I would force myself to constantly thinking in very abstract terms and not build any kind of game logic into Chingu.

During the development I've gotten feedback and input from the #gosu irc channel: Banisterfiend, shawn24, jlrn of course, jduff, apillet and others.
It's being developed in Ruby 1.9.1 so that's the preferred version. Both for Chingu-compatibility and, of course, speed. 1.8.7+ should work as well, 1.8.6 will have some problems.

gem install chingu
- By deps Date 2009-10-08 19:02
I decided to take this framework for a test drive. I'm trying to create a remake of Berzerk (It's the Finish-Something month over at the Retro Remakes forum), and wanted to try something new. :)
- By erisdiscord Date 2009-10-10 02:18

> I know nobody will even look at a framework if it's not documented …

You kidding, mang? You've described exactly the kind of framework I've tried to write. I'd look at the source code if I had to, because this sounds incredibly useful. I'll be trying it myself momentarily. Thanks in advance!
- By RunnerPack Date 2009-10-10 02:48
I got an OpenGL error (from Image#retrofy) when attempting to run example10.rb. I fixed it by changing:

require "opengl"


require "gl"

And adding:

include Gl

BTW, I'm (temporarily) using 1.8.6 p114 on WinXP and I have ruby-opengl 0.60.1 (the latest gem).

Also, example11.rb seems to be missing some graphics, and has ')'s instead of '}'s on lines 28-30.

Anyway, those little hiccups aside, this is looking really good. I definitely want to start using this for my Gosu projects!

Jolly good show, eh wot? ;)
- - By Spooner Date 2010-07-16 18:00 Edited 2010-07-16 18:04
One gotcha I found when using Chingu with TexPlay is that if you alter text at runtime then it seriously affects the FPS as you are actually creating an image each time that forces caching which is a very slow operation. It isn't obvious in Chingu that you are actually creating images since you are just doing @my_text.text = "Hello dave". There shouldn't be any reason to create images at runtime, so you can usually avoid the issue, but when I spoke to Banister about it, there was some suggestion of adding a switch to turn off caching when you didn't want to suffer the slowdown.
Parent - - By ippa Date 2010-08-02 18:23
Right, Text is indeed creating a Image. This will enable the text to act like a GameObject that can be scaled, rotated etc etc. I suggest checking out .. which might be what you need. Btw, did some changes to Text#height/width/size due to your report, more info on github.
Parent - By Spooner Date 2010-08-02 18:29
Thanks for that. In the end, I ended up writing the text directly with Gosu::Font. Sorry, should have come back and stated that here.
Up Topic Gosu / Extending Gosu / Chingu - A game framework for Ruby / Gosu

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill