Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Showcase / SongBugs
- - By Jwosty Date 2011-07-08 16:48 Edited 2011-10-28 23:54
Another one of my project; SongBugs. Like WhirlyGigs, I made it a few moths ago and it was one of my first Ruby/Gosu projects. It is newer than WhirlyGigs.

SongBugs is a very simple sandbox game. In it, you place colorful tiles (each representing a specific note) on the board. There are also bugs that you put on the board as well, and these bugs will play the tile adjacent to it (can be in front or to the side, not behind) when you start the song.

Controls:
• Press space to stop or play the song
• Tap one of the arrow keys while the mouse is over a bug to change its direction
• Right click on a tile or bug to delete it. Works on stacks as well

Work in progress:
• Attached as SongBugs-1.zip is an added feature to save your song in a file by pressing the S key and push the L key to load it. Currently the saving and loading parts work, but for some reason the song plays too fast after loading, but this can be fixed manually by deleting the bug the creating a new one. I am trying to fix this.

Possible future features:
• A title screen that will almost certainly be implemented (after I finish song saving/loading)

Oh also, instead of "s" to save and "l" to load, there will be a dialog box so you can specify the save name, and to make it nicer. This will happen... eventually.

Have fun with this!
Attachment: SongBugs.tar.gz.zip - Mac App (9759k)
Attachment: SongBugs.zip - Source (420k)
Attachment: SongBugs-1.zip - The first (sort of) working version of song saving and loading. (421k)
Parent - - By jsb Date 2011-07-09 17:15
This is pretty sweet. It would be cool if the movements of multiple bugs were synchronized so they would move on the same beat. Also how about a way to randomize the bugs' decisions to take a left/right turn in some cases so you could create random path variations?
Parent - - By Jwosty Date 2011-07-09 20:45
Thanks, I'm glad you like it!

I'm not sure what you mean by that; I think it already does what you are talking about... Care to elaborate a bit more, please?
Hmmm... That's not a bad idea... Although, it's kinda nice to have it constant so you get the same results between users. Thanks for the suggestion though! :)
Parent - - By jsb Date 2011-07-11 09:31

>I'm not sure what you mean by that; I think it already does what you are talking about... Care to elaborate a bit more, please?


Just found out it only happens when you place bugs on the field while the music is playing. Once you stop and restart, they are synchronized again.
Parent - By Jwosty Date 2011-07-11 15:41
Oh. Hey wait... I just realized that you weren't supposed to do that in the first place! I'll fix that
Parent - By Jwosty Date 2011-07-11 17:16 Edited 2012-07-28 20:32
Funny. I keep thinking you're jlnr... :P
Parent - - By Spooner Date 2011-08-10 16:40 Edited 2011-08-10 17:07
I think you could manage it with deterministic rules rather than randomness (first bug left, second right, third left, etc).

What might be interesting is if you could have bugs altering the switching, such that playing such-a-note would switch all other notes when bugs stepped on them. This might give you non-predictable, though deterministic, behaviours, such as found in the Game of Life. Not sure if that switching is a good example, but I think expanding along that sort of path might be the best way to explore.

EDIT: Incidentally, your main file requires a
$LOAD_PATH.unshift File.dirname(__FILE__)
at the start, so that it is 1.9.2 compatible (also required for Whirlygigs).
Parent - By Jwosty Date 2011-09-03 21:28
Ah, okay. I'll add that along with one other thing. Lets see if you people can figure out what it is ;)
Parent - - By RunnerPack Date 2011-07-10 06:14
Was this your inspiration? If not, maybe you can use it as such for future features...

http://www.gamesetwatch.com/2010/10/sound_fantasy_gunpei_yokois_un.php
Parent - By Jwosty Date 2011-07-11 15:54 Edited 2011-08-05 17:52
Actually, I think this is! A friend described a game called Simtunes a while ago, so I made my own Scratch version that can be found here.
Well thanks for telling me about this! I think I've actually played that before, anyway... xP
Parent - By Jwosty Date 2011-07-11 17:15
Updated.
Parent - - By jlnr (dev) Date 2011-08-24 12:41
Huh, that took me a while to figure out because I hadn't read carefully. But now I am of course hypnotized as I shouldbe. Would be nice if the squares were actual items (Mario Paint, yay!), and if it the bugs were faster :)
Parent - By Jwosty Date 2011-09-03 21:27
Actual items? What do you mean by that?
Parent - - By Jwosty Date 2011-10-15 23:45
Okay, I've been working on an update in which you will be able to save your songs. To do this, I'm trying out Ruby object serialization then writing the resulting string to a file. But one problem: I define a Note class that keeps track of tile colors using instances of Gosu::Color stored in an array, @colors. But when I want to serialize one of these Notes, it doesn't work because Gosu::Color isn't written in Ruby and therefore can't be serialized in the manner described before. Any ideas on how to make this work?

Exact error message trying to serialize Gosu::Color produces:

./save.rb:16:in dump': no marshal_dump is defined for class Gosu::Color (TypeError)
  from ./save.rb:16:in
to_file'
  from SongBugs.rb:68:in save_world'
  from SongBugs.rb:57:in
update'
  from SongBugs.rb:13:in `open'
  from SongBugs.rb:326
Parent - - By Spooner Date 2011-10-16 03:10
You need to define a way for marshal to dump and load the class from a string:

class Gosu::Color
  def _dump(depth); [red,green,blue,alpha].join(";"); end
  def self._load(data); Color.rgba(*data.split(";").map(&:to_i)); end
end

color = Gosu::Color.rgba(1, 2, 3, 4) #=> (ARGB: 4/1/2/3)
Marshal.dump(color) #=> "\x04\bIu:\x10Gosu::Color\f1;2;3;4\x06:\x06EF"
Marshal.load(Marshal.dump(color)) # => (ARGB: 4/1/2/3)
Parent - By Jwosty Date 2011-10-16 04:05
Ah, thanks! I didn't know you could do that... :P :D
Parent - By Jwosty Date 2011-10-22 22:00
I think that Marshal might be parsing my stuff incorrectly. Is this easily possible, and if so, why might it be? The string I am trying to load consists of a Map_Tile object with the instance var @tiles being an array stuffed with instances of Tile. All evidence in the file itself says that Marshal is dump everything correctly, but when I load it, I get an array of numbers that are the y positions of the tiles I originally serialized. Here is the contents of the file (as printed from the irb):

\004\bo:\rMap_File\006:\v@tiles[\006[\022u:\tTile\024A4;true;234;875u;\a\025As4;true;290;875u;\a\024B4;true;346;875u;\a\024C4;true;402;875u;\a\025Cs4;true;458;875u;\a\024D4;true;514;875u;\a\025Ds4;true;570;875u;\a\024E4;true;626;875u;\a\024F4;true;682;875u;\a\025Fs4;true;738;875u;\a\024G4;true;794;875u;\a\025Gs4;true;850;875u;\a\026rest;true;122;875

And a little easier to read (as seen from TextWrangler):

o:
Map_File:@tiles[[u:  TileA4;true;234;875u;As4;true;290;875u;B4;true;346;875u;C4;true;402;875u;Cs4;true;458;875u;D4;true;514;875u;Ds4;true;570;875u;E4;true;626;875u;F4;true;682;875u;Fs4;true;738;875u;G4;true;794;875u;Gs4;true;850;875u;rest;true;122;875
Parent - By Jwosty Date 2011-10-25 00:03
Eh, nevermind. I think I'll just write my own format; it'll be easier anyway... :P
Up Topic Gosu / Gosu Showcase / SongBugs

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill