diff --git a/src/app.rs b/src/app.rs index 392b46a..8c0a718 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,29 +1,17 @@ use crate::{ - command::CmdVec, - debug::{self, DebugState}, - game::GameState, - input::Input, - res::Res, - CliArgs, + command::CmdVec, debug::{self, DebugState}, + game::GameState, input::Input, res::Res, CliArgs, }; - use egui_sfml::SfEgui; use sfml::graphics::{RenderTexture, RenderWindow}; /// Application level state (includes game and ui state, etc.) pub(crate) struct App { - pub(crate) rw: RenderWindow, - pub(crate) should_quit: bool, pub(crate) game: GameState, pub(crate) res: Res, pub(crate) sf_egui: SfEgui, - pub(crate) input: Input, pub(crate) debug: DebugState, /// Integer scale for rendering the game pub(crate) scale: u8, - /// RenderTexture for rendering the game at its native resolution - pub(crate) rt: RenderTexture, - /// Light map overlay, blended together with the non-lighted version of the scene - pub(crate) light_map: RenderTexture, pub(crate) cmdvec: CmdVec, } impl App { diff --git a/src/cmdline.rs b/src/cmdline.rs index a414cbc..387e687 100644 --- a/src/cmdline.rs +++ b/src/cmdline.rs @@ -1,15 +1,2 @@ use clap::Parser; use crate::{command::Cmd, math::WorldPos}; -#[derive(Parser)] -pub(crate) enum CmdLine { - Quit, - Freecam, - Clear, - Tp(Tp), - Spawn, - Give(Give), -} -#[derive(Parser)] -pub(crate) struct Tp {} -#[derive(Parser)] -pub(crate) struct Give {} diff --git a/src/debug.rs b/src/debug.rs index 0528869..0521081 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -5,17 +5,7 @@ use crate::{ use egui_inspect::{derive::Inspect, inspect}; use sfml::audio::SoundSource; #[derive(Default, Debug, Inspect)] -pub(crate) struct DebugState { - pub(crate) panel: bool, - pub(crate) freecam: bool, - pub(crate) tiledb_edit: TileDbEdit, - pub(crate) show_atlas: bool, - pub(crate) console: Console, -} -#[derive(Default, Debug, Inspect)] -pub(crate) struct Console { - pub(crate) show: bool, -} +pub(crate) struct DebugState {} fn debug_panel_ui( mut debug: &mut DebugState, mut game: &mut GameState, @@ -23,26 +13,36 @@ fn debug_panel_ui( res: &mut Res, mut scale: &mut u8, ) { - egui::Window::new("Debug (F12)").show(ctx, |ui| { - egui::ScrollArea::both() - .id_source("insp_scroll") - .max_height(240.) - .max_width(340.0) - .show(ui, |ui| { - inspect! { - ui, scale, game, debug - } - }); - - egui::ScrollArea::vertical().show(ui, |ui| { - gamedebug_core::for_each_imm(|info| match info { - gamedebug_core::Info::Msg(msg) => { - ui.label(msg); - } - gamedebug_core::Info::Rect(_, _, _, _, _) => todo!(), - }); - }); - }); + egui::Window::new("Debug (F12)") + .show( + ctx, + |ui| { + egui::ScrollArea::both() + .id_source("insp_scroll") + .max_height(240.) + .max_width(340.0) + .show( + ui, + |ui| { + inspect! { + ui, scale, game, debug + } + }, + ); + egui::ScrollArea::vertical() + .show( + ui, + |ui| { + gamedebug_core::for_each_imm(|info| match info { + gamedebug_core::Info::Msg(msg) => { + ui.label(msg); + } + gamedebug_core::Info::Rect(_, _, _, _, _) => todo!(), + }); + }, + ); + }, + ); } pub(crate) fn do_debug_ui( ctx: &egui::Context, @@ -54,6 +54,3 @@ pub(crate) fn do_debug_ui( ) { debug_panel_ui(debug, game, ctx, res, scale); } -fn console_ui(ctx: &egui::Context, debug: &mut DebugState, cmd: &mut CmdVec) { - loop {} -} diff --git a/src/game.rs b/src/game.rs index 8ec8e75..45fb970 100644 --- a/src/game.rs +++ b/src/game.rs @@ -20,43 +20,5 @@ use crate::{ #[derivative(Debug)] pub(crate) struct GameState { pub(crate) camera_offset: WorldPos, - pub(crate) world: World, pub(crate) tile_db: TileDb, } -#[derive(PartialEq, Eq, Clone, Copy, Debug, Inspect)] -pub(crate) enum Biome { - Surface, - Underground, -} -impl GameState { - pub(crate) fn update(&mut self, input: &Input) { - loop {} - } - pub(crate) fn draw_world(&mut self, rt: &mut RenderTexture, res: &mut Res) { - loop {} - } - pub(crate) fn draw_entities(&mut self, rt: &mut RenderTexture) { - loop {} - } - pub(crate) fn draw_ui( - &mut self, - rt: &mut RenderTexture, - res: &Res, - ui_dims: Vector2f, - ) { - loop {} - } - pub(crate) fn light_pass(&mut self, lightmap: &mut RenderTexture, res: &Res) { - loop {} - } - pub(crate) fn new(world_name: String, path: PathBuf, res: &Res) -> GameState { - loop {} - } -} -pub(crate) fn for_each_tile_on_screen( - camera_offset: WorldPos, - rt_size: Vector2u, - mut f: impl FnMut(TilePos, ScreenVec), -) { - loop {} -} diff --git a/src/graphics.rs b/src/graphics.rs index 3adede8..fdb31fd 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -5,12 +5,8 @@ use sfml::{ }; use sfml_xt::graphics::RenderWindowExt; use crate::math::FPS_TARGET; -pub(crate) struct ScreenRes {} #[derive(Default, Clone, Copy, Debug, Inspect, Serialize, Deserialize)] -pub struct ScreenVec { - pub(crate) x: ScreenSc, - pub(crate) y: ScreenSc, -} +pub(crate) struct ScreenVec {} /// Screen position/offset scalar /// We assume this game won't be played above 32767*32767 resolution pub(crate) type ScreenSc = i16; diff --git a/src/input.rs b/src/input.rs index eeb27dc..f3b3b22 100644 --- a/src/input.rs +++ b/src/input.rs @@ -3,23 +3,3 @@ use sfml::window::{mouse, Event, Key}; use crate::graphics::ScreenVec; #[derive(Default, Debug)] pub(crate) struct Input {} -impl Input { - pub(crate) fn update_from_event( - &mut self, - ev: &Event, - egui_kbd: bool, - egui_ptr: bool, - ) { - loop {} - } - /// Pressed event should be cleared every frame - pub(crate) fn clear_pressed(&mut self) { - loop {} - } - pub(crate) fn down(&self, key: Key) -> bool { - loop {} - } - pub(crate) fn pressed(&self, key: Key) -> bool { - loop {} - } -} diff --git a/src/inventory.rs b/src/inventory.rs index 07cbe09..254982d 100644 --- a/src/inventory.rs +++ b/src/inventory.rs @@ -1,24 +1,6 @@ use egui_inspect::derive::Inspect; use crate::{math::IntRect, tiles::{BgTileId, FgTileId, MidTileId}}; -/// We won't have more than 65535 different items -pub(crate) type ItemId = u16; -/// Inventory slot -#[derive(Debug, Inspect)] -pub(crate) struct Slot {} #[derive(Debug, Inspect)] pub(crate) struct Inventory {} -#[derive(Debug, Inspect, PartialEq)] -pub(crate) enum TileLayer { - Bg, - Mid, - Fg, -} -#[derive(Debug)] -pub(crate) enum UseAction { - PlaceBgTile {}, - PlaceMidTile {}, - PlaceFgTile {}, - RemoveTile {}, -} #[derive(Debug, Inspect)] pub(crate) struct ItemDb {} diff --git a/src/main.rs b/src/main.rs index 6b1c5a3..9ae6769 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ mod app; -mod cmdline; mod command; mod debug; mod game; @@ -9,7 +8,6 @@ mod inventory; mod math; mod player; mod res; -mod stringfmt; mod texture_atlas; mod tiles; mod world; diff --git a/src/math.rs b/src/math.rs index 605f454..4905ffa 100644 --- a/src/math.rs +++ b/src/math.rs @@ -11,47 +11,13 @@ pub(crate) struct WorldPos { } /// Tile size in pixels pub(crate) const TILE_SIZE: u8 = 32; -/// Pixels per meter. -pub(crate) const PX_PER_M: f32 = TILE_SIZE as f32 * 2.; -/// Meters per pixel -pub(crate) const M_PER_PX: f32 = 1. / PX_PER_M; pub(crate) const FPS_TARGET: u8 = 60; -pub(crate) fn px_per_frame_to_km_h(px_per_frame: f32) -> f32 { - loop {} -} -/// World extent in tiles. Roughly 50km*50km. -pub(crate) const WORLD_EXTENT: TPosSc = 100_000; -impl WorldPos { - pub(crate) fn tile_pos(&self) -> TilePos { - loop {} - } - /// Horizontal center of the world - pub(crate) const CENTER: WPosSc = (WORLD_EXTENT / 2) * TILE_SIZE as WPosSc; - /// Vertical surface level. - /// You can build 10 km high. - pub(crate) const SURFACE: WPosSc = 20_000 * TILE_SIZE as WPosSc; - pub(crate) const SURFACE_CENTER: Self = Self { - x: Self::CENTER, - y: Self::SURFACE, - }; - pub(crate) fn to_s2dc(self) -> s2dc::Vec2 { - loop {} - } -} pub(crate) fn wp_to_tp(wp: WPosSc) -> TPosSc { loop {} } -pub(crate) fn center_offset + Copy + Signed>(xw: N, yw: N) -> N { - loop {} -} /// A smooth triangle-wave like transform of the input value, oscillating between 0 and the ceiling. pub(crate) fn smoothwave + PartialOrd + Copy>(input: T, max: T) -> T { loop {} } #[derive(Serialize, Deserialize, Debug, Inspect, Default, Clone, Copy)] -pub struct IntRect { - pub(crate) x: i32, - pub(crate) y: i32, - pub(crate) w: i32, - pub(crate) h: i32, -} +pub(crate) struct IntRect {} diff --git a/src/player.rs b/src/player.rs index 6742ca8..871b910 100644 --- a/src/player.rs +++ b/src/player.rs @@ -7,30 +7,4 @@ use crate::{ world::{TPosSc, TilePos}, }; #[derive(Debug, Inspect, Serialize, Deserialize)] -pub(crate) struct Player { - #[inspect_with(inspect_mobile_entity)] - pub(crate) col_en: MobileEntity, - pub(crate) vspeed: f32, - pub(crate) hspeed: f32, -} -fn inspect_mobile_entity(en: &mut MobileEntity, ui: &mut egui::Ui, _id_src: u64) { - loop {} -} -impl Player { - pub(crate) fn new_at(pos: WorldPos) -> Self { - loop {} - } - #[allow(dead_code)] - pub(crate) fn center_tp(&self) -> TilePos { - loop {} - } - pub(crate) fn can_jump(&self) -> bool { - loop {} - } - pub(crate) fn feet_y(&self) -> i32 { - loop {} - } - pub(crate) fn save(&self, path: &Path) { - loop {} - } -} +pub(crate) struct Player {} diff --git a/src/res.rs b/src/res.rs index df982cc..f142179 100644 --- a/src/res.rs +++ b/src/res.rs @@ -1,7 +1,4 @@ use sfml::audio::Music; use crate::texture_atlas::AtlasBundle; #[derive(Debug)] -pub(crate) struct Res { - pub(crate) atlas: AtlasBundle, - pub(crate) surf_music: Music<'static>, -} +pub(crate) struct Res {} diff --git a/src/stringfmt.rs b/src/stringfmt.rs index a1c1c32..5350fd7 100644 --- a/src/stringfmt.rs +++ b/src/stringfmt.rs @@ -1,8 +1,2 @@ use std::fmt; use crate::math::M_PER_PX; -pub(crate) struct LengthDisp(pub f32); -impl fmt::Display for LengthDisp { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - loop {} - } -} diff --git a/src/texture_atlas.rs b/src/texture_atlas.rs index 8bf66a9..a06b78b 100644 --- a/src/texture_atlas.rs +++ b/src/texture_atlas.rs @@ -4,12 +4,4 @@ use sfml::{graphics::Texture, SfBox}; use texture_packer::{texture::Texture as _, TexturePacker, TexturePackerConfig}; pub(crate) type RectMap = HashMap; #[derive(Debug)] -pub(crate) struct AtlasBundle { - pub(crate) tex: SfBox, - pub(crate) rects: RectMap, -} -impl AtlasBundle { - pub(crate) fn new() -> anyhow::Result { - loop {} - } -} +pub(crate) struct AtlasBundle {} diff --git a/src/tiles/tiledb_edit_ui.rs b/src/tiles/tiledb_edit_ui.rs index f48acd9..b448162 100644 --- a/src/tiles/tiledb_edit_ui.rs +++ b/src/tiles/tiledb_edit_ui.rs @@ -6,9 +6,4 @@ use crate::{ }; #[derive(Debug, Default, Inspect)] pub(crate) struct TileDbEdit {} -impl TileDbEdit { - pub(crate) fn ui(&mut self, ctx: &egui::Context, tile_db: &mut TileDb) { - loop {} - } -} use super::{Bg, Fg, Mid, TileDb, TileDef, TileLayer, DEFAULT_TILE_BB}; diff --git a/src/world.rs b/src/world.rs index 996f5d7..75f4245 100644 --- a/src/world.rs +++ b/src/world.rs @@ -12,33 +12,7 @@ use self::serialization::save_chunk; #[derive(Hash, PartialEq, Eq, Debug, Clone, Copy, Inspect)] pub(crate) struct ChunkPos {} #[derive(Debug, Inspect)] -pub(crate) struct World { - pub(crate) player: Player, -} -impl World { - pub(crate) fn new(spawn_point: WorldPos, name: &str, path: PathBuf) -> Self { - loop {} - } - /// Get mutable access to the tile at `pos`. - /// - /// Loads or generates the containing chunk if necessary. - pub(crate) fn tile_at_mut( - &mut self, - pos: TilePos, - worldgen: &Worldgen, - ) -> &mut Tile { - loop {} - } - pub(crate) fn save(&self) { - loop {} - } - pub(crate) fn save_meta(&self) { - loop {} - } - pub(crate) fn save_chunks(&self) { - loop {} - } -} +pub(crate) struct World {} fn loc_byte_idx_xy(x: u8, y: u8) -> usize { loop {} } @@ -55,10 +29,6 @@ const CHUNK_BYTES: usize = CHUNK_N_TILES * TILE_BYTES; const TILE_BYTES: usize = 3 * 2; #[derive(Debug, Clone, Copy)] pub(crate) struct TilePos {} -#[derive(Debug, PartialEq, Eq, Clone, Copy)] -pub(crate) struct ChunkLocalTilePos {} -/// Chunk-local tile position scalar. Supports up to 256 tiles per chunk. -type ChkLocalTPosSc = u8; pub(crate) type TPosSc = u32; pub(crate) const CHUNK_EXTENT: u16 = 128; const CHUNK_N_TILES: usize = CHUNK_EXTENT as usize * CHUNK_EXTENT as usize;