gorisanson / pikachu-volleyball Goto Github PK
View Code? Open in Web Editor NEWPikachu Volleyball implemented into JavaScript by reverse engineering the original game
Home Page: https://gorisanson.github.io/pikachu-volleyball/en/
Pikachu Volleyball implemented into JavaScript by reverse engineering the original game
Home Page: https://gorisanson.github.io/pikachu-volleyball/en/
The original game controls has an additional down key "V" for player 1. This "V" key works differently with the "F" key. (Thanks to @repeat_c for this information!)
영어 실력이 부족하여 긴 글이기에 한글로 작성합니다.
물론 피카츄배구가 현재 잘 작동되고 있으며, 최대속도 30FPS 안에 연산을 마치면 게임 실행에 문제가 없기 때문에 해당 내용도 크게 문제는 없습니다. 그래도 고려해봄직 하다 생각하여 작성합니다.
calculateExpectedLandingPointXFor
함수는 공의 착지 위치로 기대되는(예상되는) x 값을 계산하는 함수입니다.
위 함수는 두 곳에서 실행됩니다.
아래는 physicsEngine
함수내부이고
아래는 processCollisionBetweenBallAndPlayer
의 내부입니다.
(processCollisionBetweenBallAndPlayer
는 physicsEngine
함수에 의해 실행)
calculateExpectedLandingPointXFor
함수에서 저장된 ball.expectedLandingPointX
는
letComputerDecideUserInput
, decideWhetherInputPowerHit
(letComputerDecideUserInput
에 의해 실행) 에 의해 사용됩니다. 즉 컴퓨터의 행동을 정하기 위한 함수입니다.
pikachu-volleyball/src/resources/js/physics.js
Lines 496 to 504 in d8ec117
그렇다면 calculateExpectedLandingPointXFor
함수는 컴퓨터가 없다면 실행할 필요가 없게 됩니다. 그런데 현재는 두 플레어가 사람이어도 공의 기대 x위치를 계산하게 되는데 이때는 필요없는 연산입니다.
그리하여 아래와 같은 코드를 넣으면 될 것 같지만
if (player1.isComputer === true || player2.isComputer === true){
calculateExpectedLandingPointXFor(ball);
}
processCollisionBetweenBallAndPlayer
함수는 두 플레이어의 정보를 인자로 받지 않습니다.
하지만 해당 함수는 무조건 마지막에 calculateExpectedLandingPointXFor(ball);
를 실행합니다.
앞에서 말씀드렸다시피 processCollisionBetweenBallAndPlayer
함수는 오직physicsEngine
함수에 의해서만 실행되는데 physicsEngine
함수는 player1, player2를 받기 때문에
(물론 player1, player2를 인자로 전달해도 되지만 실행되는 장소가 한 곳이고, 코드가 너무 지저분해지기 때문에 아래가 낫다 생각했습니다.)
processCollisionBetweenBallAndPlayer
의 마지막줄인 calculateExpectedLandingPointXFor
를 실행하는 코드를 지우고
pikachu-volleyball/src/resources/js/physics.js
Lines 309 to 323 in d8ec117
를 아래와 같이 고치고 (맨 아래줄)
for (let i = 0; i < 2; i++) {
if (i === 0) {
player = player1;
theOtherPlayer = player2;
} else {
player = player2;
theOtherPlayer = player1;
}
// FUN_00402d90 omitted
// FUN_00402810 omitted
// this javascript code is refactored not to need above two function except for
// a part of FUN_00402d90:
// FUN_00402d90 include FUN_004031b0(calculateExpectedLandingPointXFor)
if (player1.isComputer === true || player2.isComputer === true){
calculateExpectedLandingPointXFor(ball);
}
pikachu-volleyball/src/resources/js/physics.js
Lines 351 to 364 in d8ec117
부분을 아래와 같이 고치면 됩니다.
(processCollisionBetweenBallAndPlayer
에서 코드를 지웠기 때문에 함수 종료 후 바로 calculateExpectedLandingPointXFor
실행)
if (isHappened === true) {
if (player.isCollisionWithBallHappened === false) {
processCollisionBetweenBallAndPlayer(
ball,
player.x,
userInputArray[i],
player.state
);
if (player1.isComputer === true || player2.isComputer === true){
calculateExpectedLandingPointXFor(ball);
}
player.isCollisionWithBallHappened = true;
}
} else {
player.isCollisionWithBallHappened = false;
}
}
제가 고려하지 못했거나 놓친 부분이 있을 수 있기 때문에 issue 탭에 말씀드립니다. 아마 이미 아셨을 것이라 생각되지만 혹시나 하여 말씀드립니다.
괜찮다면 PR 하겠습니다.
It goes back to main screen 8.5 seconds after the game over in original client, but I don't know the exact constant.
pikachu-volleyball/src/resources/js/physics.js
Lines 226 to 234 in 8b4bd7d
/** @type {number} x coord of expected lang point */
위의 주석에서
"lang" 이란 부분이 "landing", 혹은 "land"을 쓰려다 나온 오타인 것으로 보입니다.
오타가 맞다면 PR을 하겠습니다.
From the comment above
The "lang" part appears to be a typo that occurred when trying to use "landing" or "land."
If the typo is correct, I will give you a PR.
Hi,
Demo on Windows 10 x64, VSCode's Live Server and Firefox.
gh-pages branch works fine.
But I had trouble building on main branch.
using npm v8.1.2
> npm install
> npm run build
Used Live Server to test ./dist/en/index.html
After pressing Play button it stuck like this.
I guess the assets failed loading, not sure why.
Another thing is I got 80.bundle.js
instead of 511.bundle.js
, and 80.bundle.js
file size is somehow much bigger than 511.bundle.js
.
I'm new to front end and Webpack, maybe I missed something?
When I ran python3 -m gym_pikachu_volleyball.scripts.interactive, and I got this error.
Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\gym_pikachu_volleyball\scripts\interactive.py", line 11, in <module> env.render() File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\gym\core.py", line 295, in render return self.env.render(mode, **kwargs) TypeError: render() takes 1 positional argument but 2 were given
It is nice to see the project you share! I am a Unity learner and trying to repeat your work in Unity. But the code of AI is a little hard. I have read the physics.js
but I am a Javascript noob and not totally understand it. 😢
Could you use a simple text or some mathematical formulas to describe it? I will appreciate that!
(I am not a native English speaker, maybe you can understand my statement xD)
Just leaving you a message to say thank you.
Your implementation seems the same as the original one
Happy to see that this game is still alive thanks to you
Cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.