More boxes, fix camera not on player

main
Cameron Murphy Reikes 2 years ago
parent 9107643c57
commit 21f9a5eb50

@ -121,6 +121,7 @@ static void frame(void)
};
// @Robust maximum acceptable message size?
from_bytes(&msg, event.packet->data, event.packet->dataLength);
myplayer = msg.your_player;
enet_packet_destroy(event.packet);
break;
case ENET_EVENT_TYPE_DISCONNECT:
@ -202,6 +203,7 @@ static void frame(void)
sgp_set_color(1.0f, 1.0f, 1.0f, 1.0f);
sgp_push_transform();
sgp_rotate_at(box_rotation(p->box), box_pos(p->box).x, box_pos(p->box).y);
V2 bpos = box_pos(p->box);
sgp_draw_filled_rect(box_pos(p->box).x - halfbox, box_pos(p->box).y - halfbox, BOX_SIZE, BOX_SIZE);
sgp_pop_transform();
@ -218,7 +220,13 @@ static void frame(void)
sgp_set_color(0.5f, 0.5f, 0.5f, 1.0f);
sgp_push_transform();
sgp_rotate_at(box_rotation(gs.boxes[i]), box_pos(gs.boxes[i]).x, box_pos(gs.boxes[i]).y);
sgp_draw_filled_rect(box_pos(gs.boxes[i]).x - halfbox, box_pos(gs.boxes[i]).y - halfbox, BOX_SIZE, BOX_SIZE);
V2 bpos = box_pos(gs.boxes[i]);
sgp_draw_line(bpos.x - halfbox, bpos.y - halfbox, bpos.x - halfbox, bpos.y + halfbox); // left
sgp_draw_line(bpos.x - halfbox, bpos.y - halfbox, bpos.x + halfbox, bpos.y - halfbox); // top
sgp_draw_line(bpos.x + halfbox, bpos.y - halfbox, bpos.x + halfbox, bpos.y + halfbox); // right
sgp_draw_line(bpos.x - halfbox, bpos.y + halfbox, bpos.x + halfbox, bpos.y + halfbox); // bottom
sgp_draw_line(bpos.x - halfbox, bpos.y - halfbox, bpos.x + halfbox, bpos.y + halfbox); // diagonal
// sgp_draw_filled_rect(box_pos(gs.boxes[i]).x - halfbox, box_pos(gs.boxes[i]).y - halfbox, BOX_SIZE, BOX_SIZE);
sgp_pop_transform();
sgp_set_color(1.0f, 0.0f, 0.0f, 1.0f);

@ -16,12 +16,16 @@ void server(void *data)
struct GameState gs = {0};
initialize(&gs);
// two boxes stacked on top
// box haven
if (true)
{
gs.boxes[0] = box_new(&gs, (V2){.x = 0.75f, .y = 0.0});
gs.boxes[1] = box_new(&gs, (V2){.x = 0.75f, .y = 0.5f});
gs.num_boxes = 2;
gs.boxes[2] = box_new(&gs, (V2){.x = 0.75f, .y = 1.0f});
gs.boxes[3] = box_new(&gs, (V2){.x = -0.75f, .y = 0.0});
gs.boxes[4] = box_new(&gs, (V2){.x = -0.75f, .y = 0.5f});
gs.boxes[5] = box_new(&gs, (V2){.x = -0.75f, .y = 1.0f});
gs.num_boxes = 6;
}
// one box

Loading…
Cancel
Save