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
a78370fe
Commit
a78370fe
authored
Aug 19, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New game demo, initial version
parent
1393b4c6
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
826 additions
and
763 deletions
+826
-763
game_demo.dart
examples/game/lib/game_demo.dart
+2
-1
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+784
-0
game_demo_world.dart
examples/game/lib/game_demo_world.dart
+0
-752
main.dart
examples/game/lib/main.dart
+23
-10
util.dart
examples/game/lib/util.dart
+17
-0
No files found.
examples/game/lib/game_demo.dart
View file @
a78370fe
library
game
;
library
game
;
import
'dart:async'
;
import
'dart:sky'
as
sky
;
import
'dart:sky'
as
sky
;
import
'dart:math'
as
Math
;
import
'dart:math'
as
Math
;
import
'sprites.dart'
;
import
'sprites.dart'
;
...
@@ -10,4 +11,4 @@ import 'package:sky/widgets/navigator.dart';
...
@@ -10,4 +11,4 @@ import 'package:sky/widgets/navigator.dart';
import
'package:sky/animation/curves.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
part
'game_demo_
world
.dart'
;
part
'game_demo_
node
.dart'
;
examples/game/lib/game_demo_node.dart
0 → 100644
View file @
a78370fe
This diff is collapsed.
Click to expand it.
examples/game/lib/game_demo_world.dart
deleted
100644 → 0
View file @
1393b4c6
This diff is collapsed.
Click to expand it.
examples/game/lib/main.dart
View file @
a78370fe
...
@@ -77,10 +77,19 @@ main() async {
...
@@ -77,10 +77,19 @@ main() async {
class
GameDemoApp
extends
App
{
class
GameDemoApp
extends
App
{
NavigationState
_navigationState
;
NavigationState
_navigationState
;
GameDemoWorld
_game
;
NodeWithSize
_game
;
int
_lastScore
=
0
;
int
_lastScore
=
0
;
void
initState
()
{
void
initState
()
{
// _game = new GameDemoNode(
// _imageMap,
// _spriteSheet,
// _spriteSheetUI,
// _sounds,
// (lastScore) {
// setState(() {_lastScore = lastScore;});
// });
_navigationState
=
new
NavigationState
([
_navigationState
=
new
NavigationState
([
new
Route
(
new
Route
(
name:
'/'
,
name:
'/'
,
...
@@ -112,24 +121,23 @@ class GameDemoApp extends App {
...
@@ -112,24 +121,23 @@ class GameDemoApp extends App {
}
}
Widget
_buildGameScene
(
navigator
,
route
)
{
Widget
_buildGameScene
(
navigator
,
route
)
{
return
new
SpriteWidget
(
_game
);
return
new
SpriteWidget
(
_game
,
SpriteBoxTransformMode
.
fixedWidth
);
}
}
Widget
_buildMainScene
(
navigator
,
route
)
{
Widget
_buildMainScene
(
navigator
,
route
)
{
return
new
Stack
([
return
new
Stack
([
new
SpriteWidget
(
new
MainScreenBackground
()),
new
SpriteWidget
(
new
MainScreenBackground
()
,
SpriteBoxTransformMode
.
fixedWidth
),
new
Flex
([
new
Flex
([
new
TextureButton
(
new
TextureButton
(
onPressed:
()
{
onPressed:
()
{
_game
=
new
GameDemoWorld
(
_game
=
new
GameDemoNode
(
_app
,
navigator
,
_imageMap
,
_imageMap
,
_spriteSheet
,
_spriteSheet
,
_spriteSheetUI
,
_spriteSheetUI
,
_sounds
,
_sounds
,
(
lastScore
)
{
(
lastScore
)
{
setState
(()
{
_lastScore
=
lastScore
;});
setState
(()
{
_lastScore
=
lastScore
;});
navigator
.
pop
();
}
}
);
);
navigator
.
pushNamed
(
'/game'
);
navigator
.
pushNamed
(
'/game'
);
...
@@ -243,14 +251,19 @@ class _TextureButtonToken {
...
@@ -243,14 +251,19 @@ class _TextureButtonToken {
}
}
class
MainScreenBackground
extends
NodeWithSize
{
class
MainScreenBackground
extends
NodeWithSize
{
MainScreenBackground
()
:
super
(
new
Size
(
1024.0
,
1024
.0
))
{
MainScreenBackground
()
:
super
(
new
Size
(
320.0
,
320
.0
))
{
Sprite
sprtBackground
=
new
Sprite
.
fromImage
(
_imageMap
[
'assets/starfield.png'
]);
//
Sprite sprtBackground = new Sprite.fromImage(_imageMap['assets/starfield.png']);
sprtBackground
.
position
=
new
Point
(
512.0
,
512
.0
);
// sprtBackground.position = new Point(160.0, 160
.0);
addChild
(
sprtBackground
);
//
addChild(sprtBackground);
assert
(
_spriteSheet
.
image
!=
null
);
assert
(
_spriteSheet
.
image
!=
null
);
StarField
starField
=
new
StarField
(
_spriteSheet
,
200
,
true
);
StarField
starField
=
new
StarField
(
_spriteSheet
,
200
,
true
);
addChild
(
starField
);
addChild
(
starField
);
}
}
void
paint
(
PaintingCanvas
canvas
)
{
canvas
.
drawRect
(
new
Rect
.
fromLTWH
(
0.0
,
0.0
,
320.0
,
320.0
),
new
Paint
()..
color
=
new
Color
(
0xff000000
));
super
.
paint
(
canvas
);
}
}
}
examples/game/lib/util.dart
View file @
a78370fe
...
@@ -80,4 +80,21 @@ class GameMath {
...
@@ -80,4 +80,21 @@ class GameMath {
}
}
}
}
}
}
static
double
pointQuickDist
(
Point
a
,
Point
b
)
{
double
dx
=
a
.
x
-
b
.
x
;
double
dy
=
a
.
y
-
b
.
y
;
if
(
dx
<
0.0
)
dx
=
-
dx
;
if
(
dy
<
0.0
)
dy
=
-
dy
;
if
(
dx
>
dy
)
{
return
dx
+
dy
/
2.0
;
}
else
{
return
dy
+
dx
/
2.0
;
}
}
static
double
filter
(
double
a
,
double
b
,
double
filterFactor
)
{
return
(
a
*
(
1
-
filterFactor
))
+
b
*
filterFactor
;
}
}
}
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