Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-server-flip-jump
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
Vũ Gia Vương
game-server-flip-jump
Commits
4ed14930
Commit
4ed14930
authored
Aug 20, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calculator xDistance_ no loop
parent
e409da78
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
15 deletions
+24
-15
networkCtrl.ts
src/Controller/networkCtrl.ts
+0
-1
index.ts
src/index.ts
+14
-10
socket.ts
src/socket.ts
+10
-4
No files found.
src/Controller/networkCtrl.ts
View file @
4ed14930
...
...
@@ -50,7 +50,6 @@ export async function endGameApi(user: User) {
gameLevel
:
user
.
towerNumber
-
1
,
details
}
console
.
log
(
'END GAME'
);
const
res
=
await
callApi
(
URL_END_GAME
,
'POST'
,
params
);
return
res
;
...
...
src/index.ts
View file @
4ed14930
...
...
@@ -10,19 +10,23 @@ const io = new Server(server, {
path
:
'/socket'
,
cors
:
{
methods
:
[
"GET"
,
"POST"
],
origin
:
(
origin
,
callback
)
=>
{
console
.
log
(
'origin'
,
origin
)
const
allowed
=
[
origin
:[
"https://play.gamee.vn"
,
"https://dev.gamee.vn"
,
"http://localhost:7456"
];
if
(
!
origin
||
allowed
.
includes
(
origin
))
{
callback
(
null
,
origin
);
}
else
{
callback
(
new
Error
(
"Not allowed by CORS"
));
}
},
]
// origin: (origin, callback) => {
// const allowed = [
// "https://play.gamee.vn",
// "https://dev.gamee.vn",
// "http://localhost:7456"
// ];
// if (!origin || allowed.includes(origin)) {
// callback(null, origin);
// } else {
// callback(new Error("Not allowed by CORS"));
// }
// },
// credentials: true,
}
...
...
src/socket.ts
View file @
4ed14930
...
...
@@ -103,12 +103,18 @@ async function passTower(socket: Socket, data: IRequestPassTower) {
let
xDistance_
=
0
;
const
{
direction
,
nextBlock
,
towerNumber
,
position
}
=
user
;
if
(
towerNumber
>
MAX_TOWER
)
{
let
speed
=
INIT_SPEED
;
for
(
let
i
=
0
;
i
<
data
.
step
;
i
++
)
{
speed
+=
(
Math
.
min
(
towerNumber
-
MAX_TOWER
,
A_POWER
)
*
DT
);
xDistance_
+=
speed
*
DT
;
}
// data.step = Math.min(data.step, 150);
// for (let i = 0; i < data.step; i++) {
// speed += (Math.min(towerNumber - MAX_TOWER, A_POWER) * DT);
// xDistance_ += speed * DT;
// }
const
acceleration
=
Math
.
min
(
towerNumber
-
MAX_TOWER
,
A_POWER
)
*
DT
;
speed
+=
data
.
step
*
acceleration
;
xDistance_
+=
INIT_SPEED
*
data
.
step
*
DT
+
acceleration
*
DT
*
(
data
.
step
*
(
data
.
step
-
1
))
/
2
;
}
else
{
xDistance_
=
data
.
step
*
INIT_SPEED
*
DT
;
}
...
...
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