Skip to content

Commit

Permalink
Last tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Amos Wenger committed Apr 24, 2012
1 parent c8e6b72 commit f353732
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
15 changes: 8 additions & 7 deletions source/game/Buildables.ooc
Expand Up @@ -81,7 +81,7 @@ Building: class extends Buildable {
places: Int

tenants := 0
glowingBulb: EllipseSprite
glowingBulb: RectSprite

slurpTime := 10
leaseTime := 150
Expand Down Expand Up @@ -111,11 +111,12 @@ Building: class extends Buildable {
}

loadSprite: func {
offset := vec2(level terrain tileWidth, -65)
offset := vec2(level terrain tileWidth, -35)

glowingBulb = EllipseSprite new(offset)
glowingBulb = RectSprite new(offset)
glowingBulb size set!(50, 0)
glowingBulb filled = true
glowingBulb alpha = 1.0
glowingBulb color set!(0.9, 0.9, 0.1)
sprite add(glowingBulb)

sprite add(loadIsoImage("assets/png/building.png"))
Expand All @@ -125,8 +126,8 @@ Building: class extends Buildable {
percentage := tenants * 100 / places
radius := level terrain tileWidth * (0.5 + percentage / 200.0)

glowingBulb radius = radius
glowingBulb color set!(percentage / 200.0, percentage / 200.0, 0)
glowingBulb size y = radius
glowingBulb pos y = - radius / 2 + 10
}

logic: func {
Expand Down Expand Up @@ -221,7 +222,7 @@ Tree: class extends Buildable {


/*
* LAVA !
* LAVA ! (unfinished :( )
*/

Lava: class extends Buildable {
Expand Down
3 changes: 2 additions & 1 deletion source/game/Level.ooc
Expand Up @@ -274,13 +274,14 @@ Level: class {
case "tree" =>
dropBuildable(Tree new(this))
case =>
ui boombox play(ui nopeSound)
ui boombox play(ui nopeSound)
}
}

dropBuildable: func (buildable: Buildable) {
if (player cash <= buildable cost) {
ui boombox play(ui nopeSound)
buildable destroy()
} else {
drp := Dropper new(this, |pos|
buildable pos set!(pos)
Expand Down
5 changes: 4 additions & 1 deletion source/game/LevelLoader.ooc
Expand Up @@ -43,19 +43,22 @@ LevelLoader: class extends Loader {

loadStGall: func (level: Level) {
level maxHomeless = 80
level player cash = 500
level objective = "Earn 3000 CHF"
level winConditions add(EarnAtLeast new(3000))
}

loadZuerich: func (level: Level) {
level maxHomeless = 40
level player cash = 300
level objective = "Build 5 towers"
level winConditions add(HaveNThings new(5, Tower))
}

loadRomandy: func (level: Level) {
level maxHomeless = 20
level objective = "Don't let any homeless die"
level player cash = 200
level objective = "Don't let any homeless die (unfinished level :()"
level winConditions add(ZeroDeath new())
}

Expand Down
18 changes: 9 additions & 9 deletions source/ui/MainUI.ooc
Expand Up @@ -180,20 +180,20 @@ MainUI: class {
}

createLeftToolbar: func -> Toolbar {
tb := Toolbar new(this, vec2(160, 70), Placement WEST)
tb add(Item new("Restart level", || engine reload()))
tb add(Item new("Previous level", || engine jumpLevel(-1) ))
tb add(Item new("Next level", || engine jumpLevel(1) ))
tb add(Item new("Exit", || exit(0)))
tb := Toolbar new(this, vec2(180, 70), Placement WEST)
tb add(Item new("Restart level", null, || engine reload()))
tb add(Item new("Previous level", null, || engine jumpLevel(-1) ))
tb add(Item new("Next level", null, || engine jumpLevel(1) ))
tb add(Item new("Exit", null, || exit(0)))
tb
}

createRightToolbar: func -> Toolbar {
tb := Toolbar new(this, vec2(140, 140), Placement EAST)
tb add(Item new("Tree", || engine level drop("tree")))
tb add(Item new("House", || engine level drop("house")))
tb add(Item new("Building", || engine level drop("building")))
tb add(Item new("Tower", || engine level drop("tower")))
tb add(Item new("100 CHF", "assets/png/tree.png", || engine level drop("tree")))
tb add(Item new("250 CHF", "assets/png/house.png", || engine level drop("house")))
tb add(Item new("600 CHF", "assets/png/building.png", || engine level drop("building")))
tb add(Item new("1300 CHF", "assets/png/phaser.png", || engine level drop("tower")))
tb
}

Expand Down
19 changes: 16 additions & 3 deletions source/ui/Toolbar.ooc
Expand Up @@ -148,7 +148,10 @@ Item: class {

onPress: Func

init: func (=name, =onPress) {
ls: LabelSprite
is: ImageSprite

init: func (=name, =icon, =onPress) {
// FIXME: static initialization workaround suxxorz
if (colors empty?()) {
colors add(s1 := ItemState IDLE, vec3(0.5, 0.5, 0.5))
Expand All @@ -170,14 +173,24 @@ Item: class {
rect2 filled = false
sprite add(rect2)

ls := LabelSprite new(vec2(0, 0), name)
ls color set!(0.2, 0.2, 0.2)
ls = LabelSprite new(vec2(0, 0), name)
ls color set!(0.1, 0.1, 0.1)
ls centered = true
sprite add(ls)

if (icon) {
is = ImageSprite new(vec2(0, 0), icon)
is scale set!(0.5, 0.5)
is pos set!(- is width / 4, - is height / 4)
sprite add(is)
}
}

setSize: func (=width, =height) {
rect size set!(width, height)
if (icon) {
ls pos y = height / 2 - 15
}
}

hasPressed := false
Expand Down

0 comments on commit f353732

Please sign in to comment.