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
9a21cbc7
Commit
9a21cbc7
authored
Sep 01, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds level labels to demo game
parent
3f2369db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
game_demo.dart
examples/game/lib/game_demo.dart
+1
-0
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+9
-12
game_objects.dart
examples/game/lib/game_objects.dart
+17
-0
No files found.
examples/game/lib/game_demo.dart
View file @
9a21cbc7
...
...
@@ -5,6 +5,7 @@ import 'dart:math' as math;
import
'dart:sky'
as
sky
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/painting/text_style.dart'
;
import
'package:sky/widgets/framework.dart'
;
import
'package:skysprites/skysprites.dart'
;
import
'package:vector_math/vector_math.dart'
;
...
...
examples/game/lib/game_demo_node.dart
View file @
9a21cbc7
...
...
@@ -4,7 +4,7 @@ final double _gameSizeWidth = 320.0;
double
_gameSizeHeight
=
320.0
;
final
double
_chunkSpacing
=
640.0
;
final
int
_chunksPerLevel
=
5
;
final
int
_chunksPerLevel
=
6
;
final
bool
_drawDebug
=
false
;
...
...
@@ -190,25 +190,22 @@ class GameDemoNode extends NodeWithSize {
}
void
addLevelChunk
(
int
chunk
,
double
yPos
)
{
if
(
chunk
==
0
)
{
// Leave the first chunk empty
return
;
}
chunk
-=
1
;
int
level
=
chunk
~/
_chunksPerLevel
;
int
part
=
chunk
%
_chunksPerLevel
;
if
(
part
==
0
)
{
LevelLabel
lbl
=
new
LevelLabel
(
_objectFactory
,
level
+
1
);
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
));
}
else
if
(
part
==
1
)
{
_objectFactory
.
addEnemyScoutSwarm
(
4
+
level
*
2
,
yPos
);
}
else
if
(
part
==
2
)
{
_objectFactory
.
add
Asteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
)
);
_objectFactory
.
add
EnemyScoutSwarm
(
4
+
level
*
2
,
yPos
);
}
else
if
(
part
==
3
)
{
_objectFactory
.
add
EnemyDestroyerSwarm
(
2
+
level
,
yPos
);
_objectFactory
.
add
Asteroids
(
10
+
level
*
4
,
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
));
}
}
...
...
examples/game/lib/game_objects.dart
View file @
9a21cbc7
...
...
@@ -86,6 +86,23 @@ abstract class GameObject extends Node {
}
}
class
LevelLabel
extends
GameObject
{
LevelLabel
(
GameObjectFactory
f
,
int
level
)
:
super
(
f
)
{
canDamageShip
=
false
;
canBeDamaged
=
false
;
Label
lbl
=
new
Label
(
"LEVEL
$level
"
,
new
TextStyle
(
textAlign:
TextAlign
.
center
,
color:
new
Color
(
0xffffffff
),
fontSize:
24.0
,
fontWeight:
FontWeight
.
w600
));
addChild
(
lbl
);
}
}
class
Ship
extends
GameObject
{
Ship
(
GameObjectFactory
f
)
:
super
(
f
)
{
// Add main ship sprite
...
...
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