Course Hero Logo

project.py - import import import import import import...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 6 pages.

import cursesimport osimport randomimport reimport stringimport sysimport timefrom game.casting.actor import Actorfrom game.casting.artifact import Artifactfrom game.casting.cast import Castfrom game.directing.director import Directorfrom game.services.keyboard_service import KeyboardServicefrom game.services.video_service import VideoServicefrom game.shared.color import Colorfrom game.shared.point import PointFRAME_RATE = 12MAX_X = 900MAX_Y = 600CELL_SIZE = 15FONT_SIZE = 15COLS = 60ROWS = 40CAPTION = "Robot Finds Kitten"DATA_PATH = os.path.dirname(os.path.abspath(__file__)) + "/data/messages.txt"WHITE = Color(255, 255, 255)DEFAULT_ARTIFACTS = 40# code make by lourenzo/Seanclass Lop:possible_chars ='''0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"$%&\'()*+,-./:;<=>[email protected][\]^_`{|}~'''def randomChar(self):self.char = random.choice(self.possible_chars)def randomColor(self):self.color = curses.color_pair(random.randint(0,7))if random.randint(0, 1):self.color = self.color | curses.A_BOLDdef __init__(self, board):self.board = boardself.randomColor()self.randomChar()board.placeRandomly(self)class NKI(Lop):def __init__(self, msg, board):Lop.__init__(self, board)self.message = msg
def handleCollision(self, whoGoesThere):self.board.setMessage(self.message)class Kitten(Lop):def handleCollision(self, whoGoesThere):self.board.setMessage('')row = 1meet = 50where=self.board.topa = selfb = whoGoesThereif a.x > b.x:#Kitten is to the right of player; switch the#order of the animationa,b = b,afor i in range(4, 0, -1):self.board.erase(a, x=meet-i-1, y=row, where=where)self.board.draw(a, x=meet-i, y=row, where=where)self.board.erase(b, x=meet+i, y=row, where=where)self.board.draw(b, x=meet+i-1, y=row, where=where)duration = 1if i == 1:duration = .5time.sleep(duration)self.board.top.addstr(0, 49, '<3', curses.color_pair(1) | curses.A_BOLD)self.board.top.refresh()time.sleep(.75)self.board.top.addstr(row, 0, 'You found kitten! Way to go, robot!')self.board.top.refresh()time.sleep(.3)class Robot(Lop):CHAR = '#'def __init__(self, board):self.board = boardself.char = self.CHARself.color = curses.color_pair(8) | curses.A_BOLDboard.placeRandomly(self)def move(self, relX, relY):kitten = 0tryX = self.x+relXtryY = self.y+relYsomething = Noneif self.board.inBounds(tryX, tryY):

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 6 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
NoProfessor
Tags

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture