Permalink
Browse files

Instructions + working menu

  • Loading branch information...
Amos Wenger
Amos Wenger committed Aug 27, 2012
1 parent 9c07926 commit 63e7c9cd39fb338fead96e893420c3f339285eb9
Showing with 86 additions and 14 deletions.
  1. +0 −5 source/Block.ooc
  2. +49 −0 source/Instructions.ooc
  3. +3 −0 source/Level.ooc
  4. +4 −2 source/Menu.ooc
  5. +30 −7 source/bioboy.ooc
View
@@ -175,11 +175,6 @@ Block: class extends Actor {
dead = true
}
}
-
- if (playCount <= 0) {
- level play("boom")
- playCount = 15
- }
}
}
}
View
@@ -0,0 +1,49 @@
+
+import ldkit/[Engine, Dead, Math, Sprites, UI, Actor, Input, Pass]
+
+Instructions: class extends Actor {
+
+ engine: Engine
+ ui: UI
+ input: Input
+ pass: Pass
+
+ onExit: Func
+
+ init: func (=engine, =onExit) {
+ ui = engine ui
+ input = ui input sub()
+
+ pass = Pass new(ui, "instructions")
+ ui levelPass addPass(pass)
+
+ sprite := ImageSprite new(vec2(0, 0), "assets/png/fog.png")
+ pass addSprite(sprite)
+
+ input onKeyPress(Keys ESC, ||
+ "Caught esc" println()
+ clear()
+ onExit()
+ )
+
+ clear()
+ }
+
+ clear: func {
+ pass enabled = false
+ input enabled = false
+ engine remove(this)
+ }
+
+ enter: func {
+ pass enabled = true
+ input enabled = true
+ engine add(this)
+ }
+
+ update: func (delta: Float) {
+ }
+
+}
+
+
View
@@ -147,6 +147,9 @@ Level: class extends Actor {
while (iter hasNext?()) {
actor := iter next()
if (actor == this) continue
+ if (actor class name == "Game") continue
+ if (actor class name == "Menu") continue
+ if (actor class name == "LevelSelect") continue
actor destroy()
iter remove()
View
@@ -23,8 +23,9 @@ Menu: class extends Actor {
currentPos := 0
onPlay: Func
+ onInstructions: Func
- init: func (=engine, =onPlay) {
+ init: func (=engine, =onPlay, =onInstructions) {
ui = engine ui
input = ui input sub()
@@ -51,6 +52,7 @@ Menu: class extends Actor {
)
input onKeyPress(Keys ENTER, ||
+ clear()
takeAction()
)
@@ -68,7 +70,7 @@ Menu: class extends Actor {
case 0 =>
onPlay()
case 1 =>
- // nothing yet
+ onInstructions()
case 2 =>
engine quit()
}
View
@@ -2,22 +2,25 @@
use zombieconfig, ldkit, deadlogger
import zombieconfig
-import ldkit/[Engine, Dead, Math, Sprites, UI]
+import ldkit/[Engine, Dead, Math, Sprites, UI, Actor]
import deadlogger/Logger
import structs/ArrayList
-import Level, Story, Menu, LevelSelect
+import Level, Story, Menu, LevelSelect, Instructions
main: func (args: ArrayList<String>) {
Game new()
}
-Game: class {
+Game: class extends Actor {
levelSelect: LevelSelect
level: Level
story: Story
menu: Menu
+ instructions: Instructions
+
+ shouldSelectLevels := false
init: func {
@@ -40,6 +43,16 @@ Game: class {
engine ui mousePass enabled = false
engine ui escQuits = false
+ menu = Menu new(engine, ||
+ scheduleLevelSelect()
+ , ||
+ instructions enter()
+ )
+
+ instructions = Instructions new(engine, ||
+ menu enter()
+ )
+
levelSelect = LevelSelect new(engine, |levelFile|
if(level jumpTo(levelFile)) {
levelSelect clear()
@@ -50,25 +63,35 @@ Game: class {
)
level = Level new(engine, levelSelect, |success|
+ level clear()
if (success) {
levelSelect success(level millis)
}
levelSelect updateSelector(success ? 1 : 0, 0)
levelSelect enter()
)
-
- menu = Menu new(engine, ||
- levelSelect enter()
- )
+ level clear()
story = Story new(engine, "intro", ||
menu enter()
)
story loadCard()
+ engine add(this)
engine run()
}
+ scheduleLevelSelect: func {
+ shouldSelectLevels = true
+ }
+
+ update: func (delta: Float) {
+ if(shouldSelectLevels) {
+ shouldSelectLevels = false
+ levelSelect enter()
+ }
+ }
+
}

0 comments on commit 63e7c9c

Please sign in to comment.