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.
 
 
 
 
 
 

50 lines
808 B

  1. #include <util.h>
  2. #include "Bucket.h"
  3. #include "Cable.h"
  4. #include "Game.h"
  5. #include "Network.h"
  6. #include "UI.h"
  7. static Picture *picture;
  8. static MCursor *cursor;
  9. static int grabbed;
  10. void
  11. Bucket_load_pix() {
  12. UI_load_picture("bucket", 1, &picture);
  13. UI_load_cursor("bucket", CURSOR_OWN_MASK, &cursor);
  14. }
  15. int
  16. Bucket_clicked(int x, int y) {
  17. return (x > 0 && x < UI_picture_width(picture) &&
  18. y > 0 && y < UI_picture_height(picture));
  19. }
  20. void
  21. Bucket_draw() {
  22. if (!grabbed)
  23. UI_draw(picture, 0, 0);
  24. }
  25. void
  26. Bucket_grab(int x, int y) {
  27. UNUSED(x);
  28. UNUSED(y);
  29. UI_set_cursor(cursor);
  30. grabbed = 1;
  31. }
  32. void
  33. Bucket_release(int x, int y) {
  34. int i;
  35. for (i = 0; i < Network_num_cables(); i++) {
  36. Cable *cable = Network_get_cable(i);
  37. if (Cable_onspark(cable, x, y))
  38. Cable_reset(cable);
  39. }
  40. grabbed = 0;
  41. }