Skip to content

Commit

Permalink
created visuals for snake
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrwang committed Oct 15, 2024
1 parent 4ae753f commit 30682d7
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
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"
}
}

0 comments on commit 30682d7

Please sign in to comment.