Skip to content

Commit

Permalink
color design!
Browse files Browse the repository at this point in the history
Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
  • Loading branch information
j10a1n15 committed Sep 18, 2024
1 parent b3f6fee commit 56dbec7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/kotlin/gay/j10a1n15/sillygames/games/Snake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ import gg.essential.elementa.constraints.CenterConstraint
import gg.essential.elementa.dsl.childOf
import gg.essential.elementa.dsl.constrain
import gg.essential.elementa.dsl.constraint
import gg.essential.elementa.dsl.effect
import gg.essential.elementa.dsl.percent
import gg.essential.elementa.dsl.pixel
import gg.essential.elementa.effects.OutlineEffect
import gg.essential.elementa.state.BasicState
import gg.essential.elementa.utils.invisible
import org.lwjgl.input.Keyboard
import java.awt.Color

Expand Down Expand Up @@ -104,13 +101,14 @@ class Snake : Game() {

for (_x in 0 until gridWidth) {
for (_y in 0 until gridHeight) {
val gridColor = if ((_x + _y) % 2 == 0) Color(0, 100, 0) else Color(0, 120, 0)
UIBlock().constrain {
width = gridSize.pixel
height = gridSize.pixel
x = (_x * gridSize).pixel
y = (_y * gridSize).pixel
color = Color.BLACK.invisible().constraint
} childOf background effect OutlineEffect(Color.BLACK, 1f)
color = gridColor.constraint
} childOf background
}
}

Expand All @@ -123,13 +121,13 @@ class Snake : Game() {
} childOf background

for ((index, segment) in snake.withIndex()) {
val segmentColor = (if (index == 0) Color.RED else Color.ORANGE).constraint
val segmentColor = if (index == 0) Color.RED else if (index % 2 == 1) Color(23, 172, 16) else Color(72, 232, 40)
UIBlock().constrain {
width = gridSize.pixel
height = gridSize.pixel
x = (segment.x * gridSize).pixel
y = (segment.y * gridSize).pixel
color = segmentColor
color = segmentColor.constraint
} childOf background
}

Expand Down

0 comments on commit 56dbec7

Please sign in to comment.