Intersecting_Circles/intersecting-circles-modifiers/game.wren
2021-12-14 12:52:41 +01:00

64 lines
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 "luxe: render" for Render
import "random" for Random
import "outline/app" for App
import "modifiers/circle/circle" for Circle
import "modifiers/move/move" for Move
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")
spawn_circles(20)
} //ready
spawn_circles(count: Num){
var rng = Random.new()
for(i in 0...count){
//entity/transform setup
var circle_ent = Entity.create(app.world)
Transform.create(circle_ent)
var width = Render.window_w()
var height = Render.window_h()
Transform.set_pos(circle_ent, rng.float(0, width), rng.float(0, height), 0)
Circle.create(circle_ent)
Circle.set_radius(circle_ent, rng.float(20, 100))
Move.create(circle_ent)
Move.set_velocity(circle_ent, [rng.float(-20, 20), rng.float(-20, 20)])
}
}
tick(delta) {
if(Input.key_state_released(Key.escape)) {
IO.shutdown()
}
} //tick
destroy() {
System.print("unready!")
app.destroy()
} //destroy
app { _app }
app=(v) { _app=v }
} //Game