-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de23fce
commit 6ff39d8
Showing
10 changed files
with
247 additions
and
276 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Snake | ||
|
||
 | ||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.