def __init__(self, x, y, shadow): self.hp = 30 self.recoilTime = 12 self.weight = 1 self.shadow = shadow self.z = y sprIdle = pygmi.Sprite("img/enemy/apathol_idle", -8, -38, 16, 18) sprIdle.setFrameTime(30) sprRecoil = pygmi.Sprite("img/enemy/apathol_recoil", -24, -52, 42, 44) sprRecoil.setFrameTime(4) self.apathol = {'idle': sprIdle, 'recoil': sprRecoil} super().__init__(self.apathol['idle'], x, y) self.setSolid(True)
def update(self): if self.character.hp != self.hp: self.setSprite( pygmi.Sprite( pygmi.Tools.makeText(self.character.hp, None, None, None), 0, 0, 0, 0)) self.hp = self.character.hp
def __init__(self, game): self.game = game oShadowBoy = Shadow( pygmi.Sprite("img/fx/shadowHuman.png", 0, 0, 34, 10), 100 - 19, 400 - 6) oBoy = Character(100, 400, oShadowBoy, self.game) oHUD = HUD(10, 10, oBoy) oShadowApathol = Shadow( pygmi.Sprite("img/fx/shadowApathol.png", 0, 0, 16, 6), 200 - 8, 400) oApathol = Apathol(200, 400, oShadowApathol) bgStreet = pygmi.Object( pygmi.Sprite("img/bg/street.png", 0, 0, 800, 600), 0, 0) super().__init__("street", 1200, 600) self.addToRoom(bgStreet) self.addToRoom(oShadowBoy) self.addToRoom(oShadowApathol) self.addToRoom(oBoy) self.addToRoom(oHUD) self.addToRoom(oApathol)
def __init__(self, x, y, hitbox, owner): self.power = 0 self.hitbox = hitbox self.owner = owner self.enemyList = [] htbxBoyPunch1 = pygmi.Sprite("img/htbx/zPunch1.png", 0, 0, 17, 14) htbxBoyPunch2 = pygmi.Sprite("img/htbx/zPunch2.png", 0, 0, 17, 14) htbxBoyKick = pygmi.Sprite("img/htbx/zKick.png", 0, 0, 21, 16) htbxBoyDatk = pygmi.Sprite("img/htbx/zDatk.png", 0, 0, 19, 30) htbxBoyAkick = pygmi.Sprite("img/htbx/zAkick.png", 0, 0, 21, 16) self.htbxBoy = { 'punch1': htbxBoyPunch1, 'punch2': htbxBoyPunch2, 'kick': htbxBoyKick, 'datk': htbxBoyDatk, 'akick': htbxBoyAkick } if hitbox == "punch1": self.sprite = self.htbxBoy['punch1'] self.countdown = 8 self.power = 1 if hitbox == "punch2": self.sprite = self.htbxBoy['punch2'] self.countdown = 8 self.power = 1 if hitbox == "kick": self.sprite = self.htbxBoy['kick'] self.countdown = 8 self.power = 5 if hitbox == "datk": self.sprite = self.htbxBoy['datk'] self.countdown = 21 self.power = 5 if hitbox == 'akick': self.sprite = self.htbxBoy['akick'] self.countdown = 10 self.power = 8 super().__init__(self.sprite, x, y) self.setSolid(True)
@author: Catt ''' import pygmi, pygame, os, sys, math from pygame.locals import * from menu import * from street import * if __name__ == '__main__': x_dim = 800 y_dim = 600 game = pygmi.Pygmi((x_dim, y_dim), "Test Game", 0) oPlay = PlayButton(x_dim - 64, y_dim - 60, game) oQuit = QuitButton(x_dim - 64, y_dim - 30, game) mainmenu = pygmi.Room("mainmenu", x_dim, y_dim) bgMainMenu = pygmi.Object(pygmi.Sprite("img/bg/title.png", 0, 0, 800, 600), 0, 0) mainmenu.addToRoom(bgMainMenu) mainmenu.addToRoom(oPlay) mainmenu.addToRoom(oQuit) game.addRoom(mainmenu) game.addRoom(Street(game)) game.gotoRoom("mainmenu") while (True): #update game.update() #render game.render() #paint game.paint()
def __init__(self, x, y, shadow, game): self.game = game self.shadow = shadow self.xSpeed = 0 self.ySpeed = 0 self.z = y self.x_scale = 1 self.hp = 30 self.xDashSpeed = 0 self.yDashSpeed = 0 self.runModifier = 1 self.dominantX = 0 self.dominantY = 0 self.stillHolding = [0, 0, 0, 0] self.running = 0 self.listRunClock = [0, 0, 0, 0] self.attacking = 0 self.moving = 0 self.airborne = 0 self.jumpRelease = 0 self.jumpSpeed = 0 self.maxJumpSpeed = 5 self.gravity = .4 self.punch1Anim = 0 self.punch2Anim = 0 self.kickAnim = 0 self.datkAnim = 0 self.akickAnim = 0 sprIdle = pygmi.Sprite("img/char/boy_idle", -18, -64, 30, 64) sprIdle.setFrameTime(30) sprWalk = pygmi.Sprite("img/char/boy_walk", -18, -66, 30, 66) sprWalk.setFrameTime(8) sprRun = pygmi.Sprite("img/char/boy_run", -22, -70, 44, 68) sprRun.setFrameTime(5) sprPunch1 = pygmi.Sprite("img/char/boy_punch1", -18, -64, 40, 64) sprPunch1.setFrameTime(2) sprPunch2 = pygmi.Sprite("img/char/boy_punch2", -20, -64, 38, 64) sprPunch2.setFrameTime(2) sprKick = pygmi.Sprite("img/char/boy_kick", -18, -64, 40, 64) sprKick.setFrameTime(2) sprDatk = pygmi.Sprite("img/char/boy_datk", -20, -66, 40, 64) sprDatk.setFrameTime(3) sprJump = pygmi.Sprite("img/char/boy_jump", -18, -66, 32, 66) sprJump.setFrameTime(2) sprLand = pygmi.Sprite("img/char/boy_land.png", -16, -66, 30, 66) sprAkick = pygmi.Sprite("img/char/boy_akick", -12, -59, 36, 60) sprAkick.setFrameTime(2) self.boy = { 'idle': sprIdle, 'walk': sprWalk, 'run': sprRun, 'punch1': sprPunch1, 'punch2': sprPunch2, 'kick': sprKick, 'datk': sprDatk, 'jump': sprJump, 'land': sprLand, 'akick': sprAkick } super().__init__(self.boy['idle'], x, y) self.setSolid(True)
def __init__(self, x, y, character): self.hp = str(character.hp) self.character = character self.sprHP = pygmi.Sprite( pygmi.Tools.makeText(self.hp, None, None, None), 0, 0, 0, 0) super().__init__(self.sprHP, x, y)
def __init__(self, x, y, game): self.sprQuit = pygmi.Sprite("img/hud/quit.png", 0, 0, 64, 30) self.sprQuitLit = pygmi.Sprite("img/hud/quitlit.png", 0, 0, 64, 30) self.game = game super().__init__(self.sprQuit, self.sprQuitLit, x, y)
def __init__(self, x, y, game): self.sprPlay = pygmi.Sprite("img/hud/play.png", 0, 0, 64, 30) self.sprPlayLit = pygmi.Sprite("img/hud/playlit.png", 0, 0, 64, 30) self.game = game super().__init__(self.sprPlay, self.sprPlayLit, x, y)