From 90b11aef4ec3ddaabe453c1a648e5fafe81a4af9 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sat, 19 Nov 2022 19:58:12 -0800 Subject: [PATCH] Fixes/escape close build panel --- gamestate.c | 7 +++++++ main.c | 24 +++++++++++++++++------- types.h | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gamestate.c b/gamestate.c index 2148eb6..2c634b5 100644 --- a/gamestate.c +++ b/gamestate.c @@ -1593,8 +1593,15 @@ void create_station(GameState *gs, V2 pos, enum BoxType platonic_type) void create_initial_world(GameState *gs) { +#if 0 + Log("Creating debug world\n"); + create_station(gs, (V2){-5.0f,0.0f}, BoxExplosive); + create_station(gs, (V2){0.0f, 5.0f}, BoxGyroscope); +#else create_station(gs, (V2){-50.0f,0.0f}, BoxExplosive); create_station(gs, (V2){0.0f, 100.0f}, BoxGyroscope); +#endif + } void exit_seat(GameState *gs, Entity *seat_in, Entity *p) diff --git a/main.c b/main.c index 35db60f..84fec73 100644 --- a/main.c +++ b/main.c @@ -671,6 +671,8 @@ static void ui(bool draw, float dt, float width, float height) static bool picking_new_boxtype = false; static float pick_opacity = 0.0f; { + if(keypressed[SAPP_KEYCODE_ESCAPE].pressed) + picking_new_boxtype = false; AABB pick_modal = (AABB){ .x = width * 0.25f, .y = height * 0.25f, @@ -1759,9 +1761,7 @@ static void frame(void) sgp_set_image(0, image_solarpanel_charging); sgp_set_color(1.0f, 1.0f, 1.0f, b->sun_amount); pipeline_scope(goodpixel_pipeline) - { draw_texture_centered(entity_pos(b), BOX_SIZE); - } sgp_reset_image(0); sgp_set_color(1.0f, 1.0f, 1.0f, 1.0f - b->sun_amount); /* Color to_set = colhexcode(0xeb9834); @@ -1787,12 +1787,22 @@ static void frame(void) if (b->box_type == BoxScanner) { sgp_set_image(0, image_scanner_head); - sgp_rotate_at(b->scanner_head_rotate, entity_pos(b).x, entity_pos(b).y); - pipeline_scope(goodpixel_pipeline) - draw_texture_centered(entity_pos(b), BOX_SIZE); + transform_scope + { + sgp_rotate_at(b->scanner_head_rotate, entity_pos(b).x, entity_pos(b).y); + pipeline_scope(goodpixel_pipeline) + draw_texture_centered(entity_pos(b), BOX_SIZE); + } + sgp_reset_image(0); set_color(WHITE); } + if(b->box_type == BoxScanner) + { + set_color(BLUE); + draw_circle(entity_pos(b), SCANNER_RADIUS); + set_color(WHITE); + } sgp_set_color(0.5f, 0.1f, 0.1f, b->damage); draw_color_rect_centered(entity_pos(b), BOX_SIZE); } @@ -1857,13 +1867,13 @@ static void frame(void) sgp_set_image(0, image_sun); draw_texture_centered((V2){0}, SUN_RADIUS * 2.0f); sgp_reset_image(0); - + // can draw at 0,0 because everything relative to sun now! // sun DEATH RADIUS set_color(RED); draw_circle((V2){0}, INSTANT_DEATH_DISTANCE_FROM_SUN); - + set_color(BLUE); draw_circle((V2){0}, SUN_NO_MORE_ELECTRICITY_OR_GRAVITY); } diff --git a/types.h b/types.h index 07370e8..c849d1a 100644 --- a/types.h +++ b/types.h @@ -12,7 +12,6 @@ #define PLAYER_JETPACK_TORQUE 0.05f // #define PLAYER_JETPACK_FORCE 20.0f // distance at which things become geostationary and no more solar power! -#define SUN_NO_MORE_ELECTRICITY_OR_GRAVITY 100.0f #define PLAYER_JETPACK_ROTATION_ENERGY_PER_SECOND 0.2f #define PLAYER_JETPACK_SPICE_PER_SECOND 0.2f #define SCANNER_ENERGY_USE 0.05f @@ -31,12 +30,13 @@ #define MAX_SERVER_TO_CLIENT 1024 * 512 // maximum size of serialized gamestate buffer #define MAX_CLIENT_TO_SERVER 1024 * 10 // maximum size of serialized inputs and mic data #define SUN_RADIUS 10.0f +#define SUN_NO_MORE_ELECTRICITY_OR_GRAVITY 200.0f #define INSTANT_DEATH_DISTANCE_FROM_SUN 2000.0f #define SUN_POS ((V2){50.0f, 0.0f}) #ifdef NO_GRAVITY #define SUN_GRAVITY_STRENGTH 0.0f #else -#define SUN_GRAVITY_STRENGTH (9.0e2f) +#define SUN_GRAVITY_STRENGTH (11.0e2f) #endif #define SOLAR_ENERGY_PER_SECOND 0.09f #define DAMAGE_TO_PLAYER_PER_BLOCK 0.1f