From c908718f86dd409f0f2d3757057d797b2f5ff83a Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Fri, 17 Feb 2023 12:11:02 +0200 Subject: Remove sensors maze example The Maze (QML) example is a nice game implementation, but doesn't add much demonstration value in comparison to sensorsshowcase example. The one unique thing it does demonstrate is tilt sensor. Tiltsensor can be added to the sensorsshowcase too; but OTOH tilt is in some sense just 'a' sensor among the sensors, and there is probably no need to use all of them in the examples. Task-number: QTBUG-110939 Pick-to: 6.5 Change-Id: I2fd997750b05b3962428955a2929e149af6b72bd Reviewed-by: Lorn Potter --- examples/sensors/CMakeLists.txt | 1 - examples/sensors/maze/CMakeLists.txt | 77 ------ examples/sensors/maze/Congratulation.qml | 24 -- examples/sensors/maze/Info.plist | 32 --- examples/sensors/maze/LabyrinthSquare.qml | 43 ---- examples/sensors/maze/Mouse.qml | 45 ---- examples/sensors/maze/android/AndroidManifest.xml | 47 ---- .../sensors/maze/components/ApplicationWindow.qml | 14 -- examples/sensors/maze/components/Button.qml | 38 --- .../images/button_background_disabled.png | Bin 579 -> 0 bytes .../components/images/button_background_normal.png | Bin 901 -> 0 bytes .../images/button_background_pressed.png | Bin 228 -> 0 bytes examples/sensors/maze/content/00.png | Bin 70 -> 0 bytes examples/sensors/maze/content/01.png | Bin 540 -> 0 bytes examples/sensors/maze/content/cheese.png | Bin 156 -> 0 bytes examples/sensors/maze/content/cheeseeating.gif | Bin 650 -> 0 bytes examples/sensors/maze/content/congratulations.gif | Bin 10811 -> 0 bytes examples/sensors/maze/content/mouse_down.gif | Bin 974 -> 0 bytes examples/sensors/maze/content/start.png | Bin 505 -> 0 bytes examples/sensors/maze/doc/src/maze.qdoc | 41 ---- examples/sensors/maze/lib.js | 264 --------------------- examples/sensors/maze/main.cpp | 5 - examples/sensors/maze/maze.pro | 19 -- examples/sensors/maze/maze.qml | 251 -------------------- examples/sensors/maze/maze.qrc | 21 -- examples/sensors/sensors.pro | 1 - 26 files changed, 923 deletions(-) delete mode 100644 examples/sensors/maze/CMakeLists.txt delete mode 100644 examples/sensors/maze/Congratulation.qml delete mode 100644 examples/sensors/maze/Info.plist delete mode 100644 examples/sensors/maze/LabyrinthSquare.qml delete mode 100644 examples/sensors/maze/Mouse.qml delete mode 100644 examples/sensors/maze/android/AndroidManifest.xml delete mode 100644 examples/sensors/maze/components/ApplicationWindow.qml delete mode 100644 examples/sensors/maze/components/Button.qml delete mode 100644 examples/sensors/maze/components/images/button_background_disabled.png delete mode 100644 examples/sensors/maze/components/images/button_background_normal.png delete mode 100644 examples/sensors/maze/components/images/button_background_pressed.png delete mode 100644 examples/sensors/maze/content/00.png delete mode 100644 examples/sensors/maze/content/01.png delete mode 100644 examples/sensors/maze/content/cheese.png delete mode 100644 examples/sensors/maze/content/cheeseeating.gif delete mode 100644 examples/sensors/maze/content/congratulations.gif delete mode 100644 examples/sensors/maze/content/mouse_down.gif delete mode 100644 examples/sensors/maze/content/start.png delete mode 100644 examples/sensors/maze/doc/src/maze.qdoc delete mode 100644 examples/sensors/maze/lib.js delete mode 100644 examples/sensors/maze/main.cpp delete mode 100644 examples/sensors/maze/maze.pro delete mode 100644 examples/sensors/maze/maze.qml delete mode 100644 examples/sensors/maze/maze.qrc (limited to 'examples') diff --git a/examples/sensors/CMakeLists.txt b/examples/sensors/CMakeLists.txt index 69582c33..9bc70568 100644 --- a/examples/sensors/CMakeLists.txt +++ b/examples/sensors/CMakeLists.txt @@ -3,7 +3,6 @@ if(TARGET Qt::Quick) qt_internal_add_example(grue) - qt_internal_add_example(maze) qt_internal_add_example(qmlqtsensors) qt_internal_add_example(sensor_explorer) if(TARGET Qt::Svg) diff --git a/examples/sensors/maze/CMakeLists.txt b/examples/sensors/maze/CMakeLists.txt deleted file mode 100644 index 258291c4..00000000 --- a/examples/sensors/maze/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(maze LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/maze") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Sensors) - -qt_add_executable(maze - main.cpp -) - -set_target_properties(maze PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -if(ANDROID) - set_property(TARGET maze PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR - ${CMAKE_CURRENT_SOURCE_DIR}/android) - endif() -if(APPLE) - if(IOS) - set_property(TARGET maze PROPERTY - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" - ) - endif() -endif() - -target_link_libraries(maze PUBLIC - Qt::Core - Qt::Gui - Qt::Quick - Qt::Sensors -) - -# Resources: -set(maze_resource_files - "Congratulation.qml" - "LabyrinthSquare.qml" - "Mouse.qml" - "components/ApplicationWindow.qml" - "components/Button.qml" - "components/images/button_background_disabled.png" - "components/images/button_background_normal.png" - "components/images/button_background_pressed.png" - "content/00.png" - "content/01.png" - "content/cheese.png" - "content/cheeseeating.gif" - "content/congratulations.gif" - "content/mouse_down.gif" - "content/start.png" - "lib.js" - "maze.qml" -) - -qt6_add_resources(maze "maze" - PREFIX - "/" - FILES - ${maze_resource_files} -) - -install(TARGETS maze - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/sensors/maze/Congratulation.qml b/examples/sensors/maze/Congratulation.qml deleted file mode 100644 index a1e54ada..00000000 --- a/examples/sensors/maze/Congratulation.qml +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -//Import the javascript functions for this game -import "lib.js" as Lib - -//Implementation of the Congratulation control -Item { - x: Lib.cellDimension - y: Lib.cellDimension - width: Lib.cellDimension * (Lib.dimension - 2) - height: Lib.cellDimension * (Lib.dimension - 2) - - //Containing a animated gif image - AnimatedImage { - id: img - anchors.fill: parent - visible: true - source: "content/congratulations.gif" - } -} diff --git a/examples/sensors/maze/Info.plist b/examples/sensors/maze/Info.plist deleted file mode 100644 index 2458247c..00000000 --- a/examples/sensors/maze/Info.plist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - CFBundleDisplayName - maze - CFBundleExecutable - maze - CFBundleGetInfoString - Created by Qt/QMake - CFBundleIdentifier - com.qt.sensorsmaze - CFBundleName - maze - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - - - diff --git a/examples/sensors/maze/LabyrinthSquare.qml b/examples/sensors/maze/LabyrinthSquare.qml deleted file mode 100644 index d9e72db7..00000000 --- a/examples/sensors/maze/LabyrinthSquare.qml +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -//Import the javascript functions for this game -import "lib.js" as Lib - -//Implementation of the Labyrinth square control. -Rectangle { - id: sq - x: 0 - y: 0 - width: Lib.cellDimension - height: Lib.cellDimension - color: "white" - property int val: 0 - property AnimatedImage picture: img - - //Dependent of its position and the labyrinth value a square can be the start, cheese, empty or a wall - AnimatedImage { - id: img - anchors.fill: parent - source: "" - } - - function updateImage() - { - if (sq.val == -1) - sq.picture.source = "content/start.png"; - else if (sq.val == 3) - sq.picture.source = "content/cheese.png"; - else if (sq.val == 4){ - sq.picture.source = "content/cheeseeating.gif"; - sq.picture.playing = true; - } - else if (sq.val == 1) - sq.picture.source = "content/01.png"; - else - sq.picture.source = "content/00.png"; - } -} diff --git a/examples/sensors/maze/Mouse.qml b/examples/sensors/maze/Mouse.qml deleted file mode 100644 index 155f0bd6..00000000 --- a/examples/sensors/maze/Mouse.qml +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -//Import the javascript functions for this game -import "lib.js" as Lib - -//Implementation of the Mouse control. -Item { - id: mouse - x: 0 - y: 0 - width: Lib.cellDimension - height: Lib.cellDimension - property int angle - readonly property double radians_to_degrees: 180 / Math.PI - - AnimatedImage { - id: img - source: "content/mouse_down.gif" - anchors.fill: parent - visible: true - } - - //Function for moving the mouse - function move(newx, newy) - { - if (mouse.x === newx && mouse.y === newy) - return - // somehow this actually works -//! [0] - var a = newy - mouse.y - var b = newx - mouse.x - angle = Math.atan2(-b, a) * mouse.radians_to_degrees - if (angle < 0) - angle = 360 + angle - - img.rotation = angle - mouse.x = newx; - mouse.y = newy; -//! [0] - } -} diff --git a/examples/sensors/maze/android/AndroidManifest.xml b/examples/sensors/maze/android/AndroidManifest.xml deleted file mode 100644 index 8efe1ed3..00000000 --- a/examples/sensors/maze/android/AndroidManifest.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/sensors/maze/components/ApplicationWindow.qml b/examples/sensors/maze/components/ApplicationWindow.qml deleted file mode 100644 index 3f87d724..00000000 --- a/examples/sensors/maze/components/ApplicationWindow.qml +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -Rectangle { - id: appWnd - x: 0 - y: 0 - width: 320 - height: 480 - color: "#ececec" -} diff --git a/examples/sensors/maze/components/Button.qml b/examples/sensors/maze/components/Button.qml deleted file mode 100644 index 953424a4..00000000 --- a/examples/sensors/maze/components/Button.qml +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -//Implementation of the Button control. -Item { - id: button - width: 30 - height: 100 - property alias text: innerText.text - signal clicked - - Image { - id: backgroundImage - anchors.fill: parent - source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png") - } - - Text { - id: innerText - anchors.centerIn: parent - color: "white" - font.bold: true - } - - //Mouse area to react on click events - MouseArea { - anchors.fill: button - onClicked: { button.clicked();} - onPressed: { - backgroundImage.source = "images/button_background_pressed.png" } - onReleased: { - backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png") - } - } -} diff --git a/examples/sensors/maze/components/images/button_background_disabled.png b/examples/sensors/maze/components/images/button_background_disabled.png deleted file mode 100644 index 62a00b9a..00000000 Binary files a/examples/sensors/maze/components/images/button_background_disabled.png and /dev/null differ diff --git a/examples/sensors/maze/components/images/button_background_normal.png b/examples/sensors/maze/components/images/button_background_normal.png deleted file mode 100644 index 1fecad5b..00000000 Binary files a/examples/sensors/maze/components/images/button_background_normal.png and /dev/null differ diff --git a/examples/sensors/maze/components/images/button_background_pressed.png b/examples/sensors/maze/components/images/button_background_pressed.png deleted file mode 100644 index e0ba0e7a..00000000 Binary files a/examples/sensors/maze/components/images/button_background_pressed.png and /dev/null differ diff --git a/examples/sensors/maze/content/00.png b/examples/sensors/maze/content/00.png deleted file mode 100644 index 2522be5e..00000000 Binary files a/examples/sensors/maze/content/00.png and /dev/null differ diff --git a/examples/sensors/maze/content/01.png b/examples/sensors/maze/content/01.png deleted file mode 100644 index 6146b204..00000000 Binary files a/examples/sensors/maze/content/01.png and /dev/null differ diff --git a/examples/sensors/maze/content/cheese.png b/examples/sensors/maze/content/cheese.png deleted file mode 100644 index c737b9d6..00000000 Binary files a/examples/sensors/maze/content/cheese.png and /dev/null differ diff --git a/examples/sensors/maze/content/cheeseeating.gif b/examples/sensors/maze/content/cheeseeating.gif deleted file mode 100644 index 6b2cb47f..00000000 Binary files a/examples/sensors/maze/content/cheeseeating.gif and /dev/null differ diff --git a/examples/sensors/maze/content/congratulations.gif b/examples/sensors/maze/content/congratulations.gif deleted file mode 100644 index 70204176..00000000 Binary files a/examples/sensors/maze/content/congratulations.gif and /dev/null differ diff --git a/examples/sensors/maze/content/mouse_down.gif b/examples/sensors/maze/content/mouse_down.gif deleted file mode 100644 index 5491c18f..00000000 Binary files a/examples/sensors/maze/content/mouse_down.gif and /dev/null differ diff --git a/examples/sensors/maze/content/start.png b/examples/sensors/maze/content/start.png deleted file mode 100644 index 581b8c9b..00000000 Binary files a/examples/sensors/maze/content/start.png and /dev/null differ diff --git a/examples/sensors/maze/doc/src/maze.qdoc b/examples/sensors/maze/doc/src/maze.qdoc deleted file mode 100644 index a6f132f9..00000000 --- a/examples/sensors/maze/doc/src/maze.qdoc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example maze - \title Qt Sensors - Maze QML Example - \ingroup qtsensors-examples - \image maze.png - - \section2 Maze in QML - \brief The Maze example demonstrates the TiltSensor QML type. - - - To write a QML application that will use the TiltSensor QML sensors type - you need to do the following steps: - - To import the Qt Sensors QML types into your application, use the following - import statement in your .qml file: - - \snippet maze/maze.qml 0 - - Then, add the Sensor QML types into your qml file. - - In this example we use the TiltSensor: - - \snippet maze/maze.qml 1 - - The mouse should move by a factor of the tilt value: - - \snippet maze/maze.qml 2 - - The walk direction of the mouse takes into account some collision detection: - - \snippet maze/maze.qml 3 - - The rotation of the mouse image is determined according to the angle that the mouse is moving. - - \snippet maze/Mouse.qml 0 - -*/ - diff --git a/examples/sensors/maze/lib.js b/examples/sensors/maze/lib.js deleted file mode 100644 index 3bae6a86..00000000 --- a/examples/sensors/maze/lib.js +++ /dev/null @@ -1,264 +0,0 @@ -//global variables -var labyrinth = null; -var dimension = 24; -var cellDimension = 13; -var won; -var objectArray = null; -var sec = 0.0 - -//Allocate labyrinth arrays and create labyrinth and way reflected in the labyrinth array -function createLabyrinth() -{ - won = false; - //create the labyrinth matrix - labyrinth = null; - labyrinth = new Array(dimension); - for (var x = 0; x < dimension; x++ ){ - labyrinth[x] = new Array(dimension); - for (var y = 0; y < dimension; y++ ){ - labyrinth[x][y] = 0; - } - } - createWay(); - createLab(); -} - -//Create a way where the mouse can reach the cheese -function createWay() -{ - //Create rnd way to have at least one solution - //A way square is marked as a 2 in the labyrinth array - var x = 0; - var y = 0; - var ox = x; - var oy = y; - labyrinth[0][0] = 2; - while (x < dimension && y < dimension){ - var rnd = Math.floor(Math.random()*5); - if (Math.floor(Math.random()*2) == 1){ - if (rnd == 0) x--; - if (rnd >= 1) x++; - if (x < 0) x++; - if (x >= dimension){ - x = ox; - break; - } - } - else { - if (rnd == 0) y--; - if (rnd >= 1) y++; - if (y < 0) y++; - if (y >= dimension){ - y = oy; - break; - } - } - - /*avoid to have [2]2| - |2|2|*/ - if (x < (dimension - 1) && y < (dimension - 1)){ - if (labyrinth[x + 1][y] == 2 - && labyrinth[x][y + 1] == 2 - && labyrinth[x + 1][y + 1] == 2){ - y = oy; - x = ox; - continue; - } - } - /*avoid to have |2[2] - |2|2|*/ - if (x > 0 && y < (dimension - 1)){ - if (labyrinth[x - 1][y] == 2 - && labyrinth[x][y + 1] == 2 - && labyrinth[x - 1][y + 1] == 2){ - y = oy; - x = ox; - continue; - } - } - /*avoid to have |2|2| - [2]2|*/ - if (x < (dimension - 1) && y > 0){ - if (labyrinth[x + 1][y] == 2 - && labyrinth[x][y - 1] == 2 - && labyrinth[x + 1][y - 1] == 2){ - y = oy; - x = ox; - continue; - } - } - /*avoid to have |2|2| - |2[2]*/ - if (x > 0 && y > 0){ - if (labyrinth[x - 1][y] == 2 - && labyrinth[x][y - 1] == 2 - && labyrinth[x - 1][y - 1] == 2){ - y = oy; - x = ox; - continue; - } - } - - labyrinth[x][y] = 2; - ox = x; - oy = y; - } - //finish way - while (x < (dimension - 1)){ - labyrinth[x][y] = 2; - x++; - } - while (y < (dimension - 1)){ - labyrinth[x][y] = 2; - y++; - } -} - -//Create the labyrinth with rnd values -function createLab() -{ - //A wall square is marked as a 1 in the labyrinth array - //Not a wall square is marked as a 0 in the labyrinth array - //The Cheese square is marked as a 3 in the labyrinth array - //The start is marked as a -1 in the labyrinth array - for (var x = 0; x < dimension; x++ ){ - var rnd = 0; - for (var y = 0; y < dimension; y++){ - //But don't overwrite the way - if (labyrinth[x][y] != 2){ - var rnd = Math.floor(Math.random()*2); - var xy = 0; - var xxy = 0; - var xyy = 0; - var xxyy = 0; - - if (x > 0 && y > 0){ - xy = labyrinth[x - 1][y - 1]; - if (xy == 2) - xy = 0; - - xyy = labyrinth[x - 1][y]; - if (xyy == 2) - xyy = 0; - - xxy = labyrinth[x][y - 1]; - if (xxy == 2) - xxy = 0; - - xxyy = rnd; - if (xxyy == 2) - xxyy = 0; - - //avoid to have to many |0|1| or |1|0| [xy ][xxy ] - // |1[0] |0[1] [xyy ][xxyy] - if (xyy == xxy && xy == xxyy && xy != xxy){ - if (rnd == 1) - rnd = 0; - else rnd = 1; - } - - //avoid to have to many |1|1| or |0|0| - // |1[1] |0[0] - if (xy == xxy && xxy == xxyy && xxyy == xyy){ - if (rnd == 1) - rnd = 0; - else rnd = 1; - } - } - else if (x == 0 && y > 0){ - xy = labyrinth[x][y - 1]; - if (xy == 2) - xy = 0; - - xyy = rnd; - if (xyy == 2) - xyy = 0; - - xxy = labyrinth[x + 1][y - 1]; - if (xxy == 2) - xxy = 0; - - xxyy = labyrinth[x + 1][y]; - if (xxyy == 2) - xxyy = 0; - - //avoid to have to many |1|1| or |0|0| - // |1[1] |0[0] - if (xy == xxy && xxy == xxyy && xxyy == xyy){ - if (rnd == 1) - rnd = 0; - else rnd = 1; - } - - //avoid to have to many |0|1| or |1|0| [xy ][xxy ] - // |1[0] |0[1] [xyy ][xxyy] - if (xyy == xxy && xy == xxyy && xy != xxy){ - if (rnd == 1) - rnd = 0; - else rnd = 1; - } - } - labyrinth[x][y] = rnd; - } - - } - } - //set start and end - labyrinth[0][0] = -1; - labyrinth[0][1] = 0; - labyrinth[1][0] = 0; - labyrinth[1][1] = 0; - - labyrinth[dimension - 2][dimension - 2] = 0; - labyrinth[dimension - 2][dimension - 1] = 0; - labyrinth[dimension - 1][dimension - 2] = 0; - labyrinth[dimension - 1][dimension - 1] = 3; -} - -//Function that checks if the mouse can be moved in x and y -function canMove(x, y) -{ - //Check if movement is allowed - var xcenter = x + (cellDimension / 2); - var ycenter = y + (cellDimension / 2); - //try to get the index - var idx = Math.floor(xcenter / cellDimension); - var idy = Math.floor(ycenter / cellDimension); - var dx = xcenter - (idx * cellDimension + ( cellDimension / 2 )); - var dy = ycenter - (idy * cellDimension + ( cellDimension / 2 )); - - if (dx > 0){ - if (labyrinth[idx][idy] == 1) - return false; - } - if (dx < 0){ - if (labyrinth[idx][idy] == 1) - return false; - } - if (dy > 0){ - if (labyrinth[idx][idy] == 1) - return false; - } - if (dy < 0){ - if (labyrinth[idx][idy] == 1) - return false; - } - //check if won - if (idx == (dimension - 1) && idy == (dimension - 1)) - won = true; - return true; -} - -//Function that prints out the labyrith array values in the console -function printLab() -{ - //for debug purposes print out lab n console - var iy = 0; - for (var y = 0; y < dimension; y++ ){ - var line = ""; - for (var x = 0; x < dimension; x++ ){ - line += labyrinth[x][y]; - } - console.log(line); - } -} diff --git a/examples/sensors/maze/main.cpp b/examples/sensors/maze/main.cpp deleted file mode 100644 index 2dbf1aa1..00000000 --- a/examples/sensors/maze/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "../stub.h" -SENSORS_EXAMPLE_MAIN(maze) diff --git a/examples/sensors/maze/maze.pro b/examples/sensors/maze/maze.pro deleted file mode 100644 index f15fa570..00000000 --- a/examples/sensors/maze/maze.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = maze -QT += quick sensors -SOURCES = main.cpp - -OTHER_FILES = \ - components \ - $$files(*.qml) \ - $$files(*.js) \ - content \ - android/AndroidManifest.xml - -target.path = $$[QT_INSTALL_EXAMPLES]/sensors/maze -INSTALLS += target - -RESOURCES += \ - maze.qrc - -ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android diff --git a/examples/sensors/maze/maze.qml b/examples/sensors/maze/maze.qml deleted file mode 100644 index c28e970b..00000000 --- a/examples/sensors/maze/maze.qml +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -/* Layout - mainWnd - / -------------------------------/ gameRect -| / -|-----------------------------/ -||---------------------------| -||||M| || -||| \ || -||| mouseCtrl || -||| || -||| || -||| Labyrinth || -||| || -||| || -||| cheeseSquare || -||| \ || -||| |C||| -||---------------------------| -|----------------------------- -| -|----------------------------- -|| || | -|----------------------------- -| \ \ -| \ timePlayingLabel -| newGameButton ------------------------------- - -*/ -//Import the declarative plugins -import QtQuick -import "components" - -//! [0] -import QtSensors -//! [0] - -//Import the javascript functions for this game -import "lib.js" as Lib - -ApplicationWindow { - id: mainWnd - property bool gameRunning: false - - Component.onCompleted: { - initializeMaze() - newGame() - } - - function initializeMaze() { - Lib.objectArray = new Array(Lib.dimension * Lib.dimension); - Lib.createLabyrinth(); - var idx = 0; - var component = Qt.createComponent("LabyrinthSquare.qml"); - for (var y = 0; y < Lib.dimension; y++ ) { - for (var x = 0; x < Lib.dimension; x++ ) { - var square = component.createObject(gameRect); - if (!square) { - console.log("error loading labyrinth square: " + component.errorString()) - return - } - square.x = x * square.width; - square.y = y * square.height; - square.val = Lib.labyrinth[x][y]; - Lib.objectArray[idx] = square; - idx++; - } - } - } - - function newGame() { - congratulation.visible = false; - - // Reset game time - timePlayingLabel.text = "--"; - Lib.sec = 0.0; - - // Create new labyrinth - Lib.createLabyrinth(); - // Update maze tiles to match the new labyrinth - var idx = 0; - for (var y = 0; y < Lib.dimension; y++ ) { - for (var x = 0; x < Lib.dimension; x++ ) { - Lib.objectArray[idx].val = Lib.labyrinth[x][y]; - Lib.objectArray[idx].updateImage(); - idx++; - } - } - // Reset mouse position and start the game - mouseCtrl.x = 0; - mouseCtrl.y = 0; - mainWnd.gameRunning = true; - } - - function gameWon() { - // Update the cheese square at the bottom right (win animation) - Lib.objectArray[Lib.dimension * Lib.dimension - 1].val = 4 - Lib.objectArray[Lib.dimension * Lib.dimension - 1].updateImage() - congratulation.visible = true; - mainWnd.gameRunning = false; - } - - Rectangle { - id: gameRect - x: (mainWnd.width - width) / 2 - y: 5 - width: Lib.dimension * Lib.cellDimension - height: Lib.dimension * Lib.cellDimension - color: "transparent" - border.width: 2 - } - - Mouse { - id: mouseCtrl - } - - Congratulation { - id: congratulation - visible: false - } - -//! [1] - TiltSensor { - id: tiltSensor - active: true - } -//! [1] - - //Timer to read out the x and y rotation of the TiltSensor - Timer { - id: tiltTimer - interval: 50 - repeat: true - running: tiltSensor.active && mainWnd.gameRunning - - onTriggered: { - // Update the maze unless game is already won - if (Lib.won === true) { - gameWon() - return - } - Lib.sec += 0.05; - timePlayingLabel.text = Math.floor(Lib.sec) + " seconds"; - - //check if we can move the mouse - var xval = -1; - var yval = -1; - -//! [2] - var xstep = 0; - xstep = tiltSensor.reading.yRotation * 0.1 //acceleration - - var ystep = 0; - ystep = tiltSensor.reading.xRotation * 0.1 //acceleration -//! [2] -//! [3] - if (xstep < 1 && xstep > 0) - xstep = 0 - else if (xstep > -1 && xstep < 0) - xstep = 0 - - if (ystep < 1 && ystep > 0) - ystep = 0; - else if (ystep > -1 && ystep < 0) - ystep = 0; - - if ((xstep < 0 && mouseCtrl.x > 0 - && Lib.canMove(mouseCtrl.x + xstep,mouseCtrl.y))) { - xval = mouseCtrl.x + xstep; - - } else if (xstep > 0 && mouseCtrl.x < (Lib.cellDimension * (Lib.dimension - 1)) - && Lib.canMove(mouseCtrl.x + xstep,mouseCtrl.y)) { - xval = mouseCtrl.x + xstep; - } else - xval = mouseCtrl.x; - - if (ystep < 0 && mouseCtrl.y > 0 - && Lib.canMove(mouseCtrl.x, mouseCtrl.y + ystep)) { - yval = mouseCtrl.y + ystep; - } else if (ystep > 0 && (mouseCtrl.y < (Lib.cellDimension * (Lib.dimension - 1))) - && Lib.canMove(mouseCtrl.x, mouseCtrl.y + ystep)) { - yval = mouseCtrl.y + ystep; - } else - yval = mouseCtrl.y - mouseCtrl.move(xval, yval); -//! [3] - } - } - - //Button to start a new Game - Button{ - id: newGameButton - anchors.left: gameRect.left - anchors.top: gameRect.bottom - anchors.topMargin: 5 - height: 30 - width: 100 - text: qsTr("New game") - onClicked: newGame() - } - Button{ - id: calibrateButton - anchors.left: gameRect.left - anchors.top: newGameButton.bottom - anchors.topMargin: 5 - height: 30 - width: 100 - text: qsTr("Calibrate") - onClicked: tiltSensor.calibrate(); - } - - Text { - id: tiltSensorInfo - visible: tiltSensor.active - anchors.left: gameRect.left - anchors.top: calibrateButton.bottom - anchors.topMargin: 5 - text: qsTr("Tilt sensor ID: ") + tiltSensor.identifier - } - - //Label to print out the game time - Text{ - id: timePlayingLabel - anchors.right: gameRect.right - anchors.top: gameRect.bottom - anchors.topMargin: 5 - } - - Rectangle { - id: tiltSensorMissing - visible: !tiltSensor.active - anchors.fill: parent - color: "#AACCCCCC" // slightly transparent - Text { - anchors.centerIn: parent - text: qsTr("Tilt sensor\nnot found") - font.pixelSize: 24 - font.bold: true - color: "black" - } - MouseArea { - // prevent interaction with the game - anchors.fill: parent - } - } -} - diff --git a/examples/sensors/maze/maze.qrc b/examples/sensors/maze/maze.qrc deleted file mode 100644 index 10916193..00000000 --- a/examples/sensors/maze/maze.qrc +++ /dev/null @@ -1,21 +0,0 @@ - - - Congratulation.qml - LabyrinthSquare.qml - lib.js - maze.qml - Mouse.qml - components/ApplicationWindow.qml - components/Button.qml - components/images/button_background_disabled.png - components/images/button_background_pressed.png - components/images/button_background_normal.png - content/00.png - content/start.png - content/mouse_down.gif - content/congratulations.gif - content/cheeseeating.gif - content/cheese.png - content/01.png - - diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro index 77a95296..86d029b2 100644 --- a/examples/sensors/sensors.pro +++ b/examples/sensors/sensors.pro @@ -4,7 +4,6 @@ SUBDIRS += grue qtHaveModule(quick) { SUBDIRS += \ - maze \ qmlqtsensors \ sensor_explorer } -- cgit v1.2.3