Durdles - 2-Player Action Game
import QtQuick 2.0
import Felgo 4.0
import ".."
import "../entities"
import "../controls"
Item {
id: levelBaseScene
width: 320
height: 480
state: "0"
property alias playerRed: playerRed
property alias playerBlue: playerBlue
property alias tankRed: playerRed.tank
property alias tankBlue: playerBlue.tank
Item {
id: gameWindowAnchorItem
x: gameScene.gameWindowAnchorItem.x
y: gameScene.gameWindowAnchorItem.y
width: gameScene.gameWindowAnchorItem.width
height: gameScene.gameWindowAnchorItem.height
}
Rectangle {
z: 20
id: gameOver
color: "white"
anchors.centerIn: parent
width: 200
height: 80
radius: 10
border.width: GameInfo.border
border.color: "lightgrey"
opacity: GameInfo.gameOver ? 100 : 0
Text {
id: textWinner
text: "The winner of the round is <b>" + GameInfo.winner + "</b>"
color: GameInfo.winnerRed ? GameInfo.red : GameInfo.blue
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 18
font.pixelSize: 14
font.family: standardFont.name
}
Text {
id: textStatistic
text: "Blue: " + GameInfo.blueVictory + "<br>Red: " + GameInfo.redVictory
font.pixelSize: 12
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 14
horizontalAlignment: Text.AlignHCenter
font.family: standardFont.name
}
}
MenuButton {
label.height: 45
label.width: 45
label.source: Qt.resolvedUrl("../../assets/img/Back.png")
color: "transparent"
z: 10
anchors.right: gameWindowAnchorItem.right
anchors.verticalCenter: gameWindowAnchorItem.verticalCenter
onClicked: {
resetLevel()
gameScene.backButtonPressed()
}
}
Image {
z: -2
id:background
source: Qt.resolvedUrl("../../assets/img/GameBG.png")
anchors.centerIn: parent
scale: 0.5
}
Player {
z: 2
id: playerRed
entityType: "player"
variationType: "playerRed"
tank.entityId: "tankRed"
tank.variationType: "tankRed"
tank.originX: gameScene.width / 2
tank.originY: 50 + height / 2
tank.rotation: 0
}
Movement {
z: 2
id: movementRed
player: playerRed
tank: playerRed.tank
originX: gameWindowAnchorItem.width - playerMovementImage.width - 10
originY: 10
anchors{
left: gameWindowAnchorItem.left
right: gameWindowAnchorItem.right
top: gameWindowAnchorItem.top
}
height: gameWindowAnchorItem.height / 2
}
Shot {
z: 2
id: shotRed
player: playerRed
tank: playerRed.tank
anchors {
top: gameWindowAnchorItem.top
topMargin: 10
left: gameWindowAnchorItem.left
leftMargin: 10
}
}
EnergyBar {
z: 2
energy: playerRed.life
id: energyBarRed
barColor: GameInfo.red
anchors {
horizontalCenter: gameWindowAnchorItem.horizontalCenter
top: gameWindowAnchorItem.top
topMargin: 10
}
}
Player {
id: playerBlue
entityType: "player"
variationType: "playerBlue"
tank.entityId: "tankBlue"
tank.variationType: "tankBlue"
tank.originX: gameScene.width / 2
tank.originY: gameScene.height - 50 - height/2
tank.rotation: 0
}
Movement {
id: movementBlue
z: 2
player: playerBlue
tank: playerBlue.tank
originX: 10
originY: height - playerMovementImage.height - 10
anchors {
bottom: gameWindowAnchorItem.bottom
left: gameWindowAnchorItem.left
right: gameWindowAnchorItem.right
}
height: gameWindowAnchorItem.height/2
}
Shot {
z: 2
id: shotBlue
player: playerBlue
tank: playerBlue.tank
anchors {
bottom: gameWindowAnchorItem.bottom
bottomMargin: 10
right: gameWindowAnchorItem.right
rightMargin: 10
}
}
EnergyBar {
z: 2
energy: playerBlue.life
id: energyBarBlue
barColor: GameInfo.blue
anchors {
horizontalCenter: gameWindowAnchorItem.horizontalCenter
bottom: gameWindowAnchorItem.bottom
bottomMargin: 10
}
}
Wall {
id: wallLeft
width: 15
z: 1
anchors {
left: gameWindowAnchorItem.left
top: gameWindowAnchorItem.top
bottom: gameWindowAnchorItem.bottom
}
image.source: Qt.resolvedUrl("../../assets/img/Wall2.png")
image.rotation: 180
}
Wall {
id: wallRight
width: 15
z: 1
anchors {
right: gameWindowAnchorItem.right
bottom: gameWindowAnchorItem.bottom
top: gameWindowAnchorItem.top
}
image.source: Qt.resolvedUrl("../../assets/img/Wall2.png")
}
Wall {
id: wallBottom
height: 15
z: 1
anchors {
left: gameWindowAnchorItem.left
right: gameWindowAnchorItem.right
bottom: gameWindowAnchorItem.bottom
}
image.source: Qt.resolvedUrl("../../assets/img/Wall.png")
}
Wall {
id: wallTop
height: 15
z: 1
anchors {
left: gameWindowAnchorItem.left
right: gameWindowAnchorItem.right
top:gameWindowAnchorItem.top
}
image.source: Qt.resolvedUrl("../../assets/img/Wall.png")
image.rotation: 180
}
function resetLevel(){
activeLevelFileName = ""
GameInfo.gameOver = false
GameInfo.gamePaused = false
GameInfo.testLevel = false;
GameInfo.powerUpCount = 0;
var toRemoveEntityTypes = ["powAccelerator", "powLifeUp", "powPowershot", "powShield", "singleBullet", "singleBulletOpponent"];
entityManager.removeEntitiesByFilter(toRemoveEntityTypes);
playerRed.reset();
playerBlue.reset();
movementRed.reset();