mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-17 04:45:02 +01:00
more
This commit is contained in:
parent
613ed710a2
commit
593d85d668
1 changed files with 16 additions and 53 deletions
69
src/app.rs
69
src/app.rs
|
|
@ -1,4 +1,15 @@
|
||||||
use std::fmt::Write;
|
use crate::{
|
||||||
|
command::{Cmd, CmdVec},
|
||||||
|
debug::{self, DebugState},
|
||||||
|
game::{for_each_tile_on_screen, Biome, GameState},
|
||||||
|
graphics::{self, ScreenSc, ScreenVec},
|
||||||
|
input::Input,
|
||||||
|
inventory::{ItemId, Slot, TileLayer, UseAction},
|
||||||
|
math::{center_offset, TILE_SIZE},
|
||||||
|
res::Res,
|
||||||
|
tiles::TileId,
|
||||||
|
CliArgs,
|
||||||
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use egui_sfml::SfEgui;
|
use egui_sfml::SfEgui;
|
||||||
|
|
@ -6,21 +17,13 @@ use gamedebug_core::{imm, imm_dbg};
|
||||||
use sfml::{
|
use sfml::{
|
||||||
audio::SoundSource,
|
audio::SoundSource,
|
||||||
graphics::{
|
graphics::{
|
||||||
BlendMode, Color, Rect, RectangleShape, RenderStates, RenderTarget,
|
BlendMode, Color, Rect, RectangleShape, RenderStates, RenderTarget, RenderTexture,
|
||||||
RenderTexture, RenderWindow, Shape, Sprite, Transformable, View,
|
RenderWindow, Shape, Sprite, Transformable, View,
|
||||||
},
|
},
|
||||||
system::{Vector2, Vector2u},
|
system::{Vector2, Vector2u},
|
||||||
window::{Event, Key},
|
window::{Event, Key},
|
||||||
};
|
};
|
||||||
use crate::{
|
use std::fmt::Write;
|
||||||
command::{Cmd, CmdVec},
|
|
||||||
debug::{self, DebugState},
|
|
||||||
game::{for_each_tile_on_screen, Biome, GameState},
|
|
||||||
graphics::{self, ScreenSc, ScreenVec},
|
|
||||||
input::Input, inventory::{ItemId, Slot, TileLayer, UseAction},
|
|
||||||
math::{center_offset, TILE_SIZE},
|
|
||||||
res::Res, tiles::TileId, CliArgs,
|
|
||||||
};
|
|
||||||
/// Application level state (includes game and ui state, etc.)
|
/// Application level state (includes game and ui state, etc.)
|
||||||
pub(crate) struct App {
|
pub(crate) struct App {
|
||||||
pub(crate) rw: RenderWindow,
|
pub(crate) rw: RenderWindow,
|
||||||
|
|
@ -43,42 +46,9 @@ impl App {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
pub(crate) fn do_game_loop(&mut self) {
|
pub(crate) fn do_game_loop(&mut self) {
|
||||||
while !self.should_quit {
|
self.do_rendering();
|
||||||
self.do_event_handling();
|
|
||||||
self.do_update();
|
|
||||||
self.do_rendering();
|
|
||||||
self.input.clear_pressed();
|
|
||||||
gamedebug_core::inc_frame();
|
|
||||||
}
|
|
||||||
self.game.tile_db.try_save();
|
|
||||||
self.game.world.save();
|
|
||||||
}
|
|
||||||
fn do_event_handling(&mut self) {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
fn do_update(&mut self) {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
fn do_freecam(&mut self) {
|
|
||||||
loop {}
|
|
||||||
}
|
}
|
||||||
fn do_rendering(&mut self) {
|
fn do_rendering(&mut self) {
|
||||||
self.game.light_pass(&mut self.light_map, &self.res);
|
|
||||||
self.rt.clear(Color::rgb(55, 221, 231));
|
|
||||||
self.game.draw_world(&mut self.rt, &mut self.res);
|
|
||||||
self.game.draw_entities(&mut self.rt);
|
|
||||||
self.rt.display();
|
|
||||||
let mut spr = Sprite::with_texture(self.rt.texture());
|
|
||||||
spr.set_scale((self.scale as f32, self.scale as f32));
|
|
||||||
let vco = viewport_center_offset(self.rw.size(), self.rt.size(), self.scale);
|
|
||||||
spr.set_position((vco.x as f32, vco.y as f32));
|
|
||||||
self.rw.clear(Color::rgb(40, 10, 70));
|
|
||||||
self.rw.draw(&spr);
|
|
||||||
let mut rst = RenderStates::default();
|
|
||||||
rst.blend_mode = BlendMode::MULTIPLY;
|
|
||||||
self.light_map.display();
|
|
||||||
|
|
||||||
|
|
||||||
self.sf_egui
|
self.sf_egui
|
||||||
.do_frame(|ctx| {
|
.do_frame(|ctx| {
|
||||||
debug::do_debug_ui(
|
debug::do_debug_ui(
|
||||||
|
|
@ -91,12 +61,5 @@ impl App {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
}
|
|
||||||
fn execute_commands(&mut self) {
|
|
||||||
loop {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn viewport_center_offset(rw_size: Vector2u, rt_size: Vector2u, scale: u8) -> ScreenVec {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue