From e3d48cfa7550a0ea9211f5782471232818fe184d Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 11 Dec 2012 10:25:04 +0100 Subject: Initial commit... --- Button.qml | 77 ++++ CameraSlide.qml | 92 ++++ CanvasSlide.qml | 106 +++++ DemoMain.qml | 139 ++++++ EffectsSlide.qml | 203 +++++++++ ExamplesSlide.qml | 89 ++++ FontSlide.qml | 98 ++++ NoisyGradient.qml | 88 ++++ NormalMapGenerator.qml | 88 ++++ OpacityTransitionPresentation.qml | 104 +++++ ParticleSlide.qml | 79 ++++ ShaderSlide.qml | 197 ++++++++ SlideDeck.qml | 214 +++++++++ Swirl.qml | 116 +++++ VideoSlide.qml | 116 +++++ WidgetsSlide.qml | 147 ++++++ calqlatr/.DS_Store | Bin 0 -> 6148 bytes calqlatr/Calqlatr.qml | 110 +++++ calqlatr/content/Button.qml | 80 ++++ calqlatr/content/Display.qml | 124 +++++ calqlatr/content/NumberPad.qml | 69 +++ calqlatr/content/StyleLabel.qml | 50 ++ calqlatr/content/audio/touch.wav | Bin 0 -> 950 bytes calqlatr/content/calculator.js | 143 ++++++ calqlatr/content/images/icon-back.png | Bin 0 -> 328 bytes calqlatr/content/images/icon-close.png | Bin 0 -> 488 bytes calqlatr/content/images/icon-settings.png | Bin 0 -> 503 bytes calqlatr/content/images/logo.png | Bin 0 -> 5950 bytes calqlatr/content/images/paper-edge-left.png | Bin 0 -> 12401 bytes calqlatr/content/images/paper-edge-right.png | Bin 0 -> 12967 bytes calqlatr/content/images/paper-grip.png | Bin 0 -> 298 bytes calqlatr/content/images/settings-selected-a.png | Bin 0 -> 2326 bytes calqlatr/content/images/settings-selected-b.png | Bin 0 -> 2334 bytes calqlatr/content/images/touch-green.png | Bin 0 -> 4808 bytes calqlatr/content/images/touch-white.png | Bin 0 -> 4601 bytes images/ally.png | Bin 0 -> 1907941 bytes images/butterfly.png | Bin 0 -> 36912 bytes images/displace.png | Bin 0 -> 20269 bytes images/fog.png | Bin 0 -> 225653 bytes images/qt-logo.png | Bin 0 -> 49656 bytes images/widgets_boxes.png | Bin 0 -> 589779 bytes images/widgets_chips.png | Bin 0 -> 211342 bytes images/widgets_mainwindows.png | Bin 0 -> 95685 bytes images/widgets_styles_fusion.png | Bin 0 -> 65678 bytes images/widgets_styles_macstyle.png | Bin 0 -> 70514 bytes main.qml | 42 ++ main_autorun.qml | 3 + main_lofi.qml | 44 ++ maroon/.DS_Store | Bin 0 -> 6148 bytes maroon/Maroon.qml | 233 ++++++++++ maroon/content/BuildButton.qml | 90 ++++ maroon/content/GameCanvas.qml | 240 ++++++++++ maroon/content/GameOverScreen.qml | 115 +++++ maroon/content/InfoBar.qml | 84 ++++ maroon/content/NewGameScreen.qml | 111 +++++ maroon/content/SoundEffect.qml | 53 +++ maroon/content/audio/bomb-action.wav | Bin 0 -> 20972 bytes maroon/content/audio/catch-action.wav | Bin 0 -> 13274 bytes maroon/content/audio/catch.wav | Bin 0 -> 8638 bytes maroon/content/audio/currency.wav | Bin 0 -> 15790 bytes maroon/content/audio/factory-action.wav | Bin 0 -> 4936 bytes maroon/content/audio/melee-action.wav | Bin 0 -> 17798 bytes maroon/content/audio/projectile-action.wav | Bin 0 -> 2562 bytes maroon/content/audio/shooter-action.wav | Bin 0 -> 27554 bytes maroon/content/gfx/background.png | Bin 0 -> 5802 bytes maroon/content/gfx/bomb-action.png | Bin 0 -> 23974 bytes maroon/content/gfx/bomb-idle.png | Bin 0 -> 12238 bytes maroon/content/gfx/bomb.png | Bin 0 -> 4067 bytes maroon/content/gfx/button-help.png | Bin 0 -> 8916 bytes maroon/content/gfx/button-play.png | Bin 0 -> 13945 bytes maroon/content/gfx/catch-action.png | Bin 0 -> 6760 bytes maroon/content/gfx/catch.png | Bin 0 -> 4771 bytes maroon/content/gfx/cloud.png | Bin 0 -> 3398 bytes maroon/content/gfx/currency.png | Bin 0 -> 1889 bytes maroon/content/gfx/dialog-bomb.png | Bin 0 -> 3751 bytes maroon/content/gfx/dialog-factory.png | Bin 0 -> 3946 bytes maroon/content/gfx/dialog-melee.png | Bin 0 -> 4392 bytes maroon/content/gfx/dialog-pointer.png | Bin 0 -> 911 bytes maroon/content/gfx/dialog-shooter.png | Bin 0 -> 3737 bytes maroon/content/gfx/dialog.png | Bin 0 -> 3362 bytes maroon/content/gfx/factory-action.png | Bin 0 -> 22440 bytes maroon/content/gfx/factory-idle.png | Bin 0 -> 12729 bytes maroon/content/gfx/factory.png | Bin 0 -> 4138 bytes maroon/content/gfx/grid.png | Bin 0 -> 2830 bytes maroon/content/gfx/help.png | Bin 0 -> 38255 bytes maroon/content/gfx/lifes.png | Bin 0 -> 1675 bytes maroon/content/gfx/logo-bubble.png | Bin 0 -> 7706 bytes maroon/content/gfx/logo-fish.png | Bin 0 -> 3477 bytes maroon/content/gfx/logo.png | Bin 0 -> 18332 bytes maroon/content/gfx/melee-action.png | Bin 0 -> 7797 bytes maroon/content/gfx/melee-idle.png | Bin 0 -> 22832 bytes maroon/content/gfx/melee.png | Bin 0 -> 4046 bytes maroon/content/gfx/mob-idle.png | Bin 0 -> 6181 bytes maroon/content/gfx/mob.png | Bin 0 -> 2391 bytes maroon/content/gfx/points.png | Bin 0 -> 1561 bytes maroon/content/gfx/projectile-action.png | Bin 0 -> 6257 bytes maroon/content/gfx/projectile.png | Bin 0 -> 801 bytes maroon/content/gfx/scores.png | Bin 0 -> 1535 bytes maroon/content/gfx/shooter-action.png | Bin 0 -> 18121 bytes maroon/content/gfx/shooter-idle.png | Bin 0 -> 11929 bytes maroon/content/gfx/shooter.png | Bin 0 -> 4137 bytes maroon/content/gfx/sunlight.png | Bin 0 -> 248412 bytes maroon/content/gfx/text-1.png | Bin 0 -> 2777 bytes maroon/content/gfx/text-2.png | Bin 0 -> 4959 bytes maroon/content/gfx/text-3.png | Bin 0 -> 5063 bytes maroon/content/gfx/text-blank.png | Bin 0 -> 1326 bytes maroon/content/gfx/text-gameover.png | Bin 0 -> 1515 bytes maroon/content/gfx/text-go.png | Bin 0 -> 4230 bytes maroon/content/gfx/wave.png | Bin 0 -> 2763 bytes maroon/content/logic.js | 264 +++++++++++ maroon/content/mobs/MobBase.qml | 262 +++++++++++ maroon/content/towers/Bomb.qml | 133 ++++++ maroon/content/towers/Factory.qml | 114 +++++ maroon/content/towers/Melee.qml | 83 ++++ maroon/content/towers/Ranged.qml | 128 ++++++ maroon/content/towers/TowerBase.qml | 72 +++ particles/customemitter.qml | 91 ++++ particles/emitmask.qml | 76 ++++ particles/particle.png | Bin 0 -> 861 bytes particles/particle4.png | Bin 0 -> 1799 bytes particles/star.png | Bin 0 -> 1550 bytes particles/starfish_mask.png | Bin 0 -> 11301 bytes particles/velocityfrommotion.qml | 305 +++++++++++++ samegame/.DS_Store | Bin 0 -> 6148 bytes samegame/Samegame.qml | 371 +++++++++++++++ samegame/content/Block.qml | 114 +++++ samegame/content/BlockEmitter.qml | 57 +++ samegame/content/Button.qml | 70 +++ samegame/content/GameArea.qml | 226 +++++++++ samegame/content/LogoAnimation.qml | 102 +++++ samegame/content/MenuEmitter.qml | 53 +++ samegame/content/PaintEmitter.qml | 98 ++++ samegame/content/PrimaryPack.qml | 122 +++++ samegame/content/PuzzleBlock.qml | 111 +++++ samegame/content/SamegameText.qml | 49 ++ samegame/content/SimpleBlock.qml | 108 +++++ samegame/content/SmokeText.qml | 83 ++++ samegame/content/gfx/background-puzzle.png | Bin 0 -> 86666 bytes samegame/content/gfx/background.png | Bin 0 -> 101018 bytes samegame/content/gfx/bar.png | Bin 0 -> 10970 bytes samegame/content/gfx/blue-puzzle.png | Bin 0 -> 2219 bytes samegame/content/gfx/blue.png | Bin 0 -> 1018 bytes samegame/content/gfx/bubble-highscore.png | Bin 0 -> 2276 bytes samegame/content/gfx/bubble-puzzle.png | Bin 0 -> 2811 bytes samegame/content/gfx/but-game-1.png | Bin 0 -> 2728 bytes samegame/content/gfx/but-game-2.png | Bin 0 -> 3378 bytes samegame/content/gfx/but-game-3.png | Bin 0 -> 1423 bytes samegame/content/gfx/but-game-4.png | Bin 0 -> 2096 bytes samegame/content/gfx/but-game-new.png | Bin 0 -> 3662 bytes samegame/content/gfx/but-menu.png | Bin 0 -> 2391 bytes samegame/content/gfx/but-puzzle-next.png | Bin 0 -> 3658 bytes samegame/content/gfx/but-quit.png | Bin 0 -> 2100 bytes samegame/content/gfx/green-puzzle.png | Bin 0 -> 2271 bytes samegame/content/gfx/green.png | Bin 0 -> 1024 bytes samegame/content/gfx/icon-fail.png | Bin 0 -> 6549 bytes samegame/content/gfx/icon-ok.png | Bin 0 -> 7190 bytes samegame/content/gfx/icon-time.png | Bin 0 -> 1159 bytes samegame/content/gfx/logo-a.png | Bin 0 -> 1814 bytes samegame/content/gfx/logo-e.png | Bin 0 -> 1725 bytes samegame/content/gfx/logo-g.png | Bin 0 -> 1765 bytes samegame/content/gfx/logo-m.png | Bin 0 -> 1743 bytes samegame/content/gfx/logo-s.png | Bin 0 -> 1791 bytes samegame/content/gfx/logo.png | Bin 0 -> 3608 bytes samegame/content/gfx/particle-brick.png | Bin 0 -> 861 bytes samegame/content/gfx/particle-paint.png | Bin 0 -> 714 bytes samegame/content/gfx/particle-smoke.png | Bin 0 -> 5409 bytes samegame/content/gfx/red-puzzle.png | Bin 0 -> 2218 bytes samegame/content/gfx/red.png | Bin 0 -> 1018 bytes samegame/content/gfx/text-highscore-new.png | Bin 0 -> 6767 bytes samegame/content/gfx/text-highscore.png | Bin 0 -> 3179 bytes samegame/content/gfx/text-no-winner.png | Bin 0 -> 6321 bytes samegame/content/gfx/text-p1-go.png | Bin 0 -> 5395 bytes samegame/content/gfx/text-p1-won.png | Bin 0 -> 5618 bytes samegame/content/gfx/text-p1.png | Bin 0 -> 1751 bytes samegame/content/gfx/text-p2-go.png | Bin 0 -> 5874 bytes samegame/content/gfx/text-p2-won.png | Bin 0 -> 6177 bytes samegame/content/gfx/text-p2.png | Bin 0 -> 2381 bytes samegame/content/gfx/yellow-puzzle.png | Bin 0 -> 2239 bytes samegame/content/gfx/yellow.png | Bin 0 -> 1008 bytes samegame/content/levels/TemplateBase.qml | 70 +++ samegame/content/levels/level0.qml | 59 +++ samegame/content/levels/level1.qml | 59 +++ samegame/content/levels/level2.qml | 61 +++ samegame/content/levels/level3.qml | 60 +++ samegame/content/levels/level4.qml | 58 +++ samegame/content/levels/level5.qml | 59 +++ samegame/content/levels/level6.qml | 60 +++ samegame/content/levels/level7.qml | 58 +++ samegame/content/levels/level8.qml | 59 +++ samegame/content/levels/level9.qml | 62 +++ samegame/content/samegame.js | 581 ++++++++++++++++++++++++ samegame/settings.js | 56 +++ 192 files changed, 7938 insertions(+) create mode 100644 Button.qml create mode 100644 CameraSlide.qml create mode 100644 CanvasSlide.qml create mode 100644 DemoMain.qml create mode 100644 EffectsSlide.qml create mode 100644 ExamplesSlide.qml create mode 100644 FontSlide.qml create mode 100644 NoisyGradient.qml create mode 100644 NormalMapGenerator.qml create mode 100644 OpacityTransitionPresentation.qml create mode 100644 ParticleSlide.qml create mode 100644 ShaderSlide.qml create mode 100644 SlideDeck.qml create mode 100644 Swirl.qml create mode 100644 VideoSlide.qml create mode 100644 WidgetsSlide.qml create mode 100644 calqlatr/.DS_Store create mode 100644 calqlatr/Calqlatr.qml create mode 100644 calqlatr/content/Button.qml create mode 100644 calqlatr/content/Display.qml create mode 100644 calqlatr/content/NumberPad.qml create mode 100644 calqlatr/content/StyleLabel.qml create mode 100644 calqlatr/content/audio/touch.wav create mode 100644 calqlatr/content/calculator.js create mode 100644 calqlatr/content/images/icon-back.png create mode 100644 calqlatr/content/images/icon-close.png create mode 100644 calqlatr/content/images/icon-settings.png create mode 100644 calqlatr/content/images/logo.png create mode 100644 calqlatr/content/images/paper-edge-left.png create mode 100644 calqlatr/content/images/paper-edge-right.png create mode 100644 calqlatr/content/images/paper-grip.png create mode 100644 calqlatr/content/images/settings-selected-a.png create mode 100644 calqlatr/content/images/settings-selected-b.png create mode 100644 calqlatr/content/images/touch-green.png create mode 100644 calqlatr/content/images/touch-white.png create mode 100644 images/ally.png create mode 100644 images/butterfly.png create mode 100644 images/displace.png create mode 100644 images/fog.png create mode 100644 images/qt-logo.png create mode 100644 images/widgets_boxes.png create mode 100644 images/widgets_chips.png create mode 100644 images/widgets_mainwindows.png create mode 100644 images/widgets_styles_fusion.png create mode 100644 images/widgets_styles_macstyle.png create mode 100644 main.qml create mode 100644 main_autorun.qml create mode 100644 main_lofi.qml create mode 100644 maroon/.DS_Store create mode 100644 maroon/Maroon.qml create mode 100644 maroon/content/BuildButton.qml create mode 100644 maroon/content/GameCanvas.qml create mode 100644 maroon/content/GameOverScreen.qml create mode 100644 maroon/content/InfoBar.qml create mode 100644 maroon/content/NewGameScreen.qml create mode 100644 maroon/content/SoundEffect.qml create mode 100644 maroon/content/audio/bomb-action.wav create mode 100644 maroon/content/audio/catch-action.wav create mode 100644 maroon/content/audio/catch.wav create mode 100644 maroon/content/audio/currency.wav create mode 100644 maroon/content/audio/factory-action.wav create mode 100644 maroon/content/audio/melee-action.wav create mode 100644 maroon/content/audio/projectile-action.wav create mode 100644 maroon/content/audio/shooter-action.wav create mode 100644 maroon/content/gfx/background.png create mode 100644 maroon/content/gfx/bomb-action.png create mode 100644 maroon/content/gfx/bomb-idle.png create mode 100644 maroon/content/gfx/bomb.png create mode 100644 maroon/content/gfx/button-help.png create mode 100644 maroon/content/gfx/button-play.png create mode 100644 maroon/content/gfx/catch-action.png create mode 100644 maroon/content/gfx/catch.png create mode 100644 maroon/content/gfx/cloud.png create mode 100644 maroon/content/gfx/currency.png create mode 100644 maroon/content/gfx/dialog-bomb.png create mode 100644 maroon/content/gfx/dialog-factory.png create mode 100644 maroon/content/gfx/dialog-melee.png create mode 100644 maroon/content/gfx/dialog-pointer.png create mode 100644 maroon/content/gfx/dialog-shooter.png create mode 100644 maroon/content/gfx/dialog.png create mode 100644 maroon/content/gfx/factory-action.png create mode 100644 maroon/content/gfx/factory-idle.png create mode 100644 maroon/content/gfx/factory.png create mode 100644 maroon/content/gfx/grid.png create mode 100644 maroon/content/gfx/help.png create mode 100644 maroon/content/gfx/lifes.png create mode 100644 maroon/content/gfx/logo-bubble.png create mode 100644 maroon/content/gfx/logo-fish.png create mode 100644 maroon/content/gfx/logo.png create mode 100644 maroon/content/gfx/melee-action.png create mode 100644 maroon/content/gfx/melee-idle.png create mode 100644 maroon/content/gfx/melee.png create mode 100644 maroon/content/gfx/mob-idle.png create mode 100644 maroon/content/gfx/mob.png create mode 100644 maroon/content/gfx/points.png create mode 100644 maroon/content/gfx/projectile-action.png create mode 100644 maroon/content/gfx/projectile.png create mode 100644 maroon/content/gfx/scores.png create mode 100644 maroon/content/gfx/shooter-action.png create mode 100644 maroon/content/gfx/shooter-idle.png create mode 100644 maroon/content/gfx/shooter.png create mode 100644 maroon/content/gfx/sunlight.png create mode 100644 maroon/content/gfx/text-1.png create mode 100644 maroon/content/gfx/text-2.png create mode 100644 maroon/content/gfx/text-3.png create mode 100644 maroon/content/gfx/text-blank.png create mode 100644 maroon/content/gfx/text-gameover.png create mode 100644 maroon/content/gfx/text-go.png create mode 100644 maroon/content/gfx/wave.png create mode 100644 maroon/content/logic.js create mode 100644 maroon/content/mobs/MobBase.qml create mode 100644 maroon/content/towers/Bomb.qml create mode 100644 maroon/content/towers/Factory.qml create mode 100644 maroon/content/towers/Melee.qml create mode 100644 maroon/content/towers/Ranged.qml create mode 100644 maroon/content/towers/TowerBase.qml create mode 100644 particles/customemitter.qml create mode 100644 particles/emitmask.qml create mode 100644 particles/particle.png create mode 100644 particles/particle4.png create mode 100644 particles/star.png create mode 100644 particles/starfish_mask.png create mode 100644 particles/velocityfrommotion.qml create mode 100644 samegame/.DS_Store create mode 100644 samegame/Samegame.qml create mode 100644 samegame/content/Block.qml create mode 100644 samegame/content/BlockEmitter.qml create mode 100644 samegame/content/Button.qml create mode 100644 samegame/content/GameArea.qml create mode 100644 samegame/content/LogoAnimation.qml create mode 100644 samegame/content/MenuEmitter.qml create mode 100644 samegame/content/PaintEmitter.qml create mode 100644 samegame/content/PrimaryPack.qml create mode 100644 samegame/content/PuzzleBlock.qml create mode 100644 samegame/content/SamegameText.qml create mode 100644 samegame/content/SimpleBlock.qml create mode 100644 samegame/content/SmokeText.qml create mode 100644 samegame/content/gfx/background-puzzle.png create mode 100644 samegame/content/gfx/background.png create mode 100644 samegame/content/gfx/bar.png create mode 100644 samegame/content/gfx/blue-puzzle.png create mode 100644 samegame/content/gfx/blue.png create mode 100644 samegame/content/gfx/bubble-highscore.png create mode 100644 samegame/content/gfx/bubble-puzzle.png create mode 100644 samegame/content/gfx/but-game-1.png create mode 100644 samegame/content/gfx/but-game-2.png create mode 100644 samegame/content/gfx/but-game-3.png create mode 100644 samegame/content/gfx/but-game-4.png create mode 100644 samegame/content/gfx/but-game-new.png create mode 100644 samegame/content/gfx/but-menu.png create mode 100644 samegame/content/gfx/but-puzzle-next.png create mode 100644 samegame/content/gfx/but-quit.png create mode 100644 samegame/content/gfx/green-puzzle.png create mode 100644 samegame/content/gfx/green.png create mode 100644 samegame/content/gfx/icon-fail.png create mode 100644 samegame/content/gfx/icon-ok.png create mode 100644 samegame/content/gfx/icon-time.png create mode 100644 samegame/content/gfx/logo-a.png create mode 100644 samegame/content/gfx/logo-e.png create mode 100644 samegame/content/gfx/logo-g.png create mode 100644 samegame/content/gfx/logo-m.png create mode 100644 samegame/content/gfx/logo-s.png create mode 100644 samegame/content/gfx/logo.png create mode 100644 samegame/content/gfx/particle-brick.png create mode 100644 samegame/content/gfx/particle-paint.png create mode 100644 samegame/content/gfx/particle-smoke.png create mode 100644 samegame/content/gfx/red-puzzle.png create mode 100644 samegame/content/gfx/red.png create mode 100644 samegame/content/gfx/text-highscore-new.png create mode 100644 samegame/content/gfx/text-highscore.png create mode 100644 samegame/content/gfx/text-no-winner.png create mode 100644 samegame/content/gfx/text-p1-go.png create mode 100644 samegame/content/gfx/text-p1-won.png create mode 100644 samegame/content/gfx/text-p1.png create mode 100644 samegame/content/gfx/text-p2-go.png create mode 100644 samegame/content/gfx/text-p2-won.png create mode 100644 samegame/content/gfx/text-p2.png create mode 100644 samegame/content/gfx/yellow-puzzle.png create mode 100644 samegame/content/gfx/yellow.png create mode 100644 samegame/content/levels/TemplateBase.qml create mode 100644 samegame/content/levels/level0.qml create mode 100644 samegame/content/levels/level1.qml create mode 100644 samegame/content/levels/level2.qml create mode 100644 samegame/content/levels/level3.qml create mode 100644 samegame/content/levels/level4.qml create mode 100644 samegame/content/levels/level5.qml create mode 100644 samegame/content/levels/level6.qml create mode 100644 samegame/content/levels/level7.qml create mode 100644 samegame/content/levels/level8.qml create mode 100644 samegame/content/levels/level9.qml create mode 100755 samegame/content/samegame.js create mode 100644 samegame/settings.js diff --git a/Button.qml b/Button.qml new file mode 100644 index 0000000..8f519ff --- /dev/null +++ b/Button.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + + id: root; + + border.width: (pressed ? 1.5 : 1) * height / 20; + border.color: Qt.rgba(1, 1, 1, 0.4); + radius: height / 4; + + antialiasing: true + + gradient: Gradient { + GradientStop { position: 0; color: Qt.rgba(0.8, 0.8, 0.8, pressed ? 0.7 : 0.4); } + GradientStop { position: 1; color: Qt.rgba(0.5, 0.5, 0.5, pressed ? 0.7 : 0.4); } + } + + Behavior on color { ColorAnimation { duration: 100 } } + + property bool pressed; + property alias label: textItem.text; + + Text { + id: textItem + anchors.centerIn: parent + color: "white" + font.pixelSize: parent.height / 3; + } + + MouseArea { + id: mouse + anchors.fill: parent + onPressed: root.pressed = !root.pressed; + + } + +} diff --git a/CameraSlide.qml b/CameraSlide.qml new file mode 100644 index 0000000..9bc6d7e --- /dev/null +++ b/CameraSlide.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.0 +import Qt.labs.presentation 1.0 + +import QtGraphicalEffects 1.0 + +Slide { + + id: slide + + title: "Qt Multimedia - Camera" + + Camera { + id: camera + Component.onCompleted: camera.stop(); + } + + VideoOutput { + id: videoOut + anchors.fill: parent + source: camera + layer.enabled: true; + layer.effect: ZoomBlur { + samples: 16 + length: button.pressed ? parent.height / 5 : 0 + Behavior on length { + NumberAnimation { duration: 250 } + } + } + } + + onVisibleChanged: { + if (slide.visible) + camera.start(); + else + camera.stop(); + } + + Button { + id: button + anchors.bottom: videoOut.bottom + anchors.horizontalCenter: videoOut.horizontalCenter + anchors.bottomMargin: height / 2; +// anchors.bottom: slide.top; +// anchors.right: slide.right; +// anchors.bottomMargin: height; + label: pressed ? "Remove Effect" : "Zoom Effect"; + width: height * 4; + height: parent.height * 0.1 + } + +} diff --git a/CanvasSlide.qml b/CanvasSlide.qml new file mode 100644 index 0000000..970f0ed --- /dev/null +++ b/CanvasSlide.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Slide { + id: slide + + title: "Qt Quick 2.0 - Canvas" + + Rectangle { + height: parent.height + width: parent.width * 0.45 + anchors.right: parent.right; + color: "white" + Canvas { + id:canvas + anchors.fill: parent; + + antialiasing: true; + onPaint: { + eval(editor.text); + } + } + } + + Rectangle { + height: parent.height + width: parent.width * 0.45 + anchors.left: parent.left + color: "white" + clip: true; + + TextEdit { + id: editor + anchors.fill: parent; + anchors.margins: 10 + + font.pixelSize: 16 + + text: +"var ctx = canvas.getContext('2d'); +ctx.save(); +ctx.clearRect(0, 0, canvas.width, canvas.height); +ctx.strokeStyle = 'steelblue' +ctx.fillStyle = 'lightsteelblue'; +ctx.lineWidth = 5; + +ctx.beginPath(); +ctx.moveTo(100, 100); +ctx.lineTo(300, 100); +ctx.lineTo(100, 200); +ctx.lineTo(100, 100); + +ctx.fill(); +ctx.stroke(); +ctx.restore(); + +ctx.fillStyle = 'black' + +ctx.font = '20px sansserif' +ctx.fillText('Implements the HTML Canvas API', 50, 300); +ctx.fillText('Imperative Drawing from JavaScript', 50, 340); +" + onTextChanged: canvas.requestPaint(); + } + } +} diff --git a/DemoMain.qml b/DemoMain.qml new file mode 100644 index 0000000..7e40f08 --- /dev/null +++ b/DemoMain.qml @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +Item { + id: demoMain; + + property bool useDropShadow: true; + property bool useSwirls: true; + property bool useSimpleGradient: false; + property bool autorun: false; + + width: 1280 + height: 720 + + NoisyGradient { + anchors.fill: parent; + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.64, 0.82, 0.15) } + GradientStop { position: 1.0; color: "black" } + } + visible: !parent.useSimpleGradient + } + + Rectangle { + anchors.fill: parent; + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.64, 0.82, 0.15) } + GradientStop { position: 1.0; color: "black" } + } + visible: parent.useSimpleGradient; + } + + Rectangle { + id: colorTable + width: 1 + height: 46 + color: "transparent" + + Column { + spacing: 2 + y: 1 + Rectangle { width: 1; height: 10; color: "white" } + Rectangle { width: 1; height: 10; color: Qt.rgba(0.64 * 1.4, 0.82 * 1.4, 0.15 * 1.4, 1); } + Rectangle { width: 1; height: 10; color: Qt.rgba(0.64, 0.82, 0.15); } + Rectangle { width: 1; height: 10; color: Qt.rgba(0.64 * 0.7, 0.82 * 0.7, 0.15 * 0.7); } + } + + layer.enabled: true + layer.smooth: true + visible: false; + } + + + Swirl + { + x: 0; + width: parent.width + height: parent.height * 0.2 + anchors.bottom: parent.bottom; + amplitude: height * 0.2; + colorTable: colorTable; + speed: 0.2; + opacity: 0.3 + visible: parent.useSwirls; + } + + Timer { + interval: 20000 + running: parent.autorun + repeat: true + + onTriggered: { + var from = slides.currentSlide; + var to = from == slides.slides.length - 1 ? 1 : from + 1; + slides.switchSlides(slides.slides[from], slides.slides[to], true); + slides.currentSlide = to; + } + } + + SlideDeck { + id: slides + titleColor: "white" + textColor: "white" + anchors.fill: parent + layer.enabled: parent.useDropShadow + layer.effect: DropShadow { + horizontalOffset: slides.width * 0.005; + verticalOffset: slides.width * 0.005; + radius: 16.0 + samples: 16 + fast: true + color: Qt.rgba(0.0, 0.0, 0.0, 0.7); + } + } + + + +} diff --git a/EffectsSlide.qml b/EffectsSlide.qml new file mode 100644 index 0000000..6db43a0 --- /dev/null +++ b/EffectsSlide.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +import Qt.labs.presentation 1.0 + +Slide { + id: slide + + title: "Qt Graphical Effects" + writeInText: "The Qt Graphical Effects module includes a wide range of effects:" + + property real t; + SequentialAnimation on t { + NumberAnimation { from: 0; to: 1; duration: 5000; easing.type: Easing.InOutCubic } + NumberAnimation { from: 1; to: 0; duration: 5000; easing.type: Easing.InOutCubic } + loops: Animation.Infinite + running: slide.visible; + } + + SequentialAnimation { + PropertyAction { target: grid; property: "opacity"; value: 0 } + PauseAnimation { duration: 4000 } + NumberAnimation { target: grid; property: "opacity"; to: 1; duration: 2000; easing.type: Easing.InOutCubic } + running: slide.visible; + } + + Grid { + id: grid; + + opacity: 0; + + width: parent.width + height: parent.height * 0.84 + anchors.bottom: parent.bottom; + + property real cw: width / columns + property real ch: height / rows; + + property int fontSize: slide.baseFontSize * 0.5 + + columns: 4 + rows: 2 + + Item { + width: grid.cw + height: grid.ch + Text { text: "Original"; color: "white"; font.pixelSize: grid.fontSize; anchors.horizontalCenter: noEffect.horizontalCenter } + Image { + id: noEffect; + source: "images/butterfly.png" + width: grid.cw * 0.9 + fillMode: Image.PreserveAspectFit + } + } + + Column { + Glow { + id: glowEffect + radius: 8 + samples: 8 + spread: slide.t + source: noEffect + width: grid.cw * 0.9 + height: width; + Text { text: "Glow"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + + Column { + InnerShadow { + id: innerShadowEffect + radius: slide.t * 16; + samples: 16 + color: "black" + source: noEffect + width: grid.cw * 0.9 + height: width; + Text { text: "InnerShadow"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + + Column { + GaussianBlur { + id: blurEffect + radius: slide.t * samples; + samples: 8 + source: noEffect + width: grid.cw * 0.9 + height: width; + Text { text: "GaussianBlur"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + + Column { + ThresholdMask { + id: thresholdEffect + maskSource: Image { source: "images/fog.png" } + threshold: slide.t + spread: 0.3 + source: noEffect + width: grid.cw * 0.9 + height: width; + Text { text: "ThresholdMask"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + + Column { + BrightnessContrast { + id: brightnessEffect + brightness: Math.sin(slide.t * 2 * Math.PI) * 0.5; + contrast: Math.sin(slide.t * 4 * Math.PI) * 0.5; + source: noEffect + width: grid.cw * 0.9 + height: width; + Text { text: "BrightnessContrast"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + + Column { + Colorize { + id: colorizeEffect + hue: slide.t + source: noEffect + width: grid.cw * 0.9 + height: width; + Text { text: "Colorize"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + + Column { + OpacityMask { + + Item { + id: maskSource; + anchors.fill: parent; + Rectangle { + anchors.fill: parent; + opacity: slide.t; + } + + Text { + text: "Qt 5.0" + font.pixelSize: parent.height * 0.15 + font.bold: true; + font.underline: true; + anchors.centerIn: parent; + rotation: 70 + } + visible: false; + } + + id: opacityMaskEffect + source: noEffect + maskSource: maskSource; + width: grid.cw * 0.9 + height: width; + Text { text: "OpacityMask"; color: "white"; font.pixelSize: grid.fontSize; anchors.top: parent.top; anchors.horizontalCenter: parent.horizontalCenter; } + } + } + } + +} diff --git a/ExamplesSlide.qml b/ExamplesSlide.qml new file mode 100644 index 0000000..f12391b --- /dev/null +++ b/ExamplesSlide.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Slide +{ + id: slide + + title: "Qt Quick 2.0" + + Row { + anchors.fill: parent + + spacing: (width - 320 * 3) / 2 + + Item { + width: 320 + height: 480 + clip: true + Loader { + id: load1 + } + } + + Item { + width: 320 + height: 480 + clip: true; + Loader { + id: load2 + } + } + + Loader { + id: load3 + } + } + + onVisibleChanged: { + if (visible) { + load1.source = "maroon/Maroon.qml" + load2.source = "samegame/Samegame.qml" + load3.source = "calqlatr/Calqlatr.qml" + } else { + load1.source = "" + load2.source = "" + load3.source = "" + } + } +} diff --git a/FontSlide.qml b/FontSlide.qml new file mode 100644 index 0000000..f77e013 --- /dev/null +++ b/FontSlide.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Slide { + id: fontSlide; + title: "Qt Quick 2.0 - Fonts" + writeInText: "The default font rendering in Qt Quick 2.0 uses distance fields, making it possible to do fully transformable text with subpixel positioning and subpixel antialiasing. + +Native font rendering is also an option for applications that want to look native." + + Rectangle { + id: textRoot + anchors.centerIn: parent + anchors.horizontalCenterOffset: parent.width * 0.2 + anchors.verticalCenterOffset: parent.width * 0.1 + + width: 120 + height: 40 + + color: "transparent" + border.color: "white" + border.width: 1 + + Text { + anchors.centerIn: parent + + text: "Pretty neat, eh?" + color: "white" + + font.pixelSize: 20; + + SequentialAnimation on scale { + NumberAnimation { to: 4; duration: 2508; easing.type: Easing.OutElastic } + NumberAnimation { to: 1; duration: 2508; easing.type: Easing.OutElastic } + PauseAnimation { duration: 1000 } + loops: Animation.Infinite + running: fontSlide.visible + } + + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite; easing.type: Easing.InOutCubic; running: fontSlide.visible } + } + } + + ShaderEffectSource { + width: textRoot.width + height: textRoot.height + sourceItem: textRoot + anchors.bottom: parent.bottom; + anchors.left: parent.left; + smooth: false + transformOrigin: Item.BottomLeft; + + visible: true + + scale: 4; + } + +} diff --git a/NoisyGradient.qml b/NoisyGradient.qml new file mode 100644 index 0000000..c481593 --- /dev/null +++ b/NoisyGradient.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ShaderEffect { + + id: effectRoot; + + width: 1280 + height: 720 + + property Gradient gradient: Gradient { + GradientStop { position: 0; color: "white" } + GradientStop { position: 0.4; color: "blue" } + GradientStop { position: 1.0; color: "black" } + } + + Rectangle { + id: colorTable + width: 1 + height: 128; + + gradient: effectRoot.gradient; + + layer.enabled: true + layer.smooth: true + + visible: false; + } + + property variant source: colorTable; + + blending: false; + + fragmentShader:" + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + + // Noise function from: http://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl + float rand(vec2 n) { + return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233))) * 43758.5453); + } + + void main() { + lowp float len = clamp(length(vec2(0.5, 0.0) - qt_TexCoord0), 0.0, 1.0); + gl_FragColor = texture2D(source, vec2(0, len)) * qt_Opacity + rand(qt_TexCoord0) * 0.05; + } +" +} diff --git a/NormalMapGenerator.qml b/NormalMapGenerator.qml new file mode 100644 index 0000000..5fb955c --- /dev/null +++ b/NormalMapGenerator.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +ShaderEffect { + id: effectRoot; + + property alias source: blurShader.source; + + GaussianBlur + { + id: blurShader; + width: source != undefined ? source.width : 0 + height: source != undefined ? source.height : 0 + samples: 8 + radius: 8 + + layer.enabled: true; + layer.smooth: true; + + visible: false; + } + + width: 256 + height: 128 + + property variant tex: blurShader; + property size pixelSize: Qt.size(1 / blurShader.width, 1 / blurShader.height); + + fragmentShader: " + uniform lowp float qt_Opacity; + uniform lowp sampler2D tex; + uniform highp vec2 pixelSize; + varying highp vec2 qt_TexCoord0; + void main() { + + lowp vec2 xps = vec2(pixelSize.x, 0.0); + vec3 vx = vec3(1, 0, texture2D(tex, qt_TexCoord0 + xps).x - texture2D(tex, qt_TexCoord0 - xps).x); + + lowp vec2 yps = vec2(0.0, pixelSize.y); + vec3 vy = vec3(0, 1, texture2D(tex, qt_TexCoord0 + yps).x - texture2D(tex, qt_TexCoord0 - yps).x); + + vec3 n = normalize(cross(vx, vy)) * 0.5 + 0.5; + + gl_FragColor = vec4(n, 1); + } + " + +} diff --git a/OpacityTransitionPresentation.qml b/OpacityTransitionPresentation.qml new file mode 100644 index 0000000..1e09115 --- /dev/null +++ b/OpacityTransitionPresentation.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Presentation { + + id: deck + + width: 1280 + height: 720 + + property bool inTransition: false; + + property variant fromSlide; + property variant toSlide; + + property int transitionTime: 500; + + SequentialAnimation { + id: forwardTransition + PropertyAction { target: deck; property: "inTransition"; value: true } + PropertyAction { target: toSlide; property: "visible"; value: true } + ParallelAnimation { + NumberAnimation { target: fromSlide; property: "opacity"; from: 1; to: 0; duration: deck.transitionTime; easing.type: Easing.OutQuart } + NumberAnimation { target: fromSlide; property: "scale"; from: 1; to: 1.1; duration: deck.transitionTime; easing.type: Easing.InOutQuart } + NumberAnimation { target: toSlide; property: "opacity"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InQuart } + NumberAnimation { target: toSlide; property: "scale"; from: 0.7; to: 1; duration: deck.transitionTime; easing.type: Easing.InOutQuart } + } + PropertyAction { target: fromSlide; property: "visible"; value: false } + PropertyAction { target: fromSlide; property: "scale"; value: 1 } + PropertyAction { target: deck; property: "inTransition"; value: false } + } + SequentialAnimation { + id: backwardTransition + running: false + PropertyAction { target: deck; property: "inTransition"; value: true } + PropertyAction { target: toSlide; property: "visible"; value: true } + ParallelAnimation { + NumberAnimation { target: fromSlide; property: "opacity"; from: 1; to: 0; duration: deck.transitionTime; easing.type: Easing.OutQuart } + NumberAnimation { target: fromSlide; property: "scale"; from: 1; to: 0.7; duration: deck.transitionTime; easing.type: Easing.InOutQuart } + NumberAnimation { target: toSlide; property: "opacity"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InQuart } + NumberAnimation { target: toSlide; property: "scale"; from: 1.1; to: 1; duration: deck.transitionTime; easing.type: Easing.InOutQuart } + } + PropertyAction { target: fromSlide; property: "visible"; value: false } + PropertyAction { target: fromSlide; property: "scale"; value: 1 } + PropertyAction { target: deck; property: "inTransition"; value: false } + } + + function switchSlides(from, to, forward) + { + if (deck.inTransition) + return false + + deck.fromSlide = from + deck.toSlide = to + + if (forward) + forwardTransition.running = true + else + backwardTransition.running = true + + return true + } +} diff --git a/ParticleSlide.qml b/ParticleSlide.qml new file mode 100644 index 0000000..60ca9fd --- /dev/null +++ b/ParticleSlide.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Slide +{ + id: slide + + title: "Qt Quick 2.0 - Particle System" + + Row { + anchors.fill: parent + + spacing: (width - 320 * 3) / 2 + + Loader { + id: load1 + } + + Loader { + id: load2 + } + + Loader { + id: load3 + } + } + + onVisibleChanged: { + if (visible) { + load1.source = "particles/velocityfrommotion.qml" + load2.source = "particles/customemitter.qml" + load3.source = "particles/emitmask.qml" + } else { + load1.source = "" + load2.source = "" + load3.source = "" + } + } +} diff --git a/ShaderSlide.qml b/ShaderSlide.qml new file mode 100644 index 0000000..a830ff6 --- /dev/null +++ b/ShaderSlide.qml @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + + +Slide { + id: slide + + title: "Qt Quick 2.0 - ShaderEffect" + + writeInText: "Harness the raw power of the graphics processor. The ShaderEffect element lets you write GLSL inline in your QML files." + + Image { + id: sourceItem + source: "images/ally.png" + visible: false + } + + SequentialAnimation { + id: kickoffAnimation + + // setup + PropertyAction { target: rotationAnimation; property: "running"; value: false } + PropertyAction { target: timeAnimation; property: "running"; value: false } + PropertyAction { target: shader; property: "amp"; value: 0 } + PropertyAction { target: shader; property: "xrot"; value: 0 } + PropertyAction { target: shader; property: "zrot"; value: 0 } + PropertyAction { target: shader; property: "time"; value: 0 } + PropertyAction { target: shader; property: "scale"; value: 1; } + PropertyAction { target: rotationAnimation; property: "running"; value: false } + PropertyAction { target: timeAnimation; property: "running"; value: false } + // short pause + PauseAnimation { duration: 3000 } + // get started... + ParallelAnimation { + NumberAnimation { target: shader; property: "xrot"; to: 2 * Math.PI / 8; duration: 1000; easing.type: Easing.InOutCubic } + NumberAnimation { target: shader; property: "amp"; to: 0.1; duration: 1000; easing.type: Easing.InOutCubic } +// NumberAnimation { target: shader; property: "scale"; to: 1.5; duration: 1000; easing.type: Easing.InOutCubic } + PropertyAction { target: rotationAnimation; property: "running"; value: true } + PropertyAction { target: timeAnimation; property: "running"; value: true } + } + + running: slide.visible; + } + + + ShaderEffect { + id: shader + width: height + height: parent.height + anchors.centerIn: parent; + anchors.verticalCenterOffset: slide.height * 0.1 + + blending: true + + mesh: "50x50" + + property variant size: Qt.size(width, height); + + property variant source: sourceItem; + + property real amp: 0 + + property real xrot: 0; // 2 * Math.PI / 8; +// NumberAnimation on xrot { from: 0; to: Math.PI * 2; duration: 3000; loops: Animation.Infinite } + + property real zrot: 0 + NumberAnimation on zrot { + id: rotationAnimation + from: 0; + to: Math.PI * 2; + duration: 20000; + loops: Animation.Infinite + easing.type: Easing.InOutCubic + running: false; + } + + property real time: 0 + NumberAnimation on time { + id: timeAnimation + from: 0; + to: Math.PI * 2; + duration: 3457; + loops: Animation.Infinite + running: false; + } + + vertexShader: " + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_Matrix; + uniform highp float xrot; + uniform highp float zrot; + uniform highp vec2 size; + uniform highp float time; + uniform highp float amp; + varying lowp vec2 v_TexCoord; + varying lowp float v_light; + void main() { + highp float xcosa = cos(xrot); + highp float xsina = sin(xrot); + + highp mat4 xrot = mat4(1, 0, 0, 0, + 0, xcosa, xsina, 0, + 0, -xsina, xcosa, 0, + 0, 0, 0, 1); + + highp float zcosa = cos(zrot); + highp float zsina = sin(zrot); + + highp mat4 zrot = mat4(zcosa, zsina, 0, 0, + -zsina, zcosa, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + + highp float near = 2.; + highp float far = 6.; + highp float fmn = far - near; + + highp mat4 proj = mat4(near, 0, 0, 0, + 0, near, 0, 0, + 0, 0, -(far + near) / fmn, -1., + 0, 0, -2. * far * near / fmn, 1); + + highp mat4 model = mat4(2, 0, 0, 0, + 0, 2, 0, 0, + 0, 0, 2, 0, + 0, -.5, -4, 1); + + vec4 nLocPos = vec4(qt_Vertex.xy * 2.0 / size - 1.0, 0, 1); + nLocPos.z = cos(nLocPos.x * 5. + time) * amp; + + vec4 pos = proj * model * xrot * zrot * nLocPos; + pos = vec4(pos.xyx/pos.w, 1); + + gl_Position = qt_Matrix * vec4((pos.xy + 1.0) / 2.0 * size , 0, 1); + + v_TexCoord = qt_MultiTexCoord0; + + + v_light = dot(normalize(vec3(-sin(nLocPos.x * 5.0 + time) * 5.0 * amp, 0, -1)), vec3(0, 0, -1)); + } + " + + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 v_TexCoord; + varying lowp float v_light; + void main() { + highp vec4 c = texture2D(source, v_TexCoord); + gl_FragColor = (vec4(pow(v_light, 16.0)) * 0.3 + c) * qt_Opacity; + } + " + + } + +} diff --git a/SlideDeck.qml b/SlideDeck.qml new file mode 100644 index 0000000..4d67e69 --- /dev/null +++ b/SlideDeck.qml @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +import Qt.labs.presentation 1.0 + +OpacityTransitionPresentation { + id: presentation + + width: 1280 + height: 720 + + transitionTime: 2000 + + + /******************************************************************************** + * + * Introduction + * + */ + + Rectangle { + id: openingSlideBlackout + color: "black" + anchors.fill: parent; + Behavior on opacity { NumberAnimation { duration: 1000 } } + } + + onCurrentSlideChanged: { + if (currentSlide < 2) + openingSlideBlackout.opacity = 1; + else + openingSlideBlackout.opacity = 0; + } + + Slide { + + } + + Slide { + id: introSlide + + writeInText: "The following is a quick tour of what is new in Qt 5.0. + +It is an application written with Qt Quick 2.0, based on the modules shipped with Qt 5.0 and using the QML Presentation System from Qt labs. The source code is available from: +https://tada.data.da/qt5-launch-demo.git + +We hope you will enjoy Qt 5.0 as much as we have enjoyed creating it." + } + + Slide { + centeredText: "Introducing" + fontScale: 2 + } + + Slide { + centeredText: "Qt 5.0" + fontScale: 2; + } + + + Slide { + title: "Qt 5.0 - Features" + writeInText: "OpenGL based scene graph for Qt Quick 2.0 - providing velvet animations, particles and impressive graphical effects + +Multimedia - Audio, Video and Camera support on all major platforms" + + } + + + + /******************************************************************************** + * + * Qt Quick Graphics Stack + * + */ + ExamplesSlide { } + + FontSlide { } + CanvasSlide { } + ParticleSlide { } + ShaderSlide { } + + + + /******************************************************************************** + * + * Qt Graphical Effects + * + */ + + EffectsSlide {} + + + /******************************************************************************** + * + * Multimedia + * + */ + + Slide { + title: "Qt Multimedia" + writeInText: "The Qt Multmedia module is implemented on all our major platforms, including Windows, Mac OS X and Linux. + +It contains both a C++ API for use with existing Qt Widgets based applications and a QML API for use with Qt Quick 2.0. + +The features include recording and playback of video and audio and also use of camera. + +It also integrates nicely with the Qt Graphical Effects module." + } + VideoSlide { } + CameraSlide { } + + + + /******************************************************************************** + * + * The rest + * + */ + + Slide { + centeredText: "And much more..." + } + + Slide { + title: "Qt 5.0 - Features" + writeInText: "Modularization of the Qt libraries - sanitizing our codebase and making it possible to deploy only that which is needed + +Qt Platform Abstraction - Unifying the Qt codebase across platforms and greatly reducing the effort needed to port to new platforms + +WebKit - Full HTML 5 support from the worlds most popular web engine, including WebKit2 process separation + +Wayland support - Wayland 1.0 compatible Qt backend and compositor framework" + } + + Slide { + title: "Qt 5.0 - Features" + writeInText: "C++ language features - template based connect(), C++11 support, move constructors and more + +Connectivity and Networking - DNS lookup, improved IPv6 support + +JSON Support - Fast parser and writer, binary format support + +Unicode - Updated to latest Unicode specification, UTF-8 source files" + } + + Slide { + fontScale: 1.8 + centeredText: "99% source compatible with Qt 4.8" + } + + WidgetsSlide { } + + Slide { + title: "Links" + content: ["Qt Project: qt-project.org", + "Qt Commercial: qt.digia.com", + "", + "This demo: blahdi-blah-blah.org" + ]; + + Image { + source: "images/qt-logo.png" + height: parent.height + anchors.verticalCenter: parent.verticalCenter; + anchors.right: parent.right; + anchors.rightMargin: parent.width * 0.1 + fillMode: Image.PreserveAspectFit + } + + } + +} diff --git a/Swirl.qml b/Swirl.qml new file mode 100644 index 0000000..9e817cf --- /dev/null +++ b/Swirl.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ShaderEffect { + id: shader + + width: 400 + height: 300 + + property real speed: 1 + + property color d: Qt.rgba(Math.random() * 0.7, + Math.random() * 0.5, + Math.random() * 0.7, + Math.random() * 0.5) + property real tx + NumberAnimation on tx { from: 0; to: Math.PI * 2; duration: (Math.random() * 30 + 30) * 1000 / speed; loops: Animation.Infinite } + property real ty + NumberAnimation on ty { from: 0; to: Math.PI * 2; duration: (Math.random() * 30 + 30) * 1000 / speed; loops: Animation.Infinite } + property real tz + NumberAnimation on tz { from: 0; to: Math.PI * 2; duration: (Math.random() * 30 + 30) * 1000 / speed; loops: Animation.Infinite } + property real tw + NumberAnimation on tw { from: 0; to: Math.PI * 2; duration: (Math.random() * 30 + 30) * 1000 / speed; loops: Animation.Infinite } + + property real amplitude: height / 2 + + property variant colorTable: ShaderEffectSource { sourceItem: Rectangle { width: 4; height: 4; color: "green" } } + + fragmentShader: " + uniform lowp float qt_Opacity; + uniform lowp sampler2D colorTable; + varying highp vec2 qt_TexCoord0; + varying lowp float xx; + + void main() { + gl_FragColor = texture2D(colorTable, qt_TexCoord0); + gl_FragColor.xyz += xx * 0.1; + gl_FragColor *= qt_Opacity; + } + " + + vertexShader: " + uniform lowp vec4 d; + uniform highp float tx; + uniform highp float ty; + uniform highp float tz; + uniform highp float tw; + uniform highp float amplitude; + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + varying lowp float xx; + void main() { + highp vec4 pos = qt_Vertex; + + highp float y = sin(-tx + d.x * qt_MultiTexCoord0.x * 57. + 12. * d.y) + + sin(ty * 2.0 + d.z * qt_MultiTexCoord0.x * 21. + 5. * d.w) + + sin(tz * 4.0 + d.y * qt_MultiTexCoord0.x * 13. + 7.0 * d.x) + + sin(-ty * 8.0 + d.w * qt_MultiTexCoord0.x * 29. + 15. * d.z); + highp float x = sin(-tx + d.x * qt_MultiTexCoord0.x * 213. + 15. * d.y) + + sin(ty * 2.0 + d.z * qt_MultiTexCoord0.x * 107. + 12. * d.w) + + sin(tz * 4.0 + d.y * qt_MultiTexCoord0.x * 13. + 5.0 * d.x) + + sin(-ty * 8.0 + d.w * qt_MultiTexCoord0.x * 15. + 7. * d.z); + xx = x; + + pos.xy += vec2(x * sin(qt_MultiTexCoord0.x * 3.14152), + y * (1.0 - qt_MultiTexCoord0.y)) * amplitude; + + gl_Position = qt_Matrix * pos; + qt_TexCoord0 = qt_MultiTexCoord0; + } + " + + mesh: GridMesh { resolution: Qt.size(width / 10, 4) } + +} diff --git a/VideoSlide.qml b/VideoSlide.qml new file mode 100644 index 0000000..e87606b --- /dev/null +++ b/VideoSlide.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.0 +import Qt.labs.presentation 1.0 + +import QtGraphicalEffects 1.0 + +Slide { + + id: slide + + title: "Qt Multimedia - Video" + + Video { + id: video + + anchors.fill: parent + source: "bunny.mov" + autoLoad: true; + + layer.enabled: true; + layer.smooth: true; + layer.effect: Displace { + displacementSource: normalMap + displacement: button.pressed ? 1.0 : 0.0 + Behavior on displacement { + NumberAnimation { duration: 1000 } + } + } + } + + Rectangle { + id: theItem; + width: 256 + height: 128 + color: "transparent" + Text { + id: label + color: "white" + text: "Qt 5.0" + font.family: "Times New Roman" + font.bold: true; + font.pixelSize: 60 + anchors.centerIn: parent + } + visible: false; + } + + NormalMapGenerator { + anchors.left: theItem.right + width: 256 + height: 128 + id: normalMap + source: theItem; + visible: false + } + + centeredText: video.hasVideo ? "" : "'bunny.mov' is not found or cannot be played..." + + onVisibleChanged: { + if (slide.visible) + video.play(); + else + video.pause(); + } + + Button { + id: button + anchors.bottom: video.bottom + anchors.horizontalCenter: video.horizontalCenter + anchors.bottomMargin: height / 2; + label: pressed ? "Remove Effect" : "Displacement Effect"; + width: height * 4; + height: parent.height * 0.1 + } + +} diff --git a/WidgetsSlide.qml b/WidgetsSlide.qml new file mode 100644 index 0000000..dd4b082 --- /dev/null +++ b/WidgetsSlide.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Slide { + id: slide + + title: "Qt Widgets" + writeInText: "The Qt Widget module is fully supported, part of Qt Essentials." + + property int slamTime: 600; + property int waitTime: 0; + + SequentialAnimation { + id: widgetAnimation + ScriptAction { script: { + boxesImage.opacity = 0; + mainwindowsImage.opacity = 0; + chipsWindow.opacity = 0; + stylesWindow.opacity = 0; + } + } + PauseAnimation { duration: 3000 } + ParallelAnimation { + NumberAnimation { target: boxesImage; property: "opacity"; from: 0; to: 1; duration: slide.slamTime; easing.type: Easing.OutBack } + NumberAnimation { target: boxesImage; property: "rotation"; from: 20; to: 10; duration: slide.slamTime; easing.type: Easing.OutBack } + NumberAnimation { target: boxesImage; property: "scale"; from: 2; to: 1.5; duration: slide.slamTime; easing.type: Easing.OutBack } + } + PauseAnimation { duration: slide.waitTime } + ParallelAnimation { + NumberAnimation { target: mainwindowsImage; property: "opacity"; from: 0; to: 1; duration: slide.slamTime; easing.type: Easing.OutBack } + NumberAnimation { target: mainwindowsImage; property: "rotation"; from: -35; to: -20; duration: slide.slamTime; easing.type: Easing.OutBack} + NumberAnimation { target: mainwindowsImage; property: "scale"; from: 2; to: 1.5; duration: slide.slamTime; easing.type: Easing.OutBack } + } + PauseAnimation { duration: slide.waitTime } + ParallelAnimation { + NumberAnimation { target: chipsWindow; property: "opacity"; from: 0; to: 1; duration: slide.slamTime; easing.type: Easing.InOutCubic } + NumberAnimation { target: chipsWindow; property: "rotation"; from: 10; to: 25; duration: slide.slamTime; easing.type: Easing.OutBack} + NumberAnimation { target: chipsWindow; property: "scale"; from: 2.5; to: 1.6; duration: slide.slamTime; easing.type: Easing.OutBack } + } + PauseAnimation { duration: slide.waitTime } + ParallelAnimation { + NumberAnimation { target: stylesWindow; property: "opacity"; from: 0; to: 1; duration: slide.slamTime; easing.type: Easing.InOutCubic } + NumberAnimation { target: stylesWindow; property: "rotation"; from: 30; to: -15; duration: slide.slamTime; easing.type: Easing.OutBack} + NumberAnimation { target: stylesWindow; property: "scale"; from: 1.8; to: 1.4; duration: slide.slamTime; easing.type: Easing.OutBack } + } + running: false + } + + onVisibleChanged: { + widgetAnimation.running = slide.visible; + } + + Row { + x: slide.width * 0.05 + y: slide.height * 0.55; + width: parent.width + Image { + id: boxesImage; + source: "images/widgets_boxes.png" + fillMode: Image.PreserveAspectFit + width: slide.width * .2 + + opacity: 0; + y: -slide.height * 0.2 + rotation: 10 + scale: 1.5; + } + Image { + id: mainwindowsImage + source: "images/widgets_mainwindows.png" + fillMode: Image.PreserveAspectFit + width: slide.width * .2 + opacity: 0 + } + Image { + id: chipsWindow + source: "images/widgets_chips.png" + fillMode: Image.PreserveAspectFit + width: slide.width * .2 + x: slide.width * -0.05 + y: -slide.height * 0.2 + opacity: 0 + } + + Image { + id: stylesWindow + source: "images/widgets_styles_fusion.png" + fillMode: Image.PreserveAspectFit + width: slide.width * .2 + + x: slide.width * 1 + y: -slide.height * 0.1 + opacity: 0 + + Image { + source: "images/widgets_styles_macstyle.png" + fillMode: Image.PreserveAspectFit + width: slide.width * .2 + + x: parent.width * 0.3 + y: parent.width * 0.1 + rotation: -20 + } + } + } +} + diff --git a/calqlatr/.DS_Store b/calqlatr/.DS_Store new file mode 100644 index 0000000..fe95b02 Binary files /dev/null and b/calqlatr/.DS_Store differ diff --git a/calqlatr/Calqlatr.qml b/calqlatr/Calqlatr.qml new file mode 100644 index 0000000..7640fbd --- /dev/null +++ b/calqlatr/Calqlatr.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/calculator.js" as CalcEngine + + +Rectangle { + id: window + width: 320 + height: 480 + focus: true + color: "#272822" + + onWidthChanged: controller.reload() + + function operatorPressed(operator) { CalcEngine.operatorPressed(operator) } + function digitPressed(digit) { CalcEngine.digitPressed(digit) } + + Item { + id: pad + width: window.width * 0.58 + NumberPad { y: 10; anchors.horizontalCenter: parent.horizontalCenter } + } + + AnimationController { + id: controller + animation: ParallelAnimation { + id: anim + NumberAnimation { target: display; property: "x"; duration: 400; from: -16; to: window.width - display.width; easing.type: Easing.InOutQuad } + NumberAnimation { target: pad; property: "x"; duration: 400; from: window.width - pad.width; to: 0; easing.type: Easing.InOutQuad } + SequentialAnimation { + NumberAnimation { target: pad; property: "scale"; duration: 200; from: 1; to: 0.97; easing.type: Easing.InOutQuad } + NumberAnimation { target: pad; property: "scale"; duration: 200; from: 0.97; to: 1; easing.type: Easing.InOutQuad } + } + } + } + + Display { + id: display + x: -16 + width: window.width * 0.42 + height: parent.height + + MouseArea { + property real startX: 0 + property real oldP: 0 + property bool rewind: false + + anchors.fill: parent + onPositionChanged: { + var reverse = startX > window.width / 2 + var mx = mapToItem(window, mouse.x).x + var p = Math.abs((mx - startX) / (window.width - display.width)) + if (p < oldP) + rewind = reverse ? false : true + else + rewind = reverse ? true : false + controller.progress = reverse ? 1 - p : p + oldP = p + } + onPressed: startX = mapToItem(window, mouse.x).x + onReleased: { + if (rewind) + controller.completeToBeginning() + else + controller.completeToEnd() + } + } + } + +} diff --git a/calqlatr/content/Button.qml b/calqlatr/content/Button.qml new file mode 100644 index 0000000..c355c2d --- /dev/null +++ b/calqlatr/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property alias text: textItem.text + property alias color: textItem.color + + property bool operator: false + + signal clicked + + width: 30 + height: 50 + + Text { + id: textItem + font.pixelSize: 48 + wrapMode: Text.WordWrap + lineHeight: 0.75 + color: "white" + } + +// Rectangle { +// color: "red" +// opacity: 0.2 +// anchors.fill: mouse +// } + + MouseArea { + id: mouse + anchors.fill: parent + anchors.margins: -5 + onClicked: { + //parent.clicked() + if (operator) + window.operatorPressed(parent.text) + else + window.digitPressed(parent.text) + } + } +} diff --git a/calqlatr/content/Display.qml b/calqlatr/content/Display.qml new file mode 100644 index 0000000..3c1d9c0 --- /dev/null +++ b/calqlatr/content/Display.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: display + + function displayOperator(operator) + { + listView.model.append({ "operator": operator, "operand": "" }) + } + + function newLine(operator, operand) + { + listView.model.append({ "operator": operator, "operand": operand }) + } + + function appendDigit(digit) + { + if (!listView.model.count) + listView.model.append({ "operator": "", "operand": "" }) + var i = listView.model.count - 1; + listView.model.get(i).operand = listView.model.get(i).operand + digit; + } + + Item { + id: theItem + width: parent.width + 32 + height: parent.height + + Rectangle { + id: rect + x: 16 + color: "white" + height: parent.height + width: display.width - 16 + } + Image { + anchors.right: rect.left + source: "images/paper-edge-left.png" + height: parent.height + fillMode: Image.TileVertically + } + Image { + anchors.left: rect.right + source: "images/paper-edge-right.png" + height: parent.height + fillMode: Image.TileVertically + } + + Image { + source: "images/paper-grip.png" + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + } + + ListView { + id: listView + x: 16; y: 30 + width: display.width + height: display.height + delegate: Item { + height: 20 + width: parent.width + Text { + id: operator + x: 8 + font.pixelSize: 18 + color: "#6da43d" + text: model.operator + } + Text { + id: operand + font.pixelSize: 18 + anchors.right: parent.right + anchors.rightMargin: 26 + text: model.operand + } + } + model: ListModel { } + } + + } + +} diff --git a/calqlatr/content/NumberPad.qml b/calqlatr/content/NumberPad.qml new file mode 100644 index 0000000..853c763 --- /dev/null +++ b/calqlatr/content/NumberPad.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Grid { + columns: 3 + columnSpacing: 32 + rowSpacing: 16 + + Button { text: "7" } + Button { text: "8" } + Button { text: "9" } + Button { text: "4" } + Button { text: "5" } + Button { text: "6" } + Button { text: "1" } + Button { text: "2" } + Button { text: "3" } + Button { text: "0" } + Button { text: "." } + Button { text: " " } + Button { text: "±"; color: "#6da43d"; operator: true } + Button { text: "−"; color: "#6da43d"; operator: true } + Button { text: "+"; color: "#6da43d"; operator: true } + Button { text: " "; color: "#6da43d"; operator: true } + Button { text: "÷"; color: "#6da43d"; operator: true } + Button { text: "×"; color: "#6da43d"; operator: true } + Button { text: "C"; color: "#6da43d"; operator: true } + Button { text: " "; color: "#6da43d"; operator: true } + Button { text: "="; color: "#6da43d"; operator: true } +} diff --git a/calqlatr/content/StyleLabel.qml b/calqlatr/content/StyleLabel.qml new file mode 100644 index 0000000..3bdea86 --- /dev/null +++ b/calqlatr/content/StyleLabel.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Text { + width: 64 + font.pixelSize: 14 + font.bold: false + wrapMode: Text.WordWrap + lineHeight: 0.75 + color: "#676764" +} diff --git a/calqlatr/content/audio/touch.wav b/calqlatr/content/audio/touch.wav new file mode 100644 index 0000000..94cccb7 Binary files /dev/null and b/calqlatr/content/audio/touch.wav differ diff --git a/calqlatr/content/calculator.js b/calqlatr/content/calculator.js new file mode 100644 index 0000000..843ef39 --- /dev/null +++ b/calqlatr/content/calculator.js @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +var curVal = 0 +var memory = 0 +var lastOp = "" +var previousOperator = "" +var digits = "" + +function disabled(op) { + if (op == "." && digits.toString().search(/\./) != -1) { + return true + } else if (op == window.squareRoot && digits.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +function digitPressed(op) +{ + if (disabled(op)) + return + if (digits.toString().length >= 14) + return + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { + digits = digits + op.toString() + display.appendDigit(op.toString()) + } else { + digits = op + display.appendDigit(op.toString()) + } + lastOp = op +} + +function operatorPressed(op) +{ + if (disabled(op)) + return + lastOp = op + + if (previousOperator == "+") { + digits = Number(digits.valueOf()) + Number(curVal.valueOf()) + } else if (previousOperator == "−") { + digits = Number(curVal) - Number(digits.valueOf()) + } else if (previousOperator == "×") { + digits = Number(curVal) * Number(digits.valueOf()) + } else if (previousOperator == "÷") { + digits = Number(Number(curVal) / Number(digits.valueOf())).toString() + } else if (previousOperator == "=") { + } + + if (op == "+" || op == "−" || op == "×" || op == "÷") { + previousOperator = op + curVal = digits.valueOf() + display.displayOperator(previousOperator) + return + } + + if (op == "=") { + display.newLine("=", digits.toString()) + } + + curVal = 0 + previousOperator = "" + + if (op == "1/x") { + digits = (1 / digits.valueOf()).toString() + } else if (op == "x^2") { + digits = (digits.valueOf() * digits.valueOf()).toString() + } else if (op == "Abs") { + digits = (Math.abs(digits.valueOf())).toString() + } else if (op == "Int") { + digits = (Math.floor(digits.valueOf())).toString() + } else if (op == window.plusminus) { + digits = (digits.valueOf() * -1).toString() + } else if (op == window.squareRoot) { + digits = (Math.sqrt(digits.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += digits.valueOf() + } else if (op == "mr") { + digits = memory.toString() + } else if (op == "m-") { + memory = digits.valueOf() + } else if (op == window.leftArrow) { + digits = digits.toString().slice(0, -1) + if (digits.length == 0) { + digits = "0" + } + } else if (op == "Off") { + Qt.quit(); + } else if (op == "C") { + digits = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + digits ="0" + } + + +} + diff --git a/calqlatr/content/images/icon-back.png b/calqlatr/content/images/icon-back.png new file mode 100644 index 0000000..2989ee2 Binary files /dev/null and b/calqlatr/content/images/icon-back.png differ diff --git a/calqlatr/content/images/icon-close.png b/calqlatr/content/images/icon-close.png new file mode 100644 index 0000000..3e21248 Binary files /dev/null and b/calqlatr/content/images/icon-close.png differ diff --git a/calqlatr/content/images/icon-settings.png b/calqlatr/content/images/icon-settings.png new file mode 100644 index 0000000..98e662f Binary files /dev/null and b/calqlatr/content/images/icon-settings.png differ diff --git a/calqlatr/content/images/logo.png b/calqlatr/content/images/logo.png new file mode 100644 index 0000000..6bc6561 Binary files /dev/null and b/calqlatr/content/images/logo.png differ diff --git a/calqlatr/content/images/paper-edge-left.png b/calqlatr/content/images/paper-edge-left.png new file mode 100644 index 0000000..ca29a3a Binary files /dev/null and b/calqlatr/content/images/paper-edge-left.png differ diff --git a/calqlatr/content/images/paper-edge-right.png b/calqlatr/content/images/paper-edge-right.png new file mode 100644 index 0000000..7c2da7b Binary files /dev/null and b/calqlatr/content/images/paper-edge-right.png differ diff --git a/calqlatr/content/images/paper-grip.png b/calqlatr/content/images/paper-grip.png new file mode 100644 index 0000000..953c408 Binary files /dev/null and b/calqlatr/content/images/paper-grip.png differ diff --git a/calqlatr/content/images/settings-selected-a.png b/calqlatr/content/images/settings-selected-a.png new file mode 100644 index 0000000..e08ddfa Binary files /dev/null and b/calqlatr/content/images/settings-selected-a.png differ diff --git a/calqlatr/content/images/settings-selected-b.png b/calqlatr/content/images/settings-selected-b.png new file mode 100644 index 0000000..d9aa7e3 Binary files /dev/null and b/calqlatr/content/images/settings-selected-b.png differ diff --git a/calqlatr/content/images/touch-green.png b/calqlatr/content/images/touch-green.png new file mode 100644 index 0000000..64dbde6 Binary files /dev/null and b/calqlatr/content/images/touch-green.png differ diff --git a/calqlatr/content/images/touch-white.png b/calqlatr/content/images/touch-white.png new file mode 100644 index 0000000..bb02b00 Binary files /dev/null and b/calqlatr/content/images/touch-white.png differ diff --git a/images/ally.png b/images/ally.png new file mode 100644 index 0000000..05b405b Binary files /dev/null and b/images/ally.png differ diff --git a/images/butterfly.png b/images/butterfly.png new file mode 100644 index 0000000..ce544f2 Binary files /dev/null and b/images/butterfly.png differ diff --git a/images/displace.png b/images/displace.png new file mode 100644 index 0000000..440e8cb Binary files /dev/null and b/images/displace.png differ diff --git a/images/fog.png b/images/fog.png new file mode 100644 index 0000000..f462222 Binary files /dev/null and b/images/fog.png differ diff --git a/images/qt-logo.png b/images/qt-logo.png new file mode 100644 index 0000000..7f2c662 Binary files /dev/null and b/images/qt-logo.png differ diff --git a/images/widgets_boxes.png b/images/widgets_boxes.png new file mode 100644 index 0000000..3115255 Binary files /dev/null and b/images/widgets_boxes.png differ diff --git a/images/widgets_chips.png b/images/widgets_chips.png new file mode 100644 index 0000000..4ef1664 Binary files /dev/null and b/images/widgets_chips.png differ diff --git a/images/widgets_mainwindows.png b/images/widgets_mainwindows.png new file mode 100644 index 0000000..5ce5416 Binary files /dev/null and b/images/widgets_mainwindows.png differ diff --git a/images/widgets_styles_fusion.png b/images/widgets_styles_fusion.png new file mode 100644 index 0000000..d94f859 Binary files /dev/null and b/images/widgets_styles_fusion.png differ diff --git a/images/widgets_styles_macstyle.png b/images/widgets_styles_macstyle.png new file mode 100644 index 0000000..033f43b Binary files /dev/null and b/images/widgets_styles_macstyle.png differ diff --git a/main.qml b/main.qml new file mode 100644 index 0000000..3e7413d --- /dev/null +++ b/main.qml @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +DemoMain { +} diff --git a/main_autorun.qml b/main_autorun.qml new file mode 100644 index 0000000..bfe1426 --- /dev/null +++ b/main_autorun.qml @@ -0,0 +1,3 @@ +DemoMain { + autorun: true +} \ No newline at end of file diff --git a/main_lofi.qml b/main_lofi.qml new file mode 100644 index 0000000..501ed2f --- /dev/null +++ b/main_lofi.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt 5.0 launch demo. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +DemoMain { + useDropShadow: false; + useSimpleGradient: true; +} diff --git a/maroon/.DS_Store b/maroon/.DS_Store new file mode 100644 index 0000000..b5c859b Binary files /dev/null and b/maroon/.DS_Store differ diff --git a/maroon/Maroon.qml b/maroon/Maroon.qml new file mode 100644 index 0000000..d7bfcb6 --- /dev/null +++ b/maroon/Maroon.qml @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" +import "content/logic.js" as Logic + +Item { + id: root + width: 320 + height: 480 + property var gameState: Logic.newGameState(canvas); + property bool passedSplash: false + + Image { + source:"content/gfx/background.png" + anchors.bottom: view.bottom + + ParticleSystem { + id: particles + anchors.fill: parent + + ImageParticle { + id: bubble + anchors.fill: parent + source: "content/gfx/catch.png" + opacity: 0.25 + } + + Wander { + xVariance: 25; + pace: 25; + } + + Emitter { + width: parent.width + height: 150 + anchors.bottom: parent.bottom + anchors.bottomMargin: 3 + startTime: 15000 + + emitRate: 2 + lifeSpan: 15000 + + acceleration: PointDirection{ y: -6; xVariation: 2; yVariation: 2 } + + size: 24 + sizeVariation: 16 + } + } + } + + Column { + id: view + y: -(height - 480) + width: 320 + + GameOverScreen { gameCanvas: canvas } + + Item { + id: canvasArea + width: 320 + height: 480 + + Row { + height: childrenRect.height + Image { + id: wave + y: 30 + source:"content/gfx/wave.png" + } + Image { + y: 30 + source:"content/gfx/wave.png" + } + NumberAnimation on x { from: 0; to: -(wave.width); duration: 16000; loops: Animation.Infinite } + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad } + NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad } + } + } + + Row { + opacity: 0.5 + Image { + id: wave2 + y: 25 + source: "content/gfx/wave.png" + } + Image { + y: 25 + source: "content/gfx/wave.png" + } + NumberAnimation on x { from: -(wave2.width); to: 0; duration: 32000; loops: Animation.Infinite } + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad } + NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad } + } + } + + Image { + source: "content/gfx/sunlight.png" + opacity: 0.02 + y: 0 + anchors.horizontalCenter: parent.horizontalCenter + transformOrigin: Item.Top + SequentialAnimation on rotation { + loops: Animation.Infinite + NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine } + NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine } + } + } + + Image { + source: "content/gfx/sunlight.png" + opacity: 0.04 + y: 20 + anchors.horizontalCenter: parent.horizontalCenter + transformOrigin: Item.Top + SequentialAnimation on rotation { + loops: Animation.Infinite + NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine } + NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine } + } + } + + Image { + source: "content/gfx/grid.png" + opacity: 0.5 + } + + GameCanvas { + id: canvas + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + x: 32 + focus: true + } + + InfoBar { anchors.bottom: canvas.top; anchors.bottomMargin: 6; width: parent.width } + + //3..2..1..go + Timer { + id: countdownTimer + interval: 1000 + running: root.countdown < 5 + repeat: true + onTriggered: root.countdown++ + } + Repeater { + model: ["content/gfx/text-blank.png", "content/gfx/text-3.png", "content/gfx/text-2.png", "content/gfx/text-1.png", "content/gfx/text-go.png"] + delegate: Image { + visible: root.countdown <= index + opacity: root.countdown == index ? 0.5 : 0.1 + scale: root.countdown >= index ? 1.0 : 0.0 + source: modelData + Behavior on opacity { NumberAnimation {} } + Behavior on scale { NumberAnimation {} } + } + } + } + + NewGameScreen { + onStartButtonClicked: root.passedSplash = true + } + } + + property int countdown: 10 + Timer { + id: gameStarter + interval: 4000 + running: false + repeat: false + onTriggered: Logic.startGame(canvas); + } + + states: [ + State { + name: "gameOn"; when: gameState.gameOver == false && passedSplash + PropertyChanges { target: view; y: -(height - 960) } + StateChangeScript { script: root.countdown = 0; } + PropertyChanges { target: gameStarter; running: true } + }, + State { + name: "gameOver"; when: gameState.gameOver == true + PropertyChanges { target: view; y: 0 } + } + ] + + transitions: Transition { + NumberAnimation { properties: "x,y"; duration: 1200; easing.type: Easing.OutQuad } + } +} diff --git a/maroon/content/BuildButton.qml b/maroon/content/BuildButton.qml new file mode 100644 index 0000000..49641fc --- /dev/null +++ b/maroon/content/BuildButton.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "logic.js" as Logic + +Item { + id: container + width: 64 + height: 64 + property alias source: img.source + property int index + property int row: 0 + property int col: 0 + property int towerType + property bool canBuild: true + property Item gameCanvas: parent.parent.parent + signal clicked() + + Image { + id: img + opacity: (canBuild && gameCanvas.coins >= Logic.towerData[towerType-1].cost) ? 1.0 : 0.4 + } + Text { + anchors.right: parent.right + font.pointSize: 14 + font.bold: true + color: "#ffffff" + text: Logic.towerData[towerType - 1].cost + } + MouseArea { + anchors.fill: parent + onClicked: { + Logic.buildTower(towerType, col, row) + container.clicked() + } + } + Image { + visible: col == index && row != 0 + source: "gfx/dialog-pointer.png" + anchors.top: parent.bottom + anchors.topMargin: 4 + anchors.horizontalCenter: parent.horizontalCenter + } + Image { + visible: col == index && row == 0 + source: "gfx/dialog-pointer.png" + rotation: 180 + anchors.bottom: parent.top + anchors.bottomMargin: 6 + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/maroon/content/GameCanvas.qml b/maroon/content/GameCanvas.qml new file mode 100644 index 0000000..5e6e963 --- /dev/null +++ b/maroon/content/GameCanvas.qml @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "logic.js" as Logic +import "towers" as Towers + +Item { + id: grid + + property int squareSize: 64 + property int rows: 6 + property int cols: 4 + property Item canvas: grid + property int score: 0 + property int coins: 100 + property int lives: 3 + property int waveNumber: 0 + property int waveProgress: 0 + property var towers + property var mobs + property bool gameRunning: false + property bool gameOver: false + property bool errored: false + property string errorString: "" + + width: cols * squareSize + height: rows * squareSize + + function freshState() { + lives = 3 + coins = 100 + score = 0 + waveNumber = 0 + waveProgress = 0 + gameOver = false + gameRunning = false + towerMenu.shown = false + helpButton.comeBack(); + } + + Text { + id: errorText // Mostly for debug purposes + text: errorString + visible: errored + color: "red" + font.pixelSize: 18 + wrapMode: Text.WordWrap + width: parent.width / 1.2 + height: parent.height / 1.2 + anchors.centerIn: parent + z: 1000 + } + + Timer { + interval: 16 + running: true + repeat: true + onTriggered: Logic.tick() + } + + MouseArea { + id: ma + anchors.fill: parent + onClicked: { + if (towerMenu.visible) + towerMenu.finish() + else + towerMenu.open(mouse.x, mouse.y) + } + } + + Image { + id: towerMenu + visible: false + z: 1500 + scale: 0.9 + opacity: 0.7 + property int dragDistance: 16 + property int targetRow: 0 + property int targetCol: 0 + property bool shown: false + property bool towerExists: false + + function finish() { + shown = false + } + + function open(xp,yp) { + if (!grid.gameRunning) + return + targetRow = Logic.row(yp) + targetCol = Logic.col(xp) + if (targetRow == 0) + towerMenu.y = (targetRow + 1) * grid.squareSize + else + towerMenu.y = (targetRow - 1) * grid.squareSize + towerExists = (grid.towers[Logic.towerIdx(targetCol, targetRow)] != null) + shown = true + helpButton.goAway(); + } + + states: State { + name: "shown"; when: towerMenu.shown && !grid.gameOver + PropertyChanges { target: towerMenu; visible: true; scale: 1; opacity: 1 } + } + + transitions: Transition { + PropertyAction { property: "visible" } + NumberAnimation { properties: "opacity,scale"; duration: 500; easing.type: Easing.OutElastic } + } + + x: -32 + source: "gfx/dialog.png" + Row { + id: buttonRow + height: 100 + anchors.centerIn: parent + spacing: 8 + BuildButton { + row: towerMenu.targetRow; col: towerMenu.targetCol + anchors.verticalCenter: parent.verticalCenter + towerType: 1; index: 0 + canBuild: !towerMenu.towerExists + source: "gfx/dialog-melee.png" + onClicked: towerMenu.finish() + } + BuildButton { + row: towerMenu.targetRow; col: towerMenu.targetCol + anchors.verticalCenter: parent.verticalCenter + towerType: 2; index: 1 + canBuild: !towerMenu.towerExists + source: "gfx/dialog-shooter.png" + onClicked: towerMenu.finish() + } + BuildButton { + row: towerMenu.targetRow; col: towerMenu.targetCol + anchors.verticalCenter: parent.verticalCenter + towerType: 3; index: 2 + canBuild: !towerMenu.towerExists + source: "gfx/dialog-bomb.png" + onClicked: towerMenu.finish() + } + BuildButton { + row: towerMenu.targetRow; col: towerMenu.targetCol + anchors.verticalCenter: parent.verticalCenter + towerType: 4; index: 3 + canBuild: !towerMenu.towerExists + source: "gfx/dialog-factory.png" + onClicked: towerMenu.finish() + } + } + } + + + Keys.onPressed: { // Cheat Codes while Testing + if (event.key == Qt.Key_Up && (event.modifiers & Qt.ShiftModifier)) + grid.coins += 10; + if (event.key == Qt.Key_Left && (event.modifiers & Qt.ShiftModifier)) + grid.lives += 1; + if (event.key == Qt.Key_Down && (event.modifiers & Qt.ShiftModifier)) + Logic.gameState.waveProgress += 1000; + if (event.key == Qt.Key_Right && (event.modifiers & Qt.ShiftModifier)) + Logic.endGame(); + } + + Image { + id: helpButton + z: 1010 + source: "gfx/button-help.png" + function goAway() { + helpMA.enabled = false; + helpButton.opacity = 0; + } + function comeBack() { + helpMA.enabled = true; + helpButton.opacity = 1; + } + Behavior on opacity { NumberAnimation {} } + MouseArea { + id: helpMA + anchors.fill: parent + onClicked: {helpImage.visible = true; helpButton.visible = false;} + } + + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0 + } + + Image { + id: helpImage + z: 1010 + source: "gfx/help.png" + anchors.fill: parent + visible: false + MouseArea { + anchors.fill: parent + onClicked: helpImage.visible = false; + } + } + +} diff --git a/maroon/content/GameOverScreen.qml b/maroon/content/GameOverScreen.qml new file mode 100644 index 0000000..dfb439f --- /dev/null +++ b/maroon/content/GameOverScreen.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "logic.js" as Logic + +Item { + id: gameOverScreen + width: 320 + height: 400 + property GameCanvas gameCanvas + + Image { + id: img + source: "gfx/text-gameover.png" + anchors.centerIn: parent + } + + ParticleSystem { + anchors.fill: parent + ImageParticle { + id: cloud + source: "gfx/cloud.png" + alphaVariation: 0.25 + opacity: 0.25 + } + + Wander { + xVariance: 100; + pace: 1; + } + + Emitter { + id: cloudLeft + width: 160 + height: 160 + anchors.right: parent.left + emitRate: 0.5 + lifeSpan: 12000 + velocity: PointDirection{ x: 64; xVariation: 2; yVariation: 2 } + size: 160 + } + + Emitter { + id: cloudRight + width: 160 + height: 160 + anchors.left: parent.right + emitRate: 0.5 + lifeSpan: 12000 + velocity: PointDirection{ x: -64; xVariation: 2; yVariation: 2 } + size: 160 + } + } + + + Text { + visible: gameCanvas != undefined + text: "You saved " + gameCanvas.score + " fishes!" + anchors.top: img.bottom + anchors.topMargin: 12 + anchors.horizontalCenter: parent.horizontalCenter + font.bold: true + color: "#000000" + opacity: 0.5 + } + + Image { + source: "gfx/button-play.png" + anchors.bottom: parent.bottom + anchors.bottomMargin: 0 + MouseArea { + anchors.fill: parent + onClicked: gameCanvas.gameOver = false//This will actually trigger the state change in main.qml + } + } +} diff --git a/maroon/content/InfoBar.qml b/maroon/content/InfoBar.qml new file mode 100644 index 0000000..36303fc --- /dev/null +++ b/maroon/content/InfoBar.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + height: childrenRect.height + + // Display the number of lives + Row { + anchors.left: parent.left + anchors.leftMargin: 10 + spacing: 5 + Repeater { + id: rep + model: Math.min(10, canvas.lives) + delegate: Image { source: "gfx/lifes.png" } + } + } + + // Display the number of fishes saved + Row { + anchors.right: points.left + anchors.rightMargin: 20 + spacing: 5 + Image { source: "gfx/scores.png" } + Text { + text: canvas.score + font.bold: true + } + } + + // Display the number of coins + Row { + id: points + anchors.right: parent.right + anchors.rightMargin: 10 + spacing: 5 + Image { source: "gfx/points.png" } + Text { + id: pointsLabel + text: canvas.coins + font.bold: true + } + } +} + diff --git a/maroon/content/NewGameScreen.qml b/maroon/content/NewGameScreen.qml new file mode 100644 index 0000000..495e3aa --- /dev/null +++ b/maroon/content/NewGameScreen.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// This is the first screen. +// It shows the logo and emit a startButtonClicked signal +// when the user press the "PLAY" button. + +Item { + id: newGameScreen + width: 320 + height: 480 + + signal startButtonClicked + + Image { + source: "gfx/logo.png" + anchors.top: parent.top + anchors.topMargin: 60 + } + + Image { + source: "gfx/logo-fish.png" + anchors.top: parent.top + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: x + 148; to: x + 25; duration: 2000; easing.type: Easing.InOutQuad } + NumberAnimation { from: x + 25; to: x + 148; duration: 1600; easing.type: Easing.InOutQuad } + } + SequentialAnimation on anchors.topMargin { + loops: Animation.Infinite + NumberAnimation { from: 100; to: 60; duration: 1600; easing.type: Easing.InOutQuad } + NumberAnimation { from: 60; to: 100; duration: 2000; easing.type: Easing.InOutQuad } + } + } + + Image { + source: "gfx/logo-bubble.png" + anchors.top: parent.top + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: x + 140; to: x + 40; duration: 2000; easing.type: Easing.InOutQuad } + NumberAnimation { from: x + 40; to: x + 140; duration: 1600; easing.type: Easing.InOutQuad } + } + SequentialAnimation on anchors.topMargin { + loops: Animation.Infinite + NumberAnimation { from: 100; to: 60; duration: 1600; easing.type: Easing.InOutQuad } + NumberAnimation { from: 60; to: 100; duration: 2000; easing.type: Easing.InOutQuad } + } + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { from: 140; to: 160; duration: 1000; easing.type: Easing.InOutQuad } + NumberAnimation { from: 160; to: 140; duration: 800; easing.type: Easing.InOutQuad } + } + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { from: 150; to: 140; duration: 800; easing.type: Easing.InOutQuad } + NumberAnimation { from: 140; to: 150; duration: 1000; easing.type: Easing.InOutQuad } + } + } + + Image { + source: "gfx/button-play.png" + anchors.bottom: parent.bottom + anchors.bottomMargin: 60 + MouseArea { + anchors.fill: parent + onClicked: newGameScreen.startButtonClicked() + } + } +} diff --git a/maroon/content/SoundEffect.qml b/maroon/content/SoundEffect.qml new file mode 100644 index 0000000..d286a39 --- /dev/null +++ b/maroon/content/SoundEffect.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//Proxies a SoundEffect if QtMultimedia is installed +Item { + id: container + property QtObject effect: Qt.createQmlObject("import QtMultimedia 5.0; SoundEffect{ source: '" + container.source + "' }", container); + property url source: "" + onSourceChanged: if (effect != null) effect.source = source; + function play() { + if (effect != null) + effect.play(); + } + +} diff --git a/maroon/content/audio/bomb-action.wav b/maroon/content/audio/bomb-action.wav new file mode 100644 index 0000000..b334dc1 Binary files /dev/null and b/maroon/content/audio/bomb-action.wav differ diff --git a/maroon/content/audio/catch-action.wav b/maroon/content/audio/catch-action.wav new file mode 100644 index 0000000..3e22124 Binary files /dev/null and b/maroon/content/audio/catch-action.wav differ diff --git a/maroon/content/audio/catch.wav b/maroon/content/audio/catch.wav new file mode 100644 index 0000000..d3eade8 Binary files /dev/null and b/maroon/content/audio/catch.wav differ diff --git a/maroon/content/audio/currency.wav b/maroon/content/audio/currency.wav new file mode 100644 index 0000000..0d9ef2c Binary files /dev/null and b/maroon/content/audio/currency.wav differ diff --git a/maroon/content/audio/factory-action.wav b/maroon/content/audio/factory-action.wav new file mode 100644 index 0000000..a2ace6c Binary files /dev/null and b/maroon/content/audio/factory-action.wav differ diff --git a/maroon/content/audio/melee-action.wav b/maroon/content/audio/melee-action.wav new file mode 100644 index 0000000..d325af4 Binary files /dev/null and b/maroon/content/audio/melee-action.wav differ diff --git a/maroon/content/audio/projectile-action.wav b/maroon/content/audio/projectile-action.wav new file mode 100644 index 0000000..4e2284f Binary files /dev/null and b/maroon/content/audio/projectile-action.wav differ diff --git a/maroon/content/audio/shooter-action.wav b/maroon/content/audio/shooter-action.wav new file mode 100644 index 0000000..3e12b94 Binary files /dev/null and b/maroon/content/audio/shooter-action.wav differ diff --git a/maroon/content/gfx/background.png b/maroon/content/gfx/background.png new file mode 100644 index 0000000..d548b93 Binary files /dev/null and b/maroon/content/gfx/background.png differ diff --git a/maroon/content/gfx/bomb-action.png b/maroon/content/gfx/bomb-action.png new file mode 100644 index 0000000..42da5d7 Binary files /dev/null and b/maroon/content/gfx/bomb-action.png differ diff --git a/maroon/content/gfx/bomb-idle.png b/maroon/content/gfx/bomb-idle.png new file mode 100644 index 0000000..3bd62e2 Binary files /dev/null and b/maroon/content/gfx/bomb-idle.png differ diff --git a/maroon/content/gfx/bomb.png b/maroon/content/gfx/bomb.png new file mode 100644 index 0000000..380da7d Binary files /dev/null and b/maroon/content/gfx/bomb.png differ diff --git a/maroon/content/gfx/button-help.png b/maroon/content/gfx/button-help.png new file mode 100644 index 0000000..aecebc1 Binary files /dev/null and b/maroon/content/gfx/button-help.png differ diff --git a/maroon/content/gfx/button-play.png b/maroon/content/gfx/button-play.png new file mode 100644 index 0000000..6cdad6c Binary files /dev/null and b/maroon/content/gfx/button-play.png differ diff --git a/maroon/content/gfx/catch-action.png b/maroon/content/gfx/catch-action.png new file mode 100644 index 0000000..78ca9fe Binary files /dev/null and b/maroon/content/gfx/catch-action.png differ diff --git a/maroon/content/gfx/catch.png b/maroon/content/gfx/catch.png new file mode 100644 index 0000000..b7620fe Binary files /dev/null and b/maroon/content/gfx/catch.png differ diff --git a/maroon/content/gfx/cloud.png b/maroon/content/gfx/cloud.png new file mode 100644 index 0000000..d7c35f8 Binary files /dev/null and b/maroon/content/gfx/cloud.png differ diff --git a/maroon/content/gfx/currency.png b/maroon/content/gfx/currency.png new file mode 100644 index 0000000..1571341 Binary files /dev/null and b/maroon/content/gfx/currency.png differ diff --git a/maroon/content/gfx/dialog-bomb.png b/maroon/content/gfx/dialog-bomb.png new file mode 100644 index 0000000..708d916 Binary files /dev/null and b/maroon/content/gfx/dialog-bomb.png differ diff --git a/maroon/content/gfx/dialog-factory.png b/maroon/content/gfx/dialog-factory.png new file mode 100644 index 0000000..d2e2a48 Binary files /dev/null and b/maroon/content/gfx/dialog-factory.png differ diff --git a/maroon/content/gfx/dialog-melee.png b/maroon/content/gfx/dialog-melee.png new file mode 100644 index 0000000..069d18d Binary files /dev/null and b/maroon/content/gfx/dialog-melee.png differ diff --git a/maroon/content/gfx/dialog-pointer.png b/maroon/content/gfx/dialog-pointer.png new file mode 100644 index 0000000..9b51a09 Binary files /dev/null and b/maroon/content/gfx/dialog-pointer.png differ diff --git a/maroon/content/gfx/dialog-shooter.png b/maroon/content/gfx/dialog-shooter.png new file mode 100644 index 0000000..af980ca Binary files /dev/null and b/maroon/content/gfx/dialog-shooter.png differ diff --git a/maroon/content/gfx/dialog.png b/maroon/content/gfx/dialog.png new file mode 100644 index 0000000..d528ba7 Binary files /dev/null and b/maroon/content/gfx/dialog.png differ diff --git a/maroon/content/gfx/factory-action.png b/maroon/content/gfx/factory-action.png new file mode 100644 index 0000000..8981678 Binary files /dev/null and b/maroon/content/gfx/factory-action.png differ diff --git a/maroon/content/gfx/factory-idle.png b/maroon/content/gfx/factory-idle.png new file mode 100644 index 0000000..a145582 Binary files /dev/null and b/maroon/content/gfx/factory-idle.png differ diff --git a/maroon/content/gfx/factory.png b/maroon/content/gfx/factory.png new file mode 100644 index 0000000..bfb9f3f Binary files /dev/null and b/maroon/content/gfx/factory.png differ diff --git a/maroon/content/gfx/grid.png b/maroon/content/gfx/grid.png new file mode 100644 index 0000000..b595552 Binary files /dev/null and b/maroon/content/gfx/grid.png differ diff --git a/maroon/content/gfx/help.png b/maroon/content/gfx/help.png new file mode 100644 index 0000000..4654e4c Binary files /dev/null and b/maroon/content/gfx/help.png differ diff --git a/maroon/content/gfx/lifes.png b/maroon/content/gfx/lifes.png new file mode 100644 index 0000000..135310b Binary files /dev/null and b/maroon/content/gfx/lifes.png differ diff --git a/maroon/content/gfx/logo-bubble.png b/maroon/content/gfx/logo-bubble.png new file mode 100644 index 0000000..136151c Binary files /dev/null and b/maroon/content/gfx/logo-bubble.png differ diff --git a/maroon/content/gfx/logo-fish.png b/maroon/content/gfx/logo-fish.png new file mode 100644 index 0000000..c41833a Binary files /dev/null and b/maroon/content/gfx/logo-fish.png differ diff --git a/maroon/content/gfx/logo.png b/maroon/content/gfx/logo.png new file mode 100644 index 0000000..787ac99 Binary files /dev/null and b/maroon/content/gfx/logo.png differ diff --git a/maroon/content/gfx/melee-action.png b/maroon/content/gfx/melee-action.png new file mode 100644 index 0000000..c53873b Binary files /dev/null and b/maroon/content/gfx/melee-action.png differ diff --git a/maroon/content/gfx/melee-idle.png b/maroon/content/gfx/melee-idle.png new file mode 100644 index 0000000..621d9df Binary files /dev/null and b/maroon/content/gfx/melee-idle.png differ diff --git a/maroon/content/gfx/melee.png b/maroon/content/gfx/melee.png new file mode 100644 index 0000000..ab24015 Binary files /dev/null and b/maroon/content/gfx/melee.png differ diff --git a/maroon/content/gfx/mob-idle.png b/maroon/content/gfx/mob-idle.png new file mode 100644 index 0000000..dedacc7 Binary files /dev/null and b/maroon/content/gfx/mob-idle.png differ diff --git a/maroon/content/gfx/mob.png b/maroon/content/gfx/mob.png new file mode 100644 index 0000000..7569c35 Binary files /dev/null and b/maroon/content/gfx/mob.png differ diff --git a/maroon/content/gfx/points.png b/maroon/content/gfx/points.png new file mode 100644 index 0000000..1d2386d Binary files /dev/null and b/maroon/content/gfx/points.png differ diff --git a/maroon/content/gfx/projectile-action.png b/maroon/content/gfx/projectile-action.png new file mode 100644 index 0000000..aa2e650 Binary files /dev/null and b/maroon/content/gfx/projectile-action.png differ diff --git a/maroon/content/gfx/projectile.png b/maroon/content/gfx/projectile.png new file mode 100644 index 0000000..c25a0c3 Binary files /dev/null and b/maroon/content/gfx/projectile.png differ diff --git a/maroon/content/gfx/scores.png b/maroon/content/gfx/scores.png new file mode 100644 index 0000000..af757fe Binary files /dev/null and b/maroon/content/gfx/scores.png differ diff --git a/maroon/content/gfx/shooter-action.png b/maroon/content/gfx/shooter-action.png new file mode 100644 index 0000000..08e7e30 Binary files /dev/null and b/maroon/content/gfx/shooter-action.png differ diff --git a/maroon/content/gfx/shooter-idle.png b/maroon/content/gfx/shooter-idle.png new file mode 100644 index 0000000..663098d Binary files /dev/null and b/maroon/content/gfx/shooter-idle.png differ diff --git a/maroon/content/gfx/shooter.png b/maroon/content/gfx/shooter.png new file mode 100644 index 0000000..d44401e Binary files /dev/null and b/maroon/content/gfx/shooter.png differ diff --git a/maroon/content/gfx/sunlight.png b/maroon/content/gfx/sunlight.png new file mode 100644 index 0000000..d1c7042 Binary files /dev/null and b/maroon/content/gfx/sunlight.png differ diff --git a/maroon/content/gfx/text-1.png b/maroon/content/gfx/text-1.png new file mode 100644 index 0000000..3ea399c Binary files /dev/null and b/maroon/content/gfx/text-1.png differ diff --git a/maroon/content/gfx/text-2.png b/maroon/content/gfx/text-2.png new file mode 100644 index 0000000..934a481 Binary files /dev/null and b/maroon/content/gfx/text-2.png differ diff --git a/maroon/content/gfx/text-3.png b/maroon/content/gfx/text-3.png new file mode 100644 index 0000000..47523f5 Binary files /dev/null and b/maroon/content/gfx/text-3.png differ diff --git a/maroon/content/gfx/text-blank.png b/maroon/content/gfx/text-blank.png new file mode 100644 index 0000000..4a687b2 Binary files /dev/null and b/maroon/content/gfx/text-blank.png differ diff --git a/maroon/content/gfx/text-gameover.png b/maroon/content/gfx/text-gameover.png new file mode 100644 index 0000000..4f53ef0 Binary files /dev/null and b/maroon/content/gfx/text-gameover.png differ diff --git a/maroon/content/gfx/text-go.png b/maroon/content/gfx/text-go.png new file mode 100644 index 0000000..bfc26f7 Binary files /dev/null and b/maroon/content/gfx/text-go.png differ diff --git a/maroon/content/gfx/wave.png b/maroon/content/gfx/wave.png new file mode 100644 index 0000000..f97426c Binary files /dev/null and b/maroon/content/gfx/wave.png differ diff --git a/maroon/content/logic.js b/maroon/content/logic.js new file mode 100644 index 0000000..dd76b7e --- /dev/null +++ b/maroon/content/logic.js @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +.pragma library // Shared game state +.import QtQuick 2.0 as QQ + +// Game Stuff +var gameState // Local reference +function getGameState() { return gameState; } + +var towerData = [ // Name and cost, stats are in the delegate per instance + { "name": "Melee", "cost": 20 }, + { "name": "Ranged", "cost": 50 }, + { "name": "Bomb", "cost": 75 }, + { "name": "Factory", "cost": 25 } +] + +var waveBaseData = [300, 290, 280, 270, 220, 180, 160, 80, 80, 80, 30, 30, 30, 30]; +var waveData = []; + +var towerComponents = new Array(towerData.length); +var mobComponent = Qt.createComponent("mobs/MobBase.qml"); + +function endGame() +{ + gameState.gameRunning = false; + gameState.gameOver = true; + for (var i = 0; i < gameState.cols; i++) { + for (var j = 0; j < gameState.rows; j++) { + if (gameState.towers[towerIdx(i, j)]) { + gameState.towers[towerIdx(i, j)].destroy(); + gameState.towers[towerIdx(i, j)] = null; + } + } + for (var j in gameState.mobs[i]) + gameState.mobs[i][j].destroy(); + gameState.mobs[i].splice(0,gameState.mobs[i].length); //Leaves queue reusable + } +} + +function startGame(gameCanvas) +{ + waveData = new Array(); + for (var i in waveBaseData) + waveData[i] = waveBaseData[i]; + gameState.freshState(); + for (var i = 0; i < gameCanvas.cols; i++) { + for (var j = 0; j < gameCanvas.rows; j++) + gameState.towers[towerIdx(i, j)] = null; + gameState.mobs[i] = new Array(); + } + gameState.towers[towerIdx(0, 0)] = newTower(3, 0, 0);//Start with a starfish in the corner + gameState.gameRunning = true; + gameState.gameOver = false; +} + +function newGameState(gameCanvas) +{ + for (var i = 0; i < towerComponents.length; i++) { + towerComponents[i] = Qt.createComponent("towers/" + towerData[i].name + ".qml"); + if (towerComponents[i].status == QQ.Component.Error) { + gameCanvas.errored = true; + gameCanvas.errorString += "Loading Tower " + towerData[i].name + "\n" + (towerComponents[i].errorString()); + console.log(towerComponents[i].errorString()); + } + } + gameState = gameCanvas; + gameState.freshState(); + gameState.towers = new Array(gameCanvas.rows * gameCanvas.cols); + gameState.mobs = new Array(gameCanvas.cols); + return gameState; +} + +function row(y) +{ + return Math.floor(y / gameState.squareSize); +} + +function col(x) +{ + return Math.floor(x / gameState.squareSize); +} + +function towerIdx(x, y) +{ + return y + (x * gameState.rows); +} + +function newMob(col) +{ + var ret = mobComponent.createObject(gameState.canvas, + { "col" : col, + "speed" : (Math.min(2.0, 0.10 * (gameState.waveNumber + 1))), + "y" : gameState.canvas.height }); + gameState.mobs[col].push(ret); + return ret; +} + +function newTower(type, row, col) +{ + var ret = towerComponents[type].createObject(gameState.canvas); + ret.row = row; + ret.col = col; + ret.fireCounter = ret.rof; + ret.spawn(); + return ret; +} + +function buildTower(type, x, y) +{ + if (gameState.towers[towerIdx(x,y)] != null) { + if (type <= 0) { + gameState.towers[towerIdx(x,y)].sell(); + gameState.towers[towerIdx(x,y)] = null; + } + } else { + if (gameState.coins < towerData[type - 1].cost) + return; + gameState.towers[towerIdx(x, y)] = newTower(type - 1, y, x); + gameState.coins -= towerData[type - 1].cost; + } +} + +function killMob(col, mob) +{ + if (!mob) + return; + var idx = gameState.mobs[col].indexOf(mob); + if (idx == -1 || !mob.hp) + return; + mob.hp = 0; + mob.die(); + gameState.mobs[col].splice(idx,1); +} + +function killTower(row, col) +{ + var tower = gameState.towers[towerIdx(col, row)]; + if (!tower) + return; + tower.hp = 0; + tower.die(); + gameState.towers[towerIdx(col, row)] = null; +} + +function tick() +{ + if (!gameState.gameRunning) + return; + + // Spawn + gameState.waveProgress += 1; + var i = gameState.waveProgress; + var j = 0; + while (i > 0 && j < waveData.length) + i -= waveData[j++]; + if ( i == 0 ) // Spawn a mob + newMob(Math.floor(Math.random() * gameState.cols)); + if ( j == waveData.length ) { // Next Wave + gameState.waveNumber += 1; + gameState.waveProgress = 0; + var waveModifier = 10; // Constant governing how much faster the next wave is to spawn (not fish speed) + for (var k in waveData ) // Slightly faster + if (waveData[k] > waveModifier) + waveData[k] -= waveModifier; + } + + // Towers Attack + for (var j in gameState.towers) { + var tower = gameState.towers[j]; + if (tower == null) + continue; + if (tower.fireCounter > 0) { + tower.fireCounter -= 1; + continue; + } + var column = tower.col; + for (var k in gameState.mobs[column]) { + var conflict = gameState.mobs[column][k]; + if (conflict.y <= gameState.canvas.height && conflict.y + conflict.height > tower.y + && conflict.y - ((tower.row + 1) * gameState.squareSize) < gameState.squareSize * tower.range) { // In Range + tower.fire(); + tower.fireCounter = tower.rof; + conflict.hit(tower.damage); + } + } + + // Income + if (tower.income) { + gameState.coins += tower.income; + tower.fire(); + tower.fireCounter = tower.rof; + } + } + + // Mobs move + for (var i = 0; i < gameState.cols; i++) { + for (var j = 0; j < gameState.mobs[i].length; j++) { + var mob = gameState.mobs[i][j]; + var newPos = gameState.mobs[i][j].y - gameState.mobs[i][j].speed; + if (newPos < 0) { + gameState.lives -= 1; + killMob(i, mob); + if (gameState.lives <= 0) + endGame(); + continue; + } + var conflict = gameState.towers[towerIdx(i, row(newPos))]; + if (conflict != null) { + if (mob.y < conflict.y + gameState.squareSize) + gameState.mobs[i][j].y += gameState.mobs[i][j].speed * 10; // Moved inside tower, now hurry back out + if (mob.fireCounter > 0) { + mob.fireCounter--; + } else { + gameState.mobs[i][j].fire(); + conflict.hp -= mob.damage; + if (conflict.hp <= 0) + killTower(conflict.row, conflict.col); + mob.fireCounter = mob.rof; + } + } else { + gameState.mobs[i][j].y = newPos; + } + } + } + +} diff --git a/maroon/content/mobs/MobBase.qml b/maroon/content/mobs/MobBase.qml new file mode 100644 index 0000000..d4ece66 --- /dev/null +++ b/maroon/content/mobs/MobBase.qml @@ -0,0 +1,262 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../logic.js" as Logic +import ".." + +Item { + id: container + property string name: "Fish" + property int col: 0 + property real hp: 3 + property real damage: 1 + property real speed: 0.25 + property int rof: 30 //In ticks + property int fireCounter: 0 + property bool dying: false + width: parent ? parent.squareSize : 0 + height: parent ? parent.squareSize : 0 + x: col * width + z: 1001 + function fire() { } + + function die() { + if (dying) + return; + dying = true; + bubble.jumpTo("burst"); + if (fishSprite.currentSprite == "front") + fishSprite.jumpTo(Math.random() > 0.5 ? "left" : "right" ); + fishSwim.start(); + Logic.gameState.score += 1; + killedSound.play(); + bubble.scale = 0.9 + destroy(350); + } + + function inked() { + if (hp > 0) + ink.jumpTo("dirty"); + } + + function hit(dmg) { + hp -= dmg; + + if (hp <= 0) + Logic.killMob(col, container); + } + + Component.onCompleted: spawnSound.play() + + SoundEffect { + id: spawnSound + source: "../audio/catch.wav" + } + SoundEffect { + id: killedSound + source: "../audio/catch-action.wav" + } + + SpriteSequence { + id: fishSprite + width: 64 + height: 64 + interpolate: false + goalSprite: "" + + Sprite { + name: "left" + source: "../gfx/mob-idle.png" + frameWidth: 64 + frameHeight: 64 + frameCount: 1 + frameDuration: 800 + frameDurationVariation: 400 + to: { "front" : 1 } + } + + Sprite { + name: "front" + source: "../gfx/mob-idle.png" + frameCount: 1 + frameX: 64 + frameWidth: 64 + frameHeight: 64 + frameDuration: 800 + frameDurationVariation: 400 + to: { "left" : 1, "right" : 1 } + } + + Sprite { + name: "right" + source: "../gfx/mob-idle.png" + frameCount: 1 + frameX: 128 + frameWidth: 64 + frameHeight: 64 + frameDuration: 800 + frameDurationVariation: 400 + to: { "front" : 1 } + } + + + Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation. + name: "dummy" + source: "../gfx/melee-idle.png" + frameCount: 8 + frameWidth: 64 + frameHeight: 64 + frameX: 0 + frameDuration: 200 + } + + NumberAnimation on x { + id: fishSwim + running: false + property bool goingLeft: fishSprite.currentSprite == "right" + to: goingLeft ? -360 : 360 + duration: 300 + } + } + + SpriteSequence { + id: bubble + width: 64 + height: 64 + scale: 0.4 + (0.2 * hp) + interpolate: false + goalSprite: "" + + Behavior on scale { + NumberAnimation { duration: 150; easing.type: Easing.OutBack } + } + + Sprite { + name: "big" + source: "../gfx/catch.png" + frameCount: 1 + to: { "burst" : 0 } + } + + Sprite { + name: "burst" + source: "../gfx/catch-action.png" + frameCount: 3 + frameX: 64 + frameDuration: 200 + } + + Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation. + name: "dummy" + source: "../gfx/melee-idle.png" + frameCount: 8 + frameWidth: 64 + frameHeight: 64 + frameX: 0 + frameDuration: 200 + } + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { from: width * 1; to: width * 1.1; duration: 800; easing.type: Easing.InOutQuad } + NumberAnimation { from: width * 1.1; to: width * 1; duration: 1000; easing.type: Easing.InOutQuad } + } + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { from: height * 1; to: height * 1.15; duration: 1200; easing.type: Easing.InOutQuad } + NumberAnimation { from: height * 1.15; to: height * 1; duration: 1000; easing.type: Easing.InOutQuad } + } + } + + SpriteSequence { + id: ink + width: 64 + height: 64 + scale: bubble.scale + goalSprite: "" + + Sprite { + name: "clean" + source: "../gfx/projectile-action.png" + frameCount: 1 + frameX: 0 + frameWidth: 64 + frameHeight: 64 + } + Sprite { + name: "dirty" + source: "../gfx/projectile-action.png" + frameCount: 3 + frameX: 64 + frameWidth: 64 + frameHeight: 64 + frameDuration: 150 + to: {"clean":1} + } + + Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation. + name: "dummy" + source: "../gfx/melee-idle.png" + frameCount: 8 + frameWidth: 64 + frameHeight: 64 + frameX: 0 + frameDuration: 200 + } + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { from: width * 1; to: width * 1.1; duration: 800; easing.type: Easing.InOutQuad } + NumberAnimation { from: width * 1.1; to: width * 1; duration: 1000; easing.type: Easing.InOutQuad } + } + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { from: height * 1; to: height * 1.15; duration: 1200; easing.type: Easing.InOutQuad } + NumberAnimation { from: height * 1.15; to: height * 1; duration: 1000; easing.type: Easing.InOutQuad } + } + + } + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: x; to: x - 5; duration: 900; easing.type: Easing.InOutQuad } + NumberAnimation { from: x - 5; to: x; duration: 900; easing.type: Easing.InOutQuad } + } +} + diff --git a/maroon/content/towers/Bomb.qml b/maroon/content/towers/Bomb.qml new file mode 100644 index 0000000..00437f4 --- /dev/null +++ b/maroon/content/towers/Bomb.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../logic.js" as Logic +import ".." + +TowerBase { + id: container + hp: 10 + range: 0.4 + rof: 10 + property real detonationRange: 2.5 + + function fire() { + sound.play() + sprite.jumpTo("shoot") + animDelay.start() + } + + function finishFire() { + var sCol = Math.max(0, col - 1) + var eCol = Math.min(Logic.gameState.cols - 1, col + 1) + var killList = new Array() + for (var i = sCol; i <= eCol; i++) { + for (var j = 0; j < Logic.gameState.mobs[i].length; j++) + if (Math.abs(Logic.gameState.mobs[i][j].y - container.y) < Logic.gameState.squareSize * detonationRange) + killList.push(Logic.gameState.mobs[i][j]) + while (killList.length > 0) + Logic.killMob(i, killList.pop()) + } + Logic.killTower(row, col); + } + + Timer { + id: animDelay + running: false + interval: shootState.frameCount * shootState.frameDuration + onTriggered: finishFire() + } + + function die() + { + destroy() // No blink, because we usually meant to die + } + + SoundEffect { + id: sound + source: "../audio/bomb-action.wav" + } + + SpriteSequence { + id: sprite + width: 64 + height: 64 + interpolate: false + goalSprite: "" + + Sprite { + name: "idle" + source: "../gfx/bomb-idle.png" + frameCount: 4 + frameDuration: 800 + } + + Sprite { + id: shootState + name: "shoot" + source: "../gfx/bomb-action.png" + frameCount: 6 + frameDuration: 155 + to: { "dying" : 1 } // So that if it takes a frame to clean up, it is on the last frame of the explosion + } + + Sprite { + name: "dying" + source: "../gfx/bomb-action.png" + frameCount: 1 + frameX: 64 * 5 + frameWidth: 64 + frameHeight: 64 + frameDuration: 155 + } + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: x; to: x + 4; duration: 900; easing.type: Easing.InOutQuad } + NumberAnimation { from: x + 4; to: x; duration: 900; easing.type: Easing.InOutQuad } + } + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { from: y; to: y - 4; duration: 900; easing.type: Easing.InOutQuad } + NumberAnimation { from: y - 4; to: y; duration: 900; easing.type: Easing.InOutQuad } + } + } +} diff --git a/maroon/content/towers/Factory.qml b/maroon/content/towers/Factory.qml new file mode 100644 index 0000000..b34a184 --- /dev/null +++ b/maroon/content/towers/Factory.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../logic.js" as Logic +import ".." + +TowerBase { + id: container + rof: 160 + income: 5 + SpriteSequence { + id: sprite + width: 64 + height: 64 + interpolate: false + goalSprite: "" + + Sprite { + name: "idle" + source: "../gfx/factory-idle.png" + frameCount: 4 + frameDuration: 200 + } + + Sprite { + name: "action" + source: "../gfx/factory-action.png" + frameCount: 4 + frameDuration: 90 + to: { "idle" : 1 } + } + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: x; to: x + 4; duration: 900; easing.type: Easing.InOutQuad } + NumberAnimation { from: x + 4; to: x; duration: 900; easing.type: Easing.InOutQuad } + } + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { from: y; to: y - 4; duration: 900; easing.type: Easing.InOutQuad } + NumberAnimation { from: y - 4; to: y; duration: 900; easing.type: Easing.InOutQuad } + } + } + + SoundEffect { + id: actionSound + source: "../audio/factory-action.wav" + } + + function fire() { + actionSound.play() + sprite.jumpTo("action") + coinLaunch.start() + } + + function spawn() { + coin.target = Logic.gameState.mapToItem(container, 240, -32) + } + + Image { + id: coin + property var target: { "x" : 0, "y" : 0 } + source: "../gfx/currency.png" + visible: false + } + + SequentialAnimation { + id: coinLaunch + PropertyAction { target: coin; property: "visible"; value: true } + ParallelAnimation { + NumberAnimation { target: coin; property: "x"; from: 16; to: coin.target.x } + NumberAnimation { target: coin; property: "y"; from: 16; to: coin.target.y } + } + PropertyAction { target: coin; property: "visible"; value: false } + } +} diff --git a/maroon/content/towers/Melee.qml b/maroon/content/towers/Melee.qml new file mode 100644 index 0000000..1b49a45 --- /dev/null +++ b/maroon/content/towers/Melee.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import ".." + +TowerBase { + hp: 4 + range: 0.1 + damage: 1 + rof: 40 + income: 0 + + SpriteSequence { + id: sprite + width: 64 + height: 64 + interpolate: false + goalSprite: "" + + Sprite { + name: "idle" + source: "../gfx/melee-idle.png" + frameCount: 8 + frameDuration: 250 + } + + Sprite { + name: "shoot" + source: "../gfx/melee-action.png" + frameCount: 2 + frameDuration: 200 + to: { "idle" : 1 } + } + } + + function fire() { + shootSound.play() + sprite.jumpTo("shoot") + } + + SoundEffect { + id: shootSound + source: "../audio/melee-action.wav" + } +} diff --git a/maroon/content/towers/Ranged.qml b/maroon/content/towers/Ranged.qml new file mode 100644 index 0000000..33f3354 --- /dev/null +++ b/maroon/content/towers/Ranged.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../logic.js" as Logic +import ".." + +TowerBase { + id: container + hp: 2 + range: 6 + damage: 0 // By projectile + rof: 40 + income: 0 + property var targetMob + property real realDamage: 1 + function fire() { + proj.x = 32 - proj.width / 2 + proj.y = 0 + targetMob = Logic.gameState.mobs[col][0] + projAnim.to = targetMob.y - container.y -10 + projAnim.start() + shootSound.play() + sprite.jumpTo("shoot") + } + + Image { + id: proj + y: 1000 + SequentialAnimation on y { + id: projAnim + running: false + property real to: 1000 + SmoothedAnimation { + to: projAnim.to + velocity: 400 + } + ScriptAction { + script: { + if (targetMob && targetMob.hit) { + targetMob.hit(realDamage) + targetMob.inked() + projSound.play() + } + } + } + PropertyAction { + value: 1000; + } + } + source: "../gfx/projectile.png" + } + + SoundEffect { + id: shootSound + source: "../audio/shooter-action.wav" + } + SoundEffect { + id: projSound + source: "../audio/projectile-action.wav" + } + + SpriteSequence { + id: sprite + width: 64 + height: 64 + interpolate: false + goalSprite: "" + + Sprite { + name: "idle" + source: "../gfx/shooter-idle.png" + frameCount: 4 + frameDuration: 250 + } + + Sprite { + name: "shoot" + source: "../gfx/shooter-action.png" + frameCount: 5 + frameDuration: 90 + to: { "idle" : 1 } + } + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: x; to: x - 4; duration: 900; easing.type: Easing.InOutQuad } + NumberAnimation { from: x - 4; to: x; duration: 900; easing.type: Easing.InOutQuad } + } + } +} diff --git a/maroon/content/towers/TowerBase.qml b/maroon/content/towers/TowerBase.qml new file mode 100644 index 0000000..5c71cb0 --- /dev/null +++ b/maroon/content/towers/TowerBase.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property real hp: 1 + property real range: 0 + property real damage: 0 + property int rof: 100 + property int fireCounter: 0 + property int income: 0 + property int row: 0 + property int col: 0 + + width: parent ? parent.squareSize : 0 + height: parent ? parent.squareSize : 0 + //This is how it is placed on the gameboard, do not modify/animate the X/Y/Z of a TowerBase please + x: col * width + y: row * height + z: 1000 + + function fire() { } + function spawn() { } //After all game properties are set + function die() { stdDeath.start(); destroy(1000); } + function sell() { destroy(); } + + SequentialAnimation on opacity { + id: stdDeath + running: false + loops: 2 + NumberAnimation { from: 1; to: 0; } + NumberAnimation { from: 0; to: 1; } + } +} diff --git a/particles/customemitter.qml b/particles/customemitter.qml new file mode 100644 index 0000000..270935d --- /dev/null +++ b/particles/customemitter.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: sys + width: 320 + height: 480 + running: true + + property real petalLength: 180 + property real petalRotation: 0 + NumberAnimation on petalRotation { + from: 0; + to: 360; + loops: -1; + running: true + duration: 24000 + } + + function convert(a) {return a*(Math.PI/180);} + Emitter { + lifeSpan: 4000 + emitRate: 120 + size: 12 + anchors.centerIn: parent + //! [0] + onEmitParticles: { + for (var i=0; iP1: ' + gameCanvas.score + font.pixelSize: Settings.fontPixelSize + textFormat: Text.StyledText + color: "white" + opacity: gameCanvas.mode == "arcade" ? 1 : 0 + Behavior on opacity { NumberAnimation {} } + } + SamegameText { + id: arcadeHighScore + anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top} + text: 'Highscore: ' + gameCanvas.highScore + opacity: gameCanvas.mode == "arcade" ? 1 : 0 + } + SamegameText { + id: p1Score + anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top} + text: 'P1: ' + gameCanvas.score + opacity: gameCanvas.mode == "multiplayer" ? 1 : 0 + } + SamegameText { + id: p2Score + anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top} + text: 'P2: ' + gameCanvas.score2 + opacity: gameCanvas.mode == "multiplayer" ? 1 : 0 + rotation: 180 + } + SamegameText { + id: puzzleMoves + anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top} + text: 'Moves: ' + gameCanvas.moves + opacity: gameCanvas.mode == "puzzle" ? 1 : 0 + } + SamegameText { + Image { + source: "content/gfx/icon-time.png" + x: -20 + } + id: puzzleTime + anchors { topMargin: 3; top: parent.top; horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 20} + text: "00:00" + opacity: gameCanvas.mode == "puzzle" ? 1 : 0 + Timer { + interval: 1000 + repeat: true + running: gameCanvas.mode == "puzzle" && !gameCanvas.gameOver + onTriggered: { + var elapsed = Math.floor((new Date() - Logic.gameDuration)/ 1000.0); + var mins = Math.floor(elapsed/60.0); + var secs = (elapsed % 60); + puzzleTime.text = (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs; + } + } + } + SamegameText { + id: puzzleScore + anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top} + text: 'Score: ' + gameCanvas.score + opacity: gameCanvas.mode == "puzzle" ? 1 : 0 + } + } + + Image { + id: bottomBar + width: parent.width + height: Settings.footerHeight + source: "content/gfx/bar.png" + y: parent.height - Settings.footerHeight; + z: 2 + Button { + id: quitButton + height: Settings.toolButtonHeight + imgSrc: "content/gfx/but-quit.png" + onClicked: {Qt.quit(); } + anchors { left: parent.left; verticalCenter: parent.verticalCenter; leftMargin: 11 } + } + Button { + id: menuButton + height: Settings.toolButtonHeight + imgSrc: "content/gfx/but-menu.png" + visible: (root.state == "in-game"); + onClicked: {root.state = ""; Logic.cleanUp(); gameCanvas.mode = ""} + anchors { left: quitButton.right; verticalCenter: parent.verticalCenter; leftMargin: 0 } + } + Button { + id: againButton + height: Settings.toolButtonHeight + imgSrc: "content/gfx/but-game-new.png" + visible: (root.state == "in-game"); + opacity: gameCanvas.gameOver && (gameCanvas.mode == "arcade" || gameCanvas.mode == "multiplayer") + Behavior on opacity{ NumberAnimation {} } + onClicked: {if (gameCanvas.gameOver) { Logic.startNewGame(gameCanvas, gameCanvas.mode);}} + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 } + } + Button { + id: nextButton + height: Settings.toolButtonHeight + imgSrc: "content/gfx/but-puzzle-next.png" + visible: (root.state == "in-game") && gameCanvas.mode == "puzzle" && gameCanvas.puzzleWon + opacity: gameCanvas.puzzleWon ? 1 : 0 + Behavior on opacity{ NumberAnimation {} } + onClicked: {if (gameCanvas.puzzleWon) nextPuzzle();} + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 } + } + } + + Connections { + target: root + onStateChanged: stateChangeAnim.running = true + } + SequentialAnimation { + id: stateChangeAnim + ParallelAnimation { + NumberAnimation { target: bottomBar; property: "y"; to: root.height; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad } + NumberAnimation { target: scoreBar; property: "y"; to: -Settings.headerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad } + } + ParallelAnimation { + NumberAnimation { target: bottomBar; property: "y"; to: root.height - Settings.footerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce} + NumberAnimation { target: scoreBar; property: "y"; to: root.state == "" ? -Settings.headerHeight : 0; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce} + } + } + + states: [ + State { + name: "in-game" + PropertyChanges { + target: menu + opacity: 0 + visible: false + } + } + ] + + transitions: [ + Transition { + NumberAnimation {properties: "x,y,opacity"} + } + ] + + //"Debug mode" + focus: true + Keys.onAsteriskPressed: Logic.nuke(); + Keys.onSpacePressed: gameCanvas.puzzleWon = true; +} diff --git a/samegame/content/Block.qml b/samegame/content/Block.qml new file mode 100644 index 0000000..85f2e27 --- /dev/null +++ b/samegame/content/Block.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property ParticleSystem particleSystem + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + + Image { + id: img + source: { + if (type == 0){ + "gfx/red.png"; + } else if (type == 1) { + "gfx/blue.png"; + } else if (type == 2) { + "gfx/green.png"; + } else { + "gfx/yellow.png"; + } + } + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + + //Foreground particles + BlockEmitter { + id: particles + system: particleSystem + group: { + if (type == 0){ + "red"; + } else if (type == 1) { + "blue"; + } else if (type == 2) { + "green"; + } else { + "yellow"; + } + } + anchors.fill: parent + } + + //Paint particles on the background + PaintEmitter { + id: particles2 + system: particleSystem + } + + states: [ + State { + name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState"; when: dying == true + StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/samegame/content/BlockEmitter.qml b/samegame/content/BlockEmitter.qml new file mode 100644 index 0000000..7dad509 --- /dev/null +++ b/samegame/content/BlockEmitter.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +import "../settings.js" as Settings + +Emitter { + property Item block: parent + velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -40; magnitudeVariation: 40} + acceleration: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -100;} + shape: EllipseShape{fill:true} + enabled: false; + lifeSpan: 700; lifeSpanVariation: 100 + emitRate: 1000 + maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) + size: Settings.blockSize * 0.85 + endSize: Settings.blockSize * 0.85 /2 +} diff --git a/samegame/content/Button.qml b/samegame/content/Button.qml new file mode 100644 index 0000000..aab21ec --- /dev/null +++ b/samegame/content/Button.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property alias imgSrc: image.source + property alias system: emitter.system + property alias group: emitter.group + signal clicked + property bool rotatedButton: false + + width: image.width + height: image.sourceSize.height + Image { + id: image + height: parent.height + width: height/sourceSize.height * sourceSize.width + + anchors.horizontalCenter: parent.horizontalCenter + rotation: rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0 + MenuEmitter { + id: emitter + anchors.fill: parent + //shape: MaskShape {source: image.source} + } + } + MouseArea { + anchors.fill: parent + onClicked: {parent.clicked(); emitter.burst(400);} + } +} diff --git a/samegame/content/GameArea.qml b/samegame/content/GameArea.qml new file mode 100644 index 0000000..f3ca98d --- /dev/null +++ b/samegame/content/GameArea.qml @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "samegame.js" as Logic + +Item { + id: gameCanvas + property bool gameOver: true + property int score: 0 + property int highScore: 0 + property int moves: 0 + property string mode: "" + property ParticleSystem ps: particleSystem + //For easy theming + property alias backgroundVisible: bg.visible + property string background: "gfx/background.png" + property string blockFile: "Block.qml" + onBlockFileChanged: Logic.changeBlock(blockFile); + property alias particlePack: auxLoader.source + //For multiplayer + property int score2: 0 + property int curTurn: 1 + property bool autoTurnChange: false + signal swapPlayers + property bool swapping: false + //onSwapPlayers: if (autoTurnChange) Logic.turnChange();//Now implemented below + //For puzzle + property url level + property bool puzzleWon: false + signal puzzleLost //Since root is tracking the puzzle progress + function showPuzzleEnd (won) { + if (won) { + smokeParticle.color = Qt.rgba(0,1,0,0); + puzzleWin.play(); + } else { + smokeParticle.color = Qt.rgba(1,0,0,0); + puzzleFail.play(); + puzzleLost(); + } + } + function showPuzzleGoal (str) { + puzzleTextBubble.opacity = 1; + puzzleTextLabel.text = str; + } + Image { + id: bg + z: -1 + anchors.fill: parent + source: background; + fillMode: Image.PreserveAspectCrop + } + + MouseArea { + anchors.fill: parent; onClicked: { + if (puzzleTextBubble.opacity == 1) { + puzzleTextBubble.opacity = 0; + Logic.finishLoadingMap(); + } else if (!swapping) { + Logic.handleClick(mouse.x,mouse.y); + } + } + } + + Image { + id: highScoreTextBubble + opacity: mode == "arcade" && gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0 + Behavior on opacity { NumberAnimation {} } + anchors.centerIn: parent + z: 10 + source: "gfx/bubble-highscore.png" + Image { + anchors.centerIn: parent + source: "gfx/text-highscore-new.png" + rotation: -10 + } + } + + Image { + id: puzzleTextBubble + anchors.centerIn: parent + opacity: 0 + Behavior on opacity { NumberAnimation {} } + z: 10 + source: "gfx/bubble-puzzle.png" + Connections { + target: gameCanvas + onModeChanged: if (mode != "puzzle" && puzzleTextBubble.opacity > 0) puzzleTextBubble.opacity = 0; + } + Text { + id: puzzleTextLabel + width: parent.width - 24 + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + color: "white" + font.pixelSize: 24 + font.bold: true + wrapMode: Text.WordWrap + } + } + onModeChanged: { + p1WonImg.opacity = 0; + p2WonImg.opacity = 0; + } + SmokeText { id: puzzleWin; source: "gfx/icon-ok.png"; system: particleSystem } + SmokeText { id: puzzleFail; source: "gfx/icon-fail.png"; system: particleSystem } + + onSwapPlayers: { + smokeParticle.color = "yellow" + Logic.turnChange(); + if (curTurn == 1) { + p1Text.play(); + } else { + p2Text.play(); + } + clickDelay.running = true; + } + SequentialAnimation { + id: clickDelay + ScriptAction { script: gameCanvas.swapping = true; } + PauseAnimation { duration: 750 } + ScriptAction { script: gameCanvas.swapping = false; } + } + + SmokeText { + id: p1Text; source: "gfx/text-p1-go.png"; + system: particleSystem; playerNum: 1 + opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1 + } + + SmokeText { + id: p2Text; source: "gfx/text-p2-go.png"; + system: particleSystem; playerNum: 2 + opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1 + } + + onGameOverChanged: { + if (gameCanvas.mode == "multiplayer") { + if (gameCanvas.score >= gameCanvas.score2) { + p1WonImg.opacity = 1; + } else { + p2WonImg.opacity = 1; + } + } + } + Image { + id: p1WonImg + source: "gfx/text-p1-won.png" + anchors.centerIn: parent + opacity: 0 + Behavior on opacity { NumberAnimation {} } + z: 10 + } + Image { + id: p2WonImg + source: "gfx/text-p2-won.png" + anchors.centerIn: parent + opacity: 0 + Behavior on opacity { NumberAnimation {} } + z: 10 + } + + ParticleSystem{ + id: particleSystem; + anchors.fill: parent + z: 5 + ImageParticle { + id: smokeParticle + groups: ["smoke"] + source: "gfx/particle-smoke.png" + alpha: 0.1 + alphaVariation: 0.1 + color: "yellow" + } + Loader { + id: auxLoader + anchors.fill: parent + source: "PrimaryPack.qml" + onItemChanged: { + if (item && "particleSystem" in item) + item.particleSystem = particleSystem + if (item && "gameArea" in item) + item.gameArea = gameCanvas + } + } + } +} + diff --git a/samegame/content/LogoAnimation.qml b/samegame/content/LogoAnimation.qml new file mode 100644 index 0000000..c879893 --- /dev/null +++ b/samegame/content/LogoAnimation.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container //Positioned where the 48x48 S/G should be + property alias running: mainAnim.running + property ParticleSystem particleSystem + property int dur: 500 + signal boomTime + Image { + id: s1 + source: "gfx/logo-s.png" + y: 0 + } + Image { + id: g1 + source: "gfx/logo-g.png" + y: -128 + } + Column { + Repeater { + model: 2 + Item { + width: 48 + height: 48 + BlockEmitter { + id: emitter + anchors.fill: parent + group: "red" + system: particleSystem + Connections { + target: container + onBoomTime: emitter.pulse(100); + } + } + } + } + } + SequentialAnimation { + id: mainAnim + running: true + loops: -1 + PropertyAction { target: g1; property: "y"; value: -128} + PropertyAction { target: g1; property: "opacity"; value: 1} + PropertyAction { target: s1; property: "y"; value: 0} + PropertyAction { target: s1; property: "opacity"; value: 1} + NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: dur} + ParallelAnimation { + NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: dur} + NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: dur } + } + PauseAnimation { duration: dur } + ScriptAction { script: container.boomTime(); } + ParallelAnimation { + NumberAnimation { target: g1; property: "opacity"; to: 0; duration: dur } + NumberAnimation { target: s1; property: "opacity"; to: 0; duration: dur } + } + PropertyAction { target: s1; property: "y"; value: -128} + PropertyAction { target: s1; property: "opacity"; value: 1} + NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: dur * 2} + } +} diff --git a/samegame/content/MenuEmitter.qml b/samegame/content/MenuEmitter.qml new file mode 100644 index 0000000..16c7660 --- /dev/null +++ b/samegame/content/MenuEmitter.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Emitter { + anchors.fill: parent + velocity: AngleDirection{angleVariation: 360; magnitude: 140; magnitudeVariation: 40} + enabled: false; + lifeSpan: 500; + emitRate: 1 + size: 28 + endSize: 14 + group: "yellow" +} diff --git a/samegame/content/PaintEmitter.qml b/samegame/content/PaintEmitter.qml new file mode 100644 index 0000000..4a67c4a --- /dev/null +++ b/samegame/content/PaintEmitter.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "../settings.js" as Settings + +Emitter { + property Item block: parent + anchors.fill: parent + shape: EllipseShape { fill: true } + group: { + if (block.type == 0){ + "redspots"; + } else if (block.type == 1) { + "bluespots"; + } else if (block.type == 2) { + "greenspots"; + } else { + "yellowspots"; + } + } + size: Settings.blockSize * 2 + endSize: Settings.blockSize/2 + lifeSpan: 30000 + enabled: false + emitRate: 60 + maximumEmitted: 60 + velocity: PointDirection{ y: 4; yVariation: 4 } + /* Possibly better, but dependent on gerrit change,28212 + property real mainIntensity: 0.8 + property real subIntensity: 0.1 + property real colorVariation: 0.005 + onEmitParticles: {//One group, many colors, for better stacking + for (var i=0; i
Clear in three moves..." + startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , + 0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , 1 , 1 , + 0 , 0 , 0 , 1 , 1 , 3 , 3 , 3 , 3 , 3 , + 0 , 1 , 1 , 3 , 3 , 3 , 1 , 3 , 1 , 1 , + 1 , 2 , 3 , 3 , 1 , 1 , 3 , 3 , 3 , 3 , + 1 , 3 , 3 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , + 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ] +} diff --git a/samegame/content/levels/level1.qml b/samegame/content/levels/level1.qml new file mode 100644 index 0000000..4bb15cb --- /dev/null +++ b/samegame/content/levels/level1.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + timeTarget: 10 + goalText: "2 of 10

Clear in 10 seconds..." + startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 1 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 2 , + 1 , 2 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , + 2 , 2 , 1 , 3 , 3 , 3 , 1 , 1 , 1 , 2 , + 2 , 1 , 1 , 1 , 3 , 3 , 3 , 1 , 2 , 2 , + 1 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 2 , 1 ] +} diff --git a/samegame/content/levels/level2.qml b/samegame/content/levels/level2.qml new file mode 100644 index 0000000..a319479 --- /dev/null +++ b/samegame/content/levels/level2.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + scoreTarget: 1200 + timeTarget: 60 + goalText: "3 of 10

Score over 1200 points in one minute..." + mustClear: false + startingGrid: [ 3 , 1 , 2 , 1 , 1 , 2 , 1 , 1 , 3 , 3 , + 1 , 3 , 3 , 2 , 3 , 3 , 1 , 1 , 3 , 1 , + 3 , 1 , 3 , 3 , 2 , 3 , 3 , 3 , 1 , 2 , + 3 , 2 , 2 , 1 , 3 , 3 , 2 , 1 , 1 , 2 , + 3 , 1 , 2 , 2 , 2 , 2 , 2 , 1 , 3 , 1 , + 2 , 3 , 1 , 2 , 2 , 3 , 3 , 1 , 3 , 2 , + 3 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 2 , 1 , + 1 , 2 , 2 , 3 , 2 , 3 , 3 , 3 , 1 , 1 , + 1 , 3 , 3 , 3 , 1 , 2 , 2 , 3 , 3 , 1 , + 3 , 3 , 2 , 1 , 2 , 2 , 1 , 1 , 1 , 3 , + 2 , 1 , 3 , 2 , 3 , 2 , 3 , 2 , 2 , 1 , + 1 , 3 , 1 , 2 , 1 , 2 , 3 , 1 , 2 , 2 , + 1 , 2 , 2 , 2 , 1 , 1 , 2 , 3 , 1 , 2 ] +} diff --git a/samegame/content/levels/level3.qml b/samegame/content/levels/level3.qml new file mode 100644 index 0000000..43e82d7 --- /dev/null +++ b/samegame/content/levels/level3.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + scoreTarget: 3000 + timeTarget: 60 + goalText: "4 of 10
Clear the board with over 3000 points in under a minute..." + startingGrid: [ 3 , 3 , 1 , 1 , 1 , 2 , 2 , 4 , 3 , 3 , + 4 , 3 , 1 , 4 , 2 , 2 , 2 , 4 , 3 , 4 , + 4 , 3 , 3 , 4 , 1 , 1 , 3 , 3 , 4 , 4 , + 3 , 3 , 3 , 3 , 3 , 1 , 3 , 2 , 2 , 4 , + 4 , 4 , 3 , 4 , 3 , 1 , 4 , 4 , 4 , 4 , + 4 , 4 , 3 , 4 , 1 , 1 , 4 , 4 , 3 , 3 , + 4 , 2 , 2 , 2 , 2 , 2 , 4 , 4 , 4 , 1 , + 4 , 4 , 2 , 4 , 2 , 2 , 1 , 1 , 1 , 1 , + 4 , 4 , 2 , 4 , 2 , 2 , 1 , 4 , 4 , 1 , + 4 , 1 , 1 , 4 , 3 , 3 , 4 , 2 , 4 , 1 , + 4 , 1 , 1 , 2 , 3 , 3 , 4 , 2 , 2 , 1 , + 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 2 , 1 , + 4 , 1 , 1 , 2 , 2 , 3 , 4 , 3 , 4 , 4 ] +} diff --git a/samegame/content/levels/level4.qml b/samegame/content/levels/level4.qml new file mode 100644 index 0000000..46ad42f --- /dev/null +++ b/samegame/content/levels/level4.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + goalText: "5 of 10

Clear the level..." + startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 1 , 3 , 2 , 1 , 1 , 1 , 1 , 3 , 2 , 3 , + 1 , 2 , 3 , 1 , 3 , 2 , 2 , 1 , 1 , 2 , + 3 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 3 , 3 , + 2 , 1 , 1 , 3 , 2 , 1 , 1 , 2 , 1 , 3 , + 1 , 3 , 3 , 1 , 2 , 1 , 2 , 1 , 3 , 3 , + 1 , 3 , 2 , 2 , 2 , 1 , 1 , 3 , 2 , 3 , + 1 , 1 , 3 , 2 , 3 , 3 , 2 , 1 , 1 , 1 , + 1 , 2 , 2 , 3 , 2 , 2 , 1 , 3 , 1 , 3 ] +} diff --git a/samegame/content/levels/level5.qml b/samegame/content/levels/level5.qml new file mode 100644 index 0000000..3716264 --- /dev/null +++ b/samegame/content/levels/level5.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + moveTarget: 4 + goalText: "6 of 10

Clear in four or less moves..." + startingGrid: [ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , + 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 , + 4 , 2 , 4 , 4 , 4 , 3 , 2 , 3 , 4 , 4 , + 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 , + 4 , 4 , 4 , 2 , 4 , 3 , 4 , 3 , 4 , 4 , + 4 , 2 , 2 , 2 , 4 , 3 , 4 , 3 , 4 , 4 , + 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , + 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 , + 4 , 3 , 3 , 3 , 4 , 2 , 4 , 4 , 4 , 3 , + 4 , 3 , 3 , 3 , 4 , 2 , 2 , 2 , 4 , 3 , + 4 , 3 , 4 , 3 , 4 , 2 , 4 , 4 , 4 , 4 , + 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 , + 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ] +} diff --git a/samegame/content/levels/level6.qml b/samegame/content/levels/level6.qml new file mode 100644 index 0000000..4547b75 --- /dev/null +++ b/samegame/content/levels/level6.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + moveTarget: 20 + timeTarget: 40 + goalText: "7 of 10

Clear with 20 moves in 40 seconds (or better)." + startingGrid: [ 1 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 2 , + 2 , 1 , 2 , 3 , 3 , 1 , 3 , 1 , 1 , 3 , + 3 , 1 , 1 , 1 , 2 , 2 , 3 , 2 , 3 , 1 , + 1 , 3 , 1 , 1 , 3 , 1 , 1 , 1 , 2 , 3 , + 2 , 1 , 1 , 1 , 3 , 2 , 3 , 3 , 2 , 3 , + 3 , 3 , 3 , 3 , 2 , 2 , 3 , 1 , 3 , 2 , + 2 , 2 , 3 , 2 , 2 , 3 , 2 , 2 , 2 , 2 , + 1 , 2 , 1 , 2 , 1 , 3 , 2 , 3 , 2 , 3 , + 1 , 1 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , 2 , + 3 , 3 , 2 , 2 , 2 , 2 , 3 , 1 , 3 , 1 , + 1 , 2 , 3 , 3 , 3 , 1 , 3 , 2 , 1 , 2 , + 1 , 2 , 1 , 1 , 2 , 3 , 1 , 2 , 1 , 3 , + 3 , 1 , 2 , 2 , 1 , 3 , 3 , 1 , 3 , 2 ] +} diff --git a/samegame/content/levels/level7.qml b/samegame/content/levels/level7.qml new file mode 100644 index 0000000..5d71d7c --- /dev/null +++ b/samegame/content/levels/level7.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + goalText: "8 of 10

Clear the grid." + startingGrid: [ 2 , 4 , 3 , 2 , 3 , 2 , 3 , 3 , 4 , 3 , + 2 , 2 , 3 , 3 , 1 , 4 , 3 , 3 , 3 , 2 , + 1 , 4 , 2 , 3 , 4 , 3 , 3 , 1 , 1 , 1 , + 2 , 1 , 2 , 4 , 4 , 2 , 2 , 3 , 2 , 1 , + 3 , 4 , 4 , 1 , 3 , 2 , 4 , 2 , 1 , 1 , + 2 , 2 , 3 , 1 , 2 , 4 , 1 , 2 , 1 , 2 , + 1 , 2 , 3 , 2 , 4 , 4 , 3 , 1 , 1 , 2 , + 4 , 4 , 2 , 1 , 2 , 4 , 2 , 2 , 4 , 3 , + 4 , 2 , 4 , 1 , 3 , 4 , 1 , 4 , 2 , 4 , + 4 , 3 , 4 , 1 , 4 , 3 , 1 , 3 , 1 , 1 , + 3 , 3 , 2 , 3 , 2 , 4 , 1 , 2 , 4 , 4 , + 3 , 4 , 2 , 2 , 4 , 3 , 4 , 1 , 3 , 2 , + 4 , 3 , 3 , 4 , 2 , 4 , 1 , 2 , 3 , 2 ] +} diff --git a/samegame/content/levels/level8.qml b/samegame/content/levels/level8.qml new file mode 100644 index 0000000..9dbb8c2 --- /dev/null +++ b/samegame/content/levels/level8.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + scoreTarget: 1000 + goalText: "9 of 10

Score over 1000 points" + startingGrid: [ 1 , 4 , 4 , 3 , 2 , 1 , 4 , 2 , 4 , 2 , + 2 , 3 , 4 , 4 , 1 , 1 , 1 , 4 , 4 , 4 , + 1 , 3 , 1 , 2 , 2 , 1 , 2 , 1 , 4 , 2 , + 4 , 3 , 4 , 2 , 1 , 4 , 1 , 2 , 2 , 3 , + 3 , 4 , 2 , 4 , 4 , 3 , 2 , 2 , 2 , 1 , + 4 , 4 , 3 , 2 , 4 , 4 , 2 , 1 , 1 , 1 , + 1 , 2 , 1 , 3 , 4 , 1 , 1 , 3 , 2 , 3 , + 3 , 4 , 2 , 2 , 1 , 3 , 2 , 2 , 4 , 2 , + 2 , 4 , 1 , 2 , 2 , 4 , 3 , 3 , 3 , 1 , + 1 , 2 , 2 , 4 , 1 , 2 , 2 , 3 , 3 , 3 , + 4 , 4 , 1 , 4 , 3 , 1 , 3 , 3 , 3 , 4 , + 1 , 2 , 4 , 1 , 2 , 1 , 1 , 4 , 2 , 1 , + 1 , 2 , 3 , 4 , 2 , 4 , 4 , 2 , 1 , 3 ] +} diff --git a/samegame/content/levels/level9.qml b/samegame/content/levels/level9.qml new file mode 100644 index 0000000..4e8bf19 --- /dev/null +++ b/samegame/content/levels/level9.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TemplateBase{ + scoreTarget: 2000 + timeTarget: 60 + moveTarget: 20 + mustClear: false + goalText: "10 of 10

Score 2000 in one minute with less than 20 moves!" + startingGrid: [ 3 , 2 , 3 , 1 , 3 , 3 , 4 , 1 , 3 , 3 , + 2 , 3 , 2 , 1 , 1 , 2 , 2 , 2 , 4 , 1 , + 2 , 4 , 4 , 4 , 3 , 1 , 4 , 4 , 4 , 1 , + 3 , 1 , 3 , 4 , 4 , 2 , 2 , 2 , 2 , 3 , + 2 , 1 , 4 , 4 , 3 , 3 , 1 , 1 , 3 , 2 , + 3 , 2 , 1 , 4 , 3 , 4 , 1 , 3 , 4 , 2 , + 3 , 3 , 1 , 4 , 4 , 4 , 2 , 1 , 2 , 3 , + 2 , 3 , 4 , 3 , 4 , 1 , 1 , 3 , 2 , 4 , + 4 , 4 , 1 , 2 , 4 , 3 , 2 , 2 , 2 , 4 , + 1 , 4 , 2 , 2 , 1 , 1 , 2 , 1 , 1 , 4 , + 1 , 4 , 3 , 3 , 3 , 1 , 3 , 4 , 4 , 2 , + 3 , 4 , 1 , 1 , 2 , 2 , 2 , 3 , 2 , 1 , + 3 , 3 , 4 , 3 , 1 , 1 , 1 , 4 , 4 , 3 ] +} diff --git a/samegame/content/samegame.js b/samegame/content/samegame.js new file mode 100755 index 0000000..7b226cb --- /dev/null +++ b/samegame/content/samegame.js @@ -0,0 +1,581 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* This script file handles the game logic */ +.pragma library +.import QtQuick.LocalStorage 2.0 as Sql +.import "../settings.js" as Settings + +var maxColumn = 10; +var maxRow = 13; +var types = 3; +var maxIndex = maxColumn*maxRow; +var board = new Array(maxIndex); +var blockSrc = "Block.qml"; +var gameDuration; +var component = Qt.createComponent(blockSrc); +var gameCanvas; +var betweenTurns = false; + +var puzzleLevel = null; +var puzzlePath = ""; + +var gameMode = "arcade"; //Set in new game, then tweaks behaviour of other functions +var gameOver = false; + +function changeBlock(src) +{ + blockSrc = src; + component = Qt.createComponent(blockSrc); +} + +// Index function used instead of a 2D array +function index(column, row) +{ + return column + row * maxColumn; +} + +function timeStr(msecs) +{ + var secs = Math.floor(msecs/1000); + var m = Math.floor(secs/60); + var ret = "" + m + "m " + (secs%60) + "s"; + return ret; +} + +function cleanUp() +{ + if (gameCanvas == undefined) + return; + // Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + board[i] = null; + } + if (puzzleLevel != null){ + puzzleLevel.destroy(); + puzzleLevel = null; + } + gameCanvas.mode = "" +} + +function startNewGame(gc, mode, map) +{ + gameCanvas = gc; + if (mode == undefined) + gameMode = "arcade"; + else + gameMode = mode; + gameOver = false; + + cleanUp(); + + gc.gameOver = false; + gc.mode = gameMode; + // Calculate board size + maxColumn = Math.floor(gameCanvas.width/Settings.blockSize); + maxRow = Math.floor(gameCanvas.height/Settings.blockSize); + maxIndex = maxRow * maxColumn; + if (gameMode == "arcade") //Needs to be after board sizing + getHighScore(); + + + // Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + gameCanvas.score2 = 0; + gameCanvas.moves = 0; + gameCanvas.curTurn = 1; + if (gameMode == "puzzle") + loadMap(map); + else//Note that we load them in reverse order for correct visual stacking + for (var column = maxColumn - 1; column >= 0; column--) + for (var row = maxRow - 1; row >= 0; row--) + createBlock(column, row); + if (gameMode == "puzzle") + getLevelHistory();//Needs to be after map load + gameDuration = new Date(); +} + +var fillFound; // Set after a floodFill call to the number of blocks found +var floodBoard; // Set to 1 if the floodFill reaches off that node + +// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope +function handleClick(x,y) +{ + if (betweenTurns || gameOver || gameCanvas == undefined) + return; + var column = Math.floor(x/Settings.blockSize); + var row = Math.floor(y/Settings.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + // If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column,row, -1); + if (fillFound <= 0) + return; + if (gameMode == "multiplayer" && gameCanvas.curTurn == 2) + gameCanvas.score2 += (fillFound - 1) * (fillFound - 1); + else + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + if (gameMode == "multiplayer" && gameCanvas.curTurn == 2) + shuffleUp(); + else + shuffleDown(); + gameCanvas.moves += 1; + if (gameMode == "endless") + refill(); + else if (gameMode != "multiplayer") + victoryCheck(); + if (gameMode == "multiplayer" && !gc.gameOver){ + betweenTurns = true; + gameCanvas.swapPlayers();//signal, animate and call turnChange() when ready + } +} + +function floodFill(column,row,type) +{ + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column,row)].type; + + // Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; // Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() +{ + // Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column,row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * Settings.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + // Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * Settings.blockSize; + board[index(column - fallDist,row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + + +function shuffleUp() +{ + // Fall up + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = 0; row < maxRow; row++) { + if (board[index(column,row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row - fallDist) * Settings.blockSize; + board[index(column, row - fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + // Fall to the left (or should it be right, so as to be left for P2?) + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, 0)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * Settings.blockSize; + board[index(column - fallDist,row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +function turnChange()//called by ui outside +{ + betweenTurns = false; + if (gameCanvas.curTurn == 1){ + shuffleUp(); + gameCanvas.curTurn = 2; + victoryCheck(); + }else{ + shuffleDown(); + gameCanvas.curTurn = 1; + victoryCheck(); + } +} + +function refill() +{ + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + if (board[index(column, row)] == null) + createBlock(column, row); + } + } +} + +function victoryCheck() +{ + // Awards bonuses for no blocks left + var deservesBonus = true; + if (board[index(0,maxRow - 1)] != null || board[index(0,0)] != null) + deservesBonus = false; + // Checks for game over + if (deservesBonus){ + if (gameCanvas.curTurn = 1) + gameCanvas.score += 1000; + else + gameCanvas.score2 += 1000; + } + gameOver = deservesBonus; + if (gameCanvas.curTurn == 1){ + if (!(floodMoveCheck(0, maxRow - 1, -1))) + gameOver = true; + }else{ + if (!(floodMoveCheck(0, 0, -1, true))) + gameOver = true; + } + if (gameMode == "puzzle"){ + puzzleVictoryCheck(deservesBonus);//Takes it from here + return; + } + if (gameOver) { + var winnerScore = Math.max(gameCanvas.score, gameCanvas.score2); + if (gameMode == "multiplayer"){ + gameCanvas.score = winnerScore; + saveHighScore(gameCanvas.score2); + } + saveHighScore(gameCanvas.score); + gameDuration = new Date() - gameDuration; + gameCanvas.gameOver = true; + } +} + +// Only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type, goDownInstead) +{ + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + if (goDownInstead) + return floodMoveCheck(column + 1, row, myType, goDownInstead) || + floodMoveCheck(column, row + 1, myType, goDownInstead); + else + return floodMoveCheck(column + 1, row, myType) || + floodMoveCheck(column, row - 1, myType); +} + +function createBlock(column,row,type) +{ + // Note that we don't wait for the component to become ready. This will + // only work if the block QML is a local file. Otherwise the component will + // not be ready immediately. There is a statusChanged signal on the + // component you could use if you want to wait to load remote files. + if (component.status == 1){ + if (type == undefined) + type = Math.floor(Math.random() * types); + if (type < 0 || type > 4) { + console.log("Invalid type requested");//TODO: Is this triggered by custom levels much? + return; + } + var dynamicObject = component.createObject(gameCanvas, + {"type": type, + "x": column*Settings.blockSize, + "y": -1*Settings.blockSize, + "width": Settings.blockSize, + "height": Settings.blockSize, + "particleSystem": gameCanvas.ps}); + if (dynamicObject == null){ + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.y = row*Settings.blockSize; + dynamicObject.spawned = true; + + board[index(column,row)] = dynamicObject; + }else{ + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +function showPuzzleError(str) +{ + //TODO: Nice user visible UI? + console.log(str); +} + +function loadMap(map) +{ + puzzlePath = map; + var levelComp = Qt.createComponent(puzzlePath); + if (levelComp.status != 1){ + console.log("Error loading level"); + showPuzzleError(levelComp.errorString()); + return; + } + puzzleLevel = levelComp.createObject(); + if (puzzleLevel == null || !puzzleLevel.startingGrid instanceof Array) { + showPuzzleError("Bugger!"); + return; + } + gameCanvas.showPuzzleGoal(puzzleLevel.goalText); + //showPuzzleGoal should call finishLoadingMap as the next thing it does, before handling more events +} + +function finishLoadingMap() +{ + for (var i in puzzleLevel.startingGrid) + if (! (puzzleLevel.startingGrid[i] >= 0 && puzzleLevel.startingGrid[i] <= 9) ) + puzzleLevel.startingGrid[i] = 0; + //TODO: Don't allow loading larger levels, leads to cheating + while (puzzleLevel.startingGrid.length > maxIndex) puzzleLevel.startingGrid.shift(); + while (puzzleLevel.startingGrid.length < maxIndex) puzzleLevel.startingGrid.unshift(0); + for (var i in puzzleLevel.startingGrid) + if (puzzleLevel.startingGrid[i] > 0) + createBlock(i % maxColumn, Math.floor(i / maxColumn), puzzleLevel.startingGrid[i] - 1); + + //### Experimental feature - allow levels to contain arbitrary QML scenes as well! + //while (puzzleLevel.children.length) + // puzzleLevel.children[0].parent = gameCanvas; + gameDuration = new Date(); //Don't start until we finish loading +} + +function puzzleVictoryCheck(clearedAll)//gameOver has also been set if no more moves +{ + var won = true; + var soFar = new Date() - gameDuration; + if (puzzleLevel.scoreTarget != -1 && gameCanvas.score < puzzleLevel.scoreTarget){ + won = false; + } if (puzzleLevel.scoreTarget != -1 && gameCanvas.score >= puzzleLevel.scoreTarget && !puzzleLevel.mustClear){ + gameOver = true; + } if (puzzleLevel.timeTarget != -1 && soFar/1000.0 > puzzleLevel.timeTarget){ + gameOver = true; + } if (puzzleLevel.moveTarget != -1 && gameCanvas.moves >= puzzleLevel.moveTarget){ + gameOver = true; + } if (puzzleLevel.mustClear && gameOver && !clearedAll) { + won = false; + } + + if (gameOver) { + gameCanvas.gameOver = true; + gameCanvas.showPuzzleEnd(won); + + if (won) { + // Store progress + saveLevelHistory(); + } + } +} + +function getHighScore() +{ + var db = Sql.LocalStorage.openDatabaseSync( + "SameGame", + "2.0", + "SameGame Local Data", + 100 + ); + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" AND game = "' + gameMode + '" ORDER BY score desc'); + if (rs.rows.length > 0) + gameCanvas.highScore = rs.rows.item(0).score; + else + gameCanvas.highScore = 0; + } + ); +} + +function saveHighScore(score) +{ + // Offline storage + var db = Sql.LocalStorage.openDatabaseSync( + "SameGame", + "2.0", + "SameGame Local Data", + 100 + ); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [ + gameMode, + score, + maxColumn + "x" + maxRow, + Math.floor(gameDuration / 1000) + ]; + if (score >= gameCanvas.highScore)//Update UI field + gameCanvas.highScore = score; + + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + } + ); +} + +function getLevelHistory() +{ + var db = Sql.LocalStorage.openDatabaseSync( + "SameGame", + "2.0", + "SameGame Local Data", + 100 + ); + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)'); + var rs = tx.executeSql('SELECT * FROM Puzzle WHERE level = "' + puzzlePath + '" ORDER BY score desc'); + if (rs.rows.length > 0) { + gameCanvas.puzzleWon = true; + gameCanvas.highScore = rs.rows.item(0).score; + } else { + gameCanvas.puzzleWon = false; + gameCanvas.highScore = 0; + } + } + ); +} + +function saveLevelHistory() +{ + var db = Sql.LocalStorage.openDatabaseSync( + "SameGame", + "2.0", + "SameGame Local Data", + 100 + ); + var dataStr = "INSERT INTO Puzzle VALUES(?, ?, ?, ?)"; + var data = [ + puzzlePath, + gameCanvas.score, + gameCanvas.moves, + Math.floor(gameDuration / 1000) + ]; + gameCanvas.puzzleWon = true; + + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)'); + tx.executeSql(dataStr, data); + } + ); +} + +function nuke() //For "Debug mode" +{ + for (var row = 1; row <= 5; row++) { + for (var col = 0; col < 5; col++) { + if (board[index(col, maxRow - row)] != null) { + board[index(col, maxRow - row)].dying = true; + board[index(col, maxRow - row)] = null; + } + } + } + if (gameMode == "multiplayer" && gameCanvas.curTurn == 2) + shuffleUp(); + else + shuffleDown(); + if (gameMode == "endless") + refill(); + else + victoryCheck(); +} diff --git a/samegame/settings.js b/samegame/settings.js new file mode 100644 index 0000000..e09dee9 --- /dev/null +++ b/samegame/settings.js @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +.pragma library + +//This should be switched over once a proper QML settings API exists + +var menuDelay = 500 + +var headerHeight = 20 // 70 on BB10 +var footerHeight = 44 // 100 on BB10 + +var fontPixelSize = 14 // 55 on BB10 + +var blockSize = 32 // 64 on BB10 + +var toolButtonHeight = 32 // 64 on BB10 + +var menuButtonSpacing = 0 // 15 on BB10 -- cgit v1.2.3