def init(self): pyglet.clock.schedule_interval(self.spawn_item, vars.SPAWN_RATE) self.effects.append(effect.Effect(600, 42, "info_text")) self.player.eos_action = "loop" self.player.queue(resources.music) self.player.play() self.effects.extend([ effect.Effect(350, 160, "prompt_i"), effect.Effect(370, 160, "prompt_j"), effect.Effect(390, 150, "prompt_k"), effect.Effect(410, 140, "prompt_l"), ])
def convert_from(self, old_version): if old_version < 99: # < 1.0dev self.log_description = "" if old_version < 99.2: # < 1.0dev self.id = self.name self.effect = effect.Effect(self, self.result[0], self.result[1]) del self.result
def CheckColli(self, plat, embd): # plat 攻撃側 embd ダメージ側 if plat.HitSt == 0: if embd.HitSt == 0: xx = abs(plat.PosX - embd.PosX) yy = abs(plat.PosY - embd.PosY) rx = (plat.HitRectX / 2) + (embd.HitRectX / 2) ry = (plat.HitRectY / 2) + (embd.HitRectY / 2) if xx < rx and yy < ry: plat.Death = 1 # 攻撃側は消える # エフェクト imp.Eff.append(effect.Effect(plat.PosX, plat.PosY, 0, 0, 0)) plat.Hit = 1 embd.Hit = 1 embd.Life -= plat.HitPoint # ダメージ計算 if embd.Life <= 0: # 0以下なら死ぬ embd.Life = 0 if imp._DEBUG_ == True: print("hit") return True # 当たり return False # 外れ
def CheckColliBody(self, at, bd): # at 攻撃側 bd ダメージ側 if at.HitSt == 0: if bd.HitSt == 0: xx = abs(at.PosX - bd.PosX) yy = abs(at.PosY - bd.PosY) rx = (at.HitRectX / 2) + (bd.HitRectX / 2) ry = (at.HitRectY / 2) + (bd.HitRectY / 2) if xx < rx and yy < ry: if at.__class__.__name__ != "EnemyBoss": # ボス以外 at.Death = 1 # 攻撃側は消える # エフェクト imp.Eff.append(effect.Effect(at.PosX, at.PosY, 0, 0, 0)) if imp._DEBUG_ == True: print("hit body:" + bd.__class__.__name__) at.Hit = 1 bd.Hit = 1 bd.Life -= 1 # ダメージ計算 if bd.Life <= 0: # 0以下なら死ぬ bd.Life = 0 return True # 当たり return False # 外れ
def ability(self, character, targets): stat_scaling = 0.5 stat_change = character.stats['spell_damage'] * stat_scaling stat_gain = effect.Effect(attack_damage=stat_change, speed=stat_change) character.effect(stat_gain) print(character.get_name() + ' gained ' + str(stat_change) + ' strength and speed')
def check_boss(boss): global boss_die, boss_ox, state for b in gfw.world.objects_at(gfw.layer.bullet): if gobj.collides_box(b, boss): boss_dead = boss.decrease_life(b.Power) if boss_dead: effect.Effect(boss.x, boss.y, 1).generate() for i in range(30): Item(boss.x, boss.y + 100, 0, 0).generate() wav_boss_dead.play() if boss_ox < 200: score.score += 5000 if boss_ox > 200 and boss_ox < 220: score.score += 3000 if boss_ox > 220 and boss_ox < 300: score.score += 1500 boss.remove() boss_die = True b.remove() for bb in gfw.world.objects_at(gfw.layer.boss_bullet): for b in gfw.world.objects_at(gfw.layer.bullet): if LaserBullet.Shoot_state == 2: if gobj.collides_box(bb, b): bb.remove() if gobj.collides_box(bb, player): player.damage_ox = True bb.remove() player_dead = player.decrease_life() player_hit_wav.play() if player_dead: state = END_GAME if boss_die: bb.remove()
def destroy(self): # draw blood neweffect = effect.Effect(self.gameengine.effinfo["blood"], self.gameengine) neweffect.setposition(self.getposition()) self.gameengine.mapfield.effects.append(neweffect) # drop all items self.dropall() # perform death effects if self.getparam("deatheffect") is not None: neweffect = effect.Effect( self.gameengine.effinfo[self.getparam("deatheffect")], self.gameengine) neweffect.setposition(self.getposition()) neweffect.setowner(self.lastattacker) self.gameengine.mapfield.effects.append(neweffect) neweffect.update() self.gameengine.mapfield.cleanup() # inform home that I'm not going home any more if self.home is not None: self.home.removechild(self) # inform children that their home is destroyed for child in self.children: if not child.isalive: self.child.home = None # increase score for the attacker if self.lastattacker is not None and self.getparam( "score") is not None and not self.gameengine.noscore: self.lastattacker.score += int(self.getparam("score")) self.gameengine.gameevent.report( self.getname() + " killed by " + self.lastattacker.getname() + "!", None, None, None) self.raisecombo() self.lastattacker.raisecombo() self.lastattacker.killcount += 1 # update kill list self.lastattacker.killslist[self.getname( )] = self.lastattacker.killslist.get(self.getname(), 0) + 1 else: self.gameengine.gameevent.report( self.getname() + " has been killed! ", None, None, None) # game reset if self.player: self.gameengine.gameevent.report("Merfolk are ecstatic!") self.gameengine.lastscore = self.score self.gameengine.lastplayer = copy.copy(self) self.gameengine.state = "reset"
def update_key(self, action, current): if self.key_effect == current: return else: self.key_effect = current core.manager.effects.append( effect.Effect(self.x, self.y, vars.KEYS[vars.ACTIONS[action][current]], self))
def addEffect(self): # Create a new default effect newEffect = effect.Effect() # Add the effect to the charcter's effects list self.effects.append(newEffect) # Create a EffectFrame for the effect newEffectFrame = EffectFrame(newEffect, self) newEffectFrame.pack()
def ability(self, character, targets): aggro_reduction = 10 aggro_scaling = 1.0 aggro_change = aggro_reduction + character.stats[ 'spell_damage'] * aggro_scaling aggro_effect = effect.Effect(aggro=-aggro_change).return_effect() character.effect(aggro_effect) print(character.get_name() + ' faded into the shadows dropping ' + str(aggro_change) + ' aggro')
def useitem(self, ite): if ite.getflag("usable") and ite.geteffect() is not None: neweffect = effect.Effect(self.gameengine.effinfo[ite.geteffect()], self.gameengine) neweffect.setposition(self.getposition()) self.gameengine.mapfield.effects.append(neweffect) if ite.isstackable() and ite.stack > 1: ite.stack -= 1 else: self.inventory.remove(ite)
def buy_tower(self, x, y, name): if name == 'BUY_ARCHER_TOWER_1': return tower.TowerArcher1(x, y, self.game_map) elif name == 'BUY_ARCHER_TOWER_2': return tower.TowerArcher2(x, y, self.game_map) elif name == 'BUY_ARCHER_TOWER_3': return tower.TowerArcher3(x, y, self.game_map) elif name == 'BUY_ARCHER_TOWER_4': return tower.TowerArcher4(x, y, self.game_map) elif name == 'BUY_MAGIC_TOWER_1': return tower.TowerMagic1(x, y, self.game_map) elif name == 'BUY_MAGIC_TOWER_2': return tower.TowerMagic2(x, y, self.game_map) elif name == 'BUY_MAGIC_TOWER_3': return tower.TowerMagic3(x, y, self.game_map) elif name == 'BUY_MAGIC_TOWER_4': return tower.TowerMagic4(x, y, self.game_map) elif name == 'BUY_STONE_TOWER_1': return tower.TowerStone1(x, y, self.game_map) elif name == 'BUY_STONE_TOWER_2': return tower.TowerStone2(x, y, self.game_map) elif name == 'BUY_STONE_TOWER_3': return tower.TowerStone3(x, y, self.game_map) elif name == 'BUY_STONE_TOWER_4': return tower.TowerStone4(x, y, self.game_map) elif name == 'BUY_SUPPORT_TOWER_1': return tower.TowerSupport1(x, y, self.game_map) elif name == 'BUY_SUPPORT_TOWER_2': return tower.TowerSupport2(x, y, self.game_map) elif name == 'BUY_SUPPORT_TOWER_3': return tower.TowerSupport3(x, y, self.game_map) elif name == 'BUY_SUPPORT_TOWER_4': return tower.TowerSupport4(x, y, self.game_map) elif name == 'BUY_FREEZE': return effect.Effect(x, y, 'FREEZE') elif name == 'BUY_FIRE': return effect.Effect(x, y, 'FIRE') elif name == 'BUY_RAIN': return effect.Effect(x, y, 'RAIN') elif name == 'BUY_STONES': return effect.Effect(x, y, 'STONES') else: return False
def setup(self): """ All variables held here, so the game can be restarted in runtime. :param map: int :return: None """ # Setup game map game_map = self.levels[random.randint(0, len(self.levels) - 1)] self.levels.remove(game_map) self.game_settings = global_variables.game_settings self.game_board = game_board.GameBoard(self.game_settings[game_map][0]) self.screen = self.game_board.get_screen pygame.mixer.music.load('assets/sounds/music1.wav') pygame.mixer.music.set_volume(0.3) self.sound_you_lose = pygame.mixer.Sound('assets/sounds/youlose.wav') self.difficulty = 1 self.game_state = 1 # 1 - Main Menu, 2 - Game started, 3 - You lose, 4 - You win self.wave = 2 * self.difficulty self.wave_number = 0 self.wave_level = 1 self.timer = time.time() self.game_map = game_map global_variables.stats_money = 36 # Enemies pygame.time.set_timer(25, 1000) self.enemy_queue = [] self.enemy_list = pygame.sprite.Group() self.enemy_spawn_position_x = global_variables.game_settings[game_map][ 2][0][0] self.enemy_spawn_position_y = global_variables.game_settings[game_map][ 2][0][1] # Towers self.towers_list = pygame.sprite.Group() self.moving_objects = pygame.sprite.Group() self.tower_available_positions = global_variables.game_settings[ game_map][1] # Player self.player_health = global_variables.stats_player_health = 10 * self.difficulty # Effects pygame.time.set_timer(26, 2000) self.effects_list = pygame.sprite.Group() self.effects_list.add(effect.Effect(600, 400, 'FIRE')) self.positions = []
def __init__(self, id, description, known, cost, prerequisites, danger, tech_type, secondary_data): # A bit silly, but it does the trick. type = buyable.BuyableClass(id, description, cost, prerequisites, type="tech") super(Tech, self).__init__(type) self.danger = danger self.result = "" self.effect = effect.Effect(self, tech_type, secondary_data) if known: # self.finish would re-apply the tech benefit, which is already in # place. super(Tech, self).finish()
def ability(self, character, targets): ability_range = 3 base_damage = 10 damage_scaling = 1.5 targets = [ x for x in targets if (x.stats['enemy'] != character.stats['enemy']) and ( (x.stats['rank'] + character.stats['rank']) <= ability_range) ] for target in targets: spell_damage = base_damage + damage_scaling * character.stats[ 'spell_damage'] target.effect(effect.Effect(health=-spell_damage).return_effect()) print(character.get_name() + '\'s firestorm hit ' + target.get_name() + ' for ' + str(spell_damage))
def __init__(self, id=None, description=None, log_description=None, event_type=None, effects=None, chance=None, unique=None): self.event_id = self.name = self.id = id self.description = description self.log_description = log_description self.event_type = event_type self.effect = effect.Effect(self, effects) self.chance = chance self.unique = unique self.triggered = 0
def ability(self, character, targets): ability_range = 2 base_healing = 40 healing_scaling = 1.0 targets = [ x for x in targets if (x.stats['enemy'] == character.stats['enemy']) and ( (x.stats['rank'] + character.stats['rank']) <= ability_range) ] target = utils.select_target_by_aggro(targets) if target is not None: spell_damage = base_healing + healing_scaling * character.stats[ 'spell_damage'] target.effect(effect.Effect(health=spell_damage).return_effect()) print(character.get_name() + ' healed ' + target.get_name() + ' for ' + str(spell_damage))
def ability(self, character, targets): stat_scaling = 0.2 stat_change = character.stats['spell_damage'] * stat_scaling stat_loss = effect.Effect(attack_damage=-stat_change, spell_damage=-stat_change, speed=-stat_change).return_effect() ability_range = 3 targets = [ x for x in targets if (x.stats['enemy'] != character.stats['enemy']) and ( (x.stats['rank'] + character.stats['rank']) <= ability_range) ] target = utils.select_target_by_aggro(targets) if target is not None: target.effect(stat_loss) print(character.get_name() + ' gained ' + str(stat_change) + ' strength and speed')
def update(self): # do not update immidiately after firing if self.fired: self.fired = False else: if self.getflag("gravity"): if not self.gameengine.mapfield.isgrounded(self.getposition()): self.setposition((self.x, self.y + 1)) if self.getparam("fuse") is not None: if int(self.getparam("fuse")) == 1: neweffect = effect.Effect(self.gameengine.effinfo[self.getparam("fuseeffect")], self.gameengine) neweffect.setposition(self.getposition()) neweffect.setowner(self.lastuser) self.gameengine.mapfield.effects.append(neweffect) self.gameengine.mapfield.items.remove(self) elif int(self.getparam("fuse")) != -1: self.setparam("fuse", int(self.getparam("fuse")) - 1)
def AdaptNewObject(obj): if isinstance(obj, en.Entity): new_obj = en.Entity() elif isinstance(obj, it.Item): new_obj = it.Item() elif isinstance(obj, sk.Skill): new_obj = sk.Skill() elif isinstance(obj, ef.Effect): new_obj = ef.Effect() for attribute in vars(new_obj).keys(): if hasattr(obj, attribute): if not isinstance(getattr(obj, attribute), dict): setattr(new_obj, attribute, getattr(obj, attribute)) else: for sub_attribute, value in getattr(obj, attribute).iteritems(): getattr(new_obj, attribute)[sub_attribute] = value return new_obj
def ability(self, character, targets): ability_range = 0 push_distance = 1 base_damage = 10 damage_scaling = 0.1 targets = [ x for x in targets if (x.stats['enemy'] != character.stats['enemy']) and ( (x.stats['rank'] + character.stats['rank']) <= ability_range) ] target = utils.select_target_by_aggro(targets) if target is not None: spell_damage = base_damage + damage_scaling * character.stats[ 'spell_damage'] target.effect( effect.Effect(health=-spell_damage, rank=push_distance).return_effect()) print(character.get_name() + ' pushed ' + target.get_name() + ' for ' + str(spell_damage))
def theend(): clock = pygame.time.Clock() pygame.event.get() endthing = effect.Effect(["THE END"]) total = sum(record.hiscore.values()) hsthing = effect.HighScoreTotal(["High score total: LLL%s" % total]) endthing.position(vista.screen) hsthing.position(vista.screen) while True: dt = clock.tick(60) * 0.001 if settings.printfps and random.random() < dt: print(clock.get_fps()) for event in pygame.event.get(): result = 0 if event.type == QUIT: sys.exit() else: result = read_event( controller1, event, # pcRect=None, # leave default None--non-directional mb_sids=('nab', None, 'EXIT'), # always_collide_mb=2, # ^ leave default None--non-directional ) controller_changed = (result >= 2) if controller1.getBool('EXIT') and controller_changed: sys.exit() elif controller1.getBool('nab') and controller_changed: sys.exit() elif controller1.getBool('SCREENSHOT') and controller_changed: screenshot(vista.screen) elif controller1.getBool('FULLSCREEN') and controller_changed: settings.fullscreen = not settings.fullscreen vista.init() vista.screen.fill((0, 0, 0)) endthing.draw(vista.screen) hsthing.draw(vista.screen) pygame.display.flip()
def check_enemy(e): global state if gobj.collides_box(player, e): e.remove() player.damage_ox = True player_dead = player.decrease_life() player_hit_wav.play() score.score -= e.level * 1000 if player_dead: state = END_GAME for b in gfw.world.objects_at(gfw.layer.bullet): if gobj.collides_box(b, e): enemy_dead = e.decrease_life(b.Power) if enemy_dead: effect.Effect(e.x, e.y, 0).generate() score.score += e.level * 100 wav_mon_die.play() e.remove() b.remove()
def __init__(self): self.images = [ load_image("image\\char_s2.png"), load_image("image\\char_s3.png"), load_image("image\\ball.png") ] self.x = 400 self.y = 300 self.frame = 0 self.min = 0 self.count = 0 self.moving = False self.go_dir = 0 #어디방향에서 왔는지 0 1 2 3 self.dir = 3.141592 * 2 self.close_dir = [False, False] #좌우 위아래 self.step_dir = 0 #아래가0 시계방향으로 증가 self.cur_dir = 0 self.effect = effect.Effect() self.gokey = False self.imagess = [ load_image("image\\runing2.png"), load_image("image\\runing3.png") ]
def test_sound_file(self): that_effect = effect.Effect('dist_lpf') target_sound = sound_file.SoundFile('drums.wav') input_sound = sound_file.SoundFile('noise.wav') sounds = [target_sound, input_sound] project.Project(sounds) num_frames = min(target_sound.get_num_frames(), input_sound.get_num_frames()) print('num_frames', num_frames) constant_parameter_vector = [0.5] * that_effect.num_parameters parameter_vectors = [ copy.deepcopy(constant_parameter_vector) for _ in range(num_frames) ] self.start_time = time.time() cross_adapter = cross_adapt.CrossAdapter(input_sound=input_sound, neural_input_vectors=[], effect=that_effect) output_filename = 'test_cross_adapt.wav' process, output_sound_file, csd_path = cross_adapter.cross_adapt( parameter_vectors, that_effect, output_filename) self.files_to_delete.append(csd_path) print('process', process) print('output file', output_sound_file) print('csd path', csd_path) process.wait() print("Execution time: {0} seconds".format(time.time() - self.start_time))
def theend(): clock = pygame.time.Clock() pygame.event.get() endthing = effect.Effect(["THE END"]) total = sum(record.hiscore.values()) hsthing = effect.HighScoreTotal([u"High score total: \u00A3%s" % total]) endthing.position(vista.screen) hsthing.position(vista.screen) while True: dt = clock.tick(60) * 0.001 if settings.printfps and random.random() < dt: print clock.get_fps() for event in pygame.event.get(): if event.type == QUIT: exit() elif event.type == KEYDOWN and event.key in (K_ESCAPE, K_SPACE): exit() elif event.type == KEYDOWN and event.key == K_F12: pygame.image.save(vista.screen, "screenshot.png") vista.screen.fill((0, 0, 0)) endthing.draw(vista.screen) hsthing.draw(vista.screen) pygame.display.flip()
def convert_from(self, old_version): if old_version < 99.2: # < 1.0dev self.effect = effect.Effect(self, self.tech_type, self.secondary_data) del self.tech_type del self.secondary_data
def from_url(url, certificate_authority=None, verify=True): return effect.Effect(ConfigFromServer(url, verify, certificate_authority))
def from_kubeconfig(filename): return effect.Effect(FromKubeConfig(filename))
def from_service_account(): return effect.Effect(FromServiceAccount())