Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
6a8e4898
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6a8e4898
编写于
7月 24, 2015
作者:
V
Viktor Lidholt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes formatting and abstraction in GameMath
上级
8bf434a0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
39 deletion
+37
-39
sky/sdk/example/game/lib/sprites.dart
sky/sdk/example/game/lib/sprites.dart
+1
-0
sky/sdk/example/game/lib/util.dart
sky/sdk/example/game/lib/util.dart
+36
-39
未找到文件。
sky/sdk/example/game/lib/sprites.dart
浏览文件 @
6a8e4898
...
...
@@ -7,6 +7,7 @@ library sprites;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:math'
as
math
;
import
'dart:typed_data'
;
import
'dart:sky'
;
import
'package:sky/animation/curves.dart'
;
...
...
sky/sdk/example/game/lib/util.dart
浏览文件 @
6a8e4898
...
...
@@ -19,67 +19,64 @@ int randomInt(int max) {
// atan2
class
GameMath
{
static
bool
_inited
=
false
;
static
final
int
size
=
1024
;
static
final
double
stretch
=
math
.
PI
;
static
final
int
ezis
=
-
size
;
static
Float64List
atan2_table_ppy
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_ppx
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_pny
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_pnx
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_npy
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_npx
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_nny
=
new
Float64List
(
size
+
1
);
static
Float64List
atan2_table_nnx
=
new
Float64List
(
size
+
1
);
static
void
init
()
{
if
(
_inited
)
return
;
class
_Atan2Constants
{
_Atan2Constants
()
{
for
(
int
i
=
0
;
i
<=
size
;
i
++)
{
double
f
=
i
.
toDouble
()
/
size
.
toDouble
();
atan2_table_
ppy
[
i
]
=
math
.
atan
(
f
)
*
stretch
/
math
.
PI
;
atan2_table_ppx
[
i
]
=
stretch
*
0.5
-
atan2_table_
ppy
[
i
];
atan2_table_pny
[
i
]
=
-
atan2_table_
ppy
[
i
];
atan2_table_pnx
[
i
]
=
atan2_table_
ppy
[
i
]
-
stretch
*
0.5
;
atan2_table_npy
[
i
]
=
stretch
-
atan2_table_
ppy
[
i
];
atan2_table_npx
[
i
]
=
atan2_table_
ppy
[
i
]
+
stretch
*
0.5
;
atan2_table_nny
[
i
]
=
atan2_table_
ppy
[
i
]
-
stretch
;
atan2_table_nnx
[
i
]
=
-
stretch
*
0.5
-
atan2_table_
ppy
[
i
];
ppy
[
i
]
=
math
.
atan
(
f
)
*
stretch
/
math
.
PI
;
ppx
[
i
]
=
stretch
*
0.5
-
ppy
[
i
];
pny
[
i
]
=
-
ppy
[
i
];
pnx
[
i
]
=
ppy
[
i
]
-
stretch
*
0.5
;
npy
[
i
]
=
stretch
-
ppy
[
i
];
npx
[
i
]
=
ppy
[
i
]
+
stretch
*
0.5
;
nny
[
i
]
=
ppy
[
i
]
-
stretch
;
nnx
[
i
]
=
-
stretch
*
0.5
-
ppy
[
i
];
}
_inited
=
true
;
}
static
double
atan2
(
double
y
,
double
x
)
{
if
(!
_inited
)
init
();
static
const
int
size
=
1024
;
static
const
double
stretch
=
math
.
PI
;
static
const
int
ezis
=
-
size
;
final
Float64List
ppy
=
new
Float64List
(
size
+
1
);
final
Float64List
ppx
=
new
Float64List
(
size
+
1
);
final
Float64List
pny
=
new
Float64List
(
size
+
1
);
final
Float64List
pnx
=
new
Float64List
(
size
+
1
);
final
Float64List
npy
=
new
Float64List
(
size
+
1
);
final
Float64List
npx
=
new
Float64List
(
size
+
1
);
final
Float64List
nny
=
new
Float64List
(
size
+
1
);
final
Float64List
nnx
=
new
Float64List
(
size
+
1
);
}
class
GameMath
{
static
final
_Atan2Constants
_atan2
=
new
_Atan2Constants
();
static
double
atan2
(
double
y
,
double
x
)
{
if
(
x
>=
0
)
{
if
(
y
>=
0
)
{
if
(
x
>=
y
)
return
atan2_table_ppy
[(
size
*
y
/
x
+
0.5
).
toInt
()];
return
_atan2
.
ppy
[(
_Atan2Constants
.
size
*
y
/
x
+
0.5
).
floor
()];
else
return
atan2_table_ppx
[(
size
*
x
/
y
+
0.5
).
toInt
()];
return
_atan2
.
ppx
[(
_Atan2Constants
.
size
*
x
/
y
+
0.5
).
floor
()];
}
else
{
if
(
x
>=
-
y
)
return
atan2_table_pny
[(
ezis
*
y
/
x
+
0.5
).
toInt
()];
return
_atan2
.
pny
[(
_Atan2Constants
.
ezis
*
y
/
x
+
0.5
).
floor
()];
else
return
atan2_table_pnx
[(
ezis
*
x
/
y
+
0.5
).
toInt
()];
return
_atan2
.
pnx
[(
_Atan2Constants
.
ezis
*
x
/
y
+
0.5
).
floor
()];
}
}
else
{
if
(
y
>=
0
)
{
if
(-
x
>=
y
)
return
atan2_table_npy
[(
ezis
*
y
/
x
+
0.5
).
toInt
()];
return
_atan2
.
npy
[(
_Atan2Constants
.
ezis
*
y
/
x
+
0.5
).
floor
()];
else
return
atan2_table_npx
[(
ezis
*
x
/
y
+
0.5
).
toInt
()];
return
_atan2
.
npx
[(
_Atan2Constants
.
ezis
*
x
/
y
+
0.5
).
floor
()];
}
else
{
if
(
x
<=
y
)
return
atan2_table_nny
[(
size
*
y
/
x
+
0.5
).
toInt
()];
return
_atan2
.
nny
[(
_Atan2Constants
.
size
*
y
/
x
+
0.5
).
floor
()];
else
return
atan2_table_nnx
[(
size
*
x
/
y
+
0.5
).
toInt
()];
return
_atan2
.
nnx
[(
_Atan2Constants
.
size
*
x
/
y
+
0.5
).
floor
()];
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录