Skip to main content
broken images fixed (click 'rendered output' to see the difference); for more info, see https://gist.github.com/Glorfindel83/9d954d34385d2ac2597bbe864466259f
Source Link

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby). This question is about how to deal with this issue specifically in Ruby, and more specifically in libGosu.

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.pnggood

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.pngbad

In the second image the bullets are clumping together when the spaceship is rotated.

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby). This question is about how to deal with this issue specifically in Ruby, and more specifically in libGosu.

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby). This question is about how to deal with this issue specifically in Ruby, and more specifically in libGosu.

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good

In the first image (above) the bullets are separated as intended.

bad

In the second image the bullets are clumping together when the spaceship is rotated.

explained why this question is distinct from other similar question
Source Link

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby). This question is about how to deal with this issue specifically in Ruby, and more specifically in libGosu.

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby).

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby). This question is about how to deal with this issue specifically in Ruby, and more specifically in libGosu.

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

Post Closed as "Duplicate" by bummzack, Anko, Seth Battin, Sean Middleditch, House
Tweeted twitter.com/#!/StackGameDev/status/374413062650208257
removed more irrelevant code
Source Link

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby).

In the player class I have tried several variations of the following:

def fire
  @shoot.play(rand(0.05..0.1))
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby).

In the player class I have tried several variations of the following:

def fire
  @shoot.play(rand(0.05..0.1))
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

I am trying to create a weapons upgrade for my Spaceship, using libGosu and Chingu (in Ruby).

In the player class I have tried several variations of the following:

def fire
  Bullet.create(:x => @x, :y => @y, :angle => @angle)
  Bullet.create(:x => @x + Gosu::offset_x(90, 25), :y => @y + Gosu::offset_y(@angle, 0), :angle => @angle)
end

It sort of works, but not exactly how it ideally should. For reference, this is what the Bullet class looks like:

class Bullet < Chingu::GameObject
  def initialize(options)
    super(options.merge(:image => Gosu::Image["assets/laser.png"]))
    @speed = 7
    self.velocity_x = Gosu::offset_x(@angle, @speed)
    self.velocity_y = Gosu::offset_y(@angle, @speed)
  end

  def update
    @y += self.velocity_y
    @x += self.velocity_x
  end
end

How should I construct "def fire" in order to get the extra bullets to align properly when the spaceship rotates?

good http://i44.tinypic.com/2rym68h.png

In the first image (above) the bullets are separated as intended.

bad http://i40.tinypic.com/23hkbc1.png

In the second image the bullets are clumping together when the spaceship is rotated.

removed superfluous code
Source Link
Loading
improved images
Source Link
Loading
minor format change
Source Link
Loading
tags go in tags, not title
Link
House
  • 73.5k
  • 17
  • 188
  • 276
Loading
added reference to Game Engines in description
Link
Loading
Source Link
Loading