def __init__(self): pyggel.scene.BaseSceneObject.__init__(self) self.event_handler = pyggel.event.Handler() self.app = pyggel.gui.App(self.event_handler) self.app.theme.load(data.gui_path("menu_theme.py")) frame = pyggel.gui.Frame(self.app, pos=(500,275), size=(150,175), background_image=None) frame.packer.packtype = "center" pyggel.gui.Button(frame, "Play", callbacks=[self.set_play]) pyggel.gui.NewLine(frame, 10) pyggel.gui.Button(frame, "Back", callbacks=[self.set_back]) f = open(data.misc_path("intro_story.txt"), "rU") text = "\n".join([line.strip() for line in f]) l = pyggel.gui.Label(self.app, text, font_color=(0,0,0,1), font_color_inactive=(0,0,0,1), font="default-small") l.pos = (0,480-l.size[1]) self.background_image = pyggel.image.Image(data.image_path("background_crop_circle.png")) self.logo_image = pyggel.image.Image(data.image_path("chickenstein_logo.png")) self.scene = pyggel.scene.Scene() self.scene.add_2d((self.background_image, self.logo_image)) self.scene.add_2d(self.app) self.have_event = False self.event = None
def __init__(self): pyggel.scene.BaseSceneObject.__init__(self) self.event_handler = pyggel.event.Handler() self.app = pyggel.gui.App(self.event_handler) self.app.theme.load(data.gui_path("menu_theme.py")) frame = pyggel.gui.Frame(self.app, pos=(450,250), size=(175,225), background_image=None) frame.packer.packtype = "center" pyggel.gui.Button(frame, "play", callbacks=[self.set_play]) pyggel.gui.NewLine(frame, 10) pyggel.gui.Button(frame, "levelwarp", callbacks=[self.set_level]) pyggel.gui.NewLine(frame, 10) pyggel.gui.Button(frame, "story", callbacks=[self.set_story]) pyggel.gui.NewLine(frame, 10) pyggel.gui.Button(frame, "quit", callbacks=[self.set_quit]) self.background_image = pyggel.image.Image(data.image_path("background_crop_circle.png")) self.logo_image = pyggel.image.Image(data.image_path("chickenstein_logo.png")) self.scene = pyggel.scene.Scene() self.scene.add_2d((self.background_image, self.logo_image)) self.scene.add_2d(self.app) self.have_event = False self.event = None
def __init__(self, pos, rotation, color, level_data, far=False): if not AlienShot.obj: AlienShot.obj = pyggel.image.Image3D(data.image_path("flash.png")) pyggel.scene.BaseSceneObject.__init__(self) self.collision_body = pyggel.math3d.Sphere(pos, 1) if far: dis = -3.5 else: dis = -1.25 self.pos = pyggel.math3d.move_with_rotation(pos, rotation, dis) self.rotation = rotation self.level_data = level_data self.color = color self.scale_up = True self.scale = 0.75 self.twist = 0 if self.color == (1,1,0.25,1): self.damage = 2 self.speed = 3 if self.color == (0,1,0,1): self.damage = 8 self.speed = 1 if self.color == (0,0,1,1): self.damage = 4 self.speed = 2
def __init__(self, pos): if not HPBuff.obj: HPBuff.obj = pyggel.geometry.Cube(2, texture=pyggel.data.Texture(data.image_path("hp_tex.png")), mirror=True) pyggel.scene.BaseSceneObject.__init__(self) self.pos = pos self.rotation = 25, 0, 0
def __init__(self, pos, kind="quad"): if not Alien.objs: Alien.objs["quad"] = pyggel.geometry.Quad(1) Alien.objs["cube"] = pyggel.geometry.Cube(1, mirror=True, hide_faces=["top", "bottom"]) Alien.objs["sphere"] = pyggel.geometry.Sphere(1) Alien.objs["ellipsoid"] = pyggel.geometry.Sphere(1) Alien.objs["ellipsoid"].scale = 1,2,1 Alien.objs["pyramid"] = pyggel.geometry.Pyramid(2, hide_faces=["bottom"]) Alien.objs["dpyramid"] = pyggel.geometry.DoublePyramid(2) Alien.objs["boss"] = pyggel.geometry.DoublePyramid(5) Alien.objs["boss"].scale = 1,0.5,1 Alien.texs.append(pyggel.data.Texture(data.image_path("alien_face1.png"))) pyggel.scene.BaseSceneObject.__init__(self) self.pos = pos self.rotation = (0,0,0) self.obj = self.objs[kind] self.tex = random.choice(self.texs) self.kind = kind self.color = random.choice(((1,1,0.25,1), (0,1,0,1), (0,0,1,1))) if self.kind == "boss": self.collision_body = pyggel.math3d.AABox(self.pos, 5) else: self.collision_body = pyggel.math3d.AABox(self.pos, (1.5,5,1.5)) self.got_hit = False self.hit_grow = True self.hit_scale = 0 self.hit_scale_inc = 0.1 all_hp = {"quad":4, "pyramid":6, "dpyramid":8, "cube":10, "sphere":15, "ellipsoid":20, "boss":200} self.hp = all_hp[self.kind] self.dead = False if kind == "ellipsoid": self.dead_scale = 2 self.dead_scale_dec = 0.2 else: self.dead_scale = 1 self.dead_scale_dec = 0.1 self.shot_count = 0 self.noticed = False self.stored_LOS = False self.sLOS_count = Alien.base_los_count Alien.base_los_count += 1 if Alien.base_los_count >= 25: Alien.base_los_count = 0 self.connected_to = []
def __init__(self, pos, rotation): if not ChaingunPuff.obj: ChaingunPuff.obj = pyggel.image.Image3D(data.image_path("flash.png")) ChaingunPuff.obj.colorize = 1,1,0.25,1 pyggel.scene.BaseSceneObject.__init__(self) self.pos = pos self.rotation = rotation self.pos = pyggel.math3d.move_with_rotation(self.pos, self.rotation, -2) self.age = 0 self.scale = 1.5
def __init__(self, pos, rotation, size=1): if not ShotgunPuff.obj: ShotgunPuff.obj = pyggel.image.Image3D(data.image_path("shotgun_puff.png")) pyggel.scene.BaseSceneObject.__init__(self) self.pos = pos self.rotation = rotation self.pos = pyggel.math3d.move_with_rotation(self.pos, self.rotation, -1) self.puff_scale = 0.075 * size self.puff_rotate = size*3 self.puff_alpha = 0.5 - size*0.025
def __init__(self, pos, rotation, level_data, scene): if not PlasmaShot.obj: PlasmaShot.obj = pyggel.image.Image3D(data.image_path("flash.png")) PlasmaShot.obj.colorize=(1,0,1,1) pyggel.scene.BaseSceneObject.__init__(self) self.collision_body = pyggel.math3d.AABox(pos, 0.5) self.pos = pyggel.math3d.move_with_rotation((pos[0], 0, pos[2]), rotation, -1.5) self.rotation = rotation self.level_data = level_data self.scale_up = True self.scale = 1 self.twist = 0 self.speed = 2 self.damage = 8
def main(): try: pygame.mixer.pre_init(22050,-16,4,1024) except: pass pyggel.init() try: i = pygame.image.load(data.image_path("chickenstein_logo_small.png")) i.set_colorkey(i.get_at((0,0)), RLEACCEL) pygame.display.set_icon(i) except: pass try: pyggel.view.set_debug(False) except: print "Cannot disable debug, speed may be slower..." pData = PlayerData(hud.Hud()) level = 1 mode = "menu" pData.game_hud.sfx.set_track("menu") core_menu = Menu() core_story_menu = StoryMenu() core_death_menu = DeathMenu() core_win_menu = WinMenu() core_LP_menu = LevelPickMenu() while 1: pyggel.view.set_title("Chickenstein - Team [insert name] - Pyweek #9") if mode == "menu": level = 1 pData.reset() retval = core_menu.run() command = retval[0] elif mode == "game": retval = play_level(level, pData) command = retval[0] elif mode == "story": retval = core_story_menu.run() command = retval[0] elif mode == "death": pData.reset() retval = core_death_menu.run() command = retval[0] elif mode == "win": pData.reset() retval = core_win_menu.run() command = retval[0] elif mode == "level_pick": pData.reset() retval = core_LP_menu.run() command = retval[0] if command == "play warp": level = int(retval[1]) mode = "game" pick = Weapon((0,0,0), "handgun") pData.reset() pData.add_weapon(None, pick.name, pick.obj) pData.game_hud.sfx.set_track("play") continue if command == "menu": mode = "menu" pData.game_hud.sfx.set_track("menu") if command == "level_pick": mode = "level_pick" if command == "story": mode = "story" pData.game_hud.sfx.set_track("menu") if command == "quit": pyggel.quit() return None if command == "play": mode = "game" level = 1 pData.game_hud.sfx.set_track("play") if command == "next": mode = "game" do_transition(retval[1], pData) level += 1 pData.game_hud.sfx.set_track("play") continue if command == "win": mode = "win" pData.game_hud.sfx.play_win() level = 1 pData.game_hud.sfx.set_track("menu") if command == "death": mode = "death" pData.game_hud.sfx.play_loss() level = 1 pData.game_hud.sfx.set_track("menu") if len(retval) == 2: do_transition(retval[1], pData, mute=True)