Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Develop' into #111-Snake-Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sumershinde22 committed Nov 6, 2024
2 parents d635c6e + 4805cdc commit 1f862ea
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 178 deletions.
42 changes: 32 additions & 10 deletions NERODesign/content/Battery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,51 @@ Item {
Rectangle {
id: topOutlet
x: parent.width / 2 - parent.width / 4
width: parent.width / 2
width: parent.width / 4.5
height: parent.height
color: "white"
radius: 30
color: battery.value > 70 ? "#55FF00" : battery.value > 40 ? "orange" : "red"
anchors.centerIn: parent
}

Rectangle {
id: mainContainer
width: parent.width
y: 48
width: parent.width / 2.15
height: parent.height - parent.height / 10
color: "white"
radius: 30
color: battery.value > 70 ? "#55FF00" : battery.value > 40 ? "orange" : "red"
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.horizontalCenterOffset: 0
anchors.horizontalCenter: parent.horizontalCenter

Rectangle {
id: fillContainer
width: parent.width - (battery.horizontalFillMargin * 2)
height: (parent.height - (battery.verticalFillMargin * 2))
* (battery.value / battery.maxValue)
color: battery.value > 70 ? "#55FF00" : battery.value > 40 ? "orange" : "red"
id: emptyContainer
y: 123
width: parent.width - (battery.horizontalFillMargin * 1.5)
height: (parent.height - (battery.verticalFillMargin * 3))
radius: 30
color: "black"
anchors.bottom: parent.bottom
anchors.bottomMargin: 36
anchors.horizontalCenterOffset: 0
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottomMargin: battery.verticalFillMargin

Rectangle {
id: fillContainer
y: 136
width: parent.width
height: (parent.height * (battery.value / battery.maxValue))
gradient: Gradient {
GradientStop { position: 0.0; color: battery.value > 70 ? "#55FF00" : battery.value > 40 ? "orange" : "red" }
GradientStop { position: 1.0; color: "black" }
}
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.horizontalCenterOffset: 0
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
}
40 changes: 40 additions & 0 deletions NERODesign/content/Snake.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

Rectangle {
id: snake

width: 800
height: 480
color: "black"

property int minX: 200
property int maxX: 600
property int minY: 40
property int maxY: 440

property var snakeBody: [{"x": 300, "y": 300}, {"x": 280, "y": 300}, {"x": 260, "y": 300}]
property int segmentSize: 20
property string direction: "right"

property int score: 0

Rectangle {
width: 400
height: 400
anchors.centerIn: parent
border.color: "white"
border.width: 2
color: "transparent"
}

Text {
id: scoreText
text: "Score: " + snake.score
font.pixelSize: 24
color: "white"
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
}
}
17 changes: 17 additions & 0 deletions NERODesign/content/SnakeBody.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
id: food
property int dimension: 20

width: dimension
height: dimension

Rectangle {
id: foodColor
height: dimension
width: dimension
color: "lime"
}
}
17 changes: 17 additions & 0 deletions NERODesign/content/SnakeFood.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
id: food
property int dimension: 20

width: dimension
height: dimension

Rectangle {
id: foodColor
height: dimension
width: dimension
color: "red"
}
}
4 changes: 3 additions & 1 deletion NERODevelopment/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ set(PROJECT_SOURCES

find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Network Mqtt Protobuf Widgets)

qt_add_executable(NEROApp ${PROJECT_SOURCES})
qt_add_executable(NEROApp ${PROJECT_SOURCES}
src/controllers/snakecontroller.h
src/controllers/snakecontroller.cpp)

qt_add_resources(NEROApp "configuration"
PREFIX "/"
Expand Down
3 changes: 3 additions & 0 deletions NERODevelopment/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ qt6_add_qml_module(content
Arrow.qml
OffScreen2.qml
StatusDisplay.qml
Snake.qml
SnakeBody.qml
SnakeFood.qml

RESOURCES
fonts/fonts.txt
Expand Down
2 changes: 1 addition & 1 deletion NERODevelopment/content/HomeMenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Rectangle {
LabelText {
id: label
padding: 8
font.pixelSize: 16
font.pixelSize: 12
text: parent.text
}
}
13 changes: 12 additions & 1 deletion NERODevelopment/content/NavigationController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ Item {
focus: !navigation.isSelected
property int selectedPageIndex: navigationController.selectedPageIndex
property bool isSelected: navigationController.isSelected
property int exitPageIndex: 7
property int exitPageIndex: 8
property int offPageIndex: 0
property int pitPageIndex: 1
property int speedPageIndex: 2
property int efficiencyPageIndex: 3
property int debugPageIndex: 4
property int configurationPageIndex: 5
property int flappyPageIndex: 6
property int snakePageIndex: 7

Keys.onPressed: event => {
console.log(navigationController.isSelected,
Expand Down Expand Up @@ -89,6 +90,11 @@ Item {
text: "Flappy Bird"
}

HomeMenuItem {
highlighted: selectedPageIndex === snakePageIndex
text: "Snake"
}

HomeMenuItem {
highlighted: selectedPageIndex === exitPageIndex
text: "Exit"
Expand Down Expand Up @@ -129,4 +135,9 @@ Item {
visible: selectedPageIndex === flappyPageIndex && isSelected
isFocused: selectedPageIndex === flappyPageIndex && isSelected
}

Snake {
visible: selectedPageIndex === snakePageIndex && isSelected
isFocused: selectedPageIndex === snakePageIndex && isSelected
}
}
Loading

0 comments on commit 1f862ea

Please sign in to comment.