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 ".."

 // block the player's path and cause damage on contact
 EntityBase {
   id: obstacle
   entityType: "obstacle"
   entityId: "obstacle"

   // make the image and collider accessible from outside
   property alias obstacleBody: obstacleBody
   property alias circleCollider: circleCollider

   // the visual representation of the obstacle
   Image {
     id: obstacleBody
     width: 25
     height: 25
     anchors.centerIn: parent

   CircleCollider {
     id: circleCollider
     radius: obstacleBody.width/2
     x: -radius
     y: -radius
     bodyType: Body.Static

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

       // check if it hit a player
       if (collidedEntity.isOfType("tank")) {
         // call damage method on playerRed or playerBlue
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded