我现在正在尝试用 Gosu 和 Ruby 创建一个游戏。我遇到了一个问题,即我的代码中没有显示背景图像。我没有收到任何错误,但是每当我启动应用程序时,我都会出现黑屏,我很困惑为什么,有人可以帮忙吗?
require 'gosu'
require_relative 'player'
require_relative 'enemy'
require_relative 'bullet'
require_relative 'eb_bullet'
require_relative 'explosion'
class SectorFive < Gosu::Window
WIDTH = 800
HEIGHT = 600
ENEMY_FREQUENCY = 0.03
ENEMY_BULLET_FREQUENCY = 0.009
def initialize
super(WIDTH, HEIGHT)
self.caption = "Sector Five"
@background_image = Gosu::Image.new('images/start_screen.png')
end
def draw
@background_image.draw(0,0,0)
end
end
window = SectorFive.new
window.show