Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
fc6f91c2
Commit
fc6f91c2
authored
Sep 02, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1024 from vlidholt/master
Improvements to demo game
parents
75a63e0b
edbf5b73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+6
-7
game_objects.dart
examples/game/lib/game_objects.dart
+1
-0
player_state.dart
examples/game/lib/player_state.dart
+23
-2
No files found.
examples/game/lib/game_demo_node.dart
View file @
fc6f91c2
...
...
@@ -80,7 +80,6 @@ class GameDemoNode extends NodeWithSize {
PlayerState
_playerState
;
// Game properties
double
_scrollSpeed
=
2.0
;
double
_scroll
=
0.0
;
int
_framesToFire
=
0
;
...
...
@@ -95,11 +94,11 @@ class GameDemoNode extends NodeWithSize {
void
update
(
double
dt
)
{
// Scroll the level
_scroll
=
_level
.
scroll
(
_scrollSpeed
);
_starField
.
move
(
0.0
,
_scrollSpeed
);
_scroll
=
_level
.
scroll
(
_
playerState
.
scrollSpeed
);
_starField
.
move
(
0.0
,
_
playerState
.
scrollSpeed
);
_background
.
move
(
_scrollSpeed
*
0.1
);
_nebula
.
move
(
_scrollSpeed
);
_background
.
move
(
_
playerState
.
scrollSpeed
*
0.1
);
_nebula
.
move
(
_
playerState
.
scrollSpeed
);
// Add objects
addObjects
();
...
...
@@ -226,11 +225,11 @@ class GameDemoNode extends NodeWithSize {
_level
.
addChild
(
shot1
);
if
(
_playerState
.
sideLaserActive
)
{
Laser
shot2
=
new
Laser
(
_objectFactory
,
laserLevel
,
0
.0
);
Laser
shot2
=
new
Laser
(
_objectFactory
,
laserLevel
,
-
45
.0
);
shot2
.
position
=
_level
.
ship
.
position
+
new
Offset
(
17.0
,
-
10.0
);
_level
.
addChild
(
shot2
);
Laser
shot3
=
new
Laser
(
_objectFactory
,
laserLevel
,
180
.0
);
Laser
shot3
=
new
Laser
(
_objectFactory
,
laserLevel
,
-
135
.0
);
shot3
.
position
=
_level
.
ship
.
position
+
new
Offset
(-
17.0
,
-
10.0
);
_level
.
addChild
(
shot3
);
}
...
...
examples/game/lib/game_objects.dart
View file @
fc6f91c2
...
...
@@ -462,6 +462,7 @@ enum PowerUpType {
shield
,
speedLaser
,
sideLaser
,
speedBoost
,
}
List
<
PowerUpType
>
_powerUpTypes
=
new
List
.
from
(
PowerUpType
.
values
);
...
...
examples/game/lib/player_state.dart
View file @
fc6f91c2
...
...
@@ -30,6 +30,12 @@ class PlayerState extends Node {
int
laserLevel
=
0
;
static
const
double
normalScrollSpeed
=
2.0
;
double
scrollSpeed
=
normalScrollSpeed
;
double
_scrollSpeedTarget
=
normalScrollSpeed
;
Sprite
_sprtBgScore
;
ScoreDisplay
_scoreDisplay
;
Sprite
_sprtBgCoins
;
...
...
@@ -80,12 +86,15 @@ class PlayerState extends Node {
_sideLaserFrames
+=
300
;
}
else
if
(
type
==
PowerUpType
.
speedLaser
)
{
_speedLaserFrames
+=
300
;
}
else
if
(
type
==
PowerUpType
.
speedBoost
)
{
_speedBoostFrames
+=
300
;
}
}
int
_shieldFrames
=
0
;
bool
get
shieldActive
=>
_shieldFrames
>
0
;
bool
get
shieldDeactivating
=>
_shieldFrames
>
0
&&
_shieldFrames
<
60
;
bool
get
shieldActive
=>
_shieldFrames
>
0
||
_speedBoostFrames
>
0
;
bool
get
shieldDeactivating
=>
math
.
max
(
_shieldFrames
,
_speedBoostFrames
)
>
0
&&
math
.
max
(
_shieldFrames
,
_speedBoostFrames
)
<
60
;
int
_sideLaserFrames
=
0
;
bool
get
sideLaserActive
=>
_sideLaserFrames
>
0
;
...
...
@@ -93,6 +102,9 @@ class PlayerState extends Node {
int
_speedLaserFrames
=
0
;
bool
get
speedLaserActive
=>
_speedLaserFrames
>
0
;
int
_speedBoostFrames
=
0
;
bool
get
speedBoostActive
=>
_speedBoostFrames
>
0
;
void
flashBgSprite
(
Sprite
sprt
)
{
sprt
.
actions
.
stopAll
();
ActionTween
flash
=
new
ActionTween
(
...
...
@@ -107,6 +119,15 @@ class PlayerState extends Node {
if
(
_shieldFrames
>
0
)
_shieldFrames
--;
if
(
_sideLaserFrames
>
0
)
_sideLaserFrames
--;
if
(
_speedLaserFrames
>
0
)
_speedLaserFrames
--;
if
(
_speedBoostFrames
>
0
)
_speedBoostFrames
--;
// Update speed
if
(
speedBoostActive
)
_scrollSpeedTarget
=
normalScrollSpeed
*
6.0
;
else
_scrollSpeedTarget
=
normalScrollSpeed
;
scrollSpeed
=
GameMath
.
filter
(
scrollSpeed
,
_scrollSpeedTarget
,
0.1
);
}
}
...
...
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