def __init__(self, start_pos, goingRight): pygame.sprite.Sprite.__init__(self) Fireball.total_count += 1 if Fireball.image is None: Fireball.image, rect = loadImage("fireball.png", -1) Fireball.blueimage, rect = loadImage("bluefireball.png", -1) Fireball.FX = loadSoundFile("fireball.wav") self.blue = False if random.choice( range(1,11) ) == 10: # roughly 1 out of 10 fireballs is blue self.blue = True if self.blue: self.image = Fireball.blueimage self.vel_y = BLUE_Y_VEL self.vel_x = random.choice( BLUE_X_VELS ) else: self.image = Fireball.image self.vel_y = RED_Y_VEL self.vel_x = random.choice( RED_X_VELS ) if not goingRight: self.vel_x *= -1 self.rect = self.image.get_rect() self.rect.center = start_pos Fireball.FX.play()
def __init__(self, screen): pygame.sprite.Sprite.__init__(self) image, rect = loadImage('mario.png', -1) imagerun, rect = loadImage('mario_run.png', -1) self.stand = pygame.transform.scale2x(image).convert() self.run = pygame.transform.scale2x(imagerun).convert() self.standL = pygame.transform.flip(self.stand, 1, 0).convert() self.runL = pygame.transform.flip(self.run, 1, 0).convert() self.image = self.stand self.rect = self.image.get_rect() self.area = screen.get_rect() self.rect.topleft = (250, 200) self.x_vel, self.y_vel = 0, 0 self.jumping = False self.midair = True self.walkingRight = True self.running = False self.fireball_lock = False self.jump_count = 0 self.score = 0 self.isDead = False self.animTick = 0 self.jumpFX = loadSoundFile("jump.wav") self.hitFX = loadSoundFile("hit.wav")
def __init__(self, start_pos, goingRight): pygame.sprite.Sprite.__init__(self) Fireball.total_count += 1 if Fireball.image is None: Fireball.image, rect = loadImage("fireball.png", -1) Fireball.blueimage, rect = loadImage("bluefireball.png", -1) Fireball.FX = loadSoundFile("fireball.wav") self.blue = False if random.choice(range( 1, 11)) == 10: # roughly 1 out of 10 fireballs is blue self.blue = True if self.blue: self.image = Fireball.blueimage self.vel_y = BLUE_Y_VEL self.vel_x = random.choice(BLUE_X_VELS) else: self.image = Fireball.image self.vel_y = RED_Y_VEL self.vel_x = random.choice(RED_X_VELS) if not goingRight: self.vel_x *= -1 self.rect = self.image.get_rect() self.rect.center = start_pos Fireball.FX.play()
def __init__(self, start_pos, goingRight, blue): pygame.sprite.Sprite.__init__(self) Fireball.total_count += 1 if Fireball.image is None: Fireball.image, rect = loadImage("fireball.png", -1) Fireball.blueimage, rect = loadImage("bluefireball.png", -1) Fireball.FX = loadSoundFile("fireball.wav") self.blue = False ### If the blue parameter is true then use a blue fireball if blue: self.blue = True if self.blue: self.image = Fireball.blueimage self.vel_y = BLUE_Y_VEL self.vel_x = random.choice( BLUE_X_VELS ) else: self.image = Fireball.image self.vel_y = RED_Y_VEL self.vel_x = random.choice( RED_X_VELS ) if not goingRight: self.vel_x *= -1 self.rect = self.image.get_rect() self.rect.center = start_pos Fireball.FX.play()
def init_mainMenu(data): data.candyLocation = None data.mainMenuObjects = [] data.mainMenu_title = loadImage('main_menu_2.png') data.mainMenu = loadImage('background.png') data.mainMenu = pygame.transform.scale(data.mainMenu, (data.width, data.height)) setUp_main_Menu(data)
def __init__(self): super().__init__() self.pulledByGravity = False self.image = loadImage('bubble.png') self.rect = self.image.get_rect()
def __init__(self, x, y): super().__init__() self.x = x self.y = y self.pulledByGravity = False self.image = loadImage('omNom.png') self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y
def __init__(self, x, y): super().__init__() self.x = x self.y = y self.pulledByGravity = False self.image = loadImage('nail.png') self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.isRopeAttached = False
def init(data): data.mode = "mainMenu" data.time = 0 data.timer = 0 data.countdown = 60 # data.mode = 'testLevel' data.margin = 30 data.gravity = 2 data.backButtonPos = (data.width-50,data.height-20) data.caption = 'Cut the Rope' pygame.display.set_caption(data.caption) gameIcon = loadImage('gameIcon.png',-1) pygame.display.set_icon(gameIcon) data.level_bg = loadImage('background.png') data.font = pygame.font.Font('freesansbold.ttf', 20) init_mainMenu(data) init_levelsMenu(data) init_LevelTest(data)
def __init__(self, x, y): super().__init__() self.x = x self.y = y self.pulledByGravity = True self.image = loadImage('candy.png') self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.ropeAttached = False self.attachedRopes = []
def __init__(self, pos): pygame.sprite.Sprite.__init__(self) if PowBlock.image is None: PowBlock.image, rect = loadImage("pow.png", -1) PowBlock.image = pygame.transform.scale2x(PowBlock.image).convert() self.image = PowBlock.image self.rect = self.image.get_rect() self.rect.center = pos #self.rect.topleft = pos self.onGround = False
def __init__(self, screen, start_pos): pygame.sprite.Sprite.__init__(self) if Shell.image is None: tempimage, rect = loadImage("shell.png", -1) Shell.image = pygame.transform.scale2x(tempimage).convert() self.image = Shell.image self.rect = self.image.get_rect() self.rect.center = start_pos self.area = screen.get_rect() self.onGround = False self.falling = False self.vel_y = SHELL_Y_VEL self.vel_x = SHELL_X_VEL if start_pos[0] > self.area.width / 2: self.vel_x *= -1
def init(): global screen, clock, gameoverFX, hitFX, background, background_orig, mario # initialize main pygame stuff os.environ['SDL_VIDEO_CENTERED'] = '1' pygame.mixer.pre_init() #default buffer size is 4096, causes a small delay when asking for a sound to play pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode( SCREEN_SIZE ) pygame.display.set_caption("Mario Shell Defense") # load sounds gameoverFX = loadSoundFile("gameover.wav") hitFX = loadSoundFile("hit.wav") # load music if pygame.mixer: pygame.mixer.music.load( BG_MUSIC ) # set up background #background = pygame.Surface(screen.get_size()).convert() #background.fill((255,255,255)) # changed the background to a different image. # superMario.jpg bg, rect = loadImage("superMario.jpg") background_orig = pygame.transform.scale2x(bg).convert() background = pygame.transform.scale2x(bg).convert() BLOCKS.add( PowBlock((250,390)) ) BLOCKS.add( PowBlock((250+34,390)) ) BLOCKS.add( PowBlock((250+34+34,390)) ) BLOCKS.add( PowBlock((250+34+34+34,390)) ) # set up sprites mario = Mario(screen) HERO.add( mario ) if pygame.mixer: pygame.mixer.music.play(-1)
def init(): global screen, clock, gameoverFX, hitFX, background, background_orig, mario # initialize main pygame stuff os.environ['SDL_VIDEO_CENTERED'] = '1' pygame.mixer.pre_init() #default buffer size is 4096, causes a small delay when asking for a sound to play pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode( SCREEN_SIZE ) pygame.display.set_caption("Mario Shell Defense") # load sounds gameoverFX = loadSoundFile("gameover.wav") hitFX = loadSoundFile("hit.wav") # load music if pygame.mixer: pygame.mixer.music.load( BG_MUSIC ) # set up backgrounddd #background = pygame.Surface(screen.get_size()).convert() #background.fill((255,255,255)) bg, rect = loadImage("background.jpg") background_orig = pygame.transform.scale2x(bg).convert() background = pygame.transform.scale2x(bg).convert() BLOCKS.add( PowBlock((250,390)) ) BLOCKS.add( PowBlock((250+34,390)) ) BLOCKS.add( PowBlock((250+34+34,390)) ) BLOCKS.add( PowBlock((250+34+34+34,390)) ) # set up sprites mario = Mario(screen) HERO.add( mario ) if pygame.mixer: pygame.mixer.music.play(-1)
def __init__(self): super().__init__() self.pulledByGravity = True self.image = loadImage('candy.png') self.rect = self.image.get_rect() self.ropeAttached = False