Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Durdles - 2-Player Action Game

 import QtQuick 2.0
 import Felgo 3.0
 import ".."

 EntityBase {
   entityType: "tank"
   entityId: "tank"
   variationType: "tankRed"
   id: tank
   x: originX
   y: originY

   // make the twoAxisController and other variables accessible from outside
   property alias controller: twoAxisController
   property alias tankBody: tankBody
   property alias tankHead: tankHead
   property alias tankCannon: tankCannon
   property alias circleCollider: circleCollider
   property alias shield: shield
   property alias fire: fire
   property alias plingSound: plingSound
   property int life: 3
   property double originX
   property double originY

   // this is used as input for the BoxCollider force & torque properties
   TwoAxisController {
     id: twoAxisController
   }

   // the visual body of the tank
   AnimatedImage {
     id: tankBody
     width: 20
     height: 20
     anchors.centerIn: parent
     playing: false
   }

   // the cannon is a seperate part of the tank with an individual image, animation and rotation
   Rectangle {
     id: tankCannon
     x: tankBody.x + tankBody.width / 2
     y: tankBody.y + tankBody.height / 2 - 2
     width: 4
     height: 4
     transformOrigin: Item.Left
     color: "transparent"

     // the visual cannon/head of the tank
     AnimatedImage {
       z: 0
       id: tankHead
       width: 18
       height: 18
       anchors.centerIn: tankCannon
       playing: false
     }
   }

   // holds the physical properties of the tank
   CircleCollider {
     enabled: !GameInfo.gamePaused
     id: circleCollider
     radius: 10
     x: -radius
     y: -radius
     density: 0
     friction: 0.4
     restitution: 0.4
     linearDamping: 100
     bullet: true

     // this is applied every physics update tick
     linearVelocity: Qt.point(twoAxisController.xAxis * 100, twoAxisController.yAxis * (-100))
   }

   //shield effect for powerup shield
   Image {
     opacity: 0
     id: shield
     width: 35
     height: 35
     anchors.centerIn: parent
     source: "../../assets/img/Shield.png"
   }

   //rocket fire effect while having the accelerator powerUp
   AnimatedImage {
     z: -1
     rotation: tankBody.rotation + 180
     opacity: 0
     id: fire
     width: 22
     height: 34
     anchors.centerIn: parent
     playing: true
     source: "../../assets/img/Rocket.gif"
   }

   // plays when tank collects a powerUp
   SoundEffect {
     volume: 0.3
     id: plingSound
     // an ogg file is not playable on windows, because the extension is not supported!
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded