fix hotwatch for linux
This commit is contained in:
parent
c359a4f0e8
commit
95d5d5e58f
2 changed files with 20 additions and 15 deletions
18
game.ayin
18
game.ayin
|
|
@ -11,7 +11,6 @@ let bullet_dim = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let migrate = fn(state) {
|
let migrate = fn(state) {
|
||||||
return setup();
|
|
||||||
state
|
state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,7 +19,7 @@ let setup = fn() {
|
||||||
.player: {
|
.player: {
|
||||||
.pos: {
|
.pos: {
|
||||||
.x: (screen_size - dim.w) - dim.w,
|
.x: (screen_size - dim.w) - dim.w,
|
||||||
.y: dim.h,
|
.y: dim.h * 5,
|
||||||
},
|
},
|
||||||
.speed: 360,
|
.speed: 360,
|
||||||
.shot: 1,
|
.shot: 1,
|
||||||
|
|
@ -31,13 +30,13 @@ let setup = fn() {
|
||||||
.x: dim.w,
|
.x: dim.w,
|
||||||
.y: dim.h,
|
.y: dim.h,
|
||||||
},
|
},
|
||||||
.speed: 60,
|
.speed: 20,
|
||||||
.timer: 0,
|
.timer: 0,
|
||||||
},
|
},
|
||||||
.bullets: {
|
.bullets: {
|
||||||
.pos: {
|
.pos: {
|
||||||
.x: dim.w,
|
.x: -20,
|
||||||
.y: dim.h,
|
.y: -20,
|
||||||
},
|
},
|
||||||
.movement: {
|
.movement: {
|
||||||
.x: 0,
|
.x: 0,
|
||||||
|
|
@ -151,6 +150,15 @@ let update = fn(state, input) {
|
||||||
state.status = "caught";
|
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;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
use ayin::runtime::*;
|
use ayin::runtime::*;
|
||||||
use hotwatch::{
|
use hotwatch::{self};
|
||||||
self,
|
|
||||||
notify::event::{DataChange, ModifyKind},
|
|
||||||
};
|
|
||||||
use macroquad::prelude::*;
|
use macroquad::prelude::*;
|
||||||
use std::{
|
use std::{
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
|
|
@ -33,11 +30,11 @@ async fn main() {
|
||||||
|
|
||||||
let writer = Arc::new(RwLock::new(None));
|
let writer = Arc::new(RwLock::new(None));
|
||||||
let reader = writer.clone();
|
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!");
|
.expect("hotwatch failed to initialize!");
|
||||||
hotwatch
|
hotwatch
|
||||||
.watch(file.clone(), move |event: hotwatch::Event| {
|
.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()) {
|
match std::fs::read_to_string(file.clone()) {
|
||||||
Err(err) => println!("Error: {err:#?}"),
|
Err(err) => println!("Error: {err:#?}"),
|
||||||
Ok(txt) => match ayin::parser::parse_file(txt) {
|
Ok(txt) => match ayin::parser::parse_file(txt) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue