Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to make Among Us but its coded in JavaScript(originally in C++ in Unity) and I have run across a problem: My player can move off the screen! This is really frustrating, as I am trying to make a game that is bigger than the window height and width. There is no way I can add a minimal reproducible example, as my code relies on itself to work. But the code is here: https://editor.p5js.org/LttntLark/sketches/03MGbFiUhG ...

What I have tried:

I have tried moving the map, and not the player, then I realized I wanted this to be a multiplayer game. If you can, please help, as all of it is appreciated. If there is something missing, I am open to share more information.
Posted
Updated 25-Oct-20 7:01am
v3
Comments
Richard MacCutchan 25-Oct-20 4:13am    
You need to check the player's position against the dimensions of the screen before you move it.

1 solution

You don't move the map, you move the "view port".

You shift the port (up, down, left, right) as the player steps up, down, left, right.

In multiplayer, each user controls their own "view port" (x,y and width and height).

And the "view port" usually moves only when the user moves it if the "action" can occur in multiple places at the same time ... versus a "single shooter " game; there the port does follow the player.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900