add the wait command

This commit is contained in:
Lephe 2019-10-05 11:53:45 +02:00
parent 1e7ca230d4
commit ab057abddd
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 17 additions and 4 deletions

View File

@ -113,7 +113,7 @@ class Window:
x += sx
SDL_RenderDrawPoint(self.r, x, y)
def wait(self):
def wait(self, allow_any=False):
"""Wait for the window to be closed."""
if self.quiet:
@ -125,6 +125,14 @@ class Window:
if event.type == SDL_QUIT:
break
if event.type == SDL_KEYDOWN and allow_any:
break
def pause(self):
"""Display a pause message."""
# TODO: Display "paused"
self.wait(allow_any=True)
def save(self, out):
"""Save the output into a BMP file."""

View File

@ -121,8 +121,13 @@ class Context:
raise Exception("Style statement not supported yet x_x")
elif n.type == N.WAIT:
# TODO: Display "paused" and wait for a key press to continue"
print("[interpreter] Delay ignored")
print("---- pause")
print(f"x={self.x} y={self.y} theta={self.angle}")
print(f"A={self.vars['A']} B={self.vars['B']}")
print(f"C={self.vars['C']} D={self.vars['D']}")
print(f"E={self.vars['E']} F={self.vars['F']}")
print(f"M={self.vars['M']}")
self.w.pause()
# Flow control

View File

@ -136,7 +136,7 @@ class Parser:
if op.type == T.STYLE:
return Node(N.STYLE, self.style())
if op.type == T.WAIT:
return Node(N.WAIT, self.arg())
return Node(N.WAIT)
# Flow control