Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created visuals for snake #120

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
Loading