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
bd610f43
Commit
bd610f43
authored
Sep 02, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial boss fight in demo game
parent
fc6f91c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
10 deletions
+60
-10
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+3
-1
game_object_factory.dart
examples/game/lib/game_object_factory.dart
+9
-0
game_objects.dart
examples/game/lib/game_objects.dart
+33
-4
player_state.dart
examples/game/lib/player_state.dart
+15
-5
No files found.
examples/game/lib/game_demo_node.dart
View file @
bd610f43
...
...
@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0;
double
_gameSizeHeight
=
320.0
;
final
double
_chunkSpacing
=
640.0
;
final
int
_chunksPerLevel
=
8
;
final
int
_chunksPerLevel
=
9
;
final
bool
_drawDebug
=
false
;
...
...
@@ -210,6 +210,8 @@ class GameDemoNode extends NodeWithSize {
_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
));
}
else
if
(
part
==
8
)
{
_objectFactory
.
addBossFight
(
level
,
yPos
);
}
}
...
...
examples/game/lib/game_object_factory.dart
View file @
bd610f43
...
...
@@ -61,4 +61,13 @@ class GameObjectFactory {
level
.
addChild
(
obj
);
}
void
addBossFight
(
int
l
,
double
yPos
)
{
EnemyBoss
boss
=
new
EnemyBoss
(
this
);
boss
.
position
=
new
Point
(
0.0
,
yPos
+
_chunkSpacing
/
2.0
);
boss
.
setupActions
();
level
.
addChild
(
boss
);
playerState
.
boss
=
boss
;
}
}
examples/game/lib/game_objects.dart
View file @
bd610f43
...
...
@@ -377,8 +377,6 @@ class EnemyDestroyer extends Obstacle {
void
update
(
double
dt
)
{
_countDown
-=
1
;
if
(
_countDown
<=
0
)
{
print
(
"SHOOT!!"
);
// Shoot at player
EnemyLaser
laser
=
new
EnemyLaser
(
f
,
rotation
,
5.0
,
new
Color
(
0xffffe38e
));
laser
.
position
=
position
;
...
...
@@ -409,8 +407,6 @@ class EnemyLaser extends Obstacle {
double
rad
=
radians
(
rotation
);
_movement
=
new
Offset
(
math
.
cos
(
rad
)
*
speed
,
math
.
sin
(
rad
)
*
speed
);
print
(
"LASER!!"
);
}
Sprite
_sprt
;
...
...
@@ -421,6 +417,39 @@ class EnemyLaser extends Obstacle {
}
}
class
EnemyBoss
extends
Obstacle
{
EnemyBoss
(
GameObjectFactory
f
)
:
super
(
f
)
{
radius
=
48.0
;
_sprt
=
new
Sprite
(
f
.
sheet
[
"enemy_destroyer_1.png"
]);
_sprt
.
scale
=
0.64
;
addChild
(
_sprt
);
maxDamage
=
40.0
;
constraints
=
[
new
ConstraintRotationToNode
(
f
.
level
.
ship
,
dampening:
0.05
)];
}
Sprite
_sprt
;
int
_countDown
=
randomInt
(
120
)
+
240
;
void
update
(
double
dt
)
{
_countDown
-=
1
;
if
(
_countDown
<=
0
)
{
// Shoot at player
EnemyLaser
laser
=
new
EnemyLaser
(
f
,
rotation
,
5.0
,
new
Color
(
0xffffe38e
));
laser
.
position
=
position
;
f
.
level
.
addChild
(
laser
);
_countDown
=
60
+
randomInt
(
120
);
}
}
void
destroy
()
{
f
.
playerState
.
boss
=
null
;
super
.
destroy
();
}
}
class
Collectable
extends
GameObject
{
Collectable
(
GameObjectFactory
f
)
:
super
(
f
)
{
canDamageShip
=
false
;
...
...
examples/game/lib/player_state.dart
View file @
bd610f43
...
...
@@ -36,6 +36,8 @@ class PlayerState extends Node {
double
_scrollSpeedTarget
=
normalScrollSpeed
;
EnemyBoss
boss
;
Sprite
_sprtBgScore
;
ScoreDisplay
_scoreDisplay
;
Sprite
_sprtBgCoins
;
...
...
@@ -87,7 +89,7 @@ class PlayerState extends Node {
}
else
if
(
type
==
PowerUpType
.
speedLaser
)
{
_speedLaserFrames
+=
300
;
}
else
if
(
type
==
PowerUpType
.
speedBoost
)
{
_speedBoostFrames
+=
30
0
;
_speedBoostFrames
+=
15
0
;
}
}
...
...
@@ -122,10 +124,18 @@ class PlayerState extends Node {
if
(
_speedBoostFrames
>
0
)
_speedBoostFrames
--;
// Update speed
if
(
speedBoostActive
)
_scrollSpeedTarget
=
normalScrollSpeed
*
6.0
;
else
_scrollSpeedTarget
=
normalScrollSpeed
;
if
(
boss
!=
null
)
{
Point
globalBossPos
=
boss
.
convertPointToBoxSpace
(
Point
.
origin
);
if
(
globalBossPos
.
y
>
(
_gameSizeHeight
-
400.0
))
_scrollSpeedTarget
=
0.0
;
else
_scrollSpeedTarget
=
normalScrollSpeed
;
}
else
{
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