Permalink
Browse files

More bugfixes. Kinda.

  • Loading branch information...
1 parent a2cf815 commit c58a66579268bb6146e36ebcdf7ddf9b8da089e3 Amos Wenger committed Aug 26, 2012
Showing with 91 additions and 8 deletions.
  1. +21 −0 assets/levels/booma1.txt
  2. +21 −0 assets/levels/booma2.txt
  3. +4 −0 assets/levels/plan.txt
  4. +45 −8 source/Block.ooc
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ u
+
+ > <
+
+
+
+
+========
+
+
+
+ d
+ =
+
+
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+ =)=
+
+
+
+
+========
+
+
+
+ d
+ =
+
+
@@ -45,6 +45,10 @@ file: drill.txt
file: booma1.txt
+## No really
+
+file: booma2.txt
+
# Spike land
## Friendly.. not?
View
@@ -13,6 +13,7 @@ Block: class extends Actor {
x, y: Int
permanent := false
+ dead := false
box: Box
dir := vec2(0, 0)
@@ -23,6 +24,8 @@ Block: class extends Actor {
speed := 3.0
+ playCount := 0
+
sprite: ImageSprite
init: func (=engine, =level, =image, =x, =y) {
@@ -53,39 +56,73 @@ Block: class extends Actor {
}
}
- kick: func {
+ orientation: func -> Vec2 {
match image {
case "dblock-r" =>
- dir set!(1, 0)
+ vec2(1, 0)
case "dblock-l" =>
- dir set!(-1, 0)
+ vec2(-1, 0)
case "dblock-d" =>
- dir set!(0, 1)
+ vec2(0, 1)
case "dblock-u" =>
- dir set!(0, -1)
+ vec2(0, -1)
+ case =>
+ vec2(0, 0)
+ }
+ }
+
+ kick: func {
+ match image {
case "ice" =>
_destroy()
+ case =>
+ if (!dead) {
+ dir set!(orientation())
+ }
}
}
update: func (delta: Float) {
- if (dir squaredNorm() > 0.01) {
+ if (dead) return
+
+ if (playCount > 0) {
+ playCount -= 1
+ }
+
+ moving := dir squaredNorm() > 0.01
+
+ if (moving) {
pos add!(dir mul(speed))
for (block in level blocks) {
if (block == this) continue
bang := box collide(block box)
if (bang) {
if (block inert || block dir squaredNorm() < 0.1) {
- block touch(bang)
+ dir1 := dir
+ dir2 := block orientation()
+ dot := dir1 dot(dir2)
+ //"our dir = %s, their dir = %s, dot = %.2f" printfln(dir1 _, dir2 _, dot)
+
+ if (dot >= -0.5) {
+ block touch(bang)
+ }
+
pos add!(bang dir mul(bang depth))
pos set!(pos snap(SIDE))
if (permanent) {
dir set!(dir mul(-1))
} else {
dir set!(0, 0)
+ if (block inert) {
+ dead = true
+ }
+ }
+
+ if (playCount <= 0) {
+ level play("boom")
+ playCount = 15
}
- level play("boom")
}
}
}

0 comments on commit c58a665

Please sign in to comment.