Add slow typing and basic text inro

This commit is contained in:
Minz committed 2022-08-04 13:32:27 +02:00
1 parent c62df2bb21
commit de26838e1f
5 files changed
+43

No files matched your search

+14
View 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
View 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")
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+19
View 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)