Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Forum
Search
Topic Games in the browser with Ruby By nicklink483 Date 2014-12-18 08:47
Thank you for your encouraging words :)  I won't let you down, and I can't wait to see what cool games get made!
Topic Games in the browser with Ruby By nicklink483 Date 2014-12-18 06:12
Hey everyone!  I know this isn't strictly Gosu, but jlnr told me to go ahead and post this here.

I'm working on a gem called Dare which uses Opal to turn your Ruby code into Javascript.

I modeled a lot of my API after Gosu, so it won't be a big leap to a) convert your Gosu game into a Dare game, or b) learn Dare if you already know some Gosu!

Here's the repo: https://github.com/nicklink483/dare
Here's a tutorial: https://github.com/nicklink483/dare/wiki/Ruby-Tutorial

I hope I can see some cool games come out of it!
Topic Turning off interpolation? By nicklink483 Date 2014-01-06 23:00
I can't remember the link to the forum post, but here's how you do that:

First, make sure you have the ruby-opengl gem.
Then, require 'opengl' in your game file right under require 'gosu'
Then, for each image object you instantiate, add this code right after:

    @image = Gosu::Image.new("cool_retro_scaled_image.bmp", false)

    glBindTexture(GL_TEXTURE_2D, self.gl_tex_info.tex_name)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

I extracted this into a method by opening up the Gosu::Image class in my main game file

class Gosu:Image

  def retro!
   
    glBindTexture(GL_TEXTURE_2D, self.gl_tex_info.tex_name)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
   
    self
 
  end

end

so now when I have an image, I can just do this:

    @image = Gosu::Image.new("cool_retro_scaled_image.bmp", false).retro!

Try it out!  Whenever you @image.draw_rot and you have the scale to something bigger than 1, it will do nearest-neighbor approximation scaling (which is what you're looking for).

Quick edit: here's that other forum post on it: http://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=227
Topic Evolution Simulation (first project) By nicklink483 Date 2014-01-05 07:29
Hey all!  I'm new to Gosu, so please feel free to offer any constructive criticism to anything I've done, but I hope you'll check out and like my little program:

Github source: https://github.com/nicklink483/combat
Windows distribution via Ocra: https://drive.google.com/file/d/0BxnPriYofgPDLXJsOEE5dzQzU2s/edit?usp=sharing

It's a evolution sim that has little teensy tanks that run around and kill each other and have kids whose attributes are slight mutations of their parents.

When a tank has a "child" the child pops up randomly on the screen somewhere.

I haven't put the controls in the game yet, so here they are:

Return (menu) - select menu option
Down (menu) - change menu selection
Up (menu) - change menu seleciton
R - Reset simulation
P - Pause simulation
E - Output data of simulation to console including info on oldest tank, youngest tank, and tank with most kills
Esc - Return to menu
Space - Populate sim with 5 new random tanks
+ (numpad) - (experimental) make tanks larger (up to 5x)
- (numpad) - (experimental) make tanks smaller (down to 1x)

Basically a tank is a set of instructions (turn right, turn left, move forward, fire) and it passes on those instructions to it's children.  A 'child' is born randomly and put somewhere on the screen but inherits behaviors with modification and color.  So if you see a bunch of green tanks on the screen, those tanks have more well-suited "genes" to survival.

I was messing around with nearest-neighbor bitmap scaling, so you can make all tanks bigger or smaller with the plus and minus keys on your numpad.  This has no effect on existing tanks, just new ones spawned after you've pressed + or -.

If you watch for a while you'll begin to notice certain behaviors get selected against, like moving too much.  I didn't impose any kind of equilibrium rate of existing tanks or a death rate, those are emergent properties.

Thoughts? Comments? Bugs? Features?  Let me know!

- Nick
Attachment: combat.png - combat tank evolution simulator (10k)
Attachment: combat_nearest.png - Showing of Nearest-Neighbor scaling and console output of relevant tank and simulation data (98k)

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill