space/game.wren

62 lines
1.3 KiB
Text
Raw Normal View History

2020-09-19 18:36:28 +00:00
import "luxe: game" for Ready
2019-01-20 06:50:00 +00:00
import "luxe: assets" for Assets
import "luxe: input" for Input, Key
2020-09-19 18:36:28 +00:00
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera
import "luxe: render" for Material
2019-01-20 06:50:00 +00:00
import "luxe: math" for Math
2020-09-19 18:36:28 +00:00
import "luxe: draw" for Draw
2019-01-20 06:50:00 +00:00
import "luxe: io" for IO
import "outline/app" for App
2020-09-19 18:36:28 +00:00
class Game is Ready {
2019-01-20 06:50:00 +00:00
construct ready() {
2020-09-19 18:36:28 +00:00
super("ready!")
2019-01-20 06:50:00 +00:00
app = App.new()
app.color = [0,0,0,1]
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
// game vars
// camera
2020-09-19 18:36:28 +00:00
_camera_scale = 3
2019-02-03 03:33:50 +00:00
_cam_offset_x = (app.width / 2 / _camera_scale)
_cam_offset_y = (app.height / 2 / _camera_scale)
2020-09-19 18:36:28 +00:00
Camera.ortho(app.camera, 0, _cam_offset_y * 2, _cam_offset_x * 2, 0, -5, 5)
2019-01-20 06:50:00 +00:00
create_ship()
2019-01-27 00:52:14 +00:00
2019-01-20 06:50:00 +00:00
} //ready
tick(delta) {
if(Input.key_state_released(Key.escape)) {
IO.shutdown()
}
} //tick
2020-09-19 18:36:28 +00:00
// CREATORS
2019-11-02 04:42:10 +00:00
create_ship() {
2019-01-20 06:50:00 +00:00
_ship = Entity.create(app.world, "ship")
var ship_mat = Assets.material("material/ship")
Sprite.create(_ship, ship_mat, 16, 32)
2020-09-19 18:36:28 +00:00
Transform.create(_ship)
Transform.set_pos(_ship, app.width/2 / _camera_scale, app.height/2 / _camera_scale)
2019-01-20 06:50:00 +00:00
} //create_ship
destroy() {
2020-09-19 18:36:28 +00:00
2019-01-20 06:50:00 +00:00
System.print("unready!")
app.destroy()
2020-09-19 18:36:28 +00:00
2019-01-20 06:50:00 +00:00
} //destroy
app { _app }
app=(v) { _app=v }
} //Game