Add helper text on squad invitation

main
Cameron Murphy Reikes 2 years ago
parent a4997f771b
commit ea78de0165

@ -23,7 +23,7 @@
#define DEBUG_TOOLS #define DEBUG_TOOLS
#define CHIPMUNK_INTEGRITY_CHECK #define CHIPMUNK_INTEGRITY_CHECK
// #define FAT_THRUSTERS // #define FAT_THRUSTERS
// #define NO_GRAVITY #define NO_GRAVITY
// #define NO_SUNS // #define NO_SUNS
#else #else

@ -593,6 +593,7 @@ void create_missile(GameState *gs, Entity *e)
void create_player_entity(GameState *gs, Entity *e) void create_player_entity(GameState *gs, Entity *e)
{ {
e->is_player = true; e->is_player = true;
e->always_visible = true;
e->no_save_to_disk = true; e->no_save_to_disk = true;
create_body(gs, e); create_body(gs, e);
create_rectangle_shape(gs, e, e, (cpVect){0}, cpvmult(PLAYER_SIZE, 0.5), PLAYER_MASS); create_rectangle_shape(gs, e, e, (cpVect){0}, cpvmult(PLAYER_SIZE, 0.5), PLAYER_MASS);

@ -77,6 +77,7 @@ typedef struct MousePressed
} MousePressed; } MousePressed;
static MousePressed mousepressed[MAX_MOUSEBUTTON] = {0}; static MousePressed mousepressed[MAX_MOUSEBUTTON] = {0};
static EntityID maybe_inviting_this_player = {0}; static EntityID maybe_inviting_this_player = {0};
static EntityID hovering_this_player = {0};
bool confirm_invite_this_player = false; bool confirm_invite_this_player = false;
bool accept_invite = false; bool accept_invite = false;
bool reject_invite = false; bool reject_invite = false;
@ -1032,8 +1033,31 @@ static void ui(bool draw, double dt, double width, double height)
} }
} }
// draw maybe inviting // draw maybe inviting and helper text
{ {
Entity *maybe_hovering = get_entity(&gs, hovering_this_player);
if (draw && maybe_hovering != NULL && myplayer() != NULL && myplayer()->squad != SquadNone && myplayer()->squad != maybe_hovering->owning_squad)
{
cpVect pos = world_to_screen(width, height, entity_pos(maybe_hovering));
set_color(WHITE);
draw_circle(pos, 28.0 + sin(exec_time * 5.0) * 6.5);
sgp_set_image(0, image_rightclick);
cpVect draw_at = cpvadd(pos, cpv(0, 50.0));
transform_scope
{
pipeline_scope(goodpixel_pipeline)
{
scale_at(1.0, -1.0, draw_at.x, draw_at.y);
draw_texture_centered(draw_at, 100.0 + sin(exec_time * 5.0) * 10.0);
}
}
sgp_reset_image(0);
}
Entity *inviting = get_entity(&gs, maybe_inviting_this_player); Entity *inviting = get_entity(&gs, maybe_inviting_this_player);
if (inviting != NULL && myplayer() != NULL) if (inviting != NULL && myplayer() != NULL)
{ {
@ -1041,7 +1065,7 @@ static void ui(bool draw, double dt, double width, double height)
width, height, width, height,
cpvadd(entity_pos(inviting), cpvadd(entity_pos(inviting),
(cpVect){.y = player_scaling * PLAYER_SIZE.y / 2.0})); (cpVect){.y = player_scaling * PLAYER_SIZE.y / 2.0}));
cpVect pos = cpvadd(top_of_head, (cpVect){.y = -30.0}); cpVect pos = cpvadd(top_of_head, (cpVect){.y = -30.0}); // -y is up because in screen space here
cpVect to_mouse = cpvsub(mouse_pos, cpVect to_mouse = cpvsub(mouse_pos,
world_to_screen(width, height, entity_pos(inviting))); world_to_screen(width, height, entity_pos(inviting)));
bool selecting_to_invite = bool selecting_to_invite =
@ -1679,15 +1703,18 @@ static void frame(void)
// process player interaction (squad invites) // process player interaction (squad invites)
if (interact_pressed && myplayer() != NULL && myplayer()->squad != SquadNone) if (interact_pressed && myplayer() != NULL && myplayer()->squad != SquadNone)
ENTITIES_ITER(cur)
{ {
if (cur != myentity() && cur->is_player && if (get_entity(&gs, hovering_this_player) != NULL)
has_point(centered_at(entity_pos(cur), cpvmult(PLAYER_SIZE, player_scaling)), world_mouse_pos))
{ {
maybe_inviting_this_player = get_id(&gs, cur); maybe_inviting_this_player = hovering_this_player;
interact_pressed = false; interact_pressed = false;
} }
} }
ENTITIES_ITER(cur)
{
{
}
}
// Create and send input packet, and predict a frame of gamestate // Create and send input packet, and predict a frame of gamestate
static InputFrame cur_input_frame = { static InputFrame cur_input_frame = {
@ -1994,6 +2021,8 @@ static void frame(void)
if (zoom > 50.0) if (zoom > 50.0)
player_scaling = player_scaling_target; // For press tab zoom shortcut. Bad hack to make zooming in not jarring with the bigger player. Comment this out and press tab to see! player_scaling = player_scaling_target; // For press tab zoom shortcut. Bad hack to make zooming in not jarring with the bigger player. Comment this out and press tab to see!
player_scaling = lerp(player_scaling, player_scaling_target, dt * 15.0); player_scaling = lerp(player_scaling, player_scaling_target, dt * 15.0);
hovering_this_player = (EntityID){0};
// draw all types of entities
ENTITIES_ITER(e) ENTITIES_ITER(e)
{ {
// draw grid // draw grid
@ -2225,9 +2254,11 @@ static void frame(void)
} }
// draw player // draw player
if (e->is_player && if (e->is_player)
get_entity(&gs, e->currently_inside_of_box) == NULL)
{ {
if (e != myentity() && has_point(centered_at(entity_pos(e), cpvmult(PLAYER_SIZE, player_scaling)), world_mouse_pos))
hovering_this_player = get_id(&gs, e);
if (get_entity(&gs, e->currently_inside_of_box) == NULL)
transform_scope transform_scope
{ {
rotate_at(entity_rotation(e), entity_pos(e).x, entity_pos(e).y); rotate_at(entity_rotation(e), entity_pos(e).x, entity_pos(e).y);
@ -2243,6 +2274,8 @@ static void frame(void)
} }
} }
} }
// draw explosion
if (e->is_explosion) if (e->is_explosion)
{ {
sgp_set_image(0, image_explosion); sgp_set_image(0, image_explosion);

Loading…
Cancel
Save