require "dxruby"
require 'dxrubyex'
require "Kconv"
require "ostruct"
require "pp"
#
$__DEBUG_MODE__ = :true
dir = "./"
dir = "__test/" if $__DEBUG_MODE__ != :true
# --------- head Lib --------
require dir + "uhaaokww"
require dir + "Rururu"
require dir + "Fileee"
require dir + "Testtt"
# ------ head Src ------
require dir + "consttt"
require dir + "raaa_h"
# ----------- lib --------
#------------ main -----------
module Node_template
# node template----------------------------
def node_task_template hs
# sym = hs[:sym]yu.uniq_sym
sym = hs[:sym]
Testtask( sym ) do |o|
o.d = hs[:d] || Image.new(111,11,[100,100,200])
o.x = hs[:x] || 0
o.y = hs[:y] || 0
o.Testcode do
yield o
end # code //
end # task //
end # def
# ----------- game node main -------------
# ----------- game node module -------------
module Collision_m
attr_accessor :collision
def hit o
p :hit
end
def init
self.collision ||= CollisionBox.new(self, 0, 0, self.d.width, self.d.height )
end
end
# ----------- game node function -------------
def node_gameobj_template hs
sym = hs[:sym]
Testtask( sym ) do |o|
o.d = hs[:d] || Image.new(111,11,[100,100,200])
o.x = hs[:x] || 0
o.y = hs[:y] || 0
o.extend Collision_m
o.init
o.Testcode do
yield o
end # code //
end # task //
end # def
def node_field_template hs
sym = hs[:sym]
delay = hs[:delay] || 1
Testtask( sym ) do |o|
n = 0
o.Testcode do
if n > delay
# p 8
yield o
else
n += 1
end
end # code //
end # task //
end # def
end
# -------------------- module include ---------------------
class TestObject
include Node_template
end
# ----------------------------------------------------------//
# --------------------- game logic main ----------------------
# --------------------- game logic player ----------------------
class User
def initialize o
o.node_gameobj_template({ sym: :user , x: 100 , y: 100 ,
d: Image.new(50,50,[100,100,200])
}) do |o|
move o
Window.drawEx o.x , o.y , o.d
end
end
def hit o
p :h
end
def move yu , hs = Hash.new
speed = hs[:speed] || 2
angle = 0
sstr = hs[:key] || [K_DOWN , K_LEFT , K_UP , K_RIGHT]
sstr.each_with_index do |m,i|if Input.keyDown?(m);(angle=90*(i+1));( Input.keyDown?(sstr[i-1])?(break(angle-=45)):nil);end;end
yu.x , yu.y = Libaa.work yu.x , yu.y , speed , angle unless angle == 0
end
end
# --------------------- game logic Enemy ----------------------
class Teki
def initialize o
o.node_gameobj_template({ sym: :teki , x: 200 , y: 100 ,
d: Image.new(50,50,[100,100,200])
}) do |o|
Window.drawEx o.x , o.y , o.d
end
end
end
# --------------------- game logic Field ----------------------
class Field
def initialize o
o.node_field_template({ sym: :field }) do |o|
a=o.up.task.reject do | k , o |
o.sym == :field
end
.map do | k , o |
o.collision.set(o.x, o.y)
end
Collision.check(a, a)
end
end
end
# ------------------------ main ------------------------------
TestObject.new.TestMain do | o |
o.Testcode do
Window.drawFont( o.x, o.y, "_test", Testmm.font)
o.sub_task do | o |
User.new o
Teki.new o
Field.new o
o.Testcode do
end
end
end
end
cmVxdWlyZSAiZHhydWJ5IgpyZXF1aXJlICdkeHJ1YnlleCcKcmVxdWlyZSAiS2NvbnYiCnJlcXVpcmUgIm9zdHJ1Y3QiCnJlcXVpcmUgInBwIgojCiRfX0RFQlVHX01PREVfXyA9IDp0cnVlCmRpciA9ICIuLyIKZGlyID0gIl9fdGVzdC8iIGlmICRfX0RFQlVHX01PREVfXyAhPSA6dHJ1ZQojIC0tLS0tLS0tLSBoZWFkIExpYiAtLS0tLS0tLQpyZXF1aXJlIGRpciArICJ1aGFhb2t3dyIKcmVxdWlyZSBkaXIgKyAiUnVydXJ1IgpyZXF1aXJlIGRpciArICJGaWxlZWUiCnJlcXVpcmUgZGlyICsgIlRlc3R0dCIKIyAtLS0tLS0gaGVhZCBTcmMgIC0tLS0tLQpyZXF1aXJlIGRpciArICJjb25zdHR0IgpyZXF1aXJlIGRpciArICJyYWFhX2giCgojIC0tLS0tLS0tLS0tIGxpYiAtLS0tLS0tLQoKIy0tLS0tLS0tLS0tLSBtYWluIC0tLS0tLS0tLS0tCgptb2R1bGUgTm9kZV90ZW1wbGF0ZQojICAgbm9kZSB0ZW1wbGF0ZS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KICBkZWYgbm9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