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
d79b3598
Commit
d79b3598
authored
Sep 02, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves on demo game balance and adds levels for lasers
parent
1c3831e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
22 deletions
+57
-22
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+14
-8
game_objects.dart
examples/game/lib/game_objects.dart
+41
-14
player_state.dart
examples/game/lib/player_state.dart
+2
-0
No files found.
examples/game/lib/game_demo_node.dart
View file @
d79b3598
...
...
@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0;
double
_gameSizeHeight
=
320.0
;
final
double
_chunkSpacing
=
640.0
;
final
int
_chunksPerLevel
=
6
;
final
int
_chunksPerLevel
=
8
;
final
bool
_drawDebug
=
false
;
...
...
@@ -198,33 +198,39 @@ class GameDemoNode extends NodeWithSize {
lbl
.
position
=
new
Point
(
0.0
,
yPos
+
_chunkSpacing
/
2.0
-
150.0
);
_level
.
addChild
(
lbl
);
}
else
if
(
part
==
1
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
_objectFactory
.
addAsteroids
(
10
+
level
*
2
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
else
if
(
part
==
2
)
{
_objectFactory
.
addEnemyScoutSwarm
(
4
+
level
*
2
,
yPos
);
}
else
if
(
part
==
3
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
_objectFactory
.
addAsteroids
(
10
+
level
*
2
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
else
if
(
part
==
4
)
{
_objectFactory
.
addEnemyDestroyerSwarm
(
2
+
level
,
yPos
);
}
else
if
(
part
==
5
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
_objectFactory
.
addAsteroids
(
10
+
level
*
2
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
else
if
(
part
==
6
)
{
_objectFactory
.
addEnemyScoutSwarm
(
4
+
level
*
2
,
yPos
);
}
else
if
(
part
==
7
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
2
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
}
void
fire
()
{
Laser
shot0
=
new
Laser
(
_objectFactory
,
-
90.0
);
int
laserLevel
=
_objectFactory
.
playerState
.
laserLevel
;
Laser
shot0
=
new
Laser
(
_objectFactory
,
laserLevel
,
-
90.0
);
shot0
.
position
=
_level
.
ship
.
position
+
new
Offset
(
17.0
,
-
10.0
);
_level
.
addChild
(
shot0
);
Laser
shot1
=
new
Laser
(
_objectFactory
,
-
90.0
);
Laser
shot1
=
new
Laser
(
_objectFactory
,
laserLevel
,
-
90.0
);
shot1
.
position
=
_level
.
ship
.
position
+
new
Offset
(-
17.0
,
-
10.0
);
_level
.
addChild
(
shot1
);
if
(
_playerState
.
sideLaserActive
)
{
Laser
shot2
=
new
Laser
(
_objectFactory
,
0.0
);
Laser
shot2
=
new
Laser
(
_objectFactory
,
laserLevel
,
0.0
);
shot2
.
position
=
_level
.
ship
.
position
+
new
Offset
(
17.0
,
-
10.0
);
_level
.
addChild
(
shot2
);
Laser
shot3
=
new
Laser
(
_objectFactory
,
180.0
);
Laser
shot3
=
new
Laser
(
_objectFactory
,
laserLevel
,
180.0
);
shot3
.
position
=
_level
.
ship
.
position
+
new
Offset
(-
17.0
,
-
10.0
);
_level
.
addChild
(
shot3
);
}
...
...
examples/game/lib/game_objects.dart
View file @
d79b3598
...
...
@@ -92,7 +92,7 @@ class LevelLabel extends GameObject {
canBeDamaged
=
false
;
Label
lbl
=
new
Label
(
"L
EVE
L
$level
"
,
"L
E V E
L
$level
"
,
new
TextStyle
(
textAlign:
TextAlign
.
center
,
color:
new
Color
(
0xffffffff
),
...
...
@@ -156,27 +156,54 @@ class Ship extends GameObject {
}
class
Laser
extends
GameObject
{
double
impact
=
1.0
;
Laser
(
GameObjectFactory
f
,
double
r
)
:
super
(
f
)
{
// Add sprite
_sprt
=
new
Sprite
(
f
.
sheet
[
"explosion_particle.png"
]);
_sprt
.
scale
=
0.5
;
_sprt
.
colorOverlay
=
new
Color
(
0xff95f4fb
);
_sprt
.
transferMode
=
sky
.
TransferMode
.
plus
;
_sprt
.
rotation
=
r
+
90.0
;
addChild
(
_sprt
);
double
impact
=
0.0
;
final
List
<
Color
>
laserColors
=
[
new
Color
(
0xff95f4fb
),
new
Color
(
0xff5bff35
),
new
Color
(
0xffff886c
),
new
Color
(
0xffffd012
),
new
Color
(
0xfffd7fff
)
];
Laser
(
GameObjectFactory
f
,
int
level
,
double
r
)
:
super
(
f
)
{
// Game object properties
radius
=
10.0
;
removeLimit
=
640.0
;
canDamageShip
=
false
;
canBeDamaged
=
false
;
impact
=
1.0
+
level
*
0.5
;
// Offset for movement
_offset
=
new
Offset
(
math
.
cos
(
radians
(
r
))
*
10.0
,
math
.
sin
(
radians
(
r
))
*
10.0
);
// Drawing properties
rotation
=
r
+
90.0
;
int
numLasers
=
level
%
3
+
1
;
Color
laserColor
=
laserColors
[(
level
~/
3
)
%
laserColors
.
length
];
// Add sprites
List
<
Sprite
>
sprites
=
[];
for
(
int
i
=
0
;
i
<
numLasers
;
i
++)
{
Sprite
sprt
=
new
Sprite
(
f
.
sheet
[
"explosion_particle.png"
]);
sprt
.
scale
=
0.5
;
sprt
.
colorOverlay
=
laserColor
;
sprt
.
transferMode
=
sky
.
TransferMode
.
plus
;
addChild
(
sprt
);
sprites
.
add
(
sprt
);
}
// Position the individual sprites
if
(
numLasers
==
2
)
{
sprites
[
0
].
position
=
new
Point
(-
3.0
,
0.0
);
sprites
[
1
].
position
=
new
Point
(
3.0
,
0.0
);
}
else
if
(
numLasers
==
3
)
{
sprites
[
0
].
position
=
new
Point
(-
4.0
,
0.0
);
sprites
[
1
].
position
=
new
Point
(
4.0
,
0.0
);
sprites
[
2
].
position
=
new
Point
(
0.0
,
-
2.0
);
}
}
Sprite
_sprt
;
Offset
_offset
;
void
move
()
{
...
...
examples/game/lib/player_state.dart
View file @
d79b3598
...
...
@@ -28,6 +28,8 @@ class PlayerState extends Node {
final
SpriteSheet
_sheetUI
;
final
SpriteSheet
_sheetGame
;
int
laserLevel
=
0
;
Sprite
_sprtBgScore
;
ScoreDisplay
_scoreDisplay
;
Sprite
_sprtBgCoins
;
...
...
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