Merge branch '39-game-configuration-fallback' into 'dev'
Resolve "Game Configuration Fallback" See merge request softwaregrundprojekt/2025-2026/einzelprojekt/tutorium-moritz/bernroider-dominik/bernroider-dominik!9
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"grid_width": 10,
|
||||
"grid_height": 10,
|
||||
"pom_speed": 2
|
||||
"grid_width": 12,
|
||||
"grid_height": 4,
|
||||
"pom_speed": 1.5
|
||||
}
|
||||
|
||||
@@ -10,6 +10,16 @@ pub struct GameConfig {
|
||||
pub pom_speed: f32,
|
||||
}
|
||||
|
||||
impl Default for GameConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
grid_width: 12,
|
||||
grid_height: 4,
|
||||
pom_speed: 1.5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_config() -> Option<GameConfig> {
|
||||
let file = File::open("assets/config.json").ok()?;
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_aseprite_ultra::prelude::*;
|
||||
use bevy_dev_tools::fps_overlay::*;
|
||||
use pomomon_garden::config::read_config;
|
||||
use pomomon_garden::config::{GameConfig, read_config};
|
||||
use pomomon_garden::plugins;
|
||||
|
||||
fn main() {
|
||||
let config = read_config().expect("Error reading config");
|
||||
let config = read_config().unwrap_or(GameConfig::default());
|
||||
|
||||
App::new()
|
||||
.add_plugins((
|
||||
|
||||
Reference in New Issue
Block a user