Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Trying to "shoot" bullets with gosu
- - By Jarob22 (can't type) Date 2012-04-19 11:29
Hi,

I have made a small 2d game with Gosu which has scores, collecting squares, a sprite and sounds. I want to now make my sprite "shoot" bullets.

Code: https://gist.github.com/2419934

Basically, when I press spacebar, it makes the sound that I have programmed into the initializer for Bullet, but doesn't draw the bullet. I'm not sure what I'm doing wrong here.

Thanks,

/J
Parent - - By lol_o2 Date 2012-04-19 12:20
You can't make drawing in Window.update. Maybe it was possible with older versions, but drawing code needs to be in Window.draw

@bullets.each do |bullet|
      bullet.update
      bullet.draw
end


This can be placed as it is in def draw in GameWindow
Parent - - By Jarob22 (can't type) Date 2012-04-19 12:32
Ah, that gets the bullets drawn, but they aren't moving :(
Parent - - By lol_o2 Date 2012-04-19 12:46
def update
    accelerate_forwards
    move
end


This is how should Bullet.update look. They are only accelerating in your code
Parent - - By Jarob22 (can't type) Date 2012-04-19 12:56
Ahh, thanks. :D

Now they fire, but really weirdly, and I can't fire them as often as I'd like.
Parent - - By lol_o2 Date 2012-04-19 13:12
Now you have to figure it yourself.
But topic, that may help you: http://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=656
Parent - By Jarob22 (can't type) Date 2012-04-19 13:18
Aha! That worked great :D now I just need to implement bullets going different directions, which I will figure out myself :D

Thanks a lot lol_o2!
Up Topic Gosu / Gosu Exchange / Trying to "shoot" bullets with gosu

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill