Spiel für das Medientheater HBK Saar, Teil des Projektes "Fun Palace" (Reupload der Repository von 2017)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.pde 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import processing.net.*;
  2. int port = 50000;
  3. Server myServer;
  4. void setup()
  5. {
  6. size(300,300);
  7. background(0);
  8. myServer = new Server(this, port);
  9. }
  10. void draw()
  11. {
  12. getLaser();
  13. }
  14. int laserX,laserY;
  15. void getLaser() {
  16. Client thisClient = myServer.available();
  17. if (thisClient !=null) {
  18. String whatClientSaid = thisClient.readString();
  19. if (whatClientSaid != null) {
  20. String[] x = splitTokens(whatClientSaid, "(), ");
  21. //potentially add try and catch here if the client is not in synch
  22. float p1 = float(x[0]);
  23. float p2 = float(x[1]);
  24. float p3 = float(x[2]);
  25. if (p1 == 3.5) {
  26. laserX = int(map(p3, -2.3, 2.3, width/5*2, width/5*3));
  27. } else {
  28. if (p3 < 0) {
  29. laserX = int(map(p1, -3.5, 3.5, 0, width/5*2));
  30. } else {
  31. laserX = int(map(p1, 3.5, -3.5, width/5*3, width));
  32. }
  33. }
  34. laserY = int(map(p2, 4, 1, 0, height));
  35. laserX = constrain(laserX, 0, width);
  36. laserY = constrain(laserY, 0, height);
  37. }
  38. }
  39. }