blob: 66dd77677689b2cb87a1ec2d9e5d694a4160bd63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
Rectangle {
property vector2d velocity: Qt.vector2d(0,0)
property double velocityY: velocity.y
property bool gravity: true
function update() {
goUpdate()
}
function goUpdate() {
x += velocity.x
y += velocity.y
}
function colliding(other: GameObject): bool {
return x < other.x + other.width &&
x + width > other.x &&
y < other.y + other.height &&
y + height > other.y
}
onVelocityChanged: {
velocityY = velocity.y
}
}
|