-
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
6ff39d8
commit e2da5f1
Showing
9 changed files
with
217 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
// | ||
|
||
struct Point2D: Equatable { | ||
let x: Int32 | ||
let y: Int32 | ||
var x: Int32 | ||
var y: Int32 | ||
} |
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,22 @@ | ||
// | ||
// Snake | ||
// | ||
|
||
import Raylib | ||
|
||
struct Settings { | ||
var isVsync: Bool | ||
var windowWidth: Int32 | ||
var windowHeight: Int32 | ||
|
||
var theme: Theme | ||
} | ||
|
||
extension Settings { | ||
static let `default` = Settings( | ||
isVsync: true, | ||
windowWidth: 840, | ||
windowHeight: 360, | ||
theme: .dark | ||
) | ||
} |
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
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,44 @@ | ||
// | ||
// Snake | ||
// | ||
|
||
import Raylib | ||
|
||
struct Theme { | ||
var fieldBackgroundColor: Color | ||
var fieldColor: Color | ||
|
||
var snakeHeadColor: Color | ||
var snakeTailColor: Color | ||
|
||
var fruitColor: Color | ||
|
||
var textColor: Color | ||
} | ||
|
||
extension Theme { | ||
static let light = Theme( | ||
fieldBackgroundColor: Color(r: 193, g: 193, b: 210, a: 255), | ||
fieldColor: Color(r: 230, g: 230, b: 236, a: 255), | ||
snakeHeadColor: Color(r: 83, g: 83, b: 115, a: 255), // ??? | ||
snakeTailColor: Color(r: 166, g: 166, b: 191, a: 255), // ??? | ||
fruitColor: Color(r: 14, g: 14, b: 18, a: 255), | ||
textColor: Color(r: 14, g: 14, b: 18, a: 255) | ||
) | ||
static let dark = Theme( | ||
fieldBackgroundColor: Color(r: 26, g: 26, b: 36, a: 255), | ||
fieldColor: Color(r: 14, g: 14, b: 18, a: 255), | ||
snakeHeadColor: Color(r: 166, g: 166, b: 191, a: 255), | ||
snakeTailColor: Color(r: 83, g: 83, b: 115, a: 255), | ||
fruitColor: Color(r: 230, g: 230, b: 236, a: 255), | ||
textColor: Color(r: 230, g: 230, b: 236, a: 255) | ||
) | ||
static let classic = Theme( | ||
fieldBackgroundColor: .lightGray, | ||
fieldColor: .white, | ||
snakeHeadColor: .darkGreen, | ||
snakeTailColor: .green, | ||
fruitColor: .red, | ||
textColor: .black | ||
) | ||
} |
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 |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
// Snake | ||
// | ||
|
||
let game = Game() | ||
let game = Game(settings: .default) | ||
|
||
game.run() |