Example #1
0
    def on_start(self):
        import game

        game.start()

        player = entity.get_entity_type("player")()
        player.position.x, player.position.y = (10, 10)

        game.Game.spawn(player, force=True)
        game.Game.set_player(player.eid)
        player.controlled_by = player.eid

        bow = entity.get_entity_type("BasicMeleeWeapon")(player)
        player.weapon = bow
Example #2
0
    def on_host(self):
        import multiplayer
        import game

        game.start()

        game.Scene.add(multiplayer.host())

        player = entity.get_entity_type("player")()
        player.position.x, player.position.y = (200, 200)

        game.Game.spawn(player)
        game.Game.set_player(player.eid)

        bow = entity.get_entity_type("BasicBow")(player)
        player.weapon = bow
Example #3
0
    def on_update(self, t):
        self.spawn_t += self.spawn_freq * t

        if random.random() < self.spawn_t * t:
            self.spawn_t = 0
            e = entity.get_entity_type("basicenemy")()
            e.position.x = 5
            e.position.y = 5
            game.Game.spawn(e, force=True)
Example #4
0
	def on_update(self, t):
		g = game.game

		self.spawn_t += self.spawn_freq * t

		if random.random() < self.spawn_t * t:
			self.spawn_t = 0
			e = entity.get_entity_type("basicenemy")()
			g.spawn(e)
Example #5
0
    def on_host(self):
        import multiplayer
        import game.game

        scene = cocos.scene.Scene()

        scene.add(game.game.start())
        scene.add(multiplayer.host())

        g = game.game.game

        player = entity.get_entity_type("player")()
        player.position.x, player.position.y = (200, 200)

        g.spawn(player)
        g.set_player(player.eid)

        sword = entity.get_entity_type("BasicMeleeWeapon")(player)
        player.weapon = sword

        director.push(scene)
Example #6
0
    def attack(self):
        wielder = self.get_wielder()

        e = entity.get_entity_type("Projectile")()

        e.controlled_by = wielder.controlled_by
        e.position = wielder.position.copy()
        e.duration = self.proj_life
        e.rotation = wielder.rotation
        e.move_dir = euclid.Vector2(*util.rot_to_vec(e.rotation))
        game.spawn(e)
        
        if game.is_controlled(e):
            events.dispatch("on_attack", self.get_wielder(), self, e)
Example #7
0
    def attack(self):
        real_wielder = self.get_wielder() # The real entity (not the eid)
        e = entity.get_entity_type("MeleeWeaponEntity")()
        e.attached_to = self.wielder
        e.wielder = self.wielder
        e.controlled_by = real_wielder.controlled_by
        e.position = real_wielder.position.copy()
        e.duration = self.duration
        e.duration_left = e.duration
        e.offset = self.offset
        e.arc = self.arc
        e.rotation_off = -self.arc/2
        game.spawn(e)


        if game.is_controlled(e):
            events.dispatch("on_attack", self.get_wielder(), self, e)
Example #8
0
    def attack(self):
        real_wielder = self.get_wielder()

        e = entity.get_entity_type("Projectile")()

        e.damage = 20
        e.friendly = real_wielder.friendly
        e.controlled_by = real_wielder.controlled_by
        e.position = real_wielder.position.copy()
        e.duration = self.proj_life
        e.rotation = real_wielder.rotation
        e.move_dir = util.rot_to_vec(e.rotation)

        game.Game.spawn(e)

        #e.body.linearVelocity = util.rot_to_vec(e.rotation) * self.proj_speed  # TODO: This should be set in the projectille itself (currently cant because of physics body being created after the instance)

        if game.Game.is_controlled(e):
            events.dispatch("on_attack", self.get_wielder(), self, e)
Example #9
0
    def attack(self):
        real_wielder = self.get_wielder()  # The real entity (not the eid)
        e = entity.get_entity_type("MeleeWeaponEntity")()
        e.damage = self.damage
        e.friendly = real_wielder.friendly
        e.attached_to = self.wielder
        e.wielder = self.wielder
        e.controlled_by = real_wielder.controlled_by
        e.position = real_wielder.position.copy()
        e.duration = self.p_duration
        e.duration_left = e.duration
        e.offset = self.offset
        e.arc = self.arc
        e.size = self.size
        e.rotation_off = -self.arc / 2
        e.swing_speed = self.p_swing_speed
        e.width = self.p_width
        e.length = self.p_length
        game.Game.spawn(e)

        if game.Game.is_controlled(e):
            events.dispatch("on_attack", self.get_wielder(), self, e)