diff --git a/NERODevelopment/CMakeLists.txt b/NERODevelopment/CMakeLists.txt index f5bc53f..231754a 100644 --- a/NERODevelopment/CMakeLists.txt +++ b/NERODevelopment/CMakeLists.txt @@ -80,6 +80,7 @@ qt_add_resources(NEROApp "configuration" qtquickcontrols2.conf ) + qt_add_protobuf(NEROApp PROTO_FILES src/proto/serverdata/serverdata.proto diff --git a/NERODevelopment/content/CMakeLists.txt b/NERODevelopment/content/CMakeLists.txt index e9ca36d..c18a9d9 100644 --- a/NERODevelopment/content/CMakeLists.txt +++ b/NERODevelopment/content/CMakeLists.txt @@ -65,4 +65,8 @@ qt6_add_qml_module(content images/interlocks.jpg images/sidebrb.jpg images/tsms.jpg + images/flappy-bird.png + images/yellowbird-upflap.png + images/yellowbird-midflap.png + images/yellowbird-downflap.png ) diff --git a/NERODevelopment/content/FlappyBird.qml b/NERODevelopment/content/FlappyBird.qml index 5ab1f56..09af81e 100644 --- a/NERODevelopment/content/FlappyBird.qml +++ b/NERODevelopment/content/FlappyBird.qml @@ -32,6 +32,15 @@ Item { property double speed: 3 property int frameRate: 25 property bool didJump: flappyBirdController.didJump + property string birdFrame1: "qrc:/content/images/yellowbird-downflap.png" + property string birdFrame2: "qrc:/content/images/yellowbird-midflap.png" + property string birdFrame3: "qrc:/content/images/yellowbird-upflap.png" + + property int currentBirdFrame: 0 + property bool startFalling: false + + property real birdRotation: 0 + onDidJumpChanged: { if (didJump) { @@ -43,14 +52,33 @@ Item { flappyBird.xWall2 = 650 flappyBird.xWall3 = 800 flappyBird.speed = 3 + + // Reset the bird's rotation and drop speed + flappyBird.birdRotation = 0 + flappyBird.birdDrop = 1 + startFalling = false + birdFallDelay.start() // Start the fall timer to ensure bird starts falling even if no jump is pressed return } jumpAnimation.running = true birdDrop = 1 + startFalling = false + birdFallDelay.restart() } } + Timer { + id: birdFallDelay + interval: 150 + running: false + repeat: false + onTriggered: { + startFalling = true // Bird starts falling faster after delay + } + } + + Timer { function isGameOver() { return yBallValue > parent.height || yBallValue < 0 || (xBallValue + pipeWidth > xWall1 && xBallValue < xWall1 + pipeWidth && (yBallValue < wall1.y + pipeHeight || yBallValue + birdHitBox > wall11.y)) || (xBallValue + pipeWidth > xWall2 && xBallValue < xWall2 + pipeWidth && (yBallValue < wall21.y + pipeHeight || yBallValue + birdHitBox > wall22.y)) || (xBallValue + pipeWidth > xWall3 && xBallValue < xWall3 + pipeWidth && (yBallValue < wall31.y + pipeHeight || yBallValue + birdHitBox > wall32.y)) @@ -69,6 +97,7 @@ Item { if (isGameOver()) { flappyBird.gameOver = true } + if (xWall1 < 0) { xWall1 = parent.width wall1.y = -100 - Math.round(Math.random() * 100) @@ -89,9 +118,17 @@ Item { flappyBird.score += 1 } - if (!jumpAnimation.running) { + flappyBird.speed += 0.005 + + if (!jumpAnimation.running && startFalling) { yBallValue += flappyBird.birdDrop - flappyBird.birdDrop += 0.2 + flappyBird.birdDrop += 0.3 // Increase the fall speed by incrementing faster + flappyBird.birdRotation = Math.min(90, flappyBird.birdRotation + 5) // Rotate the bird faster as it falls + } else if (!jumpAnimation.running && !startFalling) { + flappyBird.birdDrop = 1 // Slow initial fall after jump or at the start + flappyBird.birdRotation = Math.min(45, flappyBird.birdRotation + 3) // Slight rotation before full dive + } else { + flappyBird.birdRotation = -45 // Bird flaps up during jump } xWall1 -= flappyBird.speed @@ -153,11 +190,12 @@ Item { Keys.onSpacePressed: { flappyBirdController.enterButtonPressed() + birdFlapAnimation.running = true } NumberAnimation on yBallValue { id: jumpAnimation - to: yBallValue - 40 + to: yBallValue - 50 duration: 100 } @@ -169,11 +207,25 @@ Item { id: ball x: xBallValue y: yBallValue - width: 50 - height: 50 - source: flappyBird.birdSrc + width: implicitWidth + height: implicitHeight + source: { + if (currentBirdFrame === 0) return birdFrame1; + else if (currentBirdFrame === 1) return birdFrame2; + else return birdFrame3; + } + rotation: flappyBird.birdRotation } + SequentialAnimation { + id: birdFlapAnimation + running: false + loops: 1 + + PropertyAnimation { target: flappyBird; property: "currentBirdFrame"; from: 2; to: 0; duration: 1000 } + PropertyAnimation { target: flappyBird; property: "currentBirdFrame"; from: 0; to: 1; duration: 500 } + } + Text { id: gameOverText visible: flappyBird.gameOver diff --git a/NERODevelopment/content/images/yellowbird-downflap.png b/NERODevelopment/content/images/yellowbird-downflap.png new file mode 100644 index 0000000..e9e1c77 Binary files /dev/null and b/NERODevelopment/content/images/yellowbird-downflap.png differ diff --git a/NERODevelopment/content/images/yellowbird-midflap.png b/NERODevelopment/content/images/yellowbird-midflap.png new file mode 100644 index 0000000..2ca3c2d Binary files /dev/null and b/NERODevelopment/content/images/yellowbird-midflap.png differ diff --git a/NERODevelopment/content/images/yellowbird-upflap.png b/NERODevelopment/content/images/yellowbird-upflap.png new file mode 100644 index 0000000..2f693da Binary files /dev/null and b/NERODevelopment/content/images/yellowbird-upflap.png differ