-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lazers now disappear when they hit things, added enemies back in.
- Loading branch information
1 parent
ffaad50
commit 7bbb6af
Showing
1 changed file
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ var map_data = [ | |
|
||
",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,", | ||
",################################, ", | ||
",#@......#..............#.......#, ", | ||
",#@......#....g.........#.......#, ", | ||
",#.......#.......#......#.......#,,,,,,", | ||
",#....####.......#..............######,", | ||
",#....####.......#..g...........######,", | ||
",#....#..........#......#............#,", | ||
",#...............#......#............#,", | ||
",#....#....#######......########.....#,", | ||
|
@@ -17,11 +17,11 @@ var map_data = [ | |
" ,#...#, ,#...#,", | ||
" ,#...#,,,,,,,,,,,,#...#,", | ||
" ,#...#.############...#,", | ||
" ,#....................#,", | ||
" ,#....g...............#,", | ||
" ,######################,", | ||
" ,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,", | ||
" ,#############.#####, ", | ||
" ,#.................#,", | ||
" ,#.....g...........#,", | ||
" ,#.................#,", | ||
" ,###################,", | ||
" ,,,,,,,,,,,,,,,,,,,,,", | ||
|
@@ -119,16 +119,22 @@ var Game = (function () { | |
if (!map[y][x].walkable) | ||
return false; | ||
|
||
if (getEntityAtPosition(x, y) != null) | ||
return false; | ||
|
||
return true; | ||
}; | ||
|
||
var getEntityAtPosition = function(x, y) { | ||
for (var key in entities) { | ||
if (entities.hasOwnProperty(key)) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
var ch = entities[key]; | ||
if (ch.x() == x && ch.y() == y) | ||
return false; | ||
var entity = entities[key]; | ||
if (entity.x() == x && entity.y() == y) | ||
return entity; | ||
} | ||
} | ||
|
||
return true; | ||
}; | ||
return null; | ||
} | ||
|
||
var makeEntity = (function (x, y, ch, col) { | ||
var last_dir = { x: 1, y: 0 }; | ||
|
@@ -227,7 +233,13 @@ var Game = (function () { | |
base.last_dir = dir; | ||
|
||
base.act = function() { | ||
base.move(base.last_dir); | ||
if(!base.move(base.last_dir)){ | ||
for(var i=0; i < entities.length; i++) { | ||
if (entities[i].x == base.x && entities[i].y == base.y) | ||
entities.splice(i,1); | ||
This comment has been minimized.
Sorry, something went wrong.
Qu4Z
Owner
|
||
} | ||
scheduler.remove(base); | ||
} | ||
}; | ||
|
||
return base; | ||
|
I know I wrote this line, but it's time we used _.js. I've made an issue for it: #2