Skip to content

Commit

Permalink
Merge branch 'master' of github.com:MathiasPaumgarten/marblerun
Browse files Browse the repository at this point in the history
  • Loading branch information
stravid committed Feb 11, 2011
2 parents 32a25c1 + ba149db commit ffad3fe
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 198 deletions.
5 changes: 3 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,12 @@
</tr>
</table>

<% #ActionView::Helpers::AssetTagHelper.register_javascript_expansion :marblerun => ["prototype", "cookie", "box2d/box2d", "marblerun/utilities/rectangle", "marblerun/utilities/utilities", "marblerun/utilities/pattern", "marblerun/utilities/event", "marblerun/utilities/eventengine", "marblerun/utilities/displayobject", "marblerun/bricks/brick", "marblerun/bricks/kicker", "marblerun/bricks/ramp", "marblerun/bricks/curve", "marblerun/bricks/line", "marblerun/bricks/exit", "marblerun/bricks/spring", "marblerun/bricks/boost", "marblerun/bricks/ball", "marblerun/bricks/breaker", "marblerun/bricks/beamer", "marblerun/bricks/oneway", "marblerun/grid", "marblerun/toolbox", "marblerun/field", "marblerun/renderer", "marblerun/editor", "marblerun/showroom", "marblerun/meter", "marblerun/sidebarcontroller", "marblerun/contentloader", "marblerun/trackstore"] %>
<% ActionView::Helpers::AssetTagHelper.register_javascript_expansion :marblerun => ["prototype", "cookie", "box2d/box2d", "marblerun/utilities/rectangle", "marblerun/utilities/utilities", "marblerun/utilities/pattern", "marblerun/utilities/event", "marblerun/utilities/eventengine", "marblerun/utilities/displayobject", "marblerun/bricks/brick", "marblerun/bricks/kicker", "marblerun/bricks/ramp", "marblerun/bricks/curve", "marblerun/bricks/line", "marblerun/bricks/exit", "marblerun/bricks/spring", "marblerun/bricks/boost", "marblerun/bricks/ball", "marblerun/bricks/breaker", "marblerun/bricks/beamer", "marblerun/bricks/oneway", "marblerun/bricks/graviton", "marblerun/grid", "marblerun/toolbox", "marblerun/field", "marblerun/renderer", "marblerun/editor", "marblerun/showroom", "marblerun/meter", "marblerun/sidebarcontroller", "marblerun/contentloader", "marblerun/trackstore"] %>
<% ActionView::Helpers::AssetTagHelper.register_javascript_expansion :marblerun => ["marblerun-compiled"] %>
<% #ActionView::Helpers::AssetTagHelper.register_javascript_expansion :marblerun => ["marblerun-compiled"] %>
<%= javascript_include_tag :marblerun %>

</body>

</html>
Binary file modified public/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 15 additions & 9 deletions public/javascripts/marblerun/bricks/beamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ var Beamer = new Class.create(Brick, {
this.partner = null;
this.hasBeamed = false;
},

reset: function() {

this.hasBeamed = false;

},

drawShape: function(context) {

Expand All @@ -28,6 +34,8 @@ var Beamer = new Class.create(Brick, {

context.fill();

context.clearShadow();

context.stroke();
},

Expand Down Expand Up @@ -129,17 +137,15 @@ var Beamer = new Class.create(Brick, {

if (this.partner && !this.hasBeamed) {

var rotateVector = function(vector, angle) {
return new b2Vec2(
vector.x * Math.cos(angle) - vector.y * Math.sin(angle),
vector.x * Math.sin(angle) + vector.y * Math.cos(angle)
);
};

var positionOffset = rotateVector(new b2Vec2(0, -0.1), this.partner.rotation);
var positionOffset = this.rotateVector(new b2Vec2(0, -0.1), this.partner.rotation);

ball.positionVector.Set(this.partner.cell.col + 0.5 + positionOffset.x, this.partner.cell.row + 0.5 + positionOffset.y);
ball.velocityVector = rotateVector(ball.body.GetLinearVelocity(), this.partner.rotation - this.rotation + Math.PI);

positionOffset.Multiply(10);
positionOffset.Multiply(ball.body.GetLinearVelocity().Length());
ball.velocityVector = positionOffset;

//ball.velocityVector = this.rotateVector(ball.body.GetLinearVelocity(), this.partner.rotation - this.rotation + Math.PI);

this.hasBeamed = this.partner.hasBeamed = true;
}
Expand Down
91 changes: 59 additions & 32 deletions public/javascripts/marblerun/bricks/boost.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,69 @@ var Boost = new Class.create(Brick, {
},

drawShape: function(context) {

context.strokeStyle = context.fillStyle;
context.lineWidth = 2;

context.beginPath();

// context.moveTo(Brick.SIZE * 4 / 5, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE / 5, Brick.SIZE * 9 / 10);
// context.lineTo(Brick.SIZE / 5, Brick.SIZE * 7/ 10);
// context.lineTo(Brick.SIZE / 2, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE / 5, Brick.SIZE * 3 / 10);
// context.lineTo(Brick.SIZE / 5, Brick.SIZE / 10);

// context.beginPath();
// context.moveTo(Brick.SIZE / 7, Brick.SIZE / 7);
// context.lineTo(Brick.SIZE * 2 / 7, Brick.SIZE / 7);
// context.lineTo(Brick.SIZE * 4 / 7, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE * 2 / 7, Brick.SIZE * 6 / 7);
// context.lineTo(Brick.SIZE / 7, Brick.SIZE * 6 / 7);
// context.lineTo(Brick.SIZE * 3 / 7, Brick.SIZE / 2);
// context.closePath();
//
// context.fill();
//
// context.beginPath();
// context.moveTo(Brick.SIZE * 3 / 7, Brick.SIZE / 7);
// context.lineTo(Brick.SIZE * 4 / 7, Brick.SIZE / 7);
// context.lineTo(Brick.SIZE * 6 / 7, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE * 4 / 7, Brick.SIZE * 6 / 7);
// context.lineTo(Brick.SIZE * 3 / 7, Brick.SIZE * 6 / 7);
// context.lineTo(Brick.SIZE * 5 / 7, Brick.SIZE / 2);
// context.closePath();
//
// context.fill();

//context.fill();
context.beginPath();
context.moveTo(Brick.SIZE / 7, Brick.SIZE * 3 / 14);
context.lineTo(Brick.SIZE * 2 / 7, Brick.SIZE * 3 / 14);
context.lineTo(Brick.SIZE * 4 / 7, Brick.SIZE / 2);
context.lineTo(Brick.SIZE * 2 / 7, Brick.SIZE * 11 / 14);
context.lineTo(Brick.SIZE / 7, Brick.SIZE * 11 / 14);
context.lineTo(Brick.SIZE * 3 / 7, Brick.SIZE / 2);
context.closePath();

context.moveTo(Brick.SIZE / 5, Brick.SIZE / 5);
context.lineTo(Brick.SIZE * 2 / 5, Brick.SIZE / 2);
context.lineTo(Brick.SIZE / 5, Brick.SIZE * 4 / 5);
context.fill();

context.moveTo(Brick.SIZE * 2 / 5, Brick.SIZE / 5);
context.lineTo(Brick.SIZE * 3 / 5, Brick.SIZE / 2);
context.lineTo(Brick.SIZE * 2 / 5, Brick.SIZE * 4 / 5);
context.beginPath();
context.moveTo(Brick.SIZE * 3 / 7, Brick.SIZE * 3 / 14);
context.lineTo(Brick.SIZE * 4 / 7, Brick.SIZE * 3 / 14);
context.lineTo(Brick.SIZE * 6 / 7, Brick.SIZE / 2);
context.lineTo(Brick.SIZE * 4 / 7, Brick.SIZE * 11 / 14);
context.lineTo(Brick.SIZE * 3 / 7, Brick.SIZE * 11 / 14);
context.lineTo(Brick.SIZE * 5 / 7, Brick.SIZE / 2);
context.closePath();

context.moveTo(Brick.SIZE * 3 / 5, Brick.SIZE / 5);
context.lineTo(Brick.SIZE * 4 / 5, Brick.SIZE / 2);
context.lineTo(Brick.SIZE * 3 / 5, Brick.SIZE * 4 / 5);
context.fill();

context.stroke();
// context.strokeStyle = context.fillStyle;
// context.lineWidth = 2;
//
// context.beginPath();
//
// context.moveTo(Brick.SIZE / 5, Brick.SIZE / 5);
// context.lineTo(Brick.SIZE * 2 / 5, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE / 5, Brick.SIZE * 4 / 5);
//
// context.moveTo(Brick.SIZE * 2 / 5, Brick.SIZE / 5);
// context.lineTo(Brick.SIZE * 3 / 5, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE * 2 / 5, Brick.SIZE * 4 / 5);
//
// context.moveTo(Brick.SIZE * 3 / 5, Brick.SIZE / 5);
// context.lineTo(Brick.SIZE * 4 / 5, Brick.SIZE / 2);
// context.lineTo(Brick.SIZE * 3 / 5, Brick.SIZE * 4 / 5);
//
// context.stroke();
},

createShapes: function(body) {
Expand Down Expand Up @@ -74,16 +108,9 @@ var Boost = new Class.create(Brick, {
ball = contact.shape2.GetBody().ballInstance;
}

var rotateVector = function(vector, angle) {
return new b2Vec2(
vector.x * Math.cos(angle) - vector.y * Math.sin(angle),
vector.x * Math.sin(angle) + vector.y * Math.cos(angle)
);
};

var boostVector = new b2Vec2(1, 0);

ball.impulseVector.Add(rotateVector(boostVector, this.body.GetAngle()));
ball.impulseVector.Add(this.rotateVector(boostVector, this.body.GetAngle()));

}

Expand Down
Loading

0 comments on commit ffad3fe

Please sign in to comment.