From 95d5d5e58f80908f63be726bfebc55da00ac8719 Mon Sep 17 00:00:00 2001 From: me Date: Sun, 21 Dec 2025 18:31:54 +0200 Subject: [PATCH] fix hotwatch for linux --- game.ayin | 26 +++++++++++++++++--------- src/main.rs | 9 +++------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/game.ayin b/game.ayin index 99f7c35..8c5fb78 100644 --- a/game.ayin +++ b/game.ayin @@ -11,17 +11,16 @@ let bullet_dim = { } let migrate = fn(state) { -return setup(); state } let setup = fn() { return { .player: { - .pos: { - .x: (screen_size - dim.w) - dim.w, - .y: dim.h, - }, + .pos: { + .x: (screen_size - dim.w) - dim.w, + .y: dim.h * 5, + }, .speed: 360, .shot: 1, .shot_timer: 0, @@ -31,13 +30,13 @@ let setup = fn() { .x: dim.w, .y: dim.h, }, - .speed: 60, + .speed: 20, .timer: 0, }, .bullets: { .pos: { - .x: dim.w, - .y: dim.h, + .x: -20, + .y: -20, }, .movement: { .x: 0, @@ -96,7 +95,7 @@ let move_enemy = fn(state) { ) ); - shoot_bullets(state, enemy_movement); + shoot_bullets(state, enemy_movement); } let shoot_bullets = fn(state, enemy_movement) { @@ -151,6 +150,15 @@ let update = fn(state, input) { state.status = "caught"; }; + if input.gamepad1.buttons.y { + let new_state = setup(); + state.player = new_state.player; + state.enemy = new_state.enemy; + state.bullets = new_state.bullets; + state.status = new_state.status; + state.timer = new_state.timer; + }; + return state; } diff --git a/src/main.rs b/src/main.rs index b089049..ef26277 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,5 @@ use ayin::runtime::*; -use hotwatch::{ - self, - notify::event::{DataChange, ModifyKind}, -}; +use hotwatch::{self}; use macroquad::prelude::*; use std::{ sync::{Arc, RwLock}, @@ -33,11 +30,11 @@ async fn main() { let writer = Arc::new(RwLock::new(None)); let reader = writer.clone(); - let mut hotwatch = hotwatch::Hotwatch::new_with_custom_delay(Duration::from_millis(10)) + let mut hotwatch = hotwatch::Hotwatch::new_with_custom_delay(Duration::from_millis(100)) .expect("hotwatch failed to initialize!"); hotwatch .watch(file.clone(), move |event: hotwatch::Event| { - if let hotwatch::EventKind::Modify(ModifyKind::Data(DataChange::Content)) = event.kind { + if let hotwatch::EventKind::Modify(_) = event.kind { match std::fs::read_to_string(file.clone()) { Err(err) => println!("Error: {err:#?}"), Ok(txt) => match ayin::parser::parse_file(txt) {