Better map system, 2d with collision

This commit is contained in:
deadvey 2025-02-25 21:22:35 +00:00
parent 4fceee3856
commit b0318ab4da
15 changed files with 190 additions and 168 deletions

View File

@ -8,3 +8,4 @@ colored = "2.2.0"
termion = "4.0.3"
serde = { version = "1.0.127", features = ["derive"] }
serde_json = "1.0"
lazy_static = "1.4"

View File

@ -5,8 +5,8 @@
"mining": 0
},
"coordinates": {
"x": 100,
"z": 29,
"x": 85,
"z": 17,
"map": "world"
},
"inventory": [

View File

@ -1,66 +1,66 @@
''''''''''''####'''''''''''''''''''''''''''''''''''####''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''#;;#'''''''''''''''''''''''''''''''''''#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''#;;;###################################;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''##;;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;;##''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;###################%%%%##########;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#########;##########;;;;;;;##########;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#######%#;####%%%%%#;;;;;;;#%%%%%%%%#;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;;;;;;;;;;;#%%%%%#;;;;;;;#####%####;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''''#;;;#######;;#%%%%%#;;;;;;;;;;;;;;;;;;#''''''''''''''''''''''''''''''''''''''';;;;;;;;;'''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''###;;##%%%%%#;;###%%##;;;;;;;;####%###;####''''''''''''''''''''''''''''''''';;;;;;'''''';;;;;;;;'''''''''[[[[[[[[[[[[[[[[[[[[[[[[
''''''''''''#;;;;#%%%%%%%;;;;;;;;;;;;;;;;;#%%%%%%#;;;;#'''''''''''''''''''''''''';;;;;;;'''''''''''''''''';;;;;''''''''';;;;[[[[[[[[[[[[[[[[[
''''''''''''#;;###################;;;;;;;###########;;#'''''''''''''''''''''';;;;;;''''''''''''''''''''''''''';;;;;;;;;;;;;;[[[[[[[[[[[[[[[[[
''''''''''''####'''''''''''''''''';;;;;;;''''''''''####''''''''''''';;;;;;;;;;'''''''''''''''''''''''''''''''''''''''';;;;;;''[[[[[[[[[[[[[[[
'''''''''''''''''''''''''''''''''';;;;;;;''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''''''''''''''''''''''';;;''''''''[[[[[[[[[[
''''''''''''''''''''''''''''''''''';;;;;;;;''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''[[[
''''''''''''####'''''''''''''''''''''''''''''''''''####''''''''''''''''''''''''''''''''''''''''''''''^^^^^^^^^^^^^^^^^^^^^^^^^^^[^^^^^^^^^^^^
''''''''''''#;;#'''''''''''''''''''''''''''''''''''#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''^^^^^^^^^^^^^^^^^^[[[[[^^^^^^^^^^^
''''''''''''#;;;###################################;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^^^^^^^^[[[[[[[[^^^^^^^^^^^^
''''''''''''##;;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;;##''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[^^^^^^^^^^^
''''''''''''''#;;#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[^^^^^^^^^^
''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[[[[[^^^^^^
''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[[[[[^^^^^^
''''''''''''''#;;###################%%%%##########;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[[[[[[[^^^^^
''''''''''''''#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[[[[[[^^^
''''''''''''''#########;##########;;;;;;;##########;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[[[[[^^^^
''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[^^^^^
''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[[[^^^^
''''''''''''''#######%#;####%%%%%#;;;;;;;#%%%%%%%%#;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[^^^^^
''''''''''''''#;;;;;;;;;;;;#%%%%%#;;;;;;;#####%####;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[^^^^^^
''''''''''''''#;;;#######;;#%%%%%#;;;;;;;;;;;;;;;;;;#''''''''''''''''''''''''''''''''''''''';;;;;;;;;'''''''''''''''^^[[[[[[[[[[[[[[[[[^^^^^^
''''''''''''###;;##%%%%%#;;###%%##;;;;;;;;####%###;####''''''''''''''''''''''''''''''''';;;;;;'''''';;;;;;;;'''''''''^^^^[[[[[[[[[[[[^^^^^^^^
''''''''''''#;;;;#%%%%%%%;;;;;;;;;;;;;;;;;#%%%%%%#;;;;#'''''''''''''''''''''''''';;;;;;;'''''''''''''''''';;;;;''''''''';;;;^^[[[[[[^^^^^^^^^
''''''''''''#;;###################;;;;;;;###########;;#'''''''''''''''''''''';;;;;;''''''''''''''''''''''''''';;;;;;;;;;;;;;^^^^^^^^^^^^^^^^^
''''''''''''####'''''''''''''''''';;;;;;;''''''''''####''''''''''''';;;;;;;;;;'''''''''''''''''''''''''''''''''''''''';;;;;;''^^^^^^^^^^^^^^^
'''''''''''''''''''''''''''''''''';;;;;;;''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''';;;''''''''^^^^^^^^^^
''''''''''''''''''''''''''''''''''';;;;;;;;''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''^^^
'''''''''''''''''''''''''''''''''''';;;;;;;''''''''''''''''''';;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''
'''''''''''''''''''''''''''''''''''';;;;;;;;;;''''''''''''''';;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''
'''''''''''''''''''''''''''''''''''';;;;;;;;;;''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''';;;;;;;''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''';;;;;;'''''';;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''
''''''''''''''''~''''''''''''''''''''''''''''''''''''''''''~';;'''''''''''''''~'''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''
''''''''''''''''~~~~~~~~'''''''''''''''''''''''''''''''''''~';;''''''''''''''~~''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''''
'''''''''''''''''''''''~~~~~'''''''''''''''''''''''''''''''~';;''''''''''''~~~~'''''''''''''''''''''''''''''''''';'''''''''''''''''''''''''''
'''''''''''''''''''''''~~~~~'''''''''''''''''''''''''''''''~';;''''''''''''~~~~''''''''''''''''''''''''''''''''';'''''''''''''''''''''''''''
''''''''''''''''''''''''''~~~'''''''''''''''''''''''''''''~~';;'''''''''~~~~'''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~'''''''''''''''''''''''''''''~~';;'''''''''~~~'''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~';;'''''''''~~~'''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~'';;;'''''''~~~'''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~'''';;'''''~~'''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~~'''''''''''''''''''''''''''~~''''';'''~~~''''''''''''''''''''''''''''''''''';;;;'''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~'''';;'''''~~''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~~'''''''''''''''''''''''''''~~'''';'''~~~''''''''''''''''''''''''''''''''''';;;;'''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''~~~'''~~~''''''''''''''''''''~~'''''';;'~~~''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''~~''~~~~~'''''''''''''''''''~~'~~~~~%%~~~''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''~~~~~~~~~~'''''''''''''''''~~~~~~~~~~%%~'''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''~~~~~~~~~~'''''''♣'''''''''~~~~~~~~~~%%~'''♣'''''''''''♣'''''''''''''''''''';;;''''''''''''''''''''''''''''''''''
::''''''''''''''''''''''''''~~~~~'''''~~~~~''''''''''''~~~~~''''';;'''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;;;'''''''''''''''''''''''
:::::::'''''''''''''''''''''~~~~''''''''~~~~''''''''~~~~~~~'''''';;'''''''''''''''''''''''''''''''''';;;;;'''''''''''';;;''''''''''''''''''''
::::::::::::'''''''''''''::::~~~'''''''''''~~~~~'''~~~~'''''''''';;;;''''''''''''''''''''''''''''''';;;''''''''''''''''';;;;'''''''''''''''''
::::::::::::::::::'''':::::~~~~~''''''''''''~~~~~~~~~~~'''''''''''';;;;''''''''''''''''''''''''''';;;'''''''''''''''''''''';;;;''''''''''''''
:::::::::::::::::::::::::~~~~~:''''''''''''''''~~~~~''''''''''''''''';;''''''''''''''''''';;;;;;;;;;;;%%%'''''''''''''''''''''';;;;;'''''''''
:::::::::::::::::::::::~~~~~:::''''''''''''''''''''''''''''''''''''''';;;'''''''''''''';;;;;''''';;;;;%"%%%%''''''''''''''''''''''';;;;''''''
:::::::::::::::::::::::~~~~::::'''''''''''''''''''''''''''''''''''''''';;'''''''''''';;;'''''''%%%;;;;%%%""%%%%%%%%%%''''''''''''''''';;;;;''
~:::::::::::::::::::::~~~~~:::::''''''''''''''''''''''''''''''''''''''';;;'''''''''';;;'''''''%%"%""""""""""""""""""%%%%''''''''''''''''';;;;
~~~~~~:::::::::::::::~~~~~:::::::'''''''''''''''''''''''''''''''''''''''';''''''''';;;'''''''%"%%%""""""""""%%%%%%"""""%%'''''''''''''''''';;
~~~~~~~~~~:::::::~~~~~~~~:::::::::'''''''''''''''''''''''''''''''''''''''';;;;;;;;;;'''''''%%%"""""""""""""%"""""%%%""""%''''''''''''''''''''
~~~~~~~~~~~~~~:::~~~~~~~~:::::::::::''''''''''''''''''''''''''''''''''''''''';;;;'''''''''%%"""""""""""""""%"""""""%""""%''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::''''''''''''''''''''''''''''''''''';;;;''''''''''''%"""%%%%""%%""""""""""""%%""""%''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::'''''''''''''''''''''''''''''';;;;;''''''''''''''%"""%""""""%"""""%%%%%%%""""""%''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::::'''''''''''''''''''''''';;;;;;'''''''''''''''''%"""%""""""%""""""""""""""""""%''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::::'''''''''''';;;;;;;;;;;;''''''''''''''''''''''%"""%%"""""%""""%""%%%""""""""%''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::'''''''';;;''''''''''''''''''''''''''''''''''%%""""%%%%%""""%""""""%%%"""""%''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::'''';;;'''''''''''''''''''''''''''''''''''''%%%"""""""""""%""""""""%%""""%''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::''';;''''''''''''''''''''''''''''''''''''''''%%%""""""""""%%%%%%%%%""""%%''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::';;''''''''''''''''''''''''''''''''''''''''''%%%%%%%%%%%%%""""""""%%%%'''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::;;:::'''''''''''''''''''''''''''''''''''''''''''''''''''''%%%%%%%%%%''''''''''''''''''''''~~
::::::::::::::::::'''':::::~~~~~''''''''''''~~~~~~~~~~~'''''''♣'''';;;;'''''♣''''''''''''''''''''';;;'''''''''''''''''''''';;;;''''''''''''''
:::::::::::::::::::::::::~~~~~:''''''''''''''''~~~~~''''''''''''''''';;''''''''''''''''''';;;;;;;;;;;;==='''''''''''''''''''''';;;;;'''''''''
:::::::::::::::::::::::~~~~~:::''''''''''''''''''''''''''''''''''''''';;;'''''''''''''';;;;;''''';;;;;="====''''''''''''''''''''''';;;;''''''
:::::::::::::::::::::::~~~~::::'''''''''''''''''''''''''''''''''''''''';;'''''''''''';;;'''''''===;;;;===""==========''''''''''''''''';;;;;''
~:::::::::::::::::::::~~~~~:::::''''''''''''''''''''''''''''''''''''''';;;''''''''♣';;;'''''''=="=""""""""""""""""""====''''''''''''''''';;;;
~~~~~~:::::::::::::::~~~~~:::::::''''''''''''''''''''''''''''''''''''''';''''''''';;;'''''''="===""""""""""======"""""=='''''''''''''''''';;
~~~~~~~~~~:::::::~~~~~~~~:::::::::'''''''''''''''''''''''''''''''''''''''';;;;;;;;;;'''''''==="""""""""""""="""""===""""=''''''''''''''''''''
~~~~~~~~~~~~~~:::~~~~~~~~:::::::::::''''''''''''''''''''''''''''''''''''''''';;;;'''''''''=="""""""""""""""="""""""=""""=''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::''''''''''''''''''''''''''''''''''';;;;''''''''''''="""====""==""""""""""""==""""=''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::'''''''''''''''''''''''''''''';;;;;''''''''''''''="""=""""""="""""=======""""""=''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::::'''''''''''''''''''''''';;;;;;'''''''''''''''''="""=""""""=""""""""""""""""""=''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::::'''''''''''';;;;;;;;;;;;''''''''''''''''''''''="""=="""""=""""=""===""""""""=''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::'''''''';;;''''''''''''''''''''''''''''''''''==""""=====""""=""""""==="""""=''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::'''';;;'''''''''''''''''''''''''''''''''''''==="""""""""""=""""""""==""""=''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::''';;''''''''''''''''''''''''''''''''''''''''===""""""""""=========""""==''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::';;''''''''''''''''''''''''''''''''''''''''''=============""""""""===='''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::;;:::'''''''''''''''''''''''''''''''''''''''''''''''''''''==========''''''''''''''''''''''~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::;;;;;:::::::''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;;;:::::::::::::'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;;;~~~~:::::::::::::'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

8
resources/alphabet.info Normal file
View File

@ -0,0 +1,8 @@
a b c d e f g h i j k l m n o p q r s t u v w x y z sh th(this) th(thing) ch 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ! ? " " sus/odd
Ь s d ⫮ g \ : i ʎ l ʍ ∩ ρ ٩ / s + V w ks ʃ 6(reversed) O Ј 0 | z 3 X S 6 ) 8 9 a u c ↋ e ٩ ¡! ¿? <<>> ඞ
hello how are you? -> ¿\ll \w / w?
fuck off, wanker! -> ⫮∪ʎ ∪⫮ w∩ʎ!

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 15 MiB

After

Width:  |  Height:  |  Size: 15 MiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

24
src/blocks.rs Normal file
View File

@ -0,0 +1,24 @@
use crate::HashMap;
// key = block character
// element = color (array), collision (bool), pretty name (&str)
lazy_static! {
pub static ref BLOCKS: HashMap<char, Vec<([u8; 3], bool, &'static str)>> = {
let mut map = HashMap::new();
map.insert('X', vec![([255, 0, 0], false, "Null")]);
map.insert('\'', vec![([0, 255, 0], false, "Grass")]);
map.insert('"', vec![([153, 102, 0], false, "Dirt")]);
map.insert(';', vec![([128, 128, 128], false, "Cobbles")]);
map.insert('~', vec![([0, 0, 255], true, "Water")]);
map.insert('D', vec![([0, 128, 128], true, "Diamond Ore")]);
map.insert('C', vec![([0, 0, 0], true, "Coal")]);
map.insert('i', vec![([138, 74, 24], true, "Iron Ore")]);
map.insert('%', vec![([195, 162, 103], false, "Wooden Planks")]);
map.insert('=', vec![([190, 170, 100], true, "Wooden Wall")]);
map.insert(':', vec![([195, 162, 103], false, "Sand")]);
map.insert('[', vec![([196, 196, 196], false, "Rock")]);
map.insert('^', vec![([196, 128, 196], true, "Mountain")]);
map.insert('#', vec![([255, 196, 196], true, "Stone Bricks")]);
map.insert('♣', vec![([0, 153, 51], true, "Oak Tree")]);
map
};
}

View File

@ -23,18 +23,3 @@ pub fn clear_screen()
.expect("Failed to clear screen");
}
pub fn read_element_from_map(vector: &Vec<Vec<char>>, index1: usize, index2: usize) -> Result<char, ()>
{
if vector.len() <= index1
{
Err(())
}
else if vector[index1].len() <= index2
{
Err(())
}
else
{
Ok(vector[index1][index2])
}
}

View File

@ -24,7 +24,7 @@ pub fn initialise() -> Player
inventory: vec!
{
("axe".to_string(), 1),
("vape".to_string(), 1)
("morphine pill".to_string(), 1)
}
};
return player;

View File

@ -1,6 +1,7 @@
use std::fs;
use std::process::{Command};
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
// Declare the modules from these files
mod parse_map; // parse_map.rs
@ -10,6 +11,10 @@ mod initialise; // initialise.rs, creates a new character
mod function; // function.rs, for misc functions
mod process_input; // process_input.rs
#[macro_use]
extern crate lazy_static;
mod blocks;
pub enum GameAction {
Continue,
Exit,
@ -36,7 +41,7 @@ struct Player {
inventory: Vec<(String, u64)>,
}
const DEBUG_MODE: bool = false;
const DEBUG_MODE: bool = true;
fn main()
{
@ -51,7 +56,7 @@ fn main()
{
println!("{:?}", player);
}
if let Ok((ground_map, above_map)) = parse_map::parse_map(&player.coordinates) // Call the parse map function from parse_map.rs
if let Ok(map) = parse_map::parse_map(&player.coordinates) // Call the parse map function from parse_map.rs
{ // Parse the map file into a vector
if DEBUG_MODE == false
{
@ -59,8 +64,8 @@ fn main()
}
output_map::output_map // Call output_map fuctino from output_map.rs
(
&ground_map,
&above_map,
&map,
&blocks::BLOCKS,
&player.coordinates,
); // Output the map
'game_loop: loop
@ -71,8 +76,8 @@ fn main()
(
user_input,
&mut player,
&ground_map,
&above_map,
&map,
&blocks::BLOCKS,
);
if let Err(e) = save::save(&save_file_path, &player)

View File

@ -3,59 +3,70 @@ use std::collections::HashMap;
use crate::Coordinates;
use crate::DEBUG_MODE;
use crate::function;
// Output the map based on map vector
pub fn output_map(
ground_map: &Vec<Vec<char>>,
above_map: &Vec<Vec<char>>,
map: &Vec<Vec<char>>,
blocks: &HashMap<char, Vec<([u8; 3],bool, &str)>>,
player_coordinates: &Coordinates,
)
{
let (screen_width, screen_height) = termion::terminal_size().unwrap();
let distance_you_can_see: [i16; 2] =
let mut distance_you_can_see: [[i16; 2]; 2] =
[
(screen_width as f32 / 2.0) as i16,
(screen_height as f32 / 2.0) as i16
[
(player_coordinates.x as f32 - (screen_width as f32 / 2.0)) as i16,
(player_coordinates.x as f32 + (screen_width as f32 / 2.0)) as i16,
],
[
(player_coordinates.z as f32 - (screen_height as f32 / 2.0)) as i16,
(player_coordinates.z as f32 + (screen_height as f32 / 2.0)) as i16,
],
];
// Dynamic sizing of output, I forgot how this works, don't change pls
// X
if distance_you_can_see[0][0] < 0
{
distance_you_can_see[0][1] -= distance_you_can_see[0][0];
distance_you_can_see[0][0] = 0;
}
if distance_you_can_see[0][1] > map[player_coordinates.z as usize].len() as i16
{
distance_you_can_see[0][0] -= map[player_coordinates.z as usize].len() as i16 - distance_you_can_see[0][1];
distance_you_can_see[0][1] = map[player_coordinates.z as usize].len() as i16;
}
// Z
if distance_you_can_see[1][0] < 0
{
distance_you_can_see[1][1] -= distance_you_can_see[1][0];
distance_you_can_see[1][0] = 0;
}
if distance_you_can_see[1][1] > map.len() as i16
{
distance_you_can_see[1][0] -= map.len() as i16 - distance_you_can_see[1][1];
distance_you_can_see[1][1] = map.len() as i16;
}
// Output debug info
if DEBUG_MODE == true
{
println!("{:?}", player_coordinates);
println!("Screen Width: {}, Screen Height: {}", screen_width, screen_height);
println!("{:?}", distance_you_can_see);
}
let blocks: HashMap<char, [u8; 3]> =
[
('X', [255,0, 0]), // Null
('\'', [0, 255,0]), // Grass
('"', [153,102,0]), // Dirt
(';', [128,128,128]), // Cobbles
('~', [0, 0, 255]), // Water/sea
('D', [0, 128,128]), // Diamond
('C', [0, 0, 0]), // Coal
('i', [138,74 ,24]), // Iron
('%', [195,162,103]), // Wood planks
(':', [195,162,103]), // Sand
('[', [196,196,196]), // Stone
('^', [196,128,196]), // Mountain
('#', [255,196,196]), // Stone bricks
('♣', [0, 153,51]), // Oak tree
]
.iter().cloned().collect();
// Loop over array and print each block
for z in player_coordinates.z - distance_you_can_see[1]..player_coordinates.z + distance_you_can_see[1]
for z in distance_you_can_see[1][0]..distance_you_can_see[1][1]
{
if z >= 0 && z < ground_map.len() as i16
if z >= 0 && z < map.len() as i16
{
for x in player_coordinates.x - distance_you_can_see[0]..player_coordinates.x+distance_you_can_see[0]
for x in distance_you_can_see[0][0]..distance_you_can_see[0][1]
{
if x >= 0 && x < ground_map[z as usize].len() as i16
if x >= 0 && x < map[z as usize].len() as i16
{
let character: char = ground_map[z as usize][x as usize];
let mut above_character: char = ' ';
if let Ok(above_element) = function::read_element_from_map(&above_map, z as usize, x as usize)
{
above_character = above_element;
}
let character: char = map[z as usize][x as usize];
// Check if the character is at the current coordinates
if z == player_coordinates.z && x == player_coordinates.x
{
@ -67,21 +78,6 @@ pub fn output_map(
.truecolor(0,0,0)
)
}
// Else check if there's something on the above y level
else if blocks.contains_key(&above_character) && above_character != ' '
{
print!
(
"{}",
above_character // Output's the current block
.to_string()
.truecolor(
blocks.get(&above_character).unwrap()[0],
blocks.get(&above_character).unwrap()[1],
blocks.get(&above_character).unwrap()[2]
)
)
}
// Else print what is below (the ground)
else if blocks.contains_key(&character)
{
@ -91,9 +87,9 @@ pub fn output_map(
character // Output's the current block
.to_string()
.truecolor(
blocks.get(&character).unwrap()[0],
blocks.get(&character).unwrap()[1],
blocks.get(&character).unwrap()[2]
blocks.get(&character).unwrap()[0].0[0],
blocks.get(&character).unwrap()[0].0[1],
blocks.get(&character).unwrap()[0].0[2]
)
)
}
@ -106,9 +102,9 @@ pub fn output_map(
"X"
.to_string()
.truecolor(
blocks.get(&'X').unwrap()[0],
blocks.get(&'X').unwrap()[1],
blocks.get(&'X').unwrap()[2]
blocks.get(&'X').unwrap()[0].0[0],
blocks.get(&'X').unwrap()[0].0[1],
blocks.get(&'X').unwrap()[0].0[2]
)
)
}

View File

@ -3,51 +3,30 @@ use crate::Coordinates;
// This function reads the map file and puts it into a 2d vector of integers, each integer
// Refers to a block (see top comment) and the function returns this vector
pub fn parse_map(player_coordinates: &Coordinates) -> Result<(Vec<Vec<char>>, Vec<Vec<char>>), u8>
pub fn parse_map(player_coordinates: &Coordinates) -> Result<Vec<Vec<char>>, u8>
{
let mut ground_map: Vec<Vec<char>> = Vec::new(); // Initialises the Ground map vector
let mut above_map: Vec<Vec<char>> = Vec::new(); // Initialises the Above Ground map vector
let ground_file = format!("data/{}_ground.map",player_coordinates.map);
let above_file = format!("data/{}_above.map",player_coordinates.map);
let mut map: Vec<Vec<char>> = Vec::new(); // Initialises the Ground map vector
let map_file = format!("data/{}.map",player_coordinates.map);
// Read the ground map file
if let Ok(parsed_ground_file_contents) = fs::read_to_string(&ground_file)
if let Ok(parsed_map_file_contents) = fs::read_to_string(&map_file)
{
let ground_file_contents = parsed_ground_file_contents;
let ground_rows = ground_file_contents.split("\n").collect::<Vec<_>>(); // Split the file contents into rows
let map_file_contents = parsed_map_file_contents;
let map_rows = map_file_contents.split("\n").collect::<Vec<_>>(); // Split the file contents into rows
// Loop over each row to parse each column of it
for row in 0..ground_rows.len()
for row in 0..map_rows.len()
{
// Turn each column into an integer and collect it into a row vector
let current_row = ground_rows[row].chars().collect();
ground_map.push(current_row); // Then push this vector to the full map vector
let current_row = map_rows[row].chars().collect();
map.push(current_row); // Then push this vector to the full map vector
}
}
else
{
eprintln!("Error: Could not read file: {}", ground_file);
return Err(1)
}
// Read the above ground map file
if let Ok(parsed_above_file_contents) = fs::read_to_string(&above_file)
{
let above_file_contents = parsed_above_file_contents;
let above_rows = above_file_contents.split("\n").collect::<Vec<_>>(); // Split the file contents into rows
// Loop over each row to parse each column of it
for row in 0..above_rows.len()
{
// Turn each column into an integer and collect it into a row vector
let current_row = above_rows[row].chars().collect();
above_map.push(current_row); // Then push this vector to the full map vector
}
}
else
{
eprintln!("Error: Could not read file: {}", ground_file);
eprintln!("Error: Could not read file: {}", map_file);
return Err(1)
}
return Ok((ground_map, above_map))
return Ok(map)
}

View File

@ -1,4 +1,6 @@
use std::fs;
use std::collections::HashMap;
use crate::GameAction;
use crate::Player;
use crate::DEBUG_MODE;
@ -9,8 +11,8 @@ pub fn process_input
(
user_input: String,
player: &mut Player,
ground_map: &Vec<Vec<char>>,
above_map: &Vec<Vec<char>>,
map: &Vec<Vec<char>>,
blocks: &HashMap<char, Vec<([u8; 3],bool, &str)>>,
) -> GameAction
{
// Split commands up, so "help && travel 5" > [["help"], ["travel", "5]]
@ -42,21 +44,21 @@ pub fn process_input
{
match command[0].to_lowercase().as_str()
{
"help"|"h" =>
"help"|"h"|":h" =>
if let Ok(help_text) = fs::read_to_string("data/help.txt") // Output text from help file
{
println!("\n{}", help_text);
},
"exit"|"quit"|"q" =>
"exit"|"quit"|"q"|":q"|":wq" =>
{
return GameAction::Exit;
},
"map"|"world" =>
"map"|"world"|"m" =>
{
output_map::output_map // Call output_map fuctino from output_map.rs
(
&ground_map,
&above_map,
&map,
&blocks,
&player.coordinates,
); // Output the map
},
@ -64,6 +66,25 @@ pub fn process_input
{
function::clear_screen();
},
"player" =>
{
println!("{:?}", player);
},
/*
"cut"|"chop"|"mine"|"pick"|"axe"|"destroy" =>
{
let vector: &str = command[1];
match vector
{
"north"|"n"|"up" |"u" => player.coordinates.z -= 1,
"east" |"e"|"right"|"r" => player.coordinates.x += 1,
"south"|"s"|"down" |"d" => player.coordinates.z += 1,
"west" |"w"|"left" |"l" => player.coordinates.x -= 1,
_ => {println!("Invalid travel direction"); break;},
}
},
*/
"travel"|"move"|"go" =>
{
let mut magnitude: usize = 1;
@ -96,6 +117,7 @@ pub fn process_input
}
for _block in 0..magnitude
{
// Movement
match vector
{
"north"|"n"|"up" |"u" => player.coordinates.z -= 1,
@ -104,7 +126,10 @@ pub fn process_input
"west" |"w"|"left" |"l" => player.coordinates.x -= 1,
_ => {println!("Invalid travel direction"); break;},
}
if above_map[player.coordinates.z as usize][player.coordinates.x as usize] != ' '
// Collision
let character: char = map[player.coordinates.z as usize][player.coordinates.x as usize];
if blocks.get(&character).unwrap()[0].1 == true
{
println!("Bumped into something!");
match vector

View File

@ -1,4 +1,3 @@
use serde::{Serialize, Deserialize};
use std::io::{self, Write};
use std::fs::File;