Skip to content

Commit

Permalink
random tube heights
Browse files Browse the repository at this point in the history
  • Loading branch information
csaez committed Feb 14, 2014
1 parent a175bf3 commit cc5c80e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions flascii_bird.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import msvcrt # windows-only :_(
from math import fmod, sqrt
from threading import Timer
from random import randint


class Vector(object):
Expand Down Expand Up @@ -65,7 +66,7 @@ def bbox(self):

@property
def shape(self):
if type(self._shape) in ((list, tuple)):
if type(self._shape) in (list, tuple):
index = 0 if self.vel.y > 0 else 1
return self._shape[index]
return self._shape
Expand Down Expand Up @@ -142,12 +143,14 @@ def flascii_bird():

# tubes
if fmod(t, 51) == 0 or t == 1:
up = Sprite("| |\n" * 4 + "--------\n--------")
pipe_height = randint(1, 7)
up = Sprite("| |\n" * pipe_height + "--------\n--------")
up.pos = Vector(TERMINAL_SIZE.x, 0)
TUBES.append(up)
dn = Sprite("--------\n" * 2 + "| |\n" * 4)
dn = Sprite("--------\n" * 2 + "| |\n" * (8 - pipe_height))
dn.shape = dn.shape[:-1] # remove last \n
dn.pos = Vector(TERMINAL_SIZE.x, TERMINAL_SIZE.y - 10)
dn.pos = Vector(TERMINAL_SIZE.x,
TERMINAL_SIZE.y + pipe_height - 8 - 6)
TUBES.append(dn)
TUBES = [x for x in TUBES if x.pos.x > -7] # cleanup
f = Vector(-1, 0)
Expand Down

0 comments on commit cc5c80e

Please sign in to comment.