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
96c11bac
Commit
96c11bac
authored
Dec 23, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
70dcb203
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
FoodManger.ts
assets/Scripts/Scenes/MainGame/Manager/FoodManger.ts
+1
-0
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+5
-2
No files found.
assets/Scripts/Scenes/MainGame/Manager/FoodManger.ts
View file @
96c11bac
...
...
@@ -79,6 +79,7 @@ export class FoodManger extends Component {
*/
check
()
{
const
{
total
,
max
}
=
this
;
console
.
log
(
total
,
max
);
for
(
let
i
=
total
;
i
<
max
;
i
++
)
{
this
.
add
();
}
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
96c11bac
...
...
@@ -562,14 +562,17 @@ export class Snake extends Component {
this
.
clearPropEffect
()
const
len
=
this
.
bodyArr
.
length
;
const
foodArr
=
this
.
bodyArr
.
map
((
body
)
=>
{
const
foodArr
=
this
.
bodyArr
.
map
((
body
,
i
)
=>
{
body
.
removeFromParent
();
bodyPool
.
put
(
body
);
if
(
body
.
position
.
x
>
99999
)
return
;
if
(
i
%
2
==
1
)
return
;
return
{
x
:
body
.
position
.
x
+
math
.
randomRange
(
-
10
,
10
),
y
:
body
.
position
.
y
+
math
.
randomRange
(
-
10
,
10
),
energy
:
~~
(
this
.
energy
/
2
/
len
),
energy
:
~~
(
this
.
energy
/
len
),
};
});
this
.
bodyArr
.
length
=
0
;
...
...
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