Hi guys,
making my way through the processing book and got to the client server chapter which is fantastic.
I haven’t gone as far as Daniel has suggested by creating a pong game but close enough. I am moving a rect around the client from the server. However, my question is I have code to move the rect, but what is the best course of action for stopping the box once a key is released? As it stands, the box continues to move.
I have tried keyReleased() to send a ‘stop’ int but clearly this is called after I release a button, meaning the rect doesn’t move :).
What does your server code look like? It is unclear from your description if you are trying to add keyReleased to your client or server sketch. Client can use IO functions, server receives signals.
When you release a key it will increment count and display on console:
keyReleased Server
1
keyReleased
keyReleased Server
2
keyReleased
keyReleased Server
3
keyReleased
keyReleased Server
4
keyReleased
Note:
Only one console is active so this is why “keyReleased Server” shows up on same console as client.
You must start “server” and then “client” for this to work.
The server draw window must be “active” to accept a keypress and release.
The client and server examples worked for me using localhost IP of 127.0.0.1