Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
citius-invaders
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomás Teijeiro Campo
citius-invaders
Commits
3a58a5c7
Commit
3a58a5c7
authored
Jun 16, 2016
by
Pablo R. Mier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a few comments on Game.js
parent
bf4f385b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
14 deletions
+12
-14
Game.js
Game.js
+12
-14
No files found.
Game.js
View file @
3a58a5c7
// Game global config vars
// Game global config vars
[MOVE TO SETTINGS]
var
WALL_MARGIN
=
80
;
var
DIR_CHANGE_MIN_TIME
=
10
;
...
...
@@ -62,28 +62,18 @@ invadersApp.Game.prototype = {
this
.
objects
.
invaders
=
this
.
add
.
group
();
this
.
objects
.
invaders
.
enableBody
=
true
;
this
.
objects
.
invaders
.
physicsBodyType
=
Phaser
.
Physics
.
ARCADE
;
for
(
var
i
=
0
;
i
<
INITIAL_INVADERS
;
i
++
)
this
.
objects
.
invaders
.
add
(
new
invadersApp
.
Invader
(
this
));
// Create and add the main player
this
.
player
=
new
invadersApp
.
Player
(
this
);
this
.
game
.
add
.
existing
(
this
.
player
);
// Create a white, immovable wall with physics enabled
this
.
createWall
();
this
.
cursors
=
this
.
game
.
input
.
keyboard
.
createCursorKeys
();
this
.
fireButton
=
this
.
game
.
input
.
keyboard
.
addKey
(
Phaser
.
Keyboard
.
SPACEBAR
);
var
readyText
=
invadersApp
.
utils
.
addText
(
this
,
this
.
game
.
width
/
2
,
this
.
game
.
height
/
2
,
'
READY!
'
,
5
);
this
.
game
.
input
.
keyboard
.
onDownCallback
=
function
()
{
that
.
game
.
paused
=
false
;
if
(
readyText
.
visible
){
readyText
.
kill
();
}
};
this
.
game
.
paused
=
true
;
// New generation event, check for every second
this
.
game
.
time
.
events
.
loop
(
Phaser
.
Timer
.
SECOND
,
this
.
createGeneration
,
this
);
...
...
@@ -99,6 +89,14 @@ invadersApp.Game.prototype = {
},
this
);
},
this
);
// Start the game paused with the message READY!
var
readyText
=
invadersApp
.
utils
.
addText
(
this
,
this
.
game
.
width
/
2
,
this
.
game
.
height
/
2
,
'
READY!
'
,
5
);
this
.
game
.
input
.
keyboard
.
onDownCallback
=
function
()
{
that
.
game
.
paused
=
false
;
if
(
readyText
.
visible
)
readyText
.
kill
();
};
this
.
game
.
paused
=
true
;
},
update
:
function
()
{
...
...
@@ -106,7 +104,7 @@ invadersApp.Game.prototype = {
var
that
=
this
;
// If physics are paused, skip all
//
if (this.game.physics.arcade.isPaused) return;
if
(
this
.
game
.
physics
.
arcade
.
isPaused
)
return
;
this
.
game
.
physics
.
arcade
.
collide
(
this
.
wall
,
this
.
objects
.
invaders
);
this
.
game
.
physics
.
arcade
.
overlap
(
this
.
player
.
bullets
,
this
.
objects
.
invaders
,
function
(
bullet
,
invader
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment