#![allow(clippy::upper_case_acronyms)] #![allow(clippy::new_without_default)] #![allow(unused)] use macroquad::prelude::*; const FISH_PARTS_RIGHT: (&str, &str) = ("><", ">"); const FISH_PARTS_LEFT: (&str, &str) = ("<", "><"); const WATER_LEVEL: i32 = 100; const WIDTH: i32 = 780; const FISH_ZONE: i32 = 500; const FONT_SIZE: f32 = 20.0; const ANIM_CHANGE: u32 = 150; // in milliseconds fn window_conf() -> Conf { Conf { window_title: "fishing minigame".to_owned(), window_width: WIDTH, window_height: FISH_ZONE, fullscreen: false, ..Default::default() } } struct Fish { length: u8, pos: Vec2, } struct Game { state: State, draw: Draw, } impl Game { fn new() -> Self { Self { state: State::new(), draw: Draw::new(), } } } struct Draw { // only two frames of animation first_frame: bool, frame_counter: usize, animations: Vec, } impl Draw { fn new() -> Self { Self { first_frame: true, frame_counter: 0, animations: Vec::new(), } } } struct Animation { width: usize, height: usize, color: Color, frames: [String; 2], } impl Animation { fn new(width: usize, height: usize, color: Color, frames: [String; 2]) -> Self { assert_eq!(width * height, frames[0].len()); assert_eq!(width * height, frames[1].len()); Self { width, height, color, frames, } } fn draw(&self, pos: Vec2) { draw_rectangle( pos.x, pos.y, self.width as f32 * FONT_SIZE, self.height as f32 * FONT_SIZE, self.color, ); } } struct State { fish: Vec, player: Vec2, caught_fish: Vec, } impl State { fn new() -> Self { State { fish: Vec::new(), player: Vec2::new(FISH_ZONE as f32 / 2.0, WATER_LEVEL as f32), caught_fish: Vec::new(), } } } #[macroquad::main(window_conf)] async fn main() { let mut game = Game::new(); loop { if is_key_down(KeyCode::Escape) { break; } draw(&game); next_frame().await; } } fn draw(game: &Game) { const FZ: f32 = FISH_ZONE as f32; const WL: f32 = WATER_LEVEL as f32; clear_background(SKYBLUE); // sky draw_rectangle(0.0, 0.0, FZ, WL, WHITE); // ground draw_rectangle(0.0, FZ - 30.0, FZ, 30.0, BEIGE); // static sprites // animated stuff // fish // sidebar draw_rectangle(FZ, 0.0, WIDTH as f32 - FZ, FZ, LIGHTGRAY); }