Created
March 10, 2017 18:25
-
-
Save stephkoltun/82d57aeed53d7e3e1bf83b55fd80ebcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void adjustPlayer(Client thisClient, String message) { | |
// which player? | |
Paddle thisPlayer = new Paddle(); | |
String clientID = thisClient.ip(); | |
if (activeClients.size() == players.length) { | |
// determine with player client is associated with | |
for (int i = 0; i < players.length; i++) { | |
if (players[i].clientID.equals(clientID)) { | |
// player identified! | |
thisPlayer = players[i]; | |
println("adjust player " + i); | |
} | |
} | |
switch (message) { | |
case "u": | |
if (thisPlayer.constMove == false) { | |
thisPlayer.y = thisPlayer.y - thisPlayer.increment; | |
} else { | |
thisPlayer.upSpeed = 1; | |
thisPlayer.dnSpeed = 0; | |
} | |
break; | |
case "d": | |
thisPlayer.y = thisPlayer.y + thisPlayer.increment; | |
if (thisPlayer.constMove == false) { | |
thisPlayer.y = thisPlayer.y + thisPlayer.increment; | |
} else { | |
thisPlayer.upSpeed = 0; | |
thisPlayer.dnSpeed = 1; | |
} | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment