space/game.wren
2020-09-19 11:36:28 -07:00

61 lines
1.3 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: render" for Material
import "luxe: math" for Math
import "luxe: draw" for Draw
import "luxe: io" for IO
import "outline/app" for App
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")
// game vars
// camera
_camera_scale = 3
_cam_offset_x = (app.width / 2 / _camera_scale)
_cam_offset_y = (app.height / 2 / _camera_scale)
Camera.ortho(app.camera, 0, _cam_offset_y * 2, _cam_offset_x * 2, 0, -5, 5)
create_ship()
} //ready
tick(delta) {
if(Input.key_state_released(Key.escape)) {
IO.shutdown()
}
} //tick
// CREATORS
create_ship() {
_ship = Entity.create(app.world, "ship")
var ship_mat = Assets.material("material/ship")
Sprite.create(_ship, ship_mat, 16, 32)
Transform.create(_ship)
Transform.set_pos(_ship, app.width/2 / _camera_scale, app.height/2 / _camera_scale)
} //create_ship
destroy() {
System.print("unready!")
app.destroy()
} //destroy
app { _app }
app=(v) { _app=v }
} //Game