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
59817111
Commit
59817111
authored
Aug 25, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes nits
parent
dec2689c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
23 deletions
+28
-23
constraint.dart
examples/game/lib/constraint.dart
+5
-8
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+19
-15
util.dart
examples/game/lib/util.dart
+4
-0
No files found.
examples/game/lib/constraint.dart
View file @
59817111
...
...
@@ -8,6 +8,9 @@ abstract class Constraint {
}
double
_dampenRotation
(
double
src
,
double
dst
,
double
dampening
)
{
if
(
dampening
==
null
)
return
dst
;
double
delta
=
dst
-
src
;
while
(
delta
>
180.0
)
delta
-=
360
;
while
(
delta
<
-
180
)
delta
+=
360
;
...
...
@@ -36,10 +39,7 @@ class ConstraintRotationToMovement {
Offset
offset
=
node
.
position
-
_lastPosition
;
double
target
=
degrees
(
GameMath
.
atan2
(
offset
.
dy
,
offset
.
dx
))
+
baseRotation
;
if
(
dampening
==
null
)
node
.
rotation
=
target
;
else
node
.
rotation
=
_dampenRotation
(
node
.
rotation
,
target
,
dampening
);
node
.
rotation
=
_dampenRotation
(
node
.
rotation
,
target
,
dampening
);
}
}
...
...
@@ -62,9 +62,6 @@ class ConstraintRotationToNode {
double
target
=
degrees
(
GameMath
.
atan2
(
offset
.
dy
,
offset
.
dx
))
+
baseRotation
;
if
(
dampening
==
null
)
node
.
rotation
=
target
;
else
node
.
rotation
=
_dampenRotation
(
node
.
rotation
,
target
,
dampening
);
node
.
rotation
=
_dampenRotation
(
node
.
rotation
,
target
,
dampening
);
}
}
examples/game/lib/game_demo_node.dart
View file @
59817111
...
...
@@ -394,7 +394,7 @@ abstract class Asteroid extends Obstacle {
void
setupActions
()
{
// Rotate obstacle
int
direction
=
1
;
if
(
random
Double
()
<
0.5
)
direction
=
-
1
;
if
(
random
Bool
()
)
direction
=
-
1
;
ActionTween
rotate
=
new
ActionTween
(
(
a
)
=>
_sprt
.
rotation
=
a
,
0.0
,
360.0
*
direction
,
5.0
+
5.0
*
randomDouble
());
...
...
@@ -442,21 +442,25 @@ class MovingEnemy extends Obstacle {
final
double
_swirlSpacing
=
80.0
;
_addRandomSquare
(
List
<
Offset
>
offsets
,
double
x
,
double
y
)
{
double
xMove
=
(
randomDouble
()
<
0.5
)
?
_swirlSpacing
:
-
_swirlSpacing
;
double
yMove
=
(
randomDouble
()
<
0.5
)
?
_swirlSpacing
:
-
_swirlSpacing
;
if
(
randomDouble
()
<
0.5
)
{
offsets
.
add
(
new
Offset
(
x
,
y
));
offsets
.
add
(
new
Offset
(
xMove
+
x
,
y
));
offsets
.
add
(
new
Offset
(
xMove
+
x
,
yMove
+
y
));
offsets
.
add
(
new
Offset
(
x
,
yMove
+
y
));
offsets
.
add
(
new
Offset
(
x
,
y
));
double
xMove
=
(
randomBool
())
?
_swirlSpacing
:
-
_swirlSpacing
;
double
yMove
=
(
randomBool
())
?
_swirlSpacing
:
-
_swirlSpacing
;
if
(
randomBool
())
{
offsets
.
addAll
([
new
Offset
(
x
,
y
),
new
Offset
(
xMove
+
x
,
y
),
new
Offset
(
xMove
+
x
,
yMove
+
y
),
new
Offset
(
x
,
yMove
+
y
),
new
Offset
(
x
,
y
)
]);
}
else
{
offsets
.
add
(
new
Offset
(
x
,
y
));
offsets
.
add
(
new
Offset
(
x
,
y
+
yMove
));
offsets
.
add
(
new
Offset
(
xMove
+
x
,
yMove
+
y
));
offsets
.
add
(
new
Offset
(
xMove
+
x
,
y
));
offsets
.
add
(
new
Offset
(
x
,
y
));
offsets
.
addAll
([
new
Offset
(
x
,
y
),
new
Offset
(
x
,
y
+
yMove
),
new
Offset
(
xMove
+
x
,
yMove
+
y
),
new
Offset
(
xMove
+
x
,
y
),
new
Offset
(
x
,
y
)
]);
}
}
...
...
examples/game/lib/util.dart
View file @
59817111
...
...
@@ -17,6 +17,10 @@ int randomInt(int max) {
return
_random
.
nextInt
(
max
);
}
bool
randomBool
(
)
{
return
_random
.
nextDouble
()
<
0.5
;
}
// atan2
class
_Atan2Constants
{
...
...
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