Skip to content
Browse files

Colors, customize esc/slomo, flashmessages have a bg now

  • Loading branch information...
1 parent d5a46b4 commit 36dc7abbc9f6b269f001d5a193b6ea490f0004e8 Amos Wenger committed
Showing with 51 additions and 12 deletions.
  1. +9 −0 source/ldkit/Colors.ooc
  2. +8 −2 source/ldkit/Engine.ooc
  3. +23 −4 source/ldkit/FlashMessages.ooc
  4. +8 −0 source/ldkit/Sprites.ooc
  5. +3 −6 source/ldkit/UI.ooc
View
9 source/ldkit/Colors.ooc
@@ -0,0 +1,9 @@
+
+import Math
+
+Colors: class {
+
+ red := static vec3(1, 0, 0)
+ grey := static vec3(0.4, 0.4, 0.4)
+
+}
View
10 source/ldkit/Engine.ooc
@@ -15,20 +15,26 @@ Engine: class {
FPS := 30.0 // let's target 30FPS
+ slomo := false
+
init: func(config: ZombieConfig) {
ui = UI new(this, config)
}
run: func {
ticks: Int
- delta := 1000.0 / 30.0 // try 30FPS
+ delta := 1000.0 / FPS // try 30FPS
// main loop
while (true) {
ticks = LTime getTicks()
+ // two physics simulation
+ actors each(|a| a update(delta * 0.5))
+ if (!slomo) {
+ actors each(|a| a update(delta * 0.5))
+ }
ui update()
- actors each(|a| a update(delta))
// teleport ourselves in the future when the next frame is due
roadToFuture := ticks + delta - LTime getTicks()
View
27 source/ldkit/FlashMessages.ooc
@@ -1,7 +1,7 @@
import structs/[Stack]
-import UI, Sprites, Math
+import UI, Sprites, Math, Pass
FlashMessages: class {
@@ -11,17 +11,30 @@ FlashMessages: class {
messageLength := 90
counter := 0
+
+ pass: Pass
labelSprite: LabelSprite
init: func (=ui) {
- labelSprite = LabelSprite new(vec2(ui display getCenter() x, (ui display getHeight() - 40) as Float), "")
+ pass = Pass new(ui, "flash")
+ ui statusPass addPass(pass)
+
+ pos := vec2(ui display getCenter() x, (ui display getHeight() - 40) as Float)
+
+ rectSprite := RectSprite new(pos)
+ rectSprite color set!(0, 0, 0)
+ rectSprite alpha = 0.7
+ rectSprite size set!(500, 80)
+ pass addSprite(rectSprite)
+
+ labelSprite = LabelSprite new(pos, "")
labelSprite color set!(0.9, 0.9, 0.5)
labelSprite fontSize = 30.0
labelSprite centered = true
counter = messageLength
- ui statusPass addSprite(labelSprite)
+ pass addSprite(labelSprite)
}
reset: func {
@@ -30,13 +43,18 @@ FlashMessages: class {
hide()
}
+ show: func {
+ pass enabled = true
+ }
+
hide: func {
- labelSprite setText("")
+ pass enabled = false
}
push: func (msg: String) {
if (msg size > 0) {
messages push(msg)
+ counter = messageLength - 10
}
}
@@ -46,6 +64,7 @@ FlashMessages: class {
} else {
if (!messages empty?()) {
labelSprite setText(messages pop())
+ show()
counter = 0
} else {
hide()
View
8 source/ldkit/Sprites.ooc
@@ -120,6 +120,10 @@ ImageSprite: class extends Sprite {
}
}
+ center!: func {
+ offset set!(- (width * scale x) / 2, - (height * scale y) / 2)
+ }
+
paint: func (cr: Context) {
if (tiled) {
for (x in -3..3) {
@@ -351,6 +355,10 @@ RectSprite: class extends Sprite {
}
}
+ center!: func {
+ offset set!(size mul(-0.5))
+ }
+
containsPoint: func(point: Vec2) -> Bool {
ap := absolutePos
halfSize := size mul(0.5)
View
9 source/ldkit/UI.ooc
@@ -28,6 +28,8 @@ UI: class {
// something we can control level loading with
engine: Engine
+ escQuits := true
+
/*
* Constructors
*/
@@ -53,11 +55,6 @@ UI: class {
initSound: func {
logger info("Initializing sound system")
boombox = Boombox new()
-
- // bgMusic = boombox load("assets/music/quiet-dignity.ogg")
- // boombox loop(bgMusic)
-
- // criekSound = boombox load("assets/sounds/criek.ogg")
}
// different UI passes
@@ -137,7 +134,7 @@ UI: class {
//input debug = true
input onKeyPress(Keys ESC, ||
- engine quit()
+ if (escQuits) engine quit()
)
input onExit(||

0 comments on commit 36dc7ab

Please sign in to comment.
Something went wrong with that request. Please try again.