--# Main
-- Gundam
function setup()
displayMode(FULLSCREEN)
long_lan = Gundam(vec2(400, 240), Animation({"gundam:long_lan_feet2", "gundam:long_lan_feet", "gundam:long_lan_feet1"}), Animation({"gundam:long_lan1", "gundam:long_lan"}), vec2(0, 0))
joystick = Joystick()
end
function draw()
background(0)
if joystick.L_vec2 ~= vec2(0, 0) then
long_lan.angle = vec2(0, 1):angleBetween(joystick.L_vec2)
long_lan.velocity = joystick.L_vec2:normalize() * long_lan.speed
long_lan.state = moving
else
long_lan.velocity = vec2(0, 0)
long_lan.state = no_action
end
if joystick.R_vec2 ~= vec2(0, 0) then
long_lan.weapon.angle = vec2(0, 1):angleBetween(joystick.R_vec2)
end
long_lan:draw()
fill(0, 255, 0)
stroke(0, 255, 0)
strokeWidth(1)
rect(10 * WIDTH / 800, 460 * HEIGHT / 480, (long_lan.hp / long_lan.fullhp) * 780 * WIDTH / 800, 10 * HEIGHT / 480)
joystick:draw()
end
function touched(touch)
joystick:touched(touch)
end
--# Weapon
Weapon = class()
function Weapon:init(offpos, anime)
-- user variable
self.offset_position = offpos
self.animation = anime
self.angle = 0 -- rad
self.bullets = {}
-- class variable
self.render = mesh()
local width, height = spriteSize(self.animation.frames[self.animation.index])
self.rectangleID = self.render:addRect(
self.offset_position.x * WIDTH / 800, self.offset_position.y * HEIGHT / 480, width * WIDTH / 800,
height * HEIGHT / 480, 0) -- define the offset drawing area
self.render:setRectTex(self.rectangleID, 0.0, 0.0, 1.0, 1.0) -- define the texture area
self.render.texture = self.animation.frames[self.animation.index] -- load the texture
end
-- Gundam
function setup()
displayMode(FULLSCREEN)
long_lan = Gundam(vec2(400, 240), Animation({"gundam:long_lan_feet2", "gundam:long_lan_feet", "gundam:long_lan_feet1"}), Animation({"gundam:long_lan1", "gundam:long_lan"}), vec2(0, 0))
joystick = Joystick()
end
function draw()
background(0)
if joystick.L_vec2 ~= vec2(0, 0) then
long_lan.angle = vec2(0, 1):angleBetween(joystick.L_vec2)
long_lan.velocity = joystick.L_vec2:normalize() * long_lan.speed
long_lan.state = moving
else
long_lan.velocity = vec2(0, 0)
long_lan.state = no_action
end
if joystick.R_vec2 ~= vec2(0, 0) then
long_lan.weapon.angle = vec2(0, 1):angleBetween(joystick.R_vec2)
end
long_lan:draw()
fill(0, 255, 0)
stroke(0, 255, 0)
strokeWidth(1)
rect(10 * WIDTH / 800, 460 * HEIGHT / 480, (long_lan.hp / long_lan.fullhp) * 780 * WIDTH / 800, 10 * HEIGHT / 480)
joystick:draw()
end
function touched(touch)
joystick:touched(touch)
end
--# Weapon
Weapon = class()
function Weapon:init(offpos, anime)
-- user variable
self.offset_position = offpos
self.animation = anime
self.angle = 0 -- rad
self.bullets = {}
-- class variable
self.render = mesh()
local width, height = spriteSize(self.animation.frames[self.animation.index])
self.rectangleID = self.render:addRect(
self.offset_position.x * WIDTH / 800, self.offset_position.y * HEIGHT / 480, width * WIDTH / 800,
height * HEIGHT / 480, 0) -- define the offset drawing area
self.render:setRectTex(self.rectangleID, 0.0, 0.0, 1.0, 1.0) -- define the texture area
self.render.texture = self.animation.frames[self.animation.index] -- load the texture
end