61 lines
No EOL
1.4 KiB
Text
61 lines
No EOL
1.4 KiB
Text
import "luxe: game" for Ready
|
|
import "luxe: assets" for Assets
|
|
import "luxe: input" for Input, Key
|
|
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera
|
|
import "luxe: math" for Math
|
|
import "luxe: draw" for Draw
|
|
import "luxe: io" for IO
|
|
|
|
import "outline/app" for App
|
|
import "trail: modifier/trail" for Trail
|
|
|
|
class Game is Ready {
|
|
|
|
construct ready() {
|
|
|
|
super("ready!")
|
|
|
|
app = App.new()
|
|
app.color = [0,0,0,1]
|
|
|
|
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
|
|
|
|
_blade = Entity.create(app.world)
|
|
Transform.create(_blade)
|
|
Transform.set_pos(_blade, 100, 100)
|
|
Trail.create(_blade)
|
|
_prev_pos = [0,0,0]
|
|
} //ready
|
|
|
|
tick(delta) {
|
|
var pos = Camera.screen_point_to_world(app.camera, Input.mouse_x(), Input.mouse_y())
|
|
var t = delta * 10
|
|
pos = [Math.lerp(_prev_pos.x, pos.x, t), Math.lerp(_prev_pos.y, pos.y, t)]
|
|
if(Math.dist2D(pos, _prev_pos) > 0.1){
|
|
var angle = Math.angle2D(_prev_pos, pos)
|
|
Transform.set_angle2D(_blade, angle)
|
|
_prev_pos = pos
|
|
}
|
|
Transform.set_pos(_blade, pos.x, pos.y)
|
|
|
|
if(Input.key_state_released(Key.escape)) {
|
|
IO.shutdown()
|
|
}
|
|
if(Input.key_state_released(Key.space)) {
|
|
Trail.reset(_blade)
|
|
}
|
|
|
|
//app.color.r = app.color.g = app.color.b = (IO.timestamp()/20 % 1)
|
|
//System.print(1/delta)
|
|
} //tick
|
|
|
|
destroy() {
|
|
|
|
System.print("unready!")
|
|
app.destroy()
|
|
|
|
} //destroy
|
|
|
|
app { _app }
|
|
app=(v) { _app=v }
|
|
} //Game |