From 7b084e0d2c63f3a931c46505f73bf4638da6f992 Mon Sep 17 00:00:00 2001 From: Jonathan Hirz Date: Fri, 1 Nov 2019 21:42:10 -0700 Subject: [PATCH] ello --- _art/player_ship.ase | Bin 1082 -> 1108 bytes game.wren | 44 +++++++++++++++++------------------------- outline/renderer.wren | 4 ++++ project.luxe | 2 +- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/_art/player_ship.ase b/_art/player_ship.ase index 936802fe5d1c210a6d4ef1ba681c4af2174b3d10..da93fdc92417141f3ec69d58ff1ccd74a51d7aca 100644 GIT binary patch delta 357 zcmdnRafO31WFlj|{2C?(hF>398B!P+7+8T=42ank7=a`hZ0yWptXBqdSrs4x|AFcu zz=J`Gp<>S4X$LtE8}PWY%BpC$$XK~41b?~XYU8#rfaC6A?~+!z%gxN8$ z%l3zW2>Y7!MJx%zo85jK%UElu(D&f0O%c1N{lu;H{XcHDeSLH1h)n1F{`sd(5|8jd zvUX74o_L_%z+U%UcJcglo;82f|9mK2EAYkF`1p6{KCKVQMedqUe{H*7V;20w>csOC z_w)0zK2Nqf9yH}!aCf`Ny7z@L%@f4q^gq;1W%<3OR)4v(z$d}g&U>H#&Hho}>wW+G zj2pJ!a=NeBiMO1pD4F|lb9g@I?e9gl?27Umt6u(n)@CDchu>)Z^n3YvN6wo)N|&#{ u_TlH9Pj3{DoVQz3gRAFqHFk)lB*YzYoaeD3C(@*gPaj^U+@&*5VJ@4#%QfEAdX-h zNA4i$C$jeM5kJSUo}HVRBk}X`bDw97_(6OJ=;S#J80M$Nd2QBZ!NA^s!Vh293PImA zb9_JKr~*GGe|MBpu5WwIXETMbgM5zs{pO}NKdEypMQJ~^cu3*;o~9`XdExZ}?^j8% zPuur)y#yg2u{zXy-oJ+b*SPe3kBQx5&$dYIb3v$#SJxRoXZ4n_eQ%Fj5b_bLm)>t~ z$OFOs@OtU}=0^M+BYw{DXAPgvEzcf8{G5~ehPV7}7WWZ9A#aUOb_OT`008>&0RUtG L00029IRhI3Vm*|d diff --git a/game.wren b/game.wren index db7698e..0ce8570 100644 --- a/game.wren +++ b/game.wren @@ -22,7 +22,7 @@ class game is Game { // game vars // camera - _camera_scale = 1.5 + _camera_scale = 2 _cam_offset_x = (app.width / 2 / _camera_scale) _cam_offset_y = (app.height / 2 / _camera_scale) @@ -50,66 +50,70 @@ class game is Game { // NOTES // z-layers: -1 stars, 0 player ship + // camera stuff: we're moving the ship in the world, based on input. then, moving the camera, + // with lerp, based on where the ship goes. then, moving star_tracker to the camera position, + // with offset. positions and offsets react to _camera_scale } //ready tick(delta) { - tick_ship(delta) tick_camera(delta) tick_starfield(delta) + something_else() if(Input.key_state_released(Key.escape)) { IO.shutdown() } app.tick(delta) - } //tick ////////////// // CREATORS // ////////////// - create_ship() { + something_else() { + //nothing + } + create_ship() { _ship = Entity.create(app.world, "ship") Transform.create(_ship) var ship_mat = Assets.material("material/ship") Sprite.create(_ship, ship_mat, 16, 32) Transform.set_pos(_ship, 0, 0) - } //create_ship create_ui_text() { - _position_text = Entity.create(app.ui) _mat_font = Assets.material("luxe: material/font") Transform.create(_position_text) Transform.set_pos(_position_text, app.width / 2 - 35, app.height - 50) Text.create(_position_text, _mat_font, 32, "fonts/lato", [1,1,1,1]) - } //create_ui_text create_asteroid(x, y) { - _asteroid = Entity.create(app.world, "asteroid") Transform.create(_asteroid) var asteroid_mat = Assets.material("material/asteroid") Sprite.create(_asteroid, asteroid_mat, 32, 32) Transform.set_pos(_asteroid, x, y) - } //create_asteroid create_startracker() { - _star_tracker = Entity.create(app.world, "star_tracker") Transform.create(_star_tracker) Transform.set_pos(_star_tracker, Transform.get_pos_x(_ship), Transform.get_pos_y(_ship), Transform.get_pos_z(_ship)) - } //create_startracker create_starfield() { + // sometimes you come back to some code and don't remember exactly how it all works + // that's ok, just trust that past you figured this out, and it works how you want it to + // hopefully you can figure it out later if needed + // + // this makes the starfield background, with randomness applied to the position, size, and set_alpha + // of each star. stars are parented to _star_tracker, which follows the player around // put a value in the new() call to make the same starfield each time var rng = Random.new() @@ -131,16 +135,15 @@ class game is Game { } // debug red star // Sprite.set_color(_stars[1], 1, 0, 0, 1) - } + } //create_starfield ////////////// // UPDATERS // ////////////// tick_ship(delta) { - - var input_vec = [get_axis("horizontal"), get_axis("vertical"), 0] - Math.normalize(input_vec) + var input_vec = [get_axis("horizontal"), get_axis("vertical")] + Math.normalize2D(input_vec) // 2d movement physics _ship_acceleration_x = input_vec.x * _ship_speed @@ -163,11 +166,9 @@ class game is Game { var ship_pos_x_int = Math.floor_around_zero(Transform.get_pos_x(_ship)) var ship_pos_y_int = Math.floor_around_zero(Transform.get_pos_y(_ship)) Text.set_text(_position_text, "[%(ship_pos_x_int), %(ship_pos_y_int)]") - } //tick_ship tick_camera(delta) { - // move the camera, with some lerp delay, along with the ship var shipx = Transform.get_pos_x(_ship) var shipy = Transform.get_pos_y(_ship) @@ -177,11 +178,9 @@ class game is Game { var camera_interp_x = lerp(shipx - _cam_offset_x, camerax, interpolation) var camera_interp_y = lerp(shipy - _cam_offset_y, cameray, interpolation) Transform.set_pos(app.camera, camera_interp_x, camera_interp_y) - } //tick_camera tick_starfield(delta) { - Transform.set_pos(_star_tracker, Transform.get_pos_x(app.camera) + _cam_offset_x, Transform.get_pos_y(app.camera) + _cam_offset_y, -1) // loop through stars[] for(star in _stars) { @@ -204,7 +203,6 @@ class game is Game { Transform.set_pos_y(star, _cam_offset_y * _camera_scale) } } - } //tick_starfield ///////////// @@ -212,7 +210,6 @@ class game is Game { ///////////// get_axis(axis) { - if(axis == "horizontal") { var xaxis = 0 if(Input.key_state_down(Key.key_a) || Input.key_state_down(Key.left)) { @@ -233,20 +230,15 @@ class game is Game { } return yaxis } - } //get_axis lerp(a, b, t) { - return a + t * (b - a) - } //lerp destroy() { - System.print("unready!") app.destroy() - } //destroy app { _app } diff --git a/outline/renderer.wren b/outline/renderer.wren index d6aac6c..ab1c929 100644 --- a/outline/renderer.wren +++ b/outline/renderer.wren @@ -13,6 +13,10 @@ class Renderer { } + tick(delta) { + + } + render_path(ctx) { if(ctx.path == "game") { diff --git a/project.luxe b/project.luxe index 3f9fe11..bbb9a3d 100644 --- a/project.luxe +++ b/project.luxe @@ -1,4 +1,4 @@ -// luxe 1.0.0-dev.81 +// luxe 1.0.0-dev.83 import "luxe: project" for Project