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 4.0
 import "../levels"
 import ".."

 // tank slips on this ground
 EntityBase {
   z: -2
   id: lake
   entityId: "lake"
   entityType: "lake"
   width: 250
   height: 200

   property alias lakeBody: lakeBody
   property alias boxCollider: boxCollider

   // the physical representation of the lake
   Image {
     id: lakeBody
     width: parent.width
     height: parent.height
     anchors.centerIn: parent
   }

   // the PolygonCollider follows the shape of the lake
   PolygonCollider {
     id: boxCollider
     anchors.centerIn: parent
     collisionTestingOnlyMode: true
     vertices: [
       Qt.point(lakeBody.x+lakeBody.width-50, lakeBody.y+45),
       Qt.point(lakeBody.x+110,lakeBody.y+15),
       Qt.point(lakeBody.x+65, lakeBody.y+lakeBody.height-65),
       Qt.point(lakeBody.x+lakeBody.width-75, lakeBody.y+lakeBody.height-45)
     ]

     // handle the begin of the collision
     fixture.onBeginContact: (other, contactNormal) => {
       var collidedEntity = other.getBody().target;

       // signal whether the red or blue tank entered the frozen lake
       if (collidedEntity.isOfType("tank")){
         collidedEntity.parent.onLake = true
       }
     }

     // handle the end of the collision
     fixture.onEndContact: other => {
       var collidedEntity = other.getBody().target;

       // signal wether the red or blue tank left the frozen lake
       if (collidedEntity.isOfType("tank")){
         collidedEntity.parent.onLake = false
         gameScene.offLake(collidedEntity.parent.variationType)
       }
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded