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
20809bc9
Commit
20809bc9
authored
Sep 03, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1047 from vlidholt/master
Adds power bar and movements to boss fights in demo game
parents
d0ad775e
dfe80a53
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
3 deletions
+76
-3
custom_actions.dart
examples/game/lib/custom_actions.dart
+14
-0
game_demo.dart
examples/game/lib/game_demo.dart
+1
-0
game_objects.dart
examples/game/lib/game_objects.dart
+40
-3
power_bar.dart
examples/game/lib/power_bar.dart
+21
-0
No files found.
examples/game/lib/custom_actions.dart
View file @
20809bc9
...
...
@@ -17,3 +17,17 @@ class ActionCircularMove extends ActionInterval {
setter
(
pos
);
}
}
class
ActionOscillate
extends
ActionInterval
{
ActionOscillate
(
this
.
setter
,
this
.
center
,
this
.
radius
,
double
duration
)
:
super
(
duration
);
final
Function
setter
;
final
Point
center
;
final
double
radius
;
void
update
(
double
t
)
{
double
rad
=
radians
(
t
*
360.0
);
Offset
offset
=
new
Offset
(
math
.
sin
(
rad
)
*
radius
,
0.0
);
setter
(
center
+
offset
);
}
}
examples/game/lib/game_demo.dart
View file @
20809bc9
...
...
@@ -17,5 +17,6 @@ part 'game_demo_node.dart';
part
'game_objects.dart'
;
part
'game_object_factory.dart'
;
part
'player_state.dart'
;
part
'power_bar.dart'
;
part
'repeated_image.dart'
;
part
'star_field.dart'
;
examples/game/lib/game_objects.dart
View file @
20809bc9
...
...
@@ -426,9 +426,15 @@ class EnemyBoss extends Obstacle {
maxDamage
=
40.0
;
constraints
=
[
new
ConstraintRotationToNode
(
f
.
level
.
ship
,
dampening:
0.05
)];
_powerBar
=
new
PowerBar
(
new
Size
(
60.0
,
10.0
));
_powerBar
.
position
=
new
Point
(-
80.0
,
0.0
);
_powerBar
.
pivot
=
new
Point
(
0.5
,
0.5
);
addChild
(
_powerBar
);
}
Sprite
_sprt
;
PowerBar
_powerBar
;
int
_countDown
=
randomInt
(
120
)
+
240
;
...
...
@@ -436,18 +442,49 @@ class EnemyBoss extends Obstacle {
_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
);
fire
(
10.0
);
fire
(
0.0
)
;
f
ire
(-
10.0
);
_countDown
=
60
+
randomInt
(
120
);
}
_powerBar
.
rotation
=
-
rotation
;
}
void
fire
(
double
r
)
{
r
+=
rotation
;
EnemyLaser
laser
=
new
EnemyLaser
(
f
,
r
,
5.0
,
new
Color
(
0xffffe38e
));
double
rad
=
radians
(
r
);
Offset
startOffset
=
new
Offset
(
math
.
cos
(
rad
)
*
30.0
,
math
.
sin
(
rad
)
*
30.0
);
laser
.
position
=
position
+
startOffset
;
f
.
level
.
addChild
(
laser
);
}
void
setupActions
()
{
ActionOscillate
oscillate
=
new
ActionOscillate
((
a
)
=>
position
=
a
,
position
,
120.0
,
3.0
);
actions
.
run
(
new
ActionRepeatForever
(
oscillate
));
}
void
destroy
()
{
f
.
playerState
.
boss
=
null
;
super
.
destroy
();
}
set
damage
(
double
d
)
{
super
.
damage
=
d
;
_sprt
.
actions
.
stopAll
();
_sprt
.
actions
.
run
(
new
ActionTween
(
(
a
)
=>
_sprt
.
colorOverlay
=
a
,
new
Color
.
fromARGB
(
180
,
255
,
3
,
86
),
new
Color
(
0x00000000
),
0.3
));
_powerBar
.
power
=
(
1.0
-
(
damage
/
maxDamage
)).
clamp
(
0.0
,
1.0
);
}
}
class
Collectable
extends
GameObject
{
...
...
examples/game/lib/power_bar.dart
0 → 100644
View file @
20809bc9
part of
game
;
class
PowerBar
extends
NodeWithSize
{
PowerBar
(
Size
size
,
[
this
.
power
=
1.0
])
:
super
(
size
);
double
power
;
Paint
_paintFill
=
new
Paint
()
..
color
=
new
Color
(
0xffffffff
);
Paint
_paintOutline
=
new
Paint
()
..
color
=
new
Color
(
0xffffffff
)
..
strokeWidth
=
1.0
..
setStyle
(
sky
.
PaintingStyle
.
stroke
);
void
paint
(
PaintingCanvas
canvas
)
{
applyTransformForPivot
(
canvas
);
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
0.0
,
0.0
,
size
.
width
-
0.0
,
size
.
height
-
0.0
),
_paintOutline
);
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
2.0
,
2.0
,
(
size
.
width
-
2.0
)
*
power
,
size
.
height
-
2.0
),
_paintFill
);
}
}
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