#!ruby # -*- mode: ruby; coding: utf-8 -*- # Last updated: <2018/02/24 21:17:40 +0900> # # DXRuby、DXOpal で、z値指定が正しく動作するのか確認 IS_DXRUBY = true # IS_DXRUBY = false if IS_DXRUBY require 'dxruby' else require 'dxopal' include DXOpal end def make_new_image img = Image.new(64, 64, C_GREEN) img.width.times do |x| img[x, 0] = C_BLACK img[x, img.height - 1] = C_BLACK end img.height.times do |y| img[0, y] = C_BLACK img[img.width - 1, y] = C_BLACK end return img end def game_main img = make_new_image() Window.loop do if IS_DXRUBY break if Input.key_push?(K_ESCAPE) end zc = 256 z = zc xs = Window.width - img.width ys = Window.height - img.height x, y = xs, ys zc.times do |i| Window.draw(x, y, img, z) x -= 10 y -= 5 if x < 0 x = xs ys -= 24 y = ys end z -= 1 end Window.draw_font(2, 2, "#{Window.real_fps} FPS", Font.default, :z => zc + 1) end end if IS_DXRUBY game_main else Window.load_resources do game_main end end