def createUnit(pos, color, factionId):
    coreInstance.addEntity(
        Entity(
            pos=pos,
            collision=Collision(['layerA'], (0.025, 0.025), colisionReaction),
            friction=0.93,
            walker=Mobile(speed=0.03),
            faction=Faction(factionId),
            mouseControlled=MouseControlled(),
            deltaVector=[0, 0, 0],
            render=Render('Cube', 0.05, color=color),
            hp=Health(100),
        ))
def createFactory(pos, color, factionId):
    coreInstance.addEntity(
        Entity(
            pos=pos,
            collision=Collision(['layerA'], (0.025, 0.025), colisionReaction),
            friction=0.93,
            walker=Mobile(speed=0.03),
            faction=Faction(factionId),
            deltaVector=[0, 0, 0],
            regularInvoker=RegularInvoker(200, lambda: combinedSpawner(pos, color, factionId)),
            render=Render('Cube', 0.05, color=color),
            hp=Health(100),
        ))
Ejemplo n.º 3
0
    def spawnBomb(self, key):
        if key != b' ':
            return

        ownerEntity = coreInstance.entities[self.ownerId]
        coreInstance.addEntity(
            Entity(
                pos=scramblePosition(ownerEntity.pos, 0.05),
                render=Render("Model1"),
                bomb=Bomb(),
                gravity=Gravity(),
                friction=0.93,
                collision=Collision(['layerA'], (0.1, 0.1)),
                deltaVector=scramblePosition(ownerEntity.deltaVector, 0.05)))
Ejemplo n.º 4
0
def initSandboxWorld():
    coreInstance.addEntity(Entity(pos=[2, 0, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[-2, 0, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[0, 2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[0, -2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))

    coreInstance.addEntity(
        Entity(
            pos=[0, 0, 0],
            collision=Collision(['layerB'], (0.1, 0.1)),
            friction=0.93,
            deltaVector=[0, 0, 0],
            render=Render('Model1'),
            hp=Health(100),
            playerControlled=PlayerControlled(),
            bomberMan=BomberMan(),
            deinit=lambdav('print("game over")\n'
                           'sys.exit()')
            #    gravity=Gravity()
        ))
Ejemplo n.º 5
0
 def onKeyDown(self, key):
     entity = coreInstance.entities[self.ownerId]
     if key == b'a':
         entity.pos[0] -= 0.035
         entity.deltaVector[0] -= 0.085
     elif key == b'd':
         entity.pos[0] += 0.035
         entity.deltaVector[0] += 0.085
     elif key == b'w':
         entity.deltaVector[1] += 0.085
         entity.pos[1] += 0.015
     elif key == b's':
         entity.deltaVector[1] -= 0.085
         entity.pos[1] -= 0.015
     elif key == b' ':
         for _ in range(0,10):
             coreInstance.addEntity(Entity(
                 pos=scramblePosition(entity.pos, 0.01),
                 friction=0.93,
                 collision=Collision(['layerA'], (0.005, 0.005), collisionCausesPositionRevert),
                 deltaVector=scramblePosition(entity.deltaVector, 0.15),
                 gravity=Gravity([0, -0.01, 0]),
                 render=Render('Cube', 0.01)
             ))
def initArkanoid():
    coreInstance.addEntity(Entity(pos=[-2, -2, 0], collision=Collision(["layerA", "layerB"], (1, 1))))
    coreInstance.addEntity(Entity(pos=[2, -2, 0], collision=Collision(["layerA", "layerB"], (1, 1))))
    coreInstance.addEntity(Entity(pos=[2, 2, 0], collision=Collision(["layerA", "layerB"], (1, 1))))
    coreInstance.addEntity(Entity(pos=[-2, 2, 0], collision=Collision(["layerA", "layerB"], (1, 1))))
    coreInstance.addEntity(Entity(pos=[-2, 0, 0], collision=Collision(["layerA", "layerB"], (1, 1))))
    coreInstance.addEntity(Entity(pos=[2, 0, 0], collision=Collision(["layerA", "layerB"], (1, 1))))
    coreInstance.addEntity(Entity(pos=[0, 2, 0], collision=Collision(["layerA", "layerB"], (1, 1))))

    coreInstance.addEntity(Entity(pos=[0, -2, 0], collision=Collision(["layerA", "layerB"], (1, 1))))

    def onCollision(entA, entB, vector):
        pass

    def onCollisionBall(entA, entB, vector):
        if abs(vector[0]) > abs(vector[1]):
            entA.deltaVector[0] *= -0.99
        else:
            entA.deltaVector[1] *= -0.99
        entA.deltaVector = scramblePosition(entA.deltaVector, 0.01)
        entA.deltaVector = [x * 0.04 for x in normalize(entA.deltaVector)]

    coreInstance.addEntity(
        Entity(
            pos=[0, -0.85, 0],
            collision=Collision(["layerA"], (0.15, 0.05), OnCollisionReaction=onCollisionBall),
            friction=0.93,
            deltaVector=[0, 0, 0],
            render=Render("Cube", dimensions=[0.3, 0.1, 1]),
            hp=Health(100),
            playerControlled=PlayerControlled()
            # gravity=Gravity()
        )
    )

    coreInstance.addEntity(
        Entity(
            name="Ball",
            pos=[0, -0.3, 0],
            collision=Collision(["layerA"], (0.05, 0.05), OnCollisionReaction=onCollisionBall),
            friction=1.0,
            deltaVector=[0.05, -0.15, 0],
            render=Render("Cube", dimensions=[0.1, 0.1, 1]),
        )
    )

    def onCollisionBrick(entA, entB, vector):
        if hasattr(entA, "name") and entA.name == "Brick":
            coreInstance.deleteEntity(entA.id)

    for xPos in range(0, 10):
        for yPos in range(0, 3):
            coreInstance.addEntity(
                Entity(
                    name="Brick",
                    pos=[xPos * 0.15 - 0.5, yPos * 0.15 + 0.5, 0],
                    collision=Collision(["layerA"], (0.05, 0.05), OnCollisionReaction=onCollisionBrick),
                    render=Render("Cube", dimensions=[0.1, 0.1, 1]),
                    deltaVector=[0.0, 0.0, 0.0],
                    friction=0.0,
                )
            )
def initPlatformer():
    coreInstance.addEntity(Entity(pos=[-2, -2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[2, -2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[2, 2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[-2, 2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))

    coreInstance.addEntity(Entity(pos=[-2, 0, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[2, 0, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[0, 2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))
    coreInstance.addEntity(Entity(pos=[0, -2, 0], collision=Collision(['layerA', 'layerB'], (1, 1))))

    coreInstance.addEntity(Entity(
        pos=[0.4, 0.2, 0], render=Render('Cube', 0.1), collision=Collision(['layerA', 'layerB'], (0.05, 0.05))))
    coreInstance.addEntity(Entity(
        pos=[-0.4, -0.6, 0], render=Render('Cube', 0.1), collision=Collision(['layerA', 'layerB'], (0.05, 0.05))))
    coreInstance.addEntity(Entity(
        pos=[0.0, -0.3, 0], render=Render('Cube', 0.1), collision=Collision(['layerA', 'layerB'], (0.05, 0.05))))

    coreInstance.addEntity(
        Entity(
            pos=[0, 0, 0],
            collision=Collision(['layerB'], (0.05, 0.05), collisionCausesPositionRevert),
            friction=0.93,
            deltaVector=[0, 0, 0],
            render=Render('Cube', 0.1),
            hp=Health(100),
            gravity=Gravity([0, -0.01, 0]),
            playerControlled=PlayerControlled(),
            deinit=lambdav('print("game over")\n'
                           'sys.exit()')
        ))