Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroshevskii committed Nov 7, 2022
1 parent de23fce commit 6ff39d8
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 276 deletions.
Binary file added Docs/Assets/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Snake

![Screenshot_20221029_025805](https://user-images.githubusercontent.com/72662383/198751977-ef376339-34d7-4830-8044-9027232eebba.png)
![Screenshot_20221029_025805](./Docs/Assets/Screenshot.png)
47 changes: 47 additions & 0 deletions Sources/Snake/Field.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Snake
//

import Raylib

class Field {
let squareSize: Int32
let columnsCount: Int32
let rowsCount: Int32

let render: RenderTexture2D
let renderDrawPosition: Point2D

init(windowWidth: Int32, windowHeight: Int32) {
squareSize = 20
columnsCount = windowWidth / squareSize - 1
rowsCount = windowHeight / squareSize - 1

render = Raylib.loadRenderTexture(columnsCount * squareSize, rowsCount * squareSize)

Raylib.beginTextureMode(render)
Raylib.clearBackground(
Color(r: 26, g: 26, b: 36, a: 255) // Dark themme
)
// Draw notebook cells
for x in 0..<columnsCount {
for y in 0..<rowsCount {
Raylib.drawRectangle(
x * squareSize + 1, y * squareSize + 1,
squareSize - 2, squareSize - 2,
Color(r: 14, g: 14, b: 18, a: 255) // Dark themme
)
}
}
Raylib.endTextureMode()

renderDrawPosition = Point2D(
x: (windowWidth - render.texture.width) / 2,
y: (windowHeight - render.texture.height) / 2
)
}

deinit {
Raylib.unloadRenderTexture(render)
}
}
10 changes: 10 additions & 0 deletions Sources/Snake/Fruit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Snake
//

import Raylib

struct Fruit {
var position: Point2D
var color = Color(r: 230, g: 230, b: 236, a: 255) // Dark themme
}
Loading

0 comments on commit 6ff39d8

Please sign in to comment.