Permalink
Browse files

Powers and stuff o/

  • Loading branch information...
Amos Wenger
Amos Wenger committed Aug 27, 2012
1 parent a5c0afd commit 50166eace3a9ce08d1185883ab0bc475586586f3
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -44,18 +44,6 @@ Hero: class extends Actor {
input onKeyPress(Keys RIGHT, || fire())
input onKeyPress(Keys UP, || fire())
input onKeyPress(Keys DOWN, || fire())
-
- input onKeyPress(Keys F1, || togglePower(Power DGUN))
- input onKeyPress(Keys F2, || togglePower(Power ARMOR))
- input onKeyPress(Keys F3, || togglePower(Power JETPACK))
- input onKeyPress(Keys F4, || togglePower(Power BOMB))
- input onKeyPress(Keys F5, || togglePower(Power BLOCK))
- input onKeyPress(Keys F6, || togglePower(Power SLOW))
- input onKeyPress(Keys F7, || togglePower(Power HOOK))
- }
-
- togglePower: func (which: Power) {
- level levelSelect togglePower(which)
}
hasPower: func (which: Power) -> Bool {
@@ -87,7 +75,7 @@ Hero: class extends Actor {
}
update: func (delta: Float) {
- if (input isPressed(Keys CTRL)) {
+ if (input isPressed(Keys CTRL) && hasPower(Power SLOW)) {
engine slomo = true
} else {
engine slomo = false
View
@@ -19,6 +19,15 @@ Medal: enum {
case This GOLD => 3
}
}
+
+ toString: func -> String {
+ match this {
+ case This NONE => "none"
+ case This BRONZE => "bronze"
+ case This SILVER => "silver"
+ case This GOLD => "gold"
+ }
+ }
}
Item: class {
@@ -103,11 +112,7 @@ LevelSelect: class extends Actor {
// powers
dgun := false
armor := false
- jetpack := false
- bomb := false
- block := false
slow := false
- hook := false
engine: Engine
ui: UI
@@ -116,6 +121,12 @@ LevelSelect: class extends Actor {
pass, gridPass, fgPass: Pass
selector: ImageSprite
+ powerDgun, powerArmor, powerTime: ImageSprite
+
+ dgunPoints := 60
+ armorPoints := 120
+ slowPoints := 200
+
colNum := 0
rowNum := 0
@@ -166,27 +177,19 @@ LevelSelect: class extends Actor {
clear()
}
- togglePower: func (which: Power) {
+ activatePower: func (which: Power) {
match which {
case Power DGUN => dgun = !dgun
case Power ARMOR => armor = !armor
- case Power JETPACK => jetpack = !jetpack
- case Power BOMB => bomb = !bomb
- case Power BLOCK => block = !block
case Power SLOW => slow = !slow
- case Power HOOK => hook = !hook
}
}
hasPower: func (which: Power) -> Bool {
match which {
case Power DGUN => dgun
case Power ARMOR => armor
- case Power JETPACK => jetpack
- case Power BOMB => bomb
- case Power BLOCK => block
case Power SLOW => slow
- case Power HOOK => hook
case => false
}
}
@@ -243,12 +246,31 @@ LevelSelect: class extends Actor {
if (item medal < medal) {
points += (medal val() - item medal val()) * 10
+
+ unlockItems()
item medal = medal
+ ui flash("Won %s medal on %s" format(medal toString(), item name))
}
if (item recordTime == -1 || millis < item recordTime) {
item recordTime = millis
- ui flash("New record: %s for %s!" format(TimeHelper format(millis), item name))
+ }
+ }
+
+ unlockItems: func {
+ if (points >= dgunPoints) {
+ dgun = true
+ powerDgun alpha = 1.0
+ }
+
+ if (points >= armorPoints) {
+ armor = true
+ powerArmor alpha = 1.0
+ }
+
+ if (points >= slowPoints) {
+ slow = true
+ powerTime alpha = 1.0
}
}
@@ -350,6 +372,23 @@ LevelSelect: class extends Actor {
pointsLabel color set!(1.0, 1.0, 1.0)
pass addSprite(pointsLabel)
+ // powers
+
+ powers := ImageSprite new(vec2(0, 0), "assets/png/powers.png")
+ pass addSprite(powers)
+
+ powerDgun = ImageSprite new(vec2(0, 0), "assets/png/power-dgun.png")
+ powerDgun alpha = 0
+ pass addSprite(powerDgun)
+
+ powerArmor = ImageSprite new(vec2(0, 0), "assets/png/power-armor.png")
+ powerArmor alpha = 0
+ pass addSprite(powerArmor)
+
+ powerTime = ImageSprite new(vec2(0, 0), "assets/png/power-time.png")
+ powerTime alpha = 0
+ pass addSprite(powerTime)
+
buildGrid()
}
View
@@ -3,9 +3,5 @@
Power: enum {
DGUN,
ARMOR,
- JETPACK,
- BOMB,
- BLOCK,
- SLOW,
- HOOK
+ SLOW
}

0 comments on commit 50166ea

Please sign in to comment.