예제 #1
0
class Skeleton(object):
    def __init__(self,x,y,w,h):
        self.screen_vars = ScreenVars()
        self.image = pygame.image.load("skeleton.jpeg")
        self.width = w
        self.height = h
        self.pos_x = x
        self.pos_y = y

        self.delay = random.randint(10,100)

        self.rect = (self.pos_x,self.pos_y,self.width,self.height)
        self.image = pygame.transform.scale(self.image, (self.width,self.height))

    def get_image(self):
        return self.image

    def get_rect(self):
        if self.delay > 0:
            return (-100,-100,self.width, self.height)
        return self.rect

    def move(self, speed):
        if self.delay>0:
            return

        self.pos_y += speed
        if self.pos_y > self.screen_vars.get_height():
            self.delay = random.randint(10,100)
            self.pos_y = 0
        self.rect = (self.pos_x,self.pos_y,self.width,self.height)

    def get_x(self):
        return self.pos_x

    def get_y(self):
        return self.pos_y

    def get_width(self):
        return self.width

    def get_height(self):
        return self.height

    def update(self):
        if self.delay > 0:
            self.delay -= 1

    def kill(self):
        self.delay = random.randint(10,100)
        self.pos_y = 0
예제 #2
0
파일: main.py 프로젝트: filtoid/PumpkinHero
from game import Game
from witch import Witch
from zombie import Zombie
from monster import Monster
from skeleton import Skeleton

import pprint

pygame.init()

FRAME_TIME = 50 #50ms is 20 frames per second

if __name__ == '__main__':
    print("Starting Pumpkin Hero...")
    screen_vars = ScreenVars()
    screen = pygame.display.set_mode((screen_vars.get_width(), screen_vars.get_height()))

    black = (0,0,0)

    witch = Witch(50,0,75,75)
    zombie = Zombie(250,0,75,75)
    monster = Monster(450,0,75,75)
    skeleton = Skeleton(650,0,75,75)

    done = False
    last_time = time.time()*1000.0
    SPEED = 5
    game = Game()
    key_monitor = KeyMonitor()

    #Message pump