Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
qamil committed Nov 5, 2011
2 parents badc99d + 8c81bf0 commit 38085c9
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 36 deletions.
16 changes: 9 additions & 7 deletions app.coffee
Expand Up @@ -40,12 +40,14 @@ require("zappa") 8080, ->

@get "/" : ->
redis_client = @redis_client();
redis_client.zrevrangebyscore "bashing::hosts", 100000000, 0, "WITHSCORES", (err, hosts) =>
redis_client.quit()
console.log err if err
@render "/shared/index.html",
foo: "bar",
hosts: hosts or []
title: "Index!"
redis_client.zrevrangebyscore "bashing::hosts", 100000000, -1, "WITHSCORES", (err, hosts) =>
redis_client.get "bashing::online.players", (err, onlineplayers) =>
redis_client.quit()
console.log err if err
@render "/shared/index.html",
foo: "bar",
hosts: hosts or [],
onlineplayers: onlineplayers or 0,
title: "Index!"


2 changes: 1 addition & 1 deletion host/host.html
Expand Up @@ -10,7 +10,7 @@
<div id="timer">test</div>
<canvas id="canvas"></canvas>

<div id="explanation"><a href="<%= name %>a">debug new</a> Play ? &nbsp; Scan →</div>
<div id="explanation">Play ? &nbsp; Scan →</div>

<div id="qr"></div>

Expand Down
3 changes: 2 additions & 1 deletion player/player.coffee
Expand Up @@ -22,7 +22,8 @@
window.location = "/error/host_not_found/" + GameHost.name
@on joined: ->
$ =>
$("#playername").val(@data.playername)
$("#player-information").css("background", "url(/img/units/unit#{(@data.id % 20)+1}.png) top left no-repeat")
$("#player-information").append(@data.playername)
@connect();
#$ =>
# #FIXME bind werkt niet goed op Android
Expand Down
30 changes: 27 additions & 3 deletions player/player.html
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" media="all" href="/css/player.css">
<title>Bashing: <%= title %></title>
<script>
window.GameHost = { name: '<%= name %>' }
Expand Down Expand Up @@ -41,7 +42,7 @@
height:180px;
background:url(/img/joystick_socket.png);
background-size:100% 100%;
margin-top:50px;
margin-top:80px;
margin-left:20px;
}
#gamepad-button {
Expand Down Expand Up @@ -70,16 +71,39 @@
height:20px;
position:absolute;
}

#pinup {
width:183px;
height:193px;
background:url(/img/pinup.png) no-repeat;
position:absolute;
right:100px;
top:60px;
}
#action-button {
width:85px;
height:91px;
background:url(/img/button.png) no-repeat;
opacity:0.8;
position:absolute;
right:50px;
top:160px;
}
#action-button:hover,
#action-button:focus {
opacity:1;
}
</style>
</head>
<body>
<div id="player-information"></div>
<div id="gamepad-container">
<div id="gamepad"><div id="gamepad-button"></div></div>
</div>
<div id="button-container"></div>

<div id="pinup"></div>
<div id="action-button"></div>
<div id="debug"></div>

<script src="/socket.io/socket.io.js"></script>
<script src="/zappa/zappa.js"></script>
<script src="http://code.jquery.com/jquery-1.7.min.js"></script>
Expand Down
7 changes: 5 additions & 2 deletions shared/index.html
@@ -1,4 +1,9 @@

<!--
=======
<h2>(<%= onlineplayers %>) online players!</h2>
>>>>>>> 8c81bf019ec884da40b7c799f9e5b5b2d1457f5f
<section id="host_game">
<form action="/game/create" method="post">
<h2>Host a new game</h2>
Expand Down Expand Up @@ -35,5 +40,3 @@ <h2>50 Most active games</h2>
<table>
</section>
-->

<a href="/">Start game</a>
1 change: 1 addition & 0 deletions static/css/host.css
Expand Up @@ -8,6 +8,7 @@ body {
background-image: url(/img/background2.jpg);
/* background-size: 100%; */
background-size: cover;
overflow: hidden;
}

#explanation {
Expand Down
36 changes: 36 additions & 0 deletions static/css/player.css
@@ -0,0 +1,36 @@
@font-face {
font-family: 'BadaBoomBBRegular';
src: url('/font/badabb__-webfont.eot');
src: url('/font/badabb__-webfont.eot?#iefix') format('embedded-opentype'),
url('/font/badabb__-webfont.woff') format('woff'),
url('/font/badabb__-webfont.ttf') format('truetype'),
url('/font/badabb__-webfont.svg#BadaBoomBBRegular') format('svg');
font-weight: normal;
font-style: normal;

}

@font-face {
font-family: 'PressStart2PRegular';
src: url('/font/pressstart2p-webfont.eot');
src: url('/font/pressstart2p-webfont.eot?#iefix') format('embedded-opentype'),
url('/font/pressstart2p-webfont.woff') format('woff'),
url('/font/pressstart2p-webfont.ttf') format('truetype'),
url('/font/pressstart2p-webfont.svg#PressStart2PRegular') format('svg');
font-weight: normal;
font-style: normal;
}

#player-information {
font-size:15px;
color:#fff;
font-family:PressStart2PRegular;

position:absolute;
left:200px;
top:20px;
width:200px;
height:200px;
padding-left:80px;
padding-top:20px;
}
13 changes: 8 additions & 5 deletions static/js/Physics.js
Expand Up @@ -31,11 +31,14 @@ function Physics(intervalRate, adaptive, width, height, scale) {
contactListener.BeginContact = function(contact, manifold) {
var fixA = contact.GetFixtureA();
var fixB = contact.GetFixtureB();
fixA.SetDensity(fixA.GetDensity() * 0.95);
fixA.GetBody().ResetMassData();
fixB.SetDensity(fixB.GetDensity() * 0.95);
fixB.GetBody().ResetMassData();

if (fixA.GetBody().GetType() == b2Body.b2_dynamicBody) {
fixA.SetDensity(fixA.GetDensity() * 0.95);
fixA.GetBody().ResetMassData();
}
if (fixB.GetBody().GetType() == b2Body.b2_dynamicBody) {
fixB.SetDensity(fixB.GetDensity() * 0.95);
fixB.GetBody().ResetMassData();
}
/*if(fixB.GetBody().GetType() == b2Body.b2_dynamicBody) { // Only dynamic bodies
var mass = fixB.GetBody().GetMass();
var newMassData = new b2MassData();
Expand Down
36 changes: 23 additions & 13 deletions static/js/Player.js
@@ -1,7 +1,6 @@
function Player(engine, id, playername) {
Entity.call(this, engine);
this.id = id;
this.name = id; // TODO
this.x = 3;
this.y = 3;
this.angle = 0;
Expand All @@ -11,10 +10,17 @@ function Player(engine, id, playername) {
this.label = null;
//this.oldForce = new b2Vec(0, 0);
this.isDead = false;
this.ballImg = new Image();
this.ballImg.src = '/img/units/wreckingball1.png';
this.engineImg = new Image();
this.engineImg.src = '/img/units/unit1.png';
this.ballImgs = [];
for (var i = 1; i <= 5; i++) {
this.ballImgs[i] = new Image();
this.ballImgs[i].src = '/img/units/wreckingball'+i+'.png'
}
this.engineImgs = [];
for (var i = 0; i < 20; i++) {
this.engineImgs[i] = new Image();
this.engineImgs[i].src = '/img/units/unit'+(i+1)+'.png';
}
this.engineImg = this.engineImgs[this.id % 20];
}
Player.prototype = new Entity();
Player.prototype.constructor = Player;
Expand All @@ -32,9 +38,11 @@ Player.prototype.update = function(state) {
this.angle = state.angle;



this.body.ApplyForce(new b2Vec2(
this.force.x, this.force.y), this.body.GetPosition());
var density = this.body.GetFixtureList().GetDensity();
this.body.ApplyForce(
new b2Vec2( this.force.x * density, this.force.y * density),
this.body.GetPosition()
);

Entity.prototype.update.call(this);
};
Expand All @@ -54,7 +62,13 @@ Player.prototype.draw = function(ctx) {

// Ball
ctx.rotate(this.angle);
ctx.drawImage(this.ballImg, - (this.ballImg.width /2), - (this.ballImg.height /2) , this.ballImg.width, this.ballImg.height);
var density = this.body.GetFixtureList().GetDensity();
var ballImg = this.ballImgs[1];
if(density < 0.2) ballImg = this.ballImgs[5];
else if(density < 0.4) ballImg = this.ballImgs[4];
else if(density < 0.6) ballImg = this.ballImgs[3];
else if(density < 0.8) ballImg = this.ballImgs[2];
ctx.drawImage(ballImg, - (ballImg.width /2), - (ballImg.height /2) , ballImg.width, ballImg.height);
ctx.rotate(-this.angle);

// Engine
Expand All @@ -65,15 +79,11 @@ Player.prototype.draw = function(ctx) {
ctx.rotate(Math.atan2(this.force.y, this.force.x));
//}


ctx.drawImage(this.engineImg, - (this.engineImg.width /2), - (this.engineImg.height /2) , this.engineImg.width, this.engineImg.height);

ctx.restore();

// Name
// TODO ctx.fillStyle
//ctx.fillText(this.name, m2px(this.x), m2px(this.y));

if (!this.label) {
this.label = $("<div/>", { "text": this.playername, "class": "playerLabel" });
$(document.body).append(this.label);
Expand Down
8 changes: 4 additions & 4 deletions static/js/gamepad/gamepad.js
Expand Up @@ -87,8 +87,8 @@ this.renderButton(this.x, this.y);

Gamepad.prototype.onTouchStart = function(e){
var bodyelem = $("body");
//bodyelem.scrollTop(25);
//e.preventDefault();
bodyelem.scrollTop(25);
e.preventDefault();
};

Gamepad.prototype.onTouchEnd = function(e){
Expand All @@ -103,7 +103,7 @@ Gamepad.prototype.onMove = function(e){
if(e.touches) {
pageX = e.touches[0].pageX;
pageY = e.touches[0].pageY;
}
}
else {
pageX = e.pageX
pageY = e.pageY
Expand All @@ -120,7 +120,7 @@ Gamepad.prototype.onMove = function(e){
y = Math.round(y * dPow);
}

utils.console.write('x:' + this.normalize(x) + ', y:' + this.normalize(y) + ', dist:' + distance + ', dpower:' + dPow);
//utils.console.write('x:' + this.normalize(x) + ', y:' + this.normalize(y) + ', dist:' + distance + ', dpower:' + dPow);

// nodejs trigger
this.sendMove(this.normalize(x), this.normalize(y));
Expand Down

0 comments on commit 38085c9

Please sign in to comment.