Giter Site home page Giter Site logo

gorisanson / pikachu-volleyball Goto Github PK

View Code? Open in Web Editor NEW
902.0 10.0 98.0 16.24 MB

Pikachu Volleyball implemented into JavaScript by reverse engineering the original game

Home Page: https://gorisanson.github.io/pikachu-volleyball/en/

HTML 31.66% JavaScript 62.28% CSS 6.06%
pikachu-volleyball game video-game reverse-engineering

pikachu-volleyball's People

Contributors

andrewpollack avatar dependabot[bot] avatar disjukr avatar gorisanson avatar helpingstar avatar ototot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pikachu-volleyball's Issues

코드 구조와 최적화 관련한 건의

영어 실력이 부족하여 긴 글이기에 한글로 작성합니다.

물론 피카츄배구가 현재 잘 작동되고 있으며, 최대속도 30FPS 안에 연산을 마치면 게임 실행에 문제가 없기 때문에 해당 내용도 크게 문제는 없습니다. 그래도 고려해봄직 하다 생각하여 작성합니다.

calculateExpectedLandingPointXFor 함수는 공의 착지 위치로 기대되는(예상되는) x 값을 계산하는 함수입니다.

위 함수는 두 곳에서 실행됩니다.

아래는 physicsEngine 함수내부이고

calculateExpectedLandingPointXFor(ball); // calculate expected_X;

아래는 processCollisionBetweenBallAndPlayer의 내부입니다.
(processCollisionBetweenBallAndPlayerphysicsEngine 함수에 의해 실행)

calculateExpectedLandingPointXFor(ball);

calculateExpectedLandingPointXFor 함수에서 저장된 ball.expectedLandingPointX

ball.expectedLandingPointX = copyBall.x;

letComputerDecideUserInput, decideWhetherInputPowerHit(letComputerDecideUserInput 에 의해 실행) 에 의해 사용됩니다. 즉 컴퓨터의 행동을 정하기 위한 함수입니다.

function processPlayerMovementAndSetPlayerPosition(
player,
userInput,
theOtherPlayer,
ball
) {
if (player.isComputer === true) {
letComputerDecideUserInput(player, ball, theOtherPlayer, userInput);
}

501-504줄을 보면 컴퓨터일 경우만 판단하도록 되어 있습니다(당연하지만)

그렇다면 calculateExpectedLandingPointXFor 함수는 컴퓨터가 없다면 실행할 필요가 없게 됩니다. 그런데 현재는 두 플레어가 사람이어도 공의 기대 x위치를 계산하게 되는데 이때는 필요없는 연산입니다.

그리하여 아래와 같은 코드를 넣으면 될 것 같지만

    if (player1.isComputer === true || player2.isComputer === true){
      calculateExpectedLandingPointXFor(ball);
    }

processCollisionBetweenBallAndPlayer 함수는 두 플레이어의 정보를 인자로 받지 않습니다.
하지만 해당 함수는 무조건 마지막에 calculateExpectedLandingPointXFor(ball); 를 실행합니다.

앞에서 말씀드렸다시피 processCollisionBetweenBallAndPlayer 함수는 오직physicsEngine 함수에 의해서만 실행되는데 physicsEngine 함수는 player1, player2를 받기 때문에

(물론 player1, player2를 인자로 전달해도 되지만 실행되는 장소가 한 곳이고, 코드가 너무 지저분해지기 때문에 아래가 낫다 생각했습니다.)

processCollisionBetweenBallAndPlayer 의 마지막줄인 calculateExpectedLandingPointXFor 를 실행하는 코드를 지우고

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)
calculateExpectedLandingPointXFor(ball); // calculate expected_X;

를 아래와 같이 고치고 (맨 아래줄)

  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);
    }

if (isHappened === true) {
if (player.isCollisionWithBallHappened === false) {
processCollisionBetweenBallAndPlayer(
ball,
player.x,
userInputArray[i],
player.state
);
player.isCollisionWithBallHappened = true;
}
} else {
player.isCollisionWithBallHappened = false;
}
}

부분을 아래와 같이 고치면 됩니다.
(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 하겠습니다.

fix typo

class Ball {
/**
* Create a ball
* @param {boolean} isPlayer2Serve Will player 2 serve on this new round?
*/
constructor(isPlayer2Serve) {
this.initializeForNewRound(isPlayer2Serve);
/** @type {number} x coord of expected lang point */
this.expectedLandingPointX = 0; // 0x40

/** @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.

Trouble building on main branch

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?

Sorry, I just posted the issue in wrong place

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

I want to know how the AI calculates where the ball lands

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 to say thanks and congratulate you

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.