fix hotwatch for linux
This commit is contained in:
parent
c359a4f0e8
commit
95d5d5e58f
2 changed files with 20 additions and 15 deletions
26
game.ayin
26
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue