Compare commits

...

2 Commits

Author SHA1 Message Date
Johannes Hendrik Gerard van der Weide adc11ec654 Unfinished levelgen script 2023-12-12 16:59:37 +01:00
Johannes Hendrik Gerard van der Weide 2720215da7 Updated README.md to inform about dev branch 2023-12-12 16:59:12 +01:00
2 changed files with 77 additions and 17 deletions

View File

@ -1,19 +1,5 @@
# RustThingy
This place is a message... and part of a system of messages... pay attention to it!
Sending this message was important to us. We considered ourselves to be a powerful culture.
This place is not a place of honor... no highly esteemed deed is commemorated here... nothing valued is here.
What is here was dangerous and repulsive to us. This message is a warning about danger.
The danger is in a particular location... it increases towards a center... the center of danger is here... of a particular size and shape, and below us.
The danger is still present, in your time, as it was in ours.
The danger is to the body, and it can kill.
The form of the danger is an emanation of energy.
The danger is unleashed only if you substantially disturb this place physically. This place is best shunned and left uninhabited.
Welcome to the development branch!
Expect it to be broken as any progress will be pushed.
If you need a gauranty of it compiling propperly use main.

74
src/levelgen.rs Normal file
View File

@ -0,0 +1,74 @@
use bevy::prelude::*;
use serde::{Serialize, Deserialze};
use std::fs;
use std::path::Path;
pub struct LevelgenPlugin;
impl Plugin for LevelgenPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup_levels)
.add_systems(Update, level_generation);
}
}
#[derive(Serialize, Deserialize)]
pub struct Level {
enemies: Vec<String>,
waves: u32,
treasure: i32,
doors: Vec<bool>,
}
#[derive(Component)]
pub struct LevelGenerator {
levels_exit_north: Vec<String>,
levels_exit_east: Vec<String>,
levels_exit_south: Vec<String>,
levels_exit_west: Vec<String>,
path: Vec<String>,
current_enemies: Vec<u32>,
current_waves: u32,
current_treasure: i32,
}
fn setup_levels(mut commands: Commands) {
let mut initial_level: String = "
# Enemies can only be set if they exist in data/enemies/
# for example data/enemies/grunt.yml
enemies: [
grunt
]
# 0 means no enemies
waves: 1
# 0 is no treasure
treasure: 0
doors: [
true, # North
true, # East
true, # South
true, # West
]
".to_string();
let initial_level_path = Path::new("./data/levels/initial_level.yml");
if initial_level_path.exists() {
initial_level =
fs::read_to_string("./data/levels/initial_level.yml").expect("Error reading data/levels/initial_level.yml");
} else {
fs::write("./data/levels/initial_level.yml", initial_level.clone())
.expect("Error writing data/levels/initial_level.yml");
}
let paths = fs::read_dir("./data/levels/").unwrap();
for path in paths {
}
commands.spawn((
LevelGenerator {
},
));
}
fn level_generation() {
}