Permalink
Browse files

Pressing space tells you via console if your close to an item or not.…

… Items are red 5x5 squares throughout the realm. Also new package.json from deploying.
  • Loading branch information...
1 parent 2bc39d6 commit cf61d8d3e8b99d179ed3790c290203bf52dbdd46 @cjstewart88 committed Apr 15, 2012
Showing with 8 additions and 9 deletions.
  1. +1 −1 package.json
  2. +5 −6 public/javascripts/client.js
  3. +2 −2 server.js
View
@@ -1,6 +1,6 @@
{
"name": "hudln",
- "version": "0.0.1-15",
+ "version": "0.0.1-17",
"dependencies": {
"express": "*",
"socket.io": "*",
@@ -38,9 +38,7 @@
}
else if (direction == "up" || direction == "down") {
clients[client_moving_id][1] = new_value;
- }
-
- console.log("x: "+clients[client_moving_id][0]+" y: "+clients[client_moving_id][1]);
+ }
draw_realm();
}
@@ -113,10 +111,11 @@
my_y = clients[my_client_id][1];
$.each(realm_items_available_to_client, function () {
- var dx = this.item_x - my_x;
- var dy = this.item_y - my_y;
+ var dx = this.item_x - (my_x + 5);
+ var dy = this.item_y - (my_y + 5);
+ var dist = Math.floor(Math.sqrt((dx * dx) + (dy * dy)));
- if (dx * dx + dy * dy <= 25 * 25) {
+ if (dist <= 20 || dist == 21) {
console.log("close to item");
}
});
View
@@ -105,8 +105,8 @@ function generate_items () {
for (var i = 0; i < 100; i++) {
generated_items.push({
item_id: i,
- item_x: Math.floor(Math.random()*209)*10,
- item_y: Math.floor(Math.random()*209)*10
+ item_x: Math.floor(Math.random()*190)*10,
+ item_y: Math.floor(Math.random()*190)*10
})
}

0 comments on commit cf61d8d

Please sign in to comment.