Skip to content

Commit

Permalink
Cannot build buildings half outside of map
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaravishankar committed Jan 29, 2012
1 parent 3644e95 commit 4765ade
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/cnc.js
Expand Up @@ -149,7 +149,8 @@ $(function() {
for (var y=0; y < grid.length; y++) {
for (var x=0; x < grid[y].length; x++) {
if(grid[y][x] == 1){
if (game.buildingObstructionGrid[mouse.gridY+y][mouse.gridX+x] == 1){
if (mouse.gridY+y<0||mouse.gridY+y>=game.buildingObstructionGrid.length||mouse.gridX+x<0||mouse.gridX+x>= game.buildingObstructionGrid[mouse.gridY+y].length|| game.buildingObstructionGrid[mouse.gridY+y][mouse.gridX+x] == 1){
//if (game.buildingObstructionGrid[mouse.gridY+y][mouse.gridX+x] == 1){
game.highlightGrid(mouse.gridX+x,mouse.gridY+y,1,1,sidebar.placementRedImage);
} else {
game.highlightGrid(mouse.gridX+x,mouse.gridY+y,1,1,sidebar.placementWhiteImage);
Expand Down Expand Up @@ -1013,10 +1014,11 @@ $(function() {
//grid.push(grid[1]);
for (var y=0; y < grid.length; y++) {
for (var x=0; x < grid[y].length; x++) {

if(grid[y][x] == 1){
if (game.buildingObstructionGrid[mouse.gridY+y][mouse.gridX+x] == 1){
console.log("mouse.gridX+x"+(mouse.gridX+x)+"mouse.gridY+y:"+(mouse.gridY+y))
if (mouse.gridY+y<0||mouse.gridY+y>=game.buildingObstructionGrid.length||mouse.gridX+x<0||mouse.gridX+x>= game.buildingObstructionGrid[mouse.gridY+y].length|| game.buildingObstructionGrid[mouse.gridY+y][mouse.gridX+x] == 1){
sounds.play('cannot_deploy_here');

return;
}
}
Expand Down Expand Up @@ -3643,8 +3645,8 @@ $(function() {
// {x1:8,y1:8,x2:10,y2:10,type:'tree-1'},
//{x1:8,y1:8,x2:10,y2:10,type:'tiberium-1'}
], //the trees and tiberium .. can terrain and overlay be in the same?
gridWidth:32,
gridHeight:32,
gridWidth:31,
gridHeight:31,
team:'gdi',
briefing:'This is a warning \n for all of you \n Kill enemy troops and have some fun',
items: {
Expand Down

0 comments on commit 4765ade

Please sign in to comment.