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

CarChallenge 3D Demo

 import QtQuick 2.0

 import Felgo 3.0
 import "entities"

 Item {
     id: level
     width: parent.width
     height: parent.width

     // use this to insert the input action (which car should fire and which to steer) to the right car
     property alias player_red: car_red
     property alias player_blue: car_blue

     // use a physics world because we need collision detection
     // NOTE: only works if the world is placed BEFORE the Level!
     PhysicsWorld {
         id: world
         updatesPerSecondForPhysics: 60
         debugDrawVisible: ingameSettings.physicsDebugVisible
         z: 1 // put it above other elements so the debugDraw is visible
     }

     // background image, only visible in 2D scene
     Image {
         id: background
         source: "../assets/img/asphalt_background.png"
         // since we are using a simple Image element to define our background, we stretch it to avoid any kind of black borders on any device
         // do not stretch it anymore, as it is now shown as a minimap
         width: parent.width*1
         height: parent.height*1
         anchors.centerIn: parent
     }

     Ground {
       anchors.fill: parent
     }

     Car {
         id: car_red
         objectName: "car_red"
         variationType: "carRed"
         x: 120
         y: 200
         // rotation in degrees clockwise
         rotation: 0
     }

     Car {
         id: car_blue
         objectName: "car_blue"
         variationType: "carBlue"
         x: 390
         y: 400
         // rotation in degrees clockwise
         rotation: 225

         image.source: "../assets/img/car_blue.png"

         inputActionsToKeyCode: {
             "up": Qt.Key_W,
             "down": Qt.Key_S,
             "left": Qt.Key_A,
             "right": Qt.Key_D,
             "fire": Qt.Key_Space
         }
     }

     // for testing to shoot a rocket instantly at app start
 //    Rocket {
 //      x: 150
 //      y: 200
 //    }

     Wall {
         id: border_bottom
         wallType: wallTypeEnum.bottom
         height: 20
         anchors {
             left: parent.left
             right: parent.right
             bottom: parent.bottom
         }
     }

     Wall {
         id: border_top
         wallType: wallTypeEnum.top
         height: 20
         anchors {
             top: parent.top
             left: parent.left
             right: parent.right
         }
     }

     Wall {
         id: border_left
         wallType: wallTypeEnum.left
         width: 20
         anchors {
             top: parent.top
             bottom: parent.bottom
             left: parent.left
         }
     }

     Wall {
         id: border_right
         wallType: wallTypeEnum.right
         width: 20
         anchors {
             top: parent.top
             bottom: parent.bottom
             right: parent.right
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded