예제 #1
0
 def newGame(self):
     pygame.mixer.stop()
     self.world.resetWorld()
     self.world.genWorld(5, 5)
     self.player = Player(*self.world.getStartPoint())
     # get enemy's random position
     pntLs = self.world.getPntList()
     # put enemy somewhere > 5 hallways away from player to start with
     xPlayer, yPlayer = self.world.getClosestIntersectPoint(self.player)
     enemyStartPositions = [p for p in pntLs if abs(p[0]-xPlayer)>4 or abs(p[1]-yPlayer)>4]
     pnt = random.choice(pntLs if len(enemyStartPositions)==0 else enemyStartPositions)
     xl, yu, xr, yd = self.world.getIntersectBoundingBox(pnt)
     px, py = ((xl+xr)/2, (yu+yd)/2)
     self.enemy = Enemy(px, py, self.world)
     self.flashlight = Flashlight(self.screen, 1)  # flashlight w/ range of 1 radian
     self.keys = None
     self.xCam = 0
     self.yCam = 0
     self.messages = ["iloveyou","yourhairsmellsnice","stop","imscared","canyouhearme?","youcantleave"]
     self.startTime = time.clock()  # time since last message started / removed
     self.currentMessage = None
예제 #2
0
#Library has a DESK that contains/hides 2 items, a key, and a quarter
library.desk=Container("inside the desk.",["key","quarter"])
library.shelf=Container("on the shelf.",["Sniper","can"])
                                                

library.create_room_item("rat")
library.create_room_item("fork")

# Small Office
#
smalloffice = Room("Small Office","A dark room with a mess of books and papers covering the desk. There is some mail and an ozon.ru PACKAGE. You can READ a book. You can look in the DESK.")
smalloffice.desk = Container("desk",["battery","envelope"])
smalloffice.package = Container("ozon.ru package",["sheet of bubble wrap","porcelain figurine of a bear","red flashlight"])
smalloffice.create_room_item("guinea pig")
redFlashlight = Flashlight("red",0,False)

# Laboratory
#
lab = Room("Laboratory","A bright room with sunlight shining through windows secured by prison bars. There is a messy SHELF on the north wall.")
# The lab has a SHELF object that contains 3 interactive items. Shelf gets a third argument because you'd say ON the shelf, not IN the shelf
lab.shelf = Container("shelf",["brass key","spork","yellow flashlight"],"on")
lab.create_room_item("rat")
yellowFlashlight = Flashlight("yellow",1,True)

# Supply Closet
#
supplycloset = Room("Supply Closet","A small dark room with a musty smell. On one side is a filing CABINET and a large plastic BIN. On the other side is a SHELF with supplies and a SHOEBOX.")

# Create a fake room called locked that represents all permenently locked doors
#
예제 #3
0
# Create an interactive item that's show in a room (not hidden in a container) with create_room_item()
kitchen.create_room_item("spoon")
kitchen.create_room_item("rat")

# Small Office
#
smalloffice = Room(
    "Small Office",
    "A dark room with a mess of books and papers covering the desk. There is some mail and an ozon.ru PACKAGE. You can READ a book. You can look in the DESK."
)
smalloffice.desk = Container("desk", ["battery", "envelope"])
smalloffice.package = Container(
    "ozon.ru package",
    ["sheet of bubble wrap", "porcelain figurine of a bear", "red flashlight"])
smalloffice.create_room_item("guinea pig")
redFlashlight = Flashlight("red", 0, False)

# Laboratory
#
aud = Room(
    "Auditorium",
    "A huge room that has very little lighting. You can hear the echos of mice running, and the support beams creaking. There is a CHEST behind stage that looks like it would have some clothing in it."
)
# The lab has a SHELF object that contains 3 interactive items. Shelf gets a third argument because you'd say ON the shelf, not IN the shelf
aud.chest = Container(
    "In the chest you see a ROBIN HOOD COSTUME, a BOW, and some ARROWS.",
    ["Robinhood Costume", "Long Bow", "quiver with arrows"], "in ")
aud.create_room_item("Cars Flashlight")
carsFlashlight = Flashlight("Cars", 1, True)

# Supply Closet