Permalink
Browse files

Invaders move slowly downwards in the most terribly-coded way I could

come up with
  • Loading branch information...
CarlQLange committed Apr 24, 2012
1 parent 0ff0b41 commit 6dd4d45cbafef19d9e6f82f9bb6ea21fba48fde4
Showing with 29 additions and 10 deletions.
  1. +13 −5 physicsinvaders2.coffee
  2. +16 −5 physicsinvaders2.js
View
@@ -27,9 +27,8 @@ window.main = () ->
initWorld()
initDebugDraw()
- times 5, ->
- new Invader(Math.random() * 400, Math.random() * 400)
-
+ #times 5, ->
+ new Invader(Math.random() * 400, Math.random() * 400)
gameloop = () ->
world.Step 1/FPS, 10, 10
@@ -95,7 +94,15 @@ class Invader
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
[ 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1 ]
[ 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0 ]
- ], @x, @y).addToWorld()
+ ], @x, @y)
+ @sp.addToWorld()
+
+ every 1/FPS, =>
+ for pi in @sp.pixels
+ #debugger
+
+ #b2Body.ApplyForce(/* b2Vec2 how much */, /* b2Vec2 from where */)
+ pi.p.body.SetLinearVelocity(new b2Vec2(0, 0)) #Don't use this!!
class Sprite
# de facto PixelManager
@@ -123,7 +130,8 @@ class Pixel
addToWorld: (x, y) ->
@bodyDef.position.x = x
@bodyDef.position.y = y
- world.CreateBody(@bodyDef).CreateFixture(@fixDef)
+ @body = world.CreateBody(@bodyDef)
+ @fixture = @body.CreateFixture(@fixDef)
#for drawing, later
x: -> @bodyDef.position.x
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 6dd4d45

Please sign in to comment.