Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Flash messages + random tunings

  • Loading branch information...
commit 7c42fdc12300690cfb7793b32cafb8320f66a66c 1 parent 4e9da5a
@nddrylliog authored
View
6 source/ldkit/Actor.ooc
@@ -4,7 +4,11 @@ Actor: class {
init: func {}
update: func (delta: Float) {
- "Override Actor#update! (delta = %.2f)" printfln(delta)
+ "Override %s#update! (delta = %.2f)" printfln(class name, delta)
+ }
+
+ destroy: func {
+ "Override %s#destroy!" printfln(class name)
}
}
View
8 source/ldkit/Collision.ooc
@@ -27,10 +27,10 @@ Box: class {
maxy2 := y2 + other height
// rule out quick cases first
- if (maxx1 < minx2) return null
- if (maxx2 < minx1) return null
- if (maxy1 < miny2) return null
- if (maxy2 < miny1) return null
+ if (maxx1 <= minx2) return null
+ if (maxx2 <= minx1) return null
+ if (maxy1 <= miny2) return null
+ if (maxy2 <= miny1) return null
bangs := false
b := Bang new()
View
58 source/ldkit/FlashMessages.ooc
@@ -0,0 +1,58 @@
+
+import structs/[Stack]
+
+import UI, Sprites, Math
+
+FlashMessages: class {
+
+ ui: UI
+
+ messages := Stack<String> new()
+
+ messageLength := 90
+ counter := 0
+
+ labelSprite: LabelSprite
+
+ init: func (=ui) {
+ labelSprite = LabelSprite new(vec2(ui display getCenter() x, (ui display getHeight() - 40) as Float), "")
+ labelSprite color set!(0.9, 0.9, 0.5)
+ labelSprite fontSize = 30.0
+ labelSprite centered = true
+ counter = messageLength
+
+ ui statusPass addSprite(labelSprite)
+ }
+
+ reset: func {
+ counter = 0
+ messages clear()
+ hide()
+ }
+
+ hide: func {
+ labelSprite setText("")
+ }
+
+ push: func (msg: String) {
+ if (msg size > 0) {
+ messages push(msg)
+ }
+ }
+
+ update: func {
+ if (counter < messageLength) {
+ counter += 1
+ } else {
+ if (!messages empty?()) {
+ labelSprite setText(messages pop())
+ counter = 0
+ } else {
+ hide()
+ }
+ }
+ }
+
+}
+
+
View
2  source/ldkit/Input.ooc
@@ -386,6 +386,8 @@ Input: class extends Proxy {
Keys: enum from Int {
LEFT = SDLK_LEFT
RIGHT = SDLK_RIGHT
+ UP = SDLK_UP
+ DOWN = SDLK_DOWN
SPACE = SDLK_SPACE
ENTER = SDLK_RETURN
F1 = SDLK_F1
View
2  source/ldkit/Sound.ooc
@@ -25,6 +25,8 @@ Source: class {
alSourceQueueBuffers(sourceID, sample bufferIDs size, sample bufferIDs toArray())
alSource3f(sourceID, AL_POSITION, 0.0, 0.0, 0.0)
+ alSourcei(sourceID, AL_REFERENCE_DISTANCE, 1.0)
+ alSourcei(sourceID, AL_MAX_DISTANCE, 1000.0)
}
getState: func -> SourceState {
View
14 source/ldkit/UI.ooc
@@ -3,7 +3,7 @@ use gobject, cairo, sdl, deadlogger, ldkit
// game deps
import Display, Input, Math, Sprites, Sound, Engine
-import Pass
+import Pass, FlashMessages
// libs deps
import deadlogger/Log
@@ -75,14 +75,10 @@ UI: class {
mousePass := Pass new(this, "mouse")
cursor: GroupSprite
- // flashMessages: FlashMessages
+ flashMessages: FlashMessages
initPasses: func {
- // flashMessages = FlashMessages new(this)
-
- // temp code, no real art :'(
- // bgPos := vec2(display getWidth() - 1920, display getHeight() - 1080)
- // bgPass addSprite(ImageSprite new(bgPos, "assets/png/background-placeholder.png"))
+ flashMessages = FlashMessages new(this)
// offset to make the hand correspond with the actual mouse
cursorImage := ImageSprite new(vec2(-12, -10), "assets/png/cursor.png")
@@ -122,12 +118,12 @@ UI: class {
}
flash: func (msg: String) {
- // flashMessages push(msg)
+ flashMessages push(msg)
}
update: func {
boombox update()
- // flashMessages update()
+ flashMessages update()
display clear()
rootPass draw()
Please sign in to comment.
Something went wrong with that request. Please try again.