Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MingSnake_241120
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
MingSnake_241120
Commits
c0b3fa4a
Commit
c0b3fa4a
authored
Nov 25, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
528e7534
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
883 additions
and
169 deletions
+883
-169
MainGame.scene
assets/Bundles/MainGame/MainGame.scene
+852
-146
CKTKingkongNum.ttf
assets/Bundles/common/CKTKingkongNum.ttf
+0
-0
CKTKingkongNum.ttf.meta
assets/Bundles/common/CKTKingkongNum.ttf.meta
+0
-12
MainGame.ts
assets/Scripts/Scenes/MainGame/MainGame.ts
+15
-6
Player.ts
assets/Scripts/Scenes/MainGame/Player.ts
+7
-0
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+9
-5
No files found.
assets/Bundles/MainGame/MainGame.scene
View file @
c0b3fa4a
This diff is collapsed.
Click to expand it.
assets/Bundles/common/CKTKingkongNum.ttf
deleted
100644 → 0
View file @
528e7534
File deleted
assets/Bundles/common/CKTKingkongNum.ttf.meta
deleted
100644 → 0
View file @
528e7534
{
"ver": "1.0.1",
"importer": "ttf-font",
"imported": true,
"uuid": "2c64cd9b-a68c-4de0-b137-694dc03e1edf",
"files": [
".json",
"CKTKingkongNum.ttf"
],
"subMetas": {},
"userData": {}
}
assets/Scripts/Scenes/MainGame/MainGame.ts
View file @
c0b3fa4a
...
@@ -67,12 +67,24 @@ export class MainGame extends Scene {
...
@@ -67,12 +67,24 @@ export class MainGame extends Scene {
@
property
(
Node
)
@
property
(
Node
)
animalNode
:
Node
=
null
;
animalNode
:
Node
=
null
;
@
property
(
Label
)
private
LTips
:
Label
=
null
;
@
property
(
Camera
)
@
property
(
Camera
)
camera
:
Camera
=
null
;
camera
:
Camera
=
null
;
@
property
({
type
:
Label
,
group
:
"UI"
})
killTxt
:
Label
=
null
;
@
property
({
type
:
Label
,
group
:
"UI"
})
lengthTxt
:
Label
=
null
;
private
_killNum
=
0
;
set
killNum
(
n
:
number
)
{
this
.
_killNum
=
n
;
this
.
killTxt
.
string
=
`
${
this
.
_killNum
}
名`
;
}
get
killNum
()
{
return
this
.
_killNum
;
}
private
state
:
GameState
=
GameState
.
READY
;
private
state
:
GameState
=
GameState
.
READY
;
private
rebirthSum
:
number
=
0
;
private
rebirthSum
:
number
=
0
;
...
@@ -148,9 +160,6 @@ export class MainGame extends Scene {
...
@@ -148,9 +160,6 @@ export class MainGame extends Scene {
update
(
dt
:
number
)
{
update
(
dt
:
number
)
{
if
(
this
.
state
==
GameState
.
READY
)
return
;
if
(
this
.
state
==
GameState
.
READY
)
return
;
// 更新UI提示
this
.
LTips
.
string
=
`长度:
${
this
.
player
.
getSnakeLen
()}
, 四叉树节点个数:
${
QuadTreeNode
.
caches
.
length
}
`
;
this
.
player
.
onUpdate
(
dt
);
this
.
player
.
onUpdate
(
dt
);
// 更新相机位置
// 更新相机位置
...
...
assets/Scripts/Scenes/MainGame/Player.ts
View file @
c0b3fa4a
...
@@ -6,6 +6,7 @@ import { Snake } from "./Snake";
...
@@ -6,6 +6,7 @@ import { Snake } from "./Snake";
import
{
Joystick
}
from
"./Components/Joystick"
;
import
{
Joystick
}
from
"./Components/Joystick"
;
import
{
FastBtn
}
from
"./Components/FastBtn"
;
import
{
FastBtn
}
from
"./Components/FastBtn"
;
import
{
Events
,
GameState
}
from
"./Common/Enums"
;
import
{
Events
,
GameState
}
from
"./Common/Enums"
;
import
{
MainGame
}
from
"./MainGame"
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
...
@@ -23,18 +24,24 @@ export class Player extends Snake {
...
@@ -23,18 +24,24 @@ export class Player extends Snake {
input
.
on
(
Input
.
EventType
.
KEY_DOWN
,
this
.
onKeyDown
,
this
);
input
.
on
(
Input
.
EventType
.
KEY_DOWN
,
this
.
onKeyDown
,
this
);
input
.
on
(
Input
.
EventType
.
KEY_UP
,
this
.
onKeyUp
,
this
);
input
.
on
(
Input
.
EventType
.
KEY_UP
,
this
.
onKeyUp
,
this
);
this
.
fastBtn
.
node
.
on
(
"fast"
,
this
.
onFast
,
this
);
this
.
fastBtn
.
node
.
on
(
"fast"
,
this
.
onFast
,
this
);
this
.
node
.
on
(
"updateLength"
,
this
.
updateLength
,
this
);
}
}
onDestroy
()
{
onDestroy
()
{
input
.
off
(
Input
.
EventType
.
KEY_DOWN
,
this
.
onKeyDown
,
this
);
input
.
off
(
Input
.
EventType
.
KEY_DOWN
,
this
.
onKeyDown
,
this
);
input
.
off
(
Input
.
EventType
.
KEY_UP
,
this
.
onKeyUp
,
this
);
input
.
off
(
Input
.
EventType
.
KEY_UP
,
this
.
onKeyUp
,
this
);
this
.
fastBtn
.
node
.
off
(
"fast"
,
this
.
onFast
,
this
);
this
.
fastBtn
.
node
.
off
(
"fast"
,
this
.
onFast
,
this
);
this
.
node
.
off
(
"updateLength"
,
this
.
updateLength
,
this
);
}
}
onFast
(
isFast
:
boolean
)
{
onFast
(
isFast
:
boolean
)
{
this
.
isFast
=
isFast
;
this
.
isFast
=
isFast
;
}
}
updateLength
(
length
:
number
)
{
MainGame
.
ins
.
lengthTxt
.
string
=
`
${
length
}
`
;
}
death
()
{
death
()
{
super
.
death
();
super
.
death
();
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
c0b3fa4a
...
@@ -58,10 +58,17 @@ export class Snake extends Component {
...
@@ -58,10 +58,17 @@ export class Snake extends Component {
protected
tag
:
number
=
0
;
protected
tag
:
number
=
0
;
// 位置相关
// 位置相关
private
vw
:
number
=
Global
.
visibleSize
.
width
/
2
+
100
;
private
vh
:
number
=
Global
.
visibleSize
.
height
/
2
+
100
;
private
ready
:
boolean
=
false
;
private
ready
:
boolean
=
false
;
private
_length
:
number
=
0
;
get
length
()
{
return
this
.
_length
;
}
set
length
(
value
:
number
)
{
this
.
_length
=
value
;
this
.
node
.
emit
(
"updateLength"
,
value
);
}
get
radius
()
{
get
radius
()
{
return
this
.
scale
*
29
;
return
this
.
scale
*
29
;
}
}
...
@@ -176,7 +183,6 @@ export class Snake extends Component {
...
@@ -176,7 +183,6 @@ export class Snake extends Component {
// 能量与成长
// 能量与成长
lastRemaining
=
0
;
lastRemaining
=
0
;
private
addEnergy
(
value
:
number
)
{
private
addEnergy
(
value
:
number
)
{
console
.
log
(
this
.
energy
,
value
);
this
.
energy
+=
value
;
this
.
energy
+=
value
;
const
growthThreshold
=
Math
.
floor
(
4
*
this
.
scale
);
const
growthThreshold
=
Math
.
floor
(
4
*
this
.
scale
);
...
@@ -191,8 +197,6 @@ export class Snake extends Component {
...
@@ -191,8 +197,6 @@ export class Snake extends Component {
}
}
}
}
console
.
log
(
this
.
energy
,
this
.
scale
,
this
.
energy
/
this
.
bodyArr
.
length
);
this
.
lastRemaining
=
value
;
this
.
lastRemaining
=
value
;
// this.speed = 600 * this.scale;
// this.speed = 600 * this.scale;
...
...
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