Skip to content

Commit

Permalink
Merge pull request #5 from MisterGC/features/assests-round1
Browse files Browse the repository at this point in the history
Features/assests round1
  • Loading branch information
MisterGC authored Apr 20, 2020
2 parents 5a001b2 + 4a422cd commit b0098e8
Show file tree
Hide file tree
Showing 37 changed files with 10,399 additions and 179 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
== Keeper of the Garden ==
![Keeper of the Garden Title](devlog/m5_clean_title_screen.png)
# Keeper of the Garden
My Game for [Ludum Dare 46](https://ldjam.com/events/ludum-dare/46).
You are the `Keeper of the Garden`, take care of plants and fight against greedy creatures.
2 changes: 1 addition & 1 deletion dep/clayground
Binary file added devlog/m4_enemies_are_alive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added devlog/m5_clean_title_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added devlog/m5_game_with_assets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added devlog/m5_game_with_assets_II.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/Enemy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QtQuick 2.12
import Box2D 2.0
import Clayground.Physics 1.0
import Clayground.ScalingCanvas 1.0
import QtMultimedia 5.12

GameEntity
{
Expand Down Expand Up @@ -76,7 +77,16 @@ GameEntity
Timer {
id: theMunchTimer
interval: 1000
onTriggered: attack(2);
onTriggered: attack(5);
repeat: true
onRunningChanged: {
if (running) munchSound.play();
else munchSound.stop();
}
}

SoundEffect {
id: munchSound
source: theWorld.resource("sound/munching.wav")
}
}
2 changes: 2 additions & 0 deletions src/EnemyMaster.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ Item {
enemy.active = Qt.binding( _ => {return gameWorld.running;} );
_spawned.push(enemy);
}
triggeredOnStart: true
}

Component { id: theSpawner; Enemy {} }


ScalingPoly {
visible: false
canvas: gameWorld
strokeStyle: ShapePath.DashLine
dashPattern: [ 1, 4 ]
Expand Down
20 changes: 11 additions & 9 deletions src/GameEnding.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ Rectangle {
referee.seasonEnded.connect(onSeasonEnded);
}

function onGardenDied() {showEnd("Garden died!");}
function onPlayerDied() {showEnd("Player died!");}
function onSeasonEnded() {showEnd("Season ended!");}
function onGardenDied() {showEnd("gardendied", "#95a3a3");}
function onPlayerDied() {showEnd("keeperdied", "#9291a3");}
function onSeasonEnded() {showEnd("youhavewon", "#d8c371")}

function showEnd(txt) {
function showEnd(img, bgColor) {
if (!visible) {
theEndTxt.text = txt;
theImage.source = theWorld.resource("visual/" + img + ".png");
color = bgColor;
visible = true;
}
}

Text {
id: theEndTxt
Image {
id: theImage
source: ""
height: parent.height
width: (sourceSize.width / sourceSize.height) * height
anchors.centerIn: parent
font.pixelSize: parent.height * .1
text: "The Game ends ..."
}
}

14 changes: 13 additions & 1 deletion src/Garden.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import QtQuick 2.12
import Box2D 2.0
import Clayground.Physics 1.0
import Clayground.ScalingCanvas 1.0
import QtGraphicalEffects 1.12

GameEntity
{
id: theGarden

source: energyPercentage > 0.75 ? gameWorld.resource("visual/garden.png")
: (energyPercentage > 0.33 ? gameWorld.resource("visual/gardend1.png")
: gameWorld.resource("visual/gardend2.png"))
bodyType: Body.Static
categories: collCat.garden
collidesWith: collCat.player |
Expand All @@ -19,10 +24,15 @@ GameEntity
property int maxEnergy: widthWu * heightWu
// Energy of the garden, if it is 0, the garden dead
property int energy: maxEnergy
property real energyPercentage: (energy * 1.0)/maxEnergy
// Protection decreases dealt damage
property real protection: 0

text: energy + "/" + protection
GlowEffect {
visible: theGarden.protection > 0
image: theGarden.image
}

Component.onCompleted: {
for (let i=0; i<fixtures.length; ++i) {
Expand Down Expand Up @@ -58,6 +68,8 @@ GameEntity

function _onAttack(damage) {
let d = damage * ((protection > 0) ? protection : 1)
energy -= d;
if (energy > 0) energy -= d;
if (energy < 0) energy = 0;

}
}
15 changes: 15 additions & 0 deletions src/GlowEffect.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// (c) [email protected] - zlib license, see "LICENSE" file
import QtQuick 2.12
import QtGraphicalEffects 1.12

Glow {
property var image: null
parent: image.parent
width: image.width
height: image.height
radius: 20
samples: 17
color: "#00dce7"
source: image
Behavior on radius { NumberAnimation {duration: 2000}}
}
30 changes: 26 additions & 4 deletions src/Player.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// (c) [email protected] - zlib license, see "LICENSE" file

import QtQuick 2.12
import QtMultimedia 5.12
import Box2D 2.0
import Clayground.Physics 1.0
import Clayground.ScalingCanvas 1.0
Expand All @@ -11,9 +12,10 @@ GameEntity
bodyType: Body.Dynamic
bullet: true

property int energy: 3
source: theWorld.resource("visual/player.png");
property int energy: 4

property real moveSpeed: 25
property real moveSpeed: 35
property real dodgeSpeed: 0
property real _desiredVeloX: 0
property real _desiredVeloY: 0
Expand All @@ -23,7 +25,22 @@ GameEntity
property bool isProtecting: false
// Workaround to trigger collision checks even if player doesn't
// move between triggering protections two time
onIsProtectingChanged: { awake = false; awake = true; }
onIsProtectingChanged: {
awake = false; awake = true;
if (isProtecting) protectSound.play();
else protectSound.stop();
}
SoundEffect {
id: protectSound
source: theWorld.resource("sound/protecting.wav")
loops: SoundEffect.Infinite
}
onIsDodgingChanged: if (isDodging) dodgeSound.play();
SoundEffect {
id: dodgeSound
source: theWorld.resource("sound/dodge.wav")
volume: .5
}

debug: true
text: energy > 0 ? "".repeat(energy) : ""
Expand All @@ -44,7 +61,7 @@ GameEntity
id: protectionRangeVisu
opacity: .2
color: "red"
visible: thePlayer.isProtecting
visible: false
property int scaleFac: thePlayer.isProtecting ? 10 : 1
x: -.5 * (width - thePlayer.width)
y: -.5 * (width - thePlayer.width)
Expand All @@ -65,6 +82,11 @@ GameEntity
property real protection: thePlayer.isProtecting ? .5 : 0
}
}
GlowEffect {
visible: thePlayer.isProtecting || thePlayer.isDodging
image: thePlayer.image
color: thePlayer.isProtecting ? "#00dce7" : "#e79100"
}

onDodgeSpeedChanged: {
_updateVelocity();
Expand Down
62 changes: 41 additions & 21 deletions src/Sandbox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ClayWorld {
property var player: null
//physicsDebugging: true

Rectangle {parent: coordSys; anchors.fill: parent; color: "#acdc83";}

QtObject {
id: collCat
readonly property int staticGeo: Box.Category1
Expand All @@ -31,17 +33,12 @@ ClayWorld {
}

onWorldAboutToBeCreated: {
if (map === "") return;
running = false;
player = null;
}
onWorldCreated: {
// theGameCtrl.selectKeyboard(Qt.Key_Up,
// Qt.Key_Down,
// Qt.Key_Left,
// Qt.Key_Right,
// Qt.Key_A,
// Qt.Key_S);
theGameCtrl.selectGamepad(0, true);
if (map === "") return;
theWorld.observedItem = player;
theWorld.running = true;
}
Expand Down Expand Up @@ -69,21 +66,30 @@ ClayWorld {

property bool inGameCtrlEnabled: theWorld.running && theWorld.player

Component.onCompleted: {
theGameCtrl.selectKeyboard(Qt.Key_Up,
Qt.Key_Down,
Qt.Key_Left,
Qt.Key_Right,
Qt.Key_A,
Qt.Key_S);
}

onButtonAPressedChanged: {
if (!inGameCtrlEnabled) return;
if (player.isProtecting) return;
player.moveSpeed = buttonAPressed ? 35 : 18;
let p = player;
if (!p.desiresToMove) {
if (buttonAPressed) p.isProtecting = true;
else p.isProtecting = false;
}
}

onButtonBPressedChanged: {
if (!inGameCtrlEnabled) return;
if (player.isProtecting) return;
let p = player;
if (buttonBPressed) {
if (buttonBPressed)
if (p.desiresToMove) p.dodgeSpeed = 75;
else p.isProtecting = true;
}
else
p.isProtecting = false;
}

onAxisXChanged: {
Expand All @@ -107,7 +113,6 @@ ClayWorld {
onObjectCreated: {
if (isInstanceOf(obj, "Player")) {
player = obj;
player.source = theWorld.resource("visual/player.png");
}
else if (isInstanceOf(obj, "Garden")) {
theReferee.addGarden(obj);
Expand All @@ -127,14 +132,12 @@ ClayWorld {

SoundEffect {
id: bgMusic
//TODO Replace music place-holder and react. play
//Component.onCompleted: play();
source: theWorld.resource("sound/bgmusic.wav")
loops: SoundEffect.Infinite
}

StartScreen {
visible: true
visible: true
Component.onCompleted: {
theGameCtrl.buttonAPressedChanged.connect(startOnDemand)
theGameCtrl.buttonBPressedChanged.connect(startOnDemand)
Expand All @@ -144,22 +147,39 @@ ClayWorld {
map = "";
map = "map.svg";
visible = false;
bgMusic.play();
}
}
}

GameEnding {
id: theEnd
referee: theReferee
Component.onCompleted: {
theGameCtrl.buttonAPressedChanged.connect(restartOnDemand)
theGameCtrl.buttonBPressedChanged.connect(restartOnDemand)
onVisibleChanged: {
if (visible) {
bgMusic.stop();
theWorld.running = false
delayReplayCtrls.start();
}
}

Timer {
id: delayReplayCtrls
interval: 2000
onTriggered: {
theGameCtrl.buttonAPressedChanged.connect(theEnd.restartOnDemand)
theGameCtrl.buttonBPressedChanged.connect(theEnd.restartOnDemand)
}
}

function restartOnDemand() {
if (visible) {
theGameCtrl.buttonAPressedChanged.disconnect(theEnd.restartOnDemand)
theGameCtrl.buttonBPressedChanged.disconnect(theEnd.restartOnDemand)
map = "";
map = "map.svg";
visible = false;
bgMusic.play();
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/StartScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ Rectangle {
visible: false
anchors.fill: parent

Text {
Image {
source: theWorld.resource("visual/titlescreen.png");
height: parent.height
width: (sourceSize.width / sourceSize.height) * height
anchors.centerIn: parent
font.pixelSize: parent.height * .07
text: "Welcome to the Game"
}

color: "#c7fcff"
}


Loading

0 comments on commit b0098e8

Please sign in to comment.