From 62be141f97f60bad19b86440b28d7c0585fbc36e Mon Sep 17 00:00:00 2001 From: jaroshevskii Date: Tue, 21 Mar 2023 22:23:00 +0200 Subject: [PATCH] Update title screen --- Sources/Snake/Settings.swift | 4 +- Sources/Snake/SnakeGame.swift | 84 ++++++++++++++++++++--------------- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/Sources/Snake/Settings.swift b/Sources/Snake/Settings.swift index b6e83da..9b0b200 100644 --- a/Sources/Snake/Settings.swift +++ b/Sources/Snake/Settings.swift @@ -15,8 +15,8 @@ struct Settings { extension Settings { static let `default` = Settings( isVsync: true, - windowWidth: 840, + windowWidth: 640, windowHeight: 360, - theme: .dark + theme: .light ) } \ No newline at end of file diff --git a/Sources/Snake/SnakeGame.swift b/Sources/Snake/SnakeGame.swift index b7071af..81da6ba 100644 --- a/Sources/Snake/SnakeGame.swift +++ b/Sources/Snake/SnakeGame.swift @@ -150,46 +150,56 @@ class Game { // Postion y field.renderDrawPosition.y + 8 ) - Raylib.drawText( - // Text - """ - Field: - Columns count: \(field.columnsCount) - Rows count: \(field.rowsCount) - - Snake head position: - X: \(snake.headPosition.x) - Y: \(snake.headPosition.y) - - Fruit position: - X: \(fruit.position.x) - Y: \(fruit.position.y) - """, - // Position x - field.renderDrawPosition.x + 8, - // Position y - field.renderDrawPosition.y + 20 + 8 + 8, - // Font height - 10, - // Color - textColor + // Raylib.drawText( + // // Text + // """ + // Field: + // Columns count: \(field.columnsCount) + // Rows count: \(field.rowsCount) + + // Snake head position: + // X: \(snake.headPosition.x) + // Y: \(snake.headPosition.y) + + // Fruit position: + // X: \(fruit.position.x) + // Y: \(fruit.position.y) + // """, + // // Position x + // field.renderDrawPosition.x + 8, + // // Position y + // field.renderDrawPosition.y + 20 + 8 + 8, + // // Font height + // 10, + // // Color + // textColor + // ) + + let text = "[ Swiftly Snake ]" + let textFontSize: Int32 = 40 + let drawPosition = Point2D( + x: (640 - Raylib.measureText(text, textFontSize)) / 2, + y: (360 - textFontSize) / 2 ) + Raylib.drawText(text, drawPosition.x, drawPosition.y, textFontSize, textColor) - var text = "[ Snake ]" - var fontSize: Int32 = 30 - var drawPosition = Point2D( - x: (840 - Raylib.measureText(text, fontSize)) / 2, - y: (360 - fontSize) / 2 + let descripion = "[ Press any key to play ]" + let descriptionFontSize: Int32 = 10 + let descriptionDrawPosition = Point2D( + x: (640 - Raylib.measureText(descripion, descriptionFontSize)) / 2, + y: 360 / 2 + (360 / 2 - descriptionFontSize) / 2 ) - Raylib.drawText(text, drawPosition.x, drawPosition.y, fontSize, textColor) - - text = "[ Play | Exit ]" - fontSize = 20 - drawPosition = Point2D( - x: (840 - Raylib.measureText(text, fontSize)) / 2, - y: (360 - fontSize) / 2 + 128 - ) - Raylib.drawText(text, drawPosition.x, drawPosition.y, fontSize, textColor) + Raylib.drawText( + descripion, descriptionDrawPosition.x, descriptionDrawPosition.y, descriptionFontSize, + textColor) + + // text = "[ Play | Exit ]" + // fontSize = 20 + // drawPosition = Point2D( + // x: (840 - Raylib.measureText(text, fontSize)) / 2, + // y: (360 - fontSize) / 2 + 128 + // ) + // Raylib.drawText(text, drawPosition.x, drawPosition.y, fontSize, textColor) Raylib.endDrawing() }