Add slow typing and basic text inro
This commit is contained in:
14
src/boarhuntingsimulator.py
Normal file
14
src/boarhuntingsimulator.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
""" Boar Hunting Simulator 2022"""
|
||||||
|
|
||||||
|
import utils.text as Text
|
||||||
|
from data import MenuText as mt
|
||||||
|
|
||||||
|
def main():
|
||||||
|
Text.type(mt.intro_text, delay=0.01, newline_delay=1.0)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
input()
|
||||||
|
exit(0)
|
||||||
10
src/data/MenuText.py
Normal file
10
src/data/MenuText.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
"""
|
||||||
|
Text for menus
|
||||||
|
"""
|
||||||
|
|
||||||
|
intro_text = ("Hello and welcome to my little game. \n"
|
||||||
|
"You are a villager living in a small village. \n"
|
||||||
|
"There are many wild boars lurking outside that are making the passage difficult for everyone to travel. \n"
|
||||||
|
"Because an old friend of you got murdered by one you've sworn yourself to revenge him. \n"
|
||||||
|
"By killing as many boars as possible. \n\n"
|
||||||
|
"Please navigate using numbers \n")
|
||||||
0
src/data/__init__.py
Normal file
0
src/data/__init__.py
Normal file
0
src/utils/__init__.py
Normal file
0
src/utils/__init__.py
Normal file
19
src/utils/text.py
Normal file
19
src/utils/text.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
"""
|
||||||
|
Utilities for text output
|
||||||
|
"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
def type(text: str, delay: float = 0.05, newline_delay: float = 0.0) -> None:
|
||||||
|
""" Prints the given text, one character at a time, with a delay between each character.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
text: The text to be printed.
|
||||||
|
delay: The delay between each character. (Default 0.05)
|
||||||
|
newline_delay: The delay between each newline. (Default 0.0)
|
||||||
|
"""
|
||||||
|
for char in text:
|
||||||
|
print(char, end="", flush=True)
|
||||||
|
if (char == "\n"):
|
||||||
|
time.sleep(newline_delay)
|
||||||
|
time.sleep(delay)
|
||||||
Reference in New Issue
Block a user