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
3b730de1
Commit
3b730de1
authored
Aug 18, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build game
parent
fded70ae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
17 deletions
+24
-17
networkCtrl.js
dist/Controller/networkCtrl.js
+1
-0
User.js
dist/Model/User.js
+2
-2
socket.js
dist/socket.js
+21
-15
No files found.
dist/Controller/networkCtrl.js
View file @
3b730de1
...
...
@@ -60,6 +60,7 @@ function endGameApi(user) {
gameLevel
:
user
.
towerNumber
-
1
,
details
};
console
.
log
(
'END GAME'
);
const
res
=
yield
callApi
(
URL_END_GAME
,
'POST'
,
params
);
return
res
;
}
...
...
dist/Model/User.js
View file @
3b730de1
...
...
@@ -19,7 +19,7 @@ class User {
this
.
screenPos
=
new
v2_1
.
default
(
0
,
0
);
this
.
position
=
new
v2_1
.
default
(
0
,
0
);
this
.
timeStart
=
0
;
this
.
is
End
Game
=
true
;
this
.
is
Start
Game
=
true
;
this
.
history
=
[];
this
.
token
=
token
;
this
.
id
=
id
;
...
...
@@ -29,7 +29,7 @@ class User {
this
.
score
=
0
;
this
.
totalScore
=
0
;
this
.
combo
=
0
;
this
.
is
EndGame
=
tru
e
;
this
.
is
StartGame
=
fals
e
;
this
.
history
=
[];
this
.
timeStart
=
0
;
this
.
towerNumber
=
0
;
...
...
dist/socket.js
View file @
3b730de1
...
...
@@ -13,13 +13,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object
.
defineProperty
(
exports
,
"__esModule"
,
{
value
:
true
});
exports
.
setupSocket
=
setupSocket
;
// import CONFIG from "./Config/config";
const
User_1
=
__importDefault
(
require
(
"./Model/User"
));
const
v2_1
=
__importDefault
(
require
(
"./Model/v2"
));
const
networkCtrl_1
=
require
(
"./Controller/networkCtrl"
);
const
users
=
new
Map
();
const
Y_RADIO
=
0.5560472
;
const
HALF_SIZE_TOWER
=
56.43580423808985
;
const
INIT_SPEED
=
300
;
const
A_POWER
=
300
;
const
DT
=
0.016
;
const
MAX_TOWER
=
50
;
const
CONFIG
=
{
EVT
:
{
START_GAME
:
'200'
,
...
...
@@ -63,11 +66,8 @@ function endGame(socket) {
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
try
{
const
user
=
getUserBySocket
(
socket
);
yield
(
0
,
networkCtrl_1
.
endGameApi
)(
user
);
user
.
reset
();
if
(
user
===
null
||
user
===
void
0
?
void
0
:
user
.
isEndGame
)
{
return
;
}
(
0
,
networkCtrl_1
.
endGameApi
)(
user
);
}
catch
(
error
)
{
console
.
log
(
'error'
,
error
);
...
...
@@ -76,7 +76,7 @@ function endGame(socket) {
}
function
onDisconnect
(
socket
)
{
console
.
log
(
`🔴 Client disconnected:
${
socket
.
id
}
`
);
endGame
(
socket
);
//
endGame(socket);
}
function
getHistory
(
socket
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
...
...
@@ -89,10 +89,12 @@ function startGame(socket, data) {
try
{
const
user
=
getUserBySocket
(
socket
);
const
result
=
yield
(
0
,
networkCtrl_1
.
startGameApi
)(
data
);
// const result = true;
if
(
result
&&
user
.
isStartGame
)
{
user
.
reset
();
}
if
(
result
)
{
socket
.
emit
(
CONFIG
.
EVT
.
REQUEST_START_GAME
,
true
);
user
.
is
EndGame
=
fals
e
;
user
.
is
StartGame
=
tru
e
;
addBlock
(
socket
);
}
else
{
...
...
@@ -109,8 +111,18 @@ function passTower(socket, data) {
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
try
{
const
user
=
getUserBySocket
(
socket
);
const
xDistance_
=
data
.
distance
;
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
;
}
}
else
{
xDistance_
=
data
.
step
*
INIT_SPEED
*
DT
;
}
const
point
=
new
v2_1
.
default
(
xDistance_
*
direction
,
xDistance_
*
Y_RADIO
);
const
nextTowerPos
=
nextBlock
;
const
distancePlayer2NextTower
=
nextTowerPos
.
clone
().
sub
(
position
).
mag
();
...
...
@@ -131,12 +143,7 @@ function passTower(socket, data) {
target
=
nextTowerPos
.
clone
();
score
=
2
;
}
// target = nextTowerPos.clone();
// score = 2;
const
heightJump
=
user
.
distance2Tower
*
0.7
;
if
(
score
<=
0
)
{
user
.
isEndGame
=
true
;
}
if
(
score
==
2
)
{
user
.
combo
=
Math
.
min
(
user
.
combo
+
1
,
2
);
score
*=
user
.
combo
;
...
...
@@ -169,7 +176,6 @@ function passTower(socket, data) {
socket
.
emit
(
CONFIG
.
EVT
.
REQUEST_HISTORY
,
user
.
history
);
yield
(
0
,
networkCtrl_1
.
endGameApi
)(
user
);
user
.
reset
();
console
.
log
(
'END'
);
}
}
catch
(
error
)
{
...
...
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