def background(score, timeLeft, life, dragonLife): ''' Prints background ''' print('\033[0;0H', end='') print(' ' * terminalSize()[0]) print('\u001b[48;5;232m\u001b[38;5;15m' + '-' * terminalSize()[0] + '\u001b[0m') for i in range(terminalSize()[1] - 4): print('\u001b[48;5;232m' + ' ' * terminalSize()[0] + '\u001b[0m') print('\u001b[48;5;232m\u001b[38;5;70m' + '-' * (terminalSize()[0]) + '\u001b[0m', end='') print('\u001b[48;5;232m \u001b[38;5;15m \033[0;0H SCORE:' + str(score) + ' LIFE:' + str(life) + ' ENEMY:' + str(dragonLife) + ' TIME LEFT:' + str(timeLeft) + '\u001b[0m', end='')
def endGame(exitCode, score): '''Prints for exiting game''' print(' ' * terminalSize()[0] * terminalSize()[1]) if exitCode == 1: print( '\u001b[48;5;232m \u001b[38;5;15m \033[0;1H YOU WON. YOUR SCORE IS ' + str(score) + ' \u001b[0m') elif exitCode == 2: print( '\u001b[48;5;232m \u001b[38;5;15m \033[0;1H YOU LOST. YOUR SCORE IS ' + str(score) + ' \u001b[0m') else: print( '\u001b[48;5;232m \u001b[38;5;15m \033[0;1H ERROR. EXITED GAME. \u001b[0m' )
def gravity(self, val): ''' Implements gravity for Din ''' if val != 'w' and self._y < terminalSize()[1]-2 - self._acc: self._coords=[] self._y += self._acc for i in range(self._acc): self._coords.append([self._x, self._y-i]) self._coords.append([self._x, self._y+1]) elif val != 'w' and self._y < terminalSize()[1]-3: self._acc = terminalSize()[1]-2 - self._y self._y = terminalSize()[1]-3 for i in range(self._acc): self._coords.append([self._x, self._y-i]) self._coords.append([self._x, self._y+1]) return self._y
def __init__(self): super().__init__() self._y = terminalSize()[1]-3 self._x = 7 self._shield = 0 self._magAttract = 0 self._acc = 1
def moveDin(self, speedVal, magnetFlag, magX): ''' Moves Din ''' if (speedVal == 'w'): self._acc = 1 if self._y > 3: self._y -= 1 else: self._acc = self._acc + 1 if (speedVal == 'a' and self._x > 0): self._x -= 1 elif (speedVal == 'd' and self._x < terminalSize()[0]): self._x += 1 else: self.magForce(magnetFlag, magX) self.gravity(speedVal)
def __init__(self): super().__init__() self._x = terminalSize()[0]-11 self._y = 3
def __init__(self): self._y = np.random.randint(5, terminalSize()[1]-3) self._x = terminalSize()[0]-1 self._coords = []
def __init__(self): super().__init__() self._y = np.random.randint(5, terminalSize()[1]-3)
def moveAcross(self): if self._x != None and self._x < terminalSize()[0] and self._x > 0: self._x -= 2 else: self._x = None