Пример #1
0
 def __init__(self):
     """
     The __init__ message for a scene should set up the camera(s) for the
     scene, and setup groups and other structures which are needed for the
     scene.
     """
     spyral.Scene.__init__(self)
     # We cannot draw directly to the root camera, so we always make a child
     # camera for our scene with our requested virtual resolution. In this
     # case we'll use the same as the window size, but this doesn't have to be
     # the case
     self.camera = self.parent_camera.make_child(SIZE)
     self.group = spyral.Group(self.camera)
     self.initialized = False
Пример #2
0
    def __init__(self, *args, **kwargs):
        super(Basketball, self).__init__(*args, **kwargs)
        
        self.user_has_shot = True
        self.waiting_for_input = True
        self.camera = self.parent_camera.make_child(virtual_size = (WIDTH, HEIGHT))
        
        self.hoops = get_hoops(self)

        self.points = []
        for i in range(int(NUM_X_POINTS + 1)):
            for j in range(int(NUM_Y_POINTS + 1)):
                self.points.append(Point(self, i, j))

        self.up_ball = Ball(self, 5)
        self.up_ball.pos = (COORD_WIDTH/2 + PAD_LEFT, HEIGHT)
        self.down_ball = Ball(self, 1)
        self.down_ball.image = spyral.Image(filename="basketball_images/basketball_small.png")

        # starts in middle, moved to correct posn later (before it drops)
        self.down_ball.pos = (WIDTH/2, -self.down_ball.image._surf.get_height())

        self.x_input = ""
        self.y_input = ""
        
        # We have to give our camera to the group so it knows where to draw
        self.group = spyral.Group(self.camera)
        # We can add the sprites to the group
        for hoop in self.hoops:
            self.group.add(hoop)
        self.group.add(self.up_ball)
        self.group.add(self.down_ball)

        self.graph = Graph(self)
        self.group.add(self.graph)

        for point in self.points:
            self.group.add(point)

        self.run_num = 1
        self.score = 0
        self.num_shots = 0

        self.scoreboard = Scoreboard(self)
        self.group.add(self.scoreboard)
        
        self.shot_point = ShotPoint(self)
        self.group.add(ShotPoint(self))
Пример #3
0
 def __init__(self):
     spyral.Scene.__init__(self)
     self.camera = self.parent_camera.make_child(
         virtual_size=(RC_WIDTH, RC_HEIGHT),
         layers=['__default__', 'on_road', 'over_road'])
     self.group = spyral.Group(self.camera)
     self.normalspeed = 200
     self.accel = 50
     self.speed = self.normalspeed
     self.slow = 1
     self.distance = RC_WIDTH
     self.timer = 0
     self.questionNum = 1
     self.linelist1 = LineList(self, UPPER_BOUND + LANE_WIDTH, 100, 6)
     self.linelist2 = LineList(self, UPPER_BOUND + LANE_WIDTH * 2, 100, 6.9)
     self.car = Car(self.group, self.normalspeed, 300, 300)
     self.turbometer = TurboMeter(self.group, 10)
     self.question = Question(self, self.distance)
     self.render()
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = spyral.Group(self.camera)

        self.font = pygame.font.SysFont(None, FONT_SIZE)

        self.head = Sprite(self.group)
        self.head.image = spyral.Image(filename=OVEN)
        self.head.x = 200
        self.head.y = 100

        instructions = TextSprite(self.group, self.font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("s: taste")

        self.heading = TextSprite(self.group, self.font)
        self.heading.anchor = 'midbottom'
        self.heading.x = 330
        self.heading.y = 50
        self.heading.render("BAKING")
Пример #5
0
    def __init__(self, *args, **kwargs):
        super(Pong, self).__init__(*args, **kwargs)

        self.camera = self.parent_camera.make_child(virtual_size=(WIDTH,
                                                                  HEIGHT))

        paddle_image = spyral.Image(size=(20, 300))
        paddle_image.fill((255, 255, 255))

        # We want to make sure we keep the paddles around, since we'll
        # work with them for motion and collision detection
        self.left_paddle = spyral.Sprite()
        self.left_paddle.image = paddle_image
        # This anchor means that the x and y coordinates we assign are
        # relative to the middle left of the image.
        self.left_paddle.anchor = 'midleft'
        # We'll keep the paddle just slightly off of the wall
        self.left_paddle.x = 20
        # We'll have the paddle start out vertically centered
        self.left_paddle.y = HEIGHT / 2

        self.right_paddle = spyral.Sprite()
        self.right_paddle.image = paddle_image
        self.right_paddle.anchor = 'midright'
        self.right_paddle.x = WIDTH - 20
        self.right_paddle.y = HEIGHT / 2

        self.ball = Ball(self)

        # We have to give our camera to the group so it knows where to draw
        self.group = spyral.Group(self.camera)
        # We can add the sprites to the group
        self.group.add(self.left_paddle, self.right_paddle, self.ball)

        # We should track whether the paddles are moving up and down
        self.left_paddle.moving = False
        self.right_paddle.moving = False
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = spyral.Group(self.camera)

        self.counter = 0
        self.font = pygame.font.SysFont(None, FONT_SIZE)

        self.nomIndex = 0
        self.cookieIndex = 0

        self.eatIndex = 0
        #PET LOCATION (TOP LEFT HAND CORNER)

        PET_X = 230
        PET_Y = 150

        self.j = 1
        self.i = STUDENT_PET[0]  # Color
        self.t = STUDENT_PET[1]  # Type

        self.head = Sprite(self.group)
        self.head.image = spyral.Image(
            filename=HEADS[TYPES[self.t]][NOM_INDEX[self.nomIndex][0]])
        self.head.layer = HEAD_LAYER
        self.head.x = PET_POINTS[1][0] + PET_X
        self.head.y = PET_POINTS[1][1] + PET_Y

        self.arms = Sprite(self.group)
        self.arms.image = spyral.Image(
            filename=ARMS[TYPES[self.t]][NOM_INDEX[self.nomIndex][2]])
        self.arms.layer = ARMS_LAYER
        self.arms.x = PET_POINTS[3][0] + PET_X
        self.arms.y = PET_POINTS[3][1] + PET_Y

        self.face = Sprite(self.group)
        if self.t <= 1:
            self.face.image = spyral.Image(filename=CD_FACES[self.j])
        elif self.t >= 2:
            self.face.image = spyral.Image(filename=DB_FACES[self.j])
        self.face.layer = FACE_LAYER
        self.face.x = PET_POINTS[2][0] + PET_X
        self.face.y = PET_POINTS[2][1] + PET_Y

        self.cookie = Sprite(self.group)
        self.cookie.image = spyral.Image(filename=COOKIES[self.cookieIndex])
        self.cookie.layer = COOKIE_LAYER
        self.cookie.x = COOKIE_POINTS[self.eatIndex][
            self.cookieIndex][0] + PET_X
        self.cookie.y = COOKIE_POINTS[self.eatIndex][
            self.cookieIndex][1] + PET_Y

        self.set_color()

        instructions = TextSprite(self.group, self.font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("s: quit")

        self.heading = TextSprite(self.group, self.font)
        self.heading.anchor = 'midbottom'
        self.heading.x = 320
        self.heading.y = 50
        self.heading.render("TASTING")
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = spyral.Group(self.camera)

        font = pygame.font.SysFont(None, FONT_SIZE)

        #BEGIN MONEY MATRIX
        self.M00 = Sprite(self.group)
        self.M00.image = spyral.Image(filename=MONIES[1])
        self.M00.layer = 1
        self.M00.x = MONEY_POINTS[0][0]
        self.M00.y = MONEY_POINTS[0][1]

        self.M10 = Sprite(self.group)
        self.M10.image = spyral.Image(filename=MONIES[2])
        self.M10.layer = 1
        self.M10.x = MONEY_POINTS[1][0]
        self.M10.y = MONEY_POINTS[1][1]

        self.M20 = Sprite(self.group)
        self.M20.image = spyral.Image(filename=MONIES[3])
        self.M20.layer = 1
        self.M20.x = MONEY_POINTS[2][0]
        self.M20.y = MONEY_POINTS[2][1]

        self.M01 = Sprite(self.group)
        self.M01.image = spyral.Image(filename=MONIES[4])
        self.M01.layer = 1
        self.M01.x = MONEY_POINTS[3][0]
        self.M01.y = MONEY_POINTS[3][1]

        self.M11 = Sprite(self.group)
        self.M11.image = spyral.Image(filename=MONIES[0])
        self.M11.layer = 1
        self.M11.x = MONEY_POINTS[4][0]
        self.M11.y = MONEY_POINTS[4][1]

        self.M21 = Sprite(self.group)
        self.M21.image = spyral.Image(filename=MONIES[1])
        self.M21.layer = 1
        self.M21.x = MONEY_POINTS[5][0]
        self.M21.y = MONEY_POINTS[5][1]

        self.M02 = Sprite(self.group)
        self.M02.image = spyral.Image(filename=MONIES[2])
        self.M02.layer = 1
        self.M02.x = MONEY_POINTS[6][0]
        self.M02.y = MONEY_POINTS[6][1]

        self.M12 = Sprite(self.group)
        self.M12.image = spyral.Image(filename=MONIES[3])
        self.M12.layer = 1
        self.M12.x = MONEY_POINTS[7][0]
        self.M12.y = MONEY_POINTS[7][1]

        self.M22 = Sprite(self.group)
        self.M22.image = spyral.Image(filename=MONIES[4])
        self.M22.layer = 1
        self.M22.x = MONEY_POINTS[8][0]
        self.M22.y = MONEY_POINTS[8][1]
        #END MONEY MATRIX

        self.i = STUDENT_PET[0]  # Color
        self.t = STUDENT_PET[1]  # Type

        #PET LOCATION (TOP LEFT HAND CORNER)
        PET_X = 430
        PET_Y = 200

        self.head = Sprite(self.group)
        self.head.image = spyral.Image(filename=HEADS[TYPES[self.t]][0])
        self.head.layer = HEAD_LAYER
        self.head.x = PET_POINTS[1][0] + PET_X
        self.head.y = PET_POINTS[1][1] + PET_Y

        self.body = Sprite(self.group)
        self.body.image = spyral.Image(filename=BODIES[TYPES[self.t]][0])
        self.body.layer = BODY_LAYER
        self.body.x = PET_POINTS[8][0] + PET_X
        self.body.y = PET_POINTS[8][1] + PET_Y

        self.arms = Sprite(self.group)
        self.arms.image = spyral.Image(filename=ARMS[TYPES[self.t]][0])
        self.arms.layer = ARMS_LAYER
        self.arms.x = PET_POINTS[3][0] + PET_X
        self.arms.y = PET_POINTS[3][1] + PET_Y

        self.legs = Sprite(self.group)
        self.legs.image = spyral.Image(filename=LEGS[TYPES[self.t]][0])
        self.legs.layer = LEGS_LAYER
        self.legs.x = PET_POINTS[5][0] + PET_X
        self.legs.y = PET_POINTS[5][1] + PET_Y

        self.tail = Sprite(self.group)
        self.tail.image = spyral.Image(filename=TAILS[TYPES[self.t]][0])
        self.tail.layer = TAIL_LAYER
        self.tail.x = PET_POINTS[9][0] + PET_X
        self.tail.y = PET_POINTS[9][1] + PET_Y

        self.j = 1

        self.face = Sprite(self.group)
        if self.t <= 1:
            self.face.image = spyral.Image(filename=CD_FACES[self.j])
        elif self.t >= 2:
            self.face.image = spyral.Image(filename=DB_FACES[self.j])
        self.face.layer = FACE_LAYER
        self.face.x = PET_POINTS[2][0] + PET_X
        self.face.y = PET_POINTS[2][1] + PET_Y

        self.p = 0

        self.pointer = Sprite(self.group)
        self.pointer.image = spyral.Image(filename=POINTER)
        self.pointer.layer = 2
        self.pointer.x = POINTER_POINTS[self.p][0]
        self.pointer.y = POINTER_POINTS[self.p][1]

        self.set_pointer()
        self.set_face()
        self.set_color()
        #self.set_type()

        instructions = TextSprite(self.group, font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("MAIN MENU (p: pick  s: select)")

        self.qbutton = Sprite(self.group)
        self.qbutton.image = spyral.Image(size=(150, 50))
        self.qbutton.image.fill(color=(0, 0, 0))
        self.qbutton.x = 430
        self.qbutton.y = 60
        self.qbutton.layer = 0

        quitbutton = TextSprite(self.group, font)
        quitbutton.anchor = 'midbottom'
        quitbutton.x = 480
        quitbutton.y = 100
        quitbutton.render("QUIT")
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = spyral.Group(self.camera)

        font = pygame.font.SysFont(None, FONT_SIZE)

        self.t = 0

        #PET LOCATION (TOP LEFT HAND CORNER)

        PET_X = 230
        PET_Y = 200

        self.head = Sprite(self.group)
        self.head.image = spyral.Image(filename=HEADS[TYPES[self.t]][0])
        self.head.layer = HEAD_LAYER
        self.head.x = PET_POINTS[1][0] + PET_X
        self.head.y = PET_POINTS[1][1] + PET_Y

        self.body = Sprite(self.group)
        self.body.image = spyral.Image(filename=BODIES[TYPES[self.t]][0])
        self.body.layer = BODY_LAYER
        self.body.x = PET_POINTS[8][0] + PET_X
        self.body.y = PET_POINTS[8][1] + PET_Y

        self.arms = Sprite(self.group)
        self.arms.image = spyral.Image(filename=ARMS[TYPES[self.t]][0])
        self.arms.layer = ARMS_LAYER
        self.arms.x = PET_POINTS[3][0] + PET_X
        self.arms.y = PET_POINTS[3][1] + PET_Y

        self.legs = Sprite(self.group)
        self.legs.image = spyral.Image(filename=LEGS[TYPES[self.t]][0])
        self.legs.layer = LEGS_LAYER
        self.legs.x = PET_POINTS[5][0] + PET_X
        self.legs.y = PET_POINTS[5][1] + PET_Y

        self.tail = Sprite(self.group)
        self.tail.image = spyral.Image(filename=TAILS[TYPES[self.t]][0])
        self.tail.layer = TAIL_LAYER
        self.tail.x = PET_POINTS[9][0] + PET_X
        self.tail.y = PET_POINTS[9][1] + PET_Y

        self.j = 1

        self.face = Sprite(self.group)
        if self.t <= 1:
            self.face.image = spyral.Image(filename=CD_FACES[self.j])
        elif self.t >= 2:
            self.face.image = spyral.Image(filename=DB_FACES[self.j])
        self.face.layer = FACE_LAYER
        self.face.x = PET_POINTS[2][0] + PET_X
        self.face.y = PET_POINTS[2][1] + PET_Y

        self.i = 0

        self.set_face()
        self.set_color()
        self.set_type()

        instructions = TextSprite(self.group, font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("i: color  j: emote t: type  s: select")

        heading = TextSprite(self.group, font)
        heading.anchor = 'midbottom'
        heading.x = 320
        heading.y = 70
        heading.render("CHESTER PETS")
Пример #9
0
 def __init__(self):
     spyral.Scene.__init__(self)
     self.camera = self.parent_camera.make_child(
         virtual_size=(CK_WIDTH, CK_HEIGHT), layers=['__default__', 'tool'])
     self.group = spyral.Group(self.camera)
     self.tools = [
         random_tool("tsp."),
         random_tool("tbsp."),
         random_tool("cup"),
         random_tool("pint")
     ]
     self.ingredients = [
         Ingredient(self.group, "flour", "FLOUR.png", 230, 10),
         Ingredient(self.group, "sugar", "SUGAR.png", 230, 170),
         Ingredient(self.group, "chocolate", "CHOCOLATE.png", 230, 330),
         Ingredient(self.group, "water", "WATER.png", 350, 10),
         Ingredient(self.group, "eggs", "EGG.png", 350, 170),
         Ingredient(self.group, "butter", "BUTTER.png", 350, 330)
     ]
     recipeSprite = self.addImage("cooking_images/RECIPE_SCROLL.png", 112,
                                  125)
     self.emptyBG = spyral.Sprite(self.group)
     self.emptyBG.image = spyral.Image(size=[CK_WIDTH, CK_HEIGHT])
     self.group.add(self.emptyBG)
     self.font = pygame.font.SysFont(None, 20)
     self.recipe = random_recipe(self.tools, self.ingredients)
     recipelist = self.recipe.__str__().split("\n")
     bigfont = pygame.font.SysFont(None, 40)
     recipeTitle = bigfont.render("COOKIES", True,
                                  [0, 0, 0, 255]).convert_alpha()
     recipeSprite.image._surf.blit(recipeTitle, [30, 10])
     for i in range(len(recipelist)):
         recipe = recipelist[i]
         surf = self.font.render(recipe, True,
                                 [0, 0, 0, 255]).convert_alpha()
         recipeSprite.image._surf.blit(
             surf, [max(max(15, 20 - 5 * i), 5 * i - 5), 50 + 25 * i])
     self.bowl = Recipe([
         Measurement(Fraction(0, 1), "tsp.") for ingred in self.ingredients
     ], self.ingredients)
     self.tsp = self.addImage("cooking_images/TEA_SPOON.png", 65, 285,
                              'tool')
     self.tbsp = self.addImage("cooking_images/TBL_SPOON.png", 165, 285,
                               'tool')
     self.cup = self.addImage("cooking_images/MEASURING_CUP2.png", 65, 395,
                              'tool')
     self.pint = self.addImage("cooking_images/MEASURING_CUP.png", 165, 395,
                               'tool')
     self.toolSprites = [self.tsp, self.tbsp, self.cup, self.pint]
     self.addImage("cooking_images/BOWL.png", 545, 225)
     for i in range(4):
         tool = self.tools[i]
         x = 65 + 100 * (i % 2)
         y = 310
         if i > 1: y += 130
         self.addText(tool.__str__(), x, y)
     for i in range(6):
         ingred = self.ingredients[i]
         string = ingred.name
         string = string[0].upper() + string[1:]
         x = 280
         if i > 2: x += 120
         y = 150 * (i % 3) + 130
         self.addText(string, x, y)
     self.toolSelect = 0
     self.pointer1 = self.addImage("cooking_images/SPOINTER.png", 65, 330)
     self.ingredSelect = 0
     self.pointer3 = self.addImage("cooking_images/SPOINTER.png", 545, 320)
     self.group.remove(self.pointer3)
     self.curTool = None
     self.state = 0