Я создаю игру с ruby и gosu и получаю сообщение об ошибке:
C: / Ruby26-x64 / destroy! /Bullet.rb: 14: в draw_rot': There is no rendering queue for this operation (RuntimeError)
from C:/Ruby26-x64/destroy!/bullet.rb:14:in
draw'из C: / Ruby26-x64 / destroy! /player.rb: 45: в fire'
from C:/Ruby26-x64/destroy!/destroy.rb:36:in
обновление' из C: /Ruby26-x64/lib/ruby/gems/2.6.0/gems/gosu-0.14.5-x64-mingw32 / lib / gosu / patches.rb: 72: в tick'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/gosu-0.14.5-x64-mingw32/lib/gosu/patches.rb:72:in
отметьте 'из C: / Ruby26-x64 / destroy! /destroy.rb: 40: в `' [Завершено за 0,517 с]
Я пытался изменить рисование в классе пули на draw_rot, но безрезультатно.
Мои классы
Уничтожить
require 'gosu'
require 'cmath'
require_relative 'player.rb'
require_relative 'enemy.rb'
require_relative 'bullet.rb'
class Destroy < Gosu::Window
def initialize
super(800, 600)
self.caption = 'Destroy!'
@player = Player.new(self)
@enemies = []
@enemies.push(Enemy.new(self))
end
def draw
@player.draw
@enemies.each do |enemy|
enemy.draw
end
end
def update
@player.righturn if button_down?(Gosu::KbRight)
@player.lefturn if button_down?(Gosu::KbLeft)
@player.startmove
@player.move if button_down?(Gosu::KbUp)
@freq = 0.0025
if rand < @freq
@enemies.push(Enemy.new(self))
end
@enemies.each do |enemy|
enemy.move
enemy.update(@player.x, @player.y)
end
if @freq < 0.5
@freq += 0.0002
end
@player.fire(self)
end
end
window = Destroy.new
window.show
Пуля
class Bullet
attr_accessor :x
attr_accessor :y
attr_accessor :fired
def initialize(window)
@image = Gosu::Image.new('C:\Ruby26-x64\destroy!\images\bullet.png')
@fired = 0
@x = 0
@y = 0
end
def draw(x, y)
@x = x
@y = y
@image.draw_rot(x, y, 1, 0)
@fired = 1
end
def update(angle)
@xspeed = Gosu.offset_x(angle, 2)
@yspeed = Gosu.offset_y(angle, 2)
if (@x > 800 || @x < 0 || @y > 600 || @y < 0)
@fired = 0
end
end
end
Игрок
require_relative 'bullet.rb'
require 'gosu'
class Player
attr_accessor :x
attr_accessor :y
def initialize(window)
@x = 200
@y = 200
@xspeed = 0
@yspeed = 0
@angle = 0
@image = Gosu::Image.new('C:/Ruby26-x64/destroy!/images/man.png')
end
def draw
@image.draw_rot(@x, @y, 1, @angle)
end
def righturn
@angle += 3
end
def lefturn
@angle -= 3
end
def startmove
@xspeed = Gosu.offset_x(@angle, 2)
@yspeed = Gosu.offset_y(@angle, 2)
end
def move
if @x > 767
@xpeed = 0
@x = 767
end
if @x < 33
@xpeed = 0
@x = 33
end
if @y > 567
@yspeed = 0
@y = 567
end
@x += @xspeed
@y += @yspeed
end
def fire(window)
@bullet = Bullet.new(window)
@bullet.draw(@x, @y)
while @bullet.fired = 1
@bullet.update(@angle)
end
end
end
Враг
require 'cmath'
class Enemy
def initialize(window)
@flipped = 0
@x = rand(800 - 2 * 30) + 30
@y = rand(600 - 2 * 30) + 30
@firefreq = 1 / 60
@health = 5
@numkilled = 0
@dead = 0
@xspeed = 0
@yspeed = 0
@angle = 0
@image = Gosu::Image.new('C:/Ruby26-x64/destroy!/images/enemy.png')
@imageflipped = Gosu::Image.new('C:/Ruby26-x64/destroy!/images/enemyflip.png')
end
def gethit
@health -= 1
end
def die
@numkilled += 1
@dead = 1
end
def move
if rand < 0.1
@xspeed = rand(-3..3)
@yspeed = rand(-3..3)
end
if @x + @xspeed > 800
@x = 800
end
if @x + @xspeed < 0
@x = 0
end
if @y + @yspeed > 600
@y = 600
end
if @y + @yspeed < 0
@y = 0
end
if !(@y + @yspeed < 0 && @y + @yspeed > 600 && @x + @xspeed < 0 && @x + @xspeed > 800)
@y += @yspeed
@x += @xspeed
end
end
def draw
if @dead == 0
if @flipped == 1
@imageflipped.draw_rot(@x, @y, 1, @angle)
end
if @flipped == 0
@image.draw_rot(@x, @y, 1, @angle)
end
end
end
def update(xdist, ydist)
if @x < xdist
(@angle = CMath.atan((ydist - @y) / (xdist - @x)) * 180 / 3.14159265358979323846264338327950289)
@flipped = 0
end
if @x > xdist
(@angle = CMath.atan(-(ydist - @y) / (@x - xdist)) * 180 / 3.14159265358979323846264338327950289)
@flipped = 1
end
end
end
Я совсем не понимаю.