Compare commits

...

6 Commits

Author SHA1 Message Date
43e770ba4e timeline 2025-02-26 22:45:43 +00:00
8b8d493df2 going to bed soon 2025-02-25 22:56:00 +00:00
b0318ab4da Better map system, 2d with collision 2025-02-25 21:22:35 +00:00
4fceee3856 better error handling on loading above map, TODOL: Optimise map parsing 2025-02-21 04:07:50 +00:00
2b809d7450 small map change 2025-02-20 22:03:19 +00:00
77c036e1fc re did map 2025-02-20 22:00:40 +00:00
19 changed files with 366 additions and 256 deletions

View File

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

View File

@@ -5,18 +5,18 @@
"mining": 0 "mining": 0
}, },
"coordinates": { "coordinates": {
"x": 41, "x": 85,
"z": 30, "z": 25,
"map": "world" "map": "world"
}, },
"inventory": [ "inventory": [
[ [
"axe", "Steel Axe",
1 1
], ],
[ [
"vape", "Morphine",
1 2
] ]
] ]
} }

77
data/world.map Normal file
View File

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

View File

@@ -1,71 +1,77 @@
88888 88888 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #### #### ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 8 8 8 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #### #### ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 8888888888888888888888888 8 ^^^^^^^^^^^^^^^^^^^^^^^^^ ########################################### ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 8 ^^^^^^^^^^^^^^^^^^^^^ #### # # # # # #### ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
88888888 88888888 888 888888 ^^^^^^^^^^^^^^^^^^^ # # # # ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
8 8 8 8 8 8888 88 ^^^^^^^^^^^^^^^^^^^^ # # # # # # # ^ ^^^^^^^^^^^^^^^^^^^^^
8 8 8 8 8 8 8 ^^^^^^^^^^^^^^^^^^^^^ # # # # # # # ^ ^^^^^^^^^^^^^^^^^
88888888 8 8 8 8 8 88888 ^^^^^^^^^^^^^^^^^^^^^ # ################### ########## # ^^^ ^^^^^^^^^
8 8 8 8 8 8 8 8 ^^^^^^^^^^^^^^^^^^^^ ^ # # ^ ^^^^^^^^^
8 8888888888888888 88888888888 8 8 ^^^^^^^^^^^^^^^^^^D ^^ ######### ########## ########## # ^^^ ^^^^^^^^^
8 8 8 888888888 ^^^^^^^^^^^^^^D ^^^ # # # # # # # ^ ^^^^^^^^
88888888 8888888 88888888 88888888 ^^^^^^^^^^^ ^^^^^ # # # # # # # ^^ ^^^^^^^
8 8 8 8 8 8 8 ^^^^^^^ ^^^ ####### # #### # # # # ^ ^^^^^
8 8 8 8 8 8888888 ^^^^ CC # # # ##### #### # ^^^ ^^^^^
8 8 8 88888888 8 8 ^^ C CC C C # ####### # # # ^^ ^^^^^
8 88888 8 8 8 8 ^CC C CCC CC C #### ## # ### ## #### ### #### ^^^^^ ^^^^^
8 8888 8 88 88888888 ^^i CC CCC CCC #### # # # #### ^ ^^^^^
8 88888 8 8 8 8 8 8 ^^^ii CC ###################### ############## ^^^ ^^^^^
8888888 8 8 8 8 8 8888888 ^^^i CC #### #### ♣ ^^^^^^^^^^^^^^^
8 8 88888888 8 88888888 8 ^^^^ i C ♣ ^^^^^^^^^^
8 8 888888 8^^^ ii C ^^^
8 88888 8 8 8 888 88888 ♣^^^^ iiCC C
88888 8 8 8 8 ^^ CC C
8 88888888888888 8888888 8^ C
8 8 8 8 ^ CC
88888 888888 88888 ♣ ♣ ^ CC
8 8 ^ CC
8 C^
888888 ♣ ♣ ^ CCC^^
^^^^^^^^^^
^^^^^^^^
♣ ♣ ^^^^^^^
♣ ♣ ^^^
^
♣ ♣
♣ ♣
♣ ♣
♣ ♣
♣ ♣
%%%%
% %
♣ % %
%%% %% ♣ %%%
% % %%%%
%% % %%% %%% %%%%%%%%%%
♣ ♣ % %%%% ♣ %% % %%%%
% % % % % %%% %%%%%% %%
%%%% % % %%% % %%% %
% % % % ♣ ♣ %% % % %
%%%%%%% % % %%% % %%%% %% %% %
% % % % ♣ % % % %%%%%%% %
% % %%% % % % % % %
% %%%%% % % %% % % %%% %
%%% %%%%%%%% %% %%%%% % %%% %
% %% %%% % %% %
% %%% %%%%%%%%% %%
%%%%%%%%% %%%%%%%%%%%%% %%%%
%%%%%%%%%%
%%%%
% %
%%%% ###
# #
###

View File

@@ -1,71 +0,0 @@
'''''''';;;;;;'''''''''''''''''''''';;;;;'''''''''''''''''''''';;''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
'''''''';;;;;;'''''''''''''''''''''';;;;;''''''''''''''''''''''';;''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
'''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''''''''''''''''''';;''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[
'''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''''''''''''''''''';;'''''''''''''[[[[[[[[[[[[[[[[[[[[[[
'''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''"'""'''''''''''''';;'''''''''''''[[[[[[[[[[[[[[[[[[[[[
'''''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''"""""%"''''''''''''';;''''''''''''[[[[[[[[[[[[[[[[[[[[[[
'''''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;'''''''"%%%%%""""''''''''';;'''''''''''[[[[[[[[[[[[[[[[[[[[[[[
'''''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''""%%%%%%%%%''''''''';;'''''''''''[[[[[[[[[[[[[[[[[[[[[[[
''''%%%%%%;;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''""%%%%%%%%%'''''''''';;''''''''''[[[[[[[[[[[[[[[[[[[[[[[
''''%%%%%%;;;;;;;;;;;;;;;;;;;;;;;;;;;;;''''''""%%%%%%%%%"''''''''';;''''''''''[[[[[[[[[[[[[[[[[[[[[[[
''''%%%%%%;;;;;;";";;;;"""";;;;;";;;;;;''''''""%""""""""''"''''''';;'''''''''''[[[[[[[[[[[[[[[[[[[[[[
"''''''''';;;;;;;;;;;;;;;;;;;;;;;;;;;;;'''''''""''""'"""''''''''''';;''''''''''[[[[[[[[[[[[[[[[[[[[[[
"''''''''';;;%%%%%;;;;%%%%%%;;";%%%%%%;''''''''"''''""'"''''''''''';;'''''''''''[[[[[[[[[[[[[[[[[[[[[
'''''''''';;;%%%%%;;;%%%%%%%;";;%%%%%%;''''''''""'"'''''''''''''''';;'''''''''''[[[[[[[[[[[[[[[[[[[[[
'''''''''';;;%%%%%;;;;";;";;;;;%%%%%%%;%%%%%''''"'''''"'''''''''''';;''''''''''''[[[[[[[[[[[[[[[[[[[[
'''''''''';;;;;;;%;;;;";;;;;;";;%%%%%%;%%%%%''''""''''''''''''''''';;'''''''''''''[[[[[[[[[[[[[[[[[[[
'''''''''';;;";";;;;";;;%;;;;;%;;;;;;;;%%%%%%%""""''''''''''''''''';;'''''''''''''[[[[[[[[[[[[[[[[[[[
'''''''''';;";;;;;%%;%%%%;;";%%%%%%;;;;%%%%%'''''"'''''''''''''''';;"'''''''''''''[[[[[[[[[[[[[[[[[[[
'''''%%%%%;;;;%%%%%%;%%%%;;;;%%%%%%;;;;''''''''''"''''''''''''''';;''"'''''''''''''[[[[[[[[[[[[[[[[[[
'''''%%%%%;;";;;;;;;;%%%%;;;;;;;;;;;;;;'''''''''"''''''''''''''';;;''""''''''''''''[[[[[[[[[[[[[[[[[[
'''''%%%%%;;;;;;%%%%;;;;;;;";";;;;;";;;''''''''""'''''''''''''';;;;;;''"''''''''''''[[[[[[[[[[[[[[[[[
'''''%%%;;;;";;;%%%%%%%;;;;";;;%;;;;;;;;;'''''"''''''''''''';;;;'''';;;;""''''''''''[[[[[[[[[[[[[[[[[
'''''''';%%%;;";%%%%%%%%;;;";;;%%%;;%%%%;'''''"''''''''';;;;;'''''''''';;;;;''''''''''[[[[[[[[[[[[[[[
'''''''';%%%;;;;;;;;;;;;;;;;";;;;;;;;%%%;'''''"''''''';";'''''''''''''''''';;''''''''''[[[[[[[[[[[[[[
"''''''';%%%;'''''''''''';;;;;;''''';%%%;''''"'''';;;;;''''''''''''''''''''';;;;'''''''[[[[[[[[[[[[[[
'''''''';;;;;''''''''''''';";;'''''';;;;;'''""'";;;'''''''''''''''''''''''''''';;;'''''[[[[[[[[[[[[[[
"''''''''''''''%%%%'''''';;;;;''''''''''''';;;;;'''''''''''''''''''''''''''''''';;;;;'''[[[[[[[[[[[[[
'''''''''''''''%%%%%""""""";;";;;''''''';;;;;'''''''''''''''''''''''''''''''''''''''';;";;[[[[[[[[[[[
'''''''''''''''""""''''''''";;;;;;;''';;;""'"'''''''''''''''''''''''''""""""""""""'"'";;;;;[[[[[[[[[[
'''''''''''''''''''''''''''''''';;;;;;;;"'"""'"'""'"""''"'"''"'""''"'""'''''''''''"""'""';;[[[[[[[[[[
"''''''''''''''''"''''''''''''''';;;;;''''''"""''''''''''''''''''''''''''''''''''''''''''';''[[[[[[[[
"''''''''''''''''''''''''''''''''';;;;;;;"""'''""''''''''''''''''''''''''''''''''''''''''';;''[[[[[[[
''''''''''''''''''''''''''''''''''''''";;;;''''''""'''''''''''''''''''''''''''''''''''''''';''''''[[[
''''''''''''''''''''''''''''''''''''''''';;;"''''''"""'''''''''''''''''''''''''''''''''''"';''''''''[
'''''''''''"'''''''''''''''''''''''''''~'';;;;''''''~'""'''''''''''''''''''''''''''''''''';''''''''''
'''''''''''''''''''''''''''''''''''''''~'''';;''''''~'''""''''''''''''''''''''''''''''''';'"'''''''''
"'''''''~''''''''''''''''''''''''''''''~''''';''''~~''''''"""''''''''''''''''''''''''''';;'"'''''''''
''''''''~~~~~~~~~~''''''''''''''"'''''~~''''';;''~~''''''''''"""''''''''''''''''''''''';;''"'''''''''
'''''''''''''''''~~~~'''''''''''''''''~''''''';'~~''''''''''''""""""'''''''''''''''''';"'''""''''''''
''''''''''''''''''''~~'''''''''''''''~~''''''';'~~'''''''''''''""'''"""'''''''''''''';''''''"''''''''
'''''''''''''''''''''~''''''''''''''~~~~~~~~~~%~~''''''''''''''''""'''"""""'''''''''';'''''''"'''''''
'''''''''''''''''''''~'''''''''''''~~~~~~~~~~~%~'''''''''''''''''''""'''''""""""''''';;''''''"'''''''
'''''''''''''''''''''~''''~~~'''''~~~~'''''''';''''''''''''''''''''''""''''''''"""""";;;''''''"''''''
'''''''''''''''''''''~~'''~~~~'''~~~''''''''''';'''''''''''''''''''''''""'''''''''''';'';;;;;;"''''''
''''''''''''''''''''''~~~~~~~~~~~~~'''''''''''';'''''''''''''''''''''''''"''''''''';;'''''''';;;'''''
''''''''''''''''''''''~~~'''~~~'''''''''''''''';'''''''''''''''''''''''''''""''"""";''''''''''';;''''
''''''''''''''''''''''~~''''''''''''''''''''''';;''''''''''''''''''''''''''''""";;;''''''''''''';;;;;
''''''''''''''''''''''~~'''''''''''''''''''''''";;;'''''''''''''''''''''''''"";";;;''""""""''''''''''
'''''''''''''''''''''~~''''''''''''''''''''''''""";;;;;;;''''''''''''''''';;;;;;;;;;"""";"""""'''''''
'''''''''''''''''''~~~'''''''''''''''''''''"'''"'''''''';;;;;;;;;";;;;;;;;;''''""""";"""""""""""''''~
''''''''''''''''''~~~'''''''''''''''''''''''''"'''''''''';;'''''''''''''''''''"""""";"""";""";""''''~
'''''''''''''''::~~~~''''''''''''''''''''''''"'"'''''''';;''''''''''''''''''''"";""""";""""""""""'''~
''''''''''''':::~~~~~:''''''''''''''''''''"'"'"''''''';;;;'''''''''''''''''''''""""""""""";"""""''''~
:'''''''''''::::~~~~~~::'''''''''''''''''''"'''''';;;;;;'''''''''''''''''''''''''""";";"""""";"""''''
::::'''::::::~~~~;~~~~::::::'''''''''''''""";;;;;;;'''''''''''''''''''''''''''''''"""""""""""""""''''
:::::::::~~~~~~~~~~~~:::::::::::::::''';;;;;;''''''''''''''''''''''''''''''''''''''""""";"""""""'''''
:::~~~~~~~~~~~~~~~~~~~~:::::::::::::::;;;:::''''''''''''''''''''''''''''''''''''''''""""""~~~~~~~~~~~
:~~~~~~~~~~~~;;~~~~~~~~~~~:::::::::::;;:::::::::::::::::''''''''''''''''''''''~~~~~~~~~~~~~~~~~~'''''
~~~~~~~~~~~~~~;~~~~~~~~~~~~~~~~~~:::::;;:::::::::::::::::::::::::::::::~~~~~~~~~~:::::::::'''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::;:::::::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::::::::''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:;:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::::::::::::::
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::;:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::;;:::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -0,0 +1 @@
,deadvey,localhost.localdomain,26.02.2025 22:32,file:///home/deadvey/.config/libreoffice/4;

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 MiB

After

Width:  |  Height:  |  Size: 15 MiB

BIN
resources/timeline.ods Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

32
src/data.rs Normal file
View File

@@ -0,0 +1,32 @@
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
};
pub static ref SKILLABLE: HashMap<char, Vec<(&'static str, u64, Vec<&'static str>)>> = {
let mut map = HashMap::new();
map.insert('D', vec![("mining", 15, vec!["Steel Pickaxe"])]);
map.insert('C', vec![("mining", 5, vec!["Bronze Pickaxe", "Steel Pickaxe"])]);
map.insert('i', vec![("mining", 10, vec!["Bronze Pickaxe", "Steel Pickaxe"])]);
map.insert('♣', vec![("woodcutting", 5, vec!["Bronze Axe", "Steel Axe"])]);
map
};
}

View File

@@ -1,5 +1,7 @@
use std::io::{stdin,stdout,Write}; use std::io::{stdin,stdout,Write};
use crate::Command; use crate::Command;
use crate::data;
use crate::Player;
pub fn input() -> String{ pub fn input() -> String{
let mut s=String::new(); let mut s=String::new();
@@ -22,3 +24,45 @@ pub fn clear_screen()
.status() .status()
.expect("Failed to clear screen"); .expect("Failed to clear screen");
} }
pub fn skill_item
(
direction: char,
player: &Player,
map: &Vec<Vec<char>>,
)
{
let mut block: char = 'X';
if direction == 'n'
{
block = map[(player.coordinates.z - 1) as usize][player.coordinates.x as usize];
}
else if direction == 'e'
{
block = map[player.coordinates.z as usize][(player.coordinates.x + 1) as usize];
}
else if direction == 's'
{
block = map[(player.coordinates.z + 1) as usize][player.coordinates.x as usize];
}
else if direction == 'w'
{
block = map[player.coordinates.z as usize][(player.coordinates.x - 1) as usize];
}
else
{
println!("Invalid Direction");
}
/*
if blocks::SKILLABLE.contains_key(&block)
{
println!("Skilling {} to the {}.", blocks::BLOCKS.get(&block).unwrap()[0].2, direction);
}
else
{
println!("Block: {} to the {} is not skillable.", blocks::BLOCKS.get(&block).unwrap()[0].2, direction);
return ();
}
*/
}

View File

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

View File

@@ -1,6 +1,7 @@
use std::fs; use std::fs;
use std::process::{Command}; use std::process::{Command};
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use std::collections::HashMap;
// Declare the modules from these files // Declare the modules from these files
mod parse_map; // parse_map.rs mod parse_map; // parse_map.rs
@@ -10,36 +11,45 @@ mod initialise; // initialise.rs, creates a new character
mod function; // function.rs, for misc functions mod function; // function.rs, for misc functions
mod process_input; // process_input.rs mod process_input; // process_input.rs
pub enum GameAction { #[macro_use]
extern crate lazy_static;
mod data;
pub enum GameAction
{
Continue, Continue,
Exit, Exit,
Error, Error,
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
struct Coordinates { struct Skills
{
woodcutting: u64,
mining: u64,
}
#[derive(Serialize, Deserialize, Debug)]
struct Coordinates
{
x: i16, x: i16,
z: i16, z: i16,
map: String, map: String,
} }
#[derive(Serialize, Deserialize, Debug)]
struct Skills {
woodcutting: u8,
mining: u8,
}
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
struct Player { struct Player
{
name: String, name: String,
skills: Skills, skills: Skills,
coordinates: Coordinates, coordinates: Coordinates,
inventory: Vec<(String, u64)>, inventory: Vec<(String, u64)>,
} }
const DEBUG_MODE: bool = false; const DEBUG_MODE: bool = true;
fn main() fn main()
{ {
let save_file_path: &str = "data/save.json"; let save_file_path: &str = "data/save.json";
let player: Player; let player: Player;
@@ -51,16 +61,16 @@ fn main()
{ {
println!("{:?}", player); 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 { // Parse the map file into a vector
if DEBUG_MODE == false if DEBUG_MODE == false
{ {
function::clear_screen; function::clear_screen();
} }
output_map::output_map // Call output_map fuctino from output_map.rs output_map::output_map // Call output_map fuctino from output_map.rs
( (
&ground_map, &map,
&above_map, &data::BLOCKS,
&player.coordinates, &player.coordinates,
); // Output the map ); // Output the map
'game_loop: loop 'game_loop: loop
@@ -71,8 +81,8 @@ fn main()
( (
user_input, user_input,
&mut player, &mut player,
&ground_map, &map,
&above_map, &data::BLOCKS,
); );
if let Err(e) = save::save(&save_file_path, &player) if let Err(e) = save::save(&save_file_path, &player)

View File

@@ -4,54 +4,69 @@ use std::collections::HashMap;
use crate::Coordinates; use crate::Coordinates;
use crate::DEBUG_MODE; use crate::DEBUG_MODE;
// Output the map based on map vector // Output the map based on map vector
pub fn output_map( pub fn output_map(
ground_map: &Vec<Vec<char>>, map: &Vec<Vec<char>>,
above_map: &Vec<Vec<char>>, blocks: &HashMap<char, Vec<([u8; 3],bool, &str)>>,
player_coordinates: &Coordinates, player_coordinates: &Coordinates,
) )
{ {
let (screen_width, screen_height) = termion::terminal_size().unwrap(); 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 if DEBUG_MODE == true
{ {
println!("{:?}", player_coordinates);
println!("Screen Width: {}, Screen Height: {}", screen_width, screen_height); 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
('8', [255,196,196]), // Stone bricks
('♣', [0, 153,51]), // Oak tree
]
.iter().cloned().collect();
// Loop over array and print each block // 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 character: char = map[z as usize][x as usize];
let above_character: char = above_map[z as usize][x as usize];
// Check if the character is at the current coordinates // Check if the character is at the current coordinates
if z == player_coordinates.z && x == player_coordinates.x if z == player_coordinates.z && x == player_coordinates.x
{ {
@@ -63,21 +78,6 @@ pub fn output_map(
.truecolor(0,0,0) .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 print what is below (the ground)
else if blocks.contains_key(&character) else if blocks.contains_key(&character)
{ {
@@ -87,9 +87,9 @@ pub fn output_map(
character // Output's the current block character // Output's the current block
.to_string() .to_string()
.truecolor( .truecolor(
blocks.get(&character).unwrap()[0], blocks.get(&character).unwrap()[0].0[0],
blocks.get(&character).unwrap()[1], blocks.get(&character).unwrap()[0].0[1],
blocks.get(&character).unwrap()[2] blocks.get(&character).unwrap()[0].0[2]
) )
) )
} }
@@ -102,12 +102,13 @@ pub fn output_map(
"X" "X"
.to_string() .to_string()
.truecolor( .truecolor(
blocks.get(&'X').unwrap()[0], blocks.get(&'X').unwrap()[0].0[0],
blocks.get(&'X').unwrap()[1], blocks.get(&'X').unwrap()[0].0[1],
blocks.get(&'X').unwrap()[2] blocks.get(&'X').unwrap()[0].0[2]
) )
) )
} }
} }
} }
println!(""); println!("");

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 // 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 // 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 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 map_file = format!("data/{}.map",player_coordinates.map);
let ground_file = format!("data/{}_ground.map",player_coordinates.map);
let above_file = format!("data/{}_above.map",player_coordinates.map);
// Read the ground map file // 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 map_file_contents = parsed_map_file_contents;
let ground_rows = ground_file_contents.split("\n").collect::<Vec<_>>(); // Split the file contents into rows 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 // 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 // Turn each column into an integer and collect it into a row vector
let current_row = ground_rows[row].chars().collect(); let current_row = map_rows[row].chars().collect();
ground_map.push(current_row); // Then push this vector to the full map vector map.push(current_row); // Then push this vector to the full map vector
} }
} }
else else
{ {
eprintln!("Error: Could not read file: {}", ground_file); eprintln!("Error: Could not read file: {}", map_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);
return Err(1) return Err(1)
} }
return Ok((ground_map, above_map)) return Ok(map)
} }

View File

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

View File

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