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.

class_stocks.pde 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. class Stock {
  2. String w; // Name
  3. int val; // Value
  4. float x; // x position
  5. float y;
  6. float z;
  7. int xspeed;
  8. color colorw =255 ;
  9. String display;
  10. boolean colorActif;
  11. Stock(String tempw, float xpos, float tempz, float ypos, int Xspeed) {
  12. w= tempw;
  13. z=tempz;
  14. x=xpos;
  15. y=ypos;
  16. xspeed=Xspeed;
  17. // Concatenate the name, value and some spaces
  18. display = w + " " ;
  19. }
  20. // A function to set x position
  21. void setX(float x_) {
  22. x = x_;
  23. }
  24. void display() {
  25. for (int i = 0; i < stocks.length; i++) {
  26. fill(colorw);
  27. textFont(f);
  28. text(display, x, height-25*i);
  29. }
  30. if (colorActif) {
  31. for (int i = 0; i < stocks.length; i++) {
  32. fill( int(random(2))*255, int(random(2))*255, int(random(2))*255);
  33. textFont(f);
  34. text(display, x, height-25*i);
  35. }
  36. }
  37. }
  38. float textW() {
  39. textFont(f);
  40. return textWidth(display);
  41. }
  42. float textH() {
  43. textFont(f);
  44. return textAscent() + textDescent();
  45. }
  46. void move() {
  47. x = x - 1;
  48. y= y-1;
  49. if (x < width-totalW && y < height-totalH) {
  50. x = width;
  51. y= height;
  52. }
  53. }
  54. void apparition() {
  55. colorActif =! colorActif;
  56. }
  57. }