Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Can you tell if I'm going in the right way?
- By geo Date 2009-09-18 21:46
Sorry to be asking so many questions about Gosu. I hope this isn't bothering anyone ( if it is, tell me and I'll stop ).

I wrote a small app ( I'm trying to write a game ). I've uploaded the source and the sprites I'm using at http://www.mediafire.com/download.php?mzjnbjimztn . Here are my questions:

- in order to make the character not move that fast I made update check for a number of milliseconds before changing the image shown on the screen ( I don't know if this is the way it's supposed to be done). The movement now doesn't seem very smooth. Is there another way of achieving this ?
- when moving left, I want to use the same sprites as the ones from moving right so I'm using the @image.draw(x,y,0,-1) call. The thing is, this isn't drawing the image at the same spot, even though the coordinates seem to be the same ones as when drawing the image to the right. I don't know how I could make this right, any suggestions?

I commented the code to the best of my ability, so I think it should be pretty easy to understand ( if anyone should take the time to read it ) . It's about 100 lines long.

I'm curious about how I could go and fix those bugs, so I'll eagerly wait your reply.

Thanks!
- By deps Date 2009-09-18 22:01 Edited 2009-09-18 22:11
I tried it out really quickly and out of the top of my head:
- You could move the fighter with smaller steps than 1, like 0.1 for example. That will slow the movement down.
- Add a offset variable, and set it to the width of the sprite when you move left, and 0 when you move right. This value should then be added to the x position of the fighter when you render him.

EDIT:
I hacked around a little and found that draw_rot could be used instead:
    @img.draw_rot(@ix,@iy,0,0,0.5,0.5,@if)# if !@img.nil?
Now you don't need that extra offset variable.

EDIT AGAIN:
I moved most of the code inside the every(130) call out from it. The only thing left in it was the code that updates the frame to draw in the animation.
And then I changed step to 2 instead of 20 and it feels a lot smoother now.
- By geo Date 2009-09-18 22:16
You're right, it does move a lot smoother. I think I should do something about the static image, because it shows up a lot when the character moves.
Up Topic Gosu / Gosu Exchange / Can you tell if I'm going in the right way?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill