Skip to content

Commit

Permalink
Update title screen
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroshevskii committed Mar 21, 2023
1 parent 86362db commit 62be141
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Sources/Snake/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct Settings {
extension Settings {
static let `default` = Settings(
isVsync: true,
windowWidth: 840,
windowWidth: 640,
windowHeight: 360,
theme: .dark
theme: .light
)
}
84 changes: 47 additions & 37 deletions Sources/Snake/SnakeGame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 62be141

Please sign in to comment.