回転させてみた

やっぱりアフターバーナーならぐるぐるまわらないと。

この単純なやりかただと、地面のオブジェクトが増えたときに厳しい。
例えばアフターバーナー2みたいに横一列ごとに処理するとか、そういう感じでマシにはなりそうだが。

require 'dxruby'

image = Image.new(32,32)
image.box(13, 16, 18, 26, [255, 200, 50, 50]) # 木
image.line(13, 16, 13, 26, [255, 0, 0, 0])
image.line(18, 16, 18, 26, [255, 0, 0, 0])
image.circleFill(16, 8, 8, [255, 0, 255, 0])
image.circle(16, 8, 8, [255, 0, 0, 0])

bg = Image.new(1000,480, [255, 0, 0, 255])

Window.bgcolor = [200,250,255]

x = 320
y = 1000
z = []
Obj = Struct.new(:x, :z)
font = Font.new(32)

angle = 0

Window.loop do

  z.push(Obj.new((rand(640)-320)*10, 20))
  z.push(Obj.new((rand(640)-320)*10, 20))

  angle -= Input.x

  Window.drawRot(-180,290, bg, angle, 500, -50, 0)
  z.delete_if do |i|

    drawx = i.x * Math.cos(angle/180.0*Math::PI) - 1000 * Math.sin(angle/180.0*Math::PI)
    drawy = 1000 * Math.cos(angle/180.0*Math::PI) + i.x * Math.sin(angle/180.0*Math::PI)

    Window.drawEx((drawx - 320) / i.z + 320, (drawy - 240) / i.z + 240, image, :scalex=>10.0 / i.z, :scaley=>10.0 / i.z, :z=>20 - i.z, :angle=>angle)
    i.z -= 1
    if i.z < 1 then
      true
    else
      false
    end
  end

  break if Input.keyPush?(K_ESCAPE)
  Window.drawFont(0, 448, Window.getLoad.to_i.to_s + " %", font)
end