Durdles - 2-Player Action Game
import QtQuick 2.0
import Felgo 4.0
import "../../levels"
import "../.."
EntityBase {
id: powerUpSpawn
entityType: "powerUpSpawn"
z: 2
property alias spawnBody: spawnBody
property alias circleCollider: circleCollider
property alias spawnSound: spawnSound
property int minSpawnRadius: 27
property double spawnRadiusDelta: 1.5
GameSoundEffect {
volume: 0.3
id: spawnSound
source: Qt.resolvedUrl("../../../assets/snd/Spawn.wav")
}
Image {
id: spawnBody
width: 40
height: 40
anchors.centerIn: parent
}
CircleCollider {
id: circleCollider
radius: 20
x: -radius
y: -radius
bodyType: Body.Static
}
property int timeMin: 8000
property int timeSpan: 12000
property int limit: Math.ceil(Math.random() * (timeSpan) + timeMin);
Timer {
id: timerGame
interval: limit;
running: GameInfo.gamePaused ? false : true;
repeat: true;
onTriggered: {
limit = Math.ceil(Math.random() * (timeSpan) + timeMin);
if (GameInfo.powerUpCount<GameInfo.maxPowerUpsOnField){
spawnRandomItem()
}
}
}
function spawnRandomItem(){
var differentItems = 4
var randomItem = Math.ceil(Math.random() * (differentItems));
var randomAngle = Math.ceil(Math.random() * (359));
var radius = Math.ceil(Math.random() * (spawnRadiusDelta)) + minSpawnRadius;
var startX = (radius*Math.cos((randomAngle)*Math.PI/180)) + powerUpSpawn.x
var startY = (radius*Math.sin((randomAngle)*Math.PI/180)) + powerUpSpawn.y
var url
if (randomItem==1){url = "PowerUpAccelerator.qml"}
if (randomItem==2){url = "PowerUpLifeUp.qml"}
if (randomItem==3){url = "PowerUpPowershot.qml"}
if (randomItem==4){url = "PowerUpShield.qml"}
spawnSound.play()
entityManager.createEntityFromUrlWithProperties(
Qt.resolvedUrl(url), {
"z": 1,
"x": startX-12,
"y": startY-12,
}