ZombieBreak Demo
import Felgo 4.0
import QtQuick 2.0
EntityBase {
id: entity
entityType: "bullet"
width: sprite.width
height: sprite.height
property int speed
CircleCollider {
id: circleCollider
radius: sprite.width/2
anchors.centerIn: parent
fixture.friction: 0
fixture.restitution: 1
bullet: true
}
Image {
id: sprite
source: Qt.resolvedUrl("../../assets/img/bullet.png")
}
function reStart(posx,posy) {
reset(posx,posy)
var angle = utils.generateRandomValueBetween(-135,-115)
if (typeof(Number.prototype.toRad) === "undefined") {
Number.prototype.toRad = function() {
return this * Math.PI / 180;
}
}
var x = Math.cos(angle.toRad())*speed
var y = Math.sin(angle.toRad())*speed
circleCollider.applyLinearImpulse(Qt.point(x, y), Qt.point(circleCollider.x, circleCollider.y))
}
function reset(xpos,ypos) {
x = xpos
y = ypos
speed = 350