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

Durdles - 2-Player Action Game

 import Felgo 4.0
 import QtQuick 2.0
 import "../common"
 import ".."
 import "../entities"
 import "../controls"

 // scene with the actual game
 SceneBase {
   id: gameScene

   // filename of the current level
   property string activeLevelFileName
   // currently loaded level
   property var activeLevel
   // countdown shown at level start
   property int countdown: 0
   property alias loader: loader
   // signal when a player leaves the frozen lake and stop his slide movement
   signal offLake(string playerVariationType)

   // set the name of the current level, this will cause the Loader to load the corresponding level
   function setLevel(fileName) {
     activeLevelFileName = fileName
   }

   // physics world for collision detection
   PhysicsWorld {
     id: world
     debugDrawVisible: false
     updatesPerSecondForPhysics: GameInfo.gamePaused ? 0 : 30
     z: 0
   }

   // load levels at runtime
   Loader {
     id: loader
     source: activeLevelFileName ? "../levels/" + activeLevelFileName : ""
     onLoaded: {
       // store the loaded level as activeLevel for easier access
       activeLevel = item
       // restarts the countdown
       countdown = 3
       GameInfo.gamePaused = true
     }
   }

   // text displays either the countdown or ""
   Text {
     anchors.centerIn: parent
     color: "black"
     font.pixelSize: countdown > 0 ? 200 : 18
     font.bold: true
     text: countdown > 0 ? countdown : ""
     font.family: standardFont.name
     opacity: 1
   }

   // if the countdown is greater than 0, this timer is triggered every second, decreasing the countdown (until it hits 0 again)
   Timer {
     repeat: true
     running: countdown > 0
     onTriggered: {
       countdown--
       if (countdown==0) GameInfo.gamePaused = false
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded