Overv / WebCraft

Minecraft clone written in Javascript.
zlib License
386 stars 179 forks source link

Fly command #40

Open SmilerRyan opened 5 years ago

SmilerRyan commented 5 years ago

Currently to reach places high up, you must build, jump and delete blocks after to get to a location. How would I add a /fly command, which simply disables falling when users press (or hold) a key (ex. f)?

cymno commented 5 years ago

Like this: a5e1d17e024baddb68b90e2843529312c28cca40 Btw, the movement code in ./js/player.js is very nice to play around with and modify. You could easily e.g. add a sprint option by finding out how to detect a "shift" press in javascript and then increase the speed here accordingly.

Here are the steps I took to actually run the project (a bit hidden imo):

$git clone this-repo
$npm install socket.io express
$node server

Then visit http://localhost:3000/multiplayer.html or http://localhost:3000/singleplayer.html in a browser (or replace localhost by your ip-adress)

SmilerRyan commented 5 years ago

Thanks, however this has only partially solved my solution as I cannot move any other direction except for up/down while holding the key to fly.

cymno commented 5 years ago

Yes, for that it is necessary to enable in-air movement. This also makes the jump more responsive, as it is possible to adjust the direction after the jump has already started. If you'd really like to keep the old system it's also possible to enable in-air movement only when "f" is pressed.