Durdles - 2-Player Action Game
import QtQuick 2.0
import Felgo 4.0
import "../levels"
EntityBase {
id: singleBullet
entityType: "singleBullet"
x: start.x
y: start.y
property point start
property point velocity
property int bulletType
Image {
width: 7
height: 14
source: bulletType ? "../../assets/img/Icicle.png" : "../../assets/img/Snowball.png"
anchors.centerIn: parent
}
BoxCollider {
id: boxCollider
width: 10
height: 10
anchors.fill: parent
collisionTestingOnlyMode: true
density: 0
friction: 0
restitution: 0
body.bullet: true
body.fixedRotation: false
fixture.onBeginContact: (other, contactNormal) => {
var collidedEntity = other.getBody().target;
var otherEntityId = collidedEntity.entityId;
var otherEntityParent = collidedEntity.parent;
if (otherEntityId.substring(0, 3) !== "lak" && otherEntityId.substring(0, 3) !== "pow") {
singleBullet.destroy();
entityManager.createEntityFromUrlWithProperties(
Qt.resolvedUrl("Splat.qml"), {
"z": 1,
"x": singleBullet.x,
"y": singleBullet.y,
"rotation": singleBullet.rotation
}
);
if (otherEntityId.substring(0, 4) === "tank") {
otherEntityParent.onDamageWithBulletType(bulletType);
}
}
}
}
MovementAnimation {
target: singleBullet
property: "x"
velocity: singleBullet.velocity.x
running: true
}
MovementAnimation {
target: singleBullet
property: "y"
velocity: singleBullet.velocity.y
running: true
onStopped: {
singleBullet.destroy()