This is awful

but it shows some prototpe stuff
This commit is contained in:
Joe S 2021-02-06 00:19:16 -05:00
parent 298e5abdbe
commit ed4b5abd24
3 changed files with 43 additions and 28 deletions

1
Adventure Game/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
venv

View File

@ -1,35 +1,40 @@
# std imports
from math import floor
# local
from blessed import Terminal from blessed import Terminal
class Graphics:
def __init__(self):
self.bottom_left_corner = u""
self.bottom_right_corner = u""
self.top_left_corner = u""
self.top_right_corner = u""
self.border_horizontal = u""
self.border_vertical = u""
def roundxy(x, y): class Window:
return int(floor(x)), int(floor(y)) def __init__(self, term, height, width, xpos, ypos, title=None):
self.term = term
self.title = title
term = Terminal() self.height = height
self.width = width
self.xpos = xpos
self.ypos = ypos
x, y, xs, ys = 2, 2, 0.4, 0.3 def draw_borders(self):
with term.cbreak(), term.hidden_cursor(): # Print the top
# clear the screen print(
print(term.home + term.black_on_olivedrab4 + term.clear) self.term.move_xy(self.xpos, self.ypos) +
u"" +
u"" * (self.width - 2) +
u""
)
# loop every 20ms # Print the middle
while term.inkey(timeout=0.02) != 'q': # We exclude the top and bottom rows since we'll draw them with other chars
# erase, for dx in range (1, self.height - 1):
txt_erase = term.move_xy(*roundxy(x, y)) + ' ' print(self.term.move_xy(self.xpos + dx, self.ypos) + u'')
print(self.term.move_xy(self.xpos + dx, self.ypos + self.width - 1) + u'')
# bounce, terminal = Terminal()
if x >= (term.width - 1) or x <= 0: my_window = Window(terminal, 4, 20, 10, 10)
xs *= -1 my_window.draw_borders()
if y >= term.height or y <= 0:
ys *= -1
# move,
x, y = x + xs, y + ys
# draw !
txt_ball = term.move_xy(*roundxy(x, y)) + ''
print(txt_erase + txt_ball, end='', flush=True)

View File

@ -0,0 +1,9 @@
from blessed import Terminal
import time
term = Terminal()
for x in range(10):
for y in range(10):
print(term.move_xy(x, y) + '*')
time.sleep(0.1)