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 "scenes"
 import "levels"
 import "common"

 GameWindow {
   // You get free licenseKeys from https://felgo.com/licenseKey
   // With a licenseKey you can:
   //  * Publish your games & apps for the app stores
   //  * Remove the Felgo Splash Screen or set a custom one (available with the Pro Licenses)
   //  * Add plugins to monetize, analyze & improve your apps (available with the Pro Licenses)
   //licenseKey: "<generate one from https://felgo.com/licenseKey>"

   // the size of the Window can be changed at runtime by pressing Ctrl (or Cmd on Mac) + the number keys 1-8
   // the content of the logical scene size (480x320 for landscape mode by default) gets scaled to the window size based on the scaleMode
   // you can set this size to any resolution you would like your project to start with, most of the times the one of your main target device

   screenHeight: 960
   screenWidth: 640

   id: window

   Rectangle {
     id: background
     color: "white"
     anchors.fill: parent

   // create and remove entities at runtime
   EntityManager {
     id: entityManager
     entityContainer: gameScene

   FontLoader {
     id: standardFont
     source: Qt.resolvedUrl("fonts/bubblegum.ttf")

   // menu scene
   MenuScene {
     id: menuScene
     // listen to the button signals of the scene and change the state according to it
     onSelectLevelPressed: window.state = "selectLevel"
     onCreditsPressed: window.state = "credits"
     onSettingsPressed: window.state = "settings"

     // the menu scene is our start scene, so if back is pressed there we ask the user if he wants to quit the application
     onBackButtonPressed: {
       NativeUtils.displayMessageBox(qsTr("Really quit the game?"), "", 2);

     // listen to the return value of the MessageBox
     Connections {
       target: NativeUtils
       onMessageBoxFinished: {
         if (accepted) {

   // scene for selecting levels
   SelectLevelScene {
     id: selectLevelScene
     onLevelPressed: selectedLevel => {
       // selectedLevel is the parameter of the levelPressed signal
       window.state = "game"
     onBackButtonPressed: window.state = "menu"

   // credits scene
   CreditsScene {
     id: creditsScene
     onBackButtonPressed: window.state = "menu"


   // credits scene
   SettingScene {
     id: settingScene
     onBackButtonPressed: window.state = "menu"


   // game scene to play a level
   GameScene {
     id: gameScene
     onBackButtonPressed: window.state = "selectLevel"


   // menuScene is our first scene, so set the state to menu initially
   state: "menu"
   activeScene: menuScene

   // state machine, takes care reversing the PropertyChanges when changing the state, like changing the opacity back to 0
   states: [
     State {
       name: "menu"
       PropertyChanges {target: menuScene; opacity: 1}
       PropertyChanges {target: window; activeScene: menuScene}
     State {
       name: "selectLevel"
       PropertyChanges {target: selectLevelScene; opacity: 1}
       PropertyChanges {target: window; activeScene: selectLevelScene}
     State {
       name: "credits"
       PropertyChanges {target: creditsScene; opacity: 1}
       PropertyChanges {target: window; activeScene: creditsScene}
     State {
       name: "settings"
       PropertyChanges {target: settingScene; opacity: 1}
       PropertyChanges {target: window; activeScene: settingScene}
     State {
       name: "game"
       PropertyChanges {target: gameScene; opacity: 1}
       PropertyChanges {target: window; activeScene: gameScene}
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded