This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
$dsl = [] | |
$if_stack = [] | |
def IF(cond=Proc.new) | |
$if_stack << [] | |
$if_stack.last << {} | |
$if_stack.last.last[:cond] = cond | |
end | |
def THEN(expr=Proc.new) | |
$if_stack.last.last[:expr] = expr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def event_handler(*names) | |
names.each do |name| | |
class_eval <<-EOS | |
def on_#{name}(*args) | |
event_handlers[:#{name}] and event_handlers[:#{name}].(*args) | |
end | |
EOS | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> stack, arg { stack.tap { stack.push(arg) } and yield.tap { stack.pop } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dxruby' | |
require_relative 'ui' | |
class UI::TextLabel < Sprite | |
attr_reader :text | |
def text=(text) @text = text.to_s end | |
def initialize(x=0, y=0, text='', *argv) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "dxruby" | |
Player = Struct.new(:x, :y, :vx, :vy, :image) | |
player = Player.new(32, 416, 0, 0, Image.load("image/player_image.png")) | |
enemy_image = Image.load("image/enemy_image.png") | |
enemy_image2 = Image.load("image/enemy_image2.png") | |
Enemy = Struct.new(:x, :y, :image) | |
enemies = [ | |
Enemy.new(576, 416, enemy_image), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "dxruby" | |
Player = Struct.new(:x, :y, :image) | |
player = Player.new(0, 0, Image.load("image/player_image.png")), | |
enemy_image = Image.load("image/enemy_image.png") | |
enemy_image2 = Image.load("image/enemy_image2.png") | |
Enemy = Struct.new(:x, :y, :image) | |
enemies = [ | |
Enemy.new(608, 448, enemy_image), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "dxruby" | |
player_x = 0 | |
player_y = 0 | |
player_image = Image.load("image/player_image.png") | |
enemy_image = Image.load("image/enemy_image.png") | |
enemy_image2 = Image.load("image/enemy_image2.png") | |
enemies = [ | |
{x: 608, y: 448, image: enemy_image}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "dxruby" | |
player_x = 0 | |
player_y = 0 | |
player_image = Image.load("image/player_image.png") | |
enemy_image = Image.load("image/enemy_image.png") | |
enemy_image2 = Image.load("image/enemy_image2.png") | |
enemies = [ | |
{x: 608, y: 448, image: enemy_image}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "dxruby" | |
player_x = 0 | |
player_y = 0 | |
player_image = Image.load("image/player_image.png") | |
enemies = [ | |
[608, 448], | |
[576, 448], | |
[542, 448] |