mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-14 19:55:02 +01:00
manual
This commit is contained in:
parent
dac93f611b
commit
ded76b32b8
15 changed files with 39 additions and 261 deletions
16
src/app.rs
16
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 {
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
65
src/debug.rs
65
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 {}
|
||||
}
|
||||
|
|
|
|||
38
src/game.rs
38
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 {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
20
src/input.rs
20
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 {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
36
src/math.rs
36
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<N: From<u8> + 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<T: Num + From<u8> + 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 {}
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,4 @@ use sfml::{graphics::Texture, SfBox};
|
|||
use texture_packer::{texture::Texture as _, TexturePacker, TexturePackerConfig};
|
||||
pub(crate) type RectMap = HashMap<String, IntRect>;
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct AtlasBundle {
|
||||
pub(crate) tex: SfBox<Texture>,
|
||||
pub(crate) rects: RectMap,
|
||||
}
|
||||
impl AtlasBundle {
|
||||
pub(crate) fn new() -> anyhow::Result<Self> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
pub(crate) struct AtlasBundle {}
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
32
src/world.rs
32
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue