Not logged inGosu Forums
Forum Gosu Homepage Help Search Register Login
Up Topic Gosu / Gosu Showcase / SpriteDodge - My first game with Ruby
- - By parananon Date 2011-08-02 04:52
So far, the game is mainly just a test project, but I figured some people may enjoy/get advice from it, or (hopefully) give me some advice. There's a mac wrapper in the downloads section of the github page, or you can download the source and run Main.rb. (Credits for art and sound are in the readme file.) Enjoy!

https://github.com/parananon/SpriteDodge
Parent - - By parananon Date 2011-08-02 20:48
I'm particularly looking for advice on improving collision detection, if possible :)
Parent - - By jlnr (dev) Date 2011-08-05 02:19
Yeah, that was the biggest problem with the game. :) I think Spooner already mentioned this on IRC: The first issue is that you call draw_rot with the wrong arguments in ball.rb, I think you should pass 0.5 to center_x and center_y. This would draw the ball with the center of the graphic over its @x/@y.
Then you should adjust the Player so that it also draws its @icon with its center over @x/@y.
If you change both, the collision detection would feel much better.
Parent - By parananon Date 2011-08-05 05:49
Thanks, I think I fixed it (it's better at least). I also added more gem types :)
Parent - By Jwosty Date 2011-08-05 15:13
Not bad, great job! This sort of reminds me of the Ruby4Kids tutorial... :P
One thing though: Sometimes when the gem is touching the player (to the right of the center), it doesn't detect it.
But great little game anyway!
Parent - - By arrow Date 2011-08-12 17:54
There's a glitch when you try to move past the right side of the level. It's source is the move_right function in the player.

def move_right
  if @x > 800
    @x = 800
  else
    @x = [@x + 10, 0].max
  end
end


It's because the player moves beyond the level on one frame and is moved back on the next, so the player flicker quickly between the two positions. To solve this you can simply check if the player has moved outside the level just after moving.

def move_right
  @x = [@x + 10, 0].max
  @x = 800 if @x > 800
end


I see how you use the array max to keep the player on the level, but I would just do this ^^

def move_left
  @x = @x - 10
  @x = 0 if @x < 0
end

def move_right
  @x = @x + 10
  @x = 800 if @x > 800
end


If you want a better hit test you could try checking the distance from the center of the head, instead of the players center. I don't know how much of a difference it would make though..
Parent - - By lol_o2 Date 2011-08-12 18:01
Couldn't it be just:

def move_right
  @x = [@x + 10,800].min
end


?
Parent - By arrow Date 2011-08-12 18:15
hmm :/ haven't seen or considered this method before. It works fine, and is a one-liner ^^
I like the way of doing it, however strikes me as a little cryptic :/ matters of taste I guess

def move_right
  @x = [@x + 10, @level.right_side].min
end

def move_left
  @x = [@x - 10, @level.left_side].max
end
Up Topic Gosu / Gosu Showcase / SpriteDodge - My first game with Ruby

Powered by mwForum 2.29.1 © 1999-2013 Markus Wichitill