From 30682d7ff44a6a8095cc7bc45f5ce95aaf591825 Mon Sep 17 00:00:00 2001 From: mattrwang Date: Tue, 15 Oct 2024 19:52:32 -0400 Subject: [PATCH] created visuals for snake --- NERODesign/content/Snake.qml | 40 ++++++++++++++++++++++++++++++++ NERODesign/content/SnakeBody.qml | 17 ++++++++++++++ NERODesign/content/SnakeFood.qml | 17 ++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 NERODesign/content/Snake.qml create mode 100644 NERODesign/content/SnakeBody.qml create mode 100644 NERODesign/content/SnakeFood.qml diff --git a/NERODesign/content/Snake.qml b/NERODesign/content/Snake.qml new file mode 100644 index 0000000..11ed22a --- /dev/null +++ b/NERODesign/content/Snake.qml @@ -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 + } +} diff --git a/NERODesign/content/SnakeBody.qml b/NERODesign/content/SnakeBody.qml new file mode 100644 index 0000000..6283614 --- /dev/null +++ b/NERODesign/content/SnakeBody.qml @@ -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" + } +} diff --git a/NERODesign/content/SnakeFood.qml b/NERODesign/content/SnakeFood.qml new file mode 100644 index 0000000..43852a6 --- /dev/null +++ b/NERODesign/content/SnakeFood.qml @@ -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" + } +}