handle cross socket message passing

This commit is contained in:
2025-05-18 16:32:01 -06:00
parent b6a4936247
commit af0fd811b3
10 changed files with 240 additions and 63 deletions
+22 -7
View File
@@ -1,16 +1,12 @@
use macroquad::{
color::{BLACK, WHITE},
text::draw_text,
window::{clear_background, screen_height, screen_width},
};
use macroquad::prelude::*;
use crate::screen::Screen;
use crate::{model::ClientMessage, screen::Screen};
#[derive(Default)]
pub struct HostScreen {}
impl Screen for HostScreen {
fn handle_frame(&mut self, _ctx: &mut crate::context::Context) {
fn handle_frame(&mut self, ctx: &mut crate::context::Context) {
clear_background(WHITE);
draw_text(
@@ -20,6 +16,25 @@ impl Screen for HostScreen {
100.0,
BLACK,
);
let button_size = screen_width() * 0.01;
let button_location = Vec2::new(screen_width() * 0.50, screen_height() * 0.70);
draw_circle(
button_location.x,
button_location.y,
button_size * 1.1,
DARKBROWN,
);
draw_circle(button_location.x, button_location.y, button_size, RED);
if is_mouse_button_pressed(MouseButton::Left) {
let loc = Vec2::from(mouse_position());
let normalize = loc - button_location;
if normalize.length() < button_size {
ctx.send_msg(&ClientMessage::ResetBuzzers);
}
}
}
fn handle_messages(
+1
View File
@@ -11,6 +11,7 @@ pub enum ClientMessage {
BuzzIn(BuzzIn),
Register(Register),
CreateRoom(Register),
ResetBuzzers,
}
#[derive(Debug, Serialize)]