Advertisement
tdog442

Sound element for Powder Toy

May 30th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include "simulation/Elements.h"
  2. #ifdef WIN
  3. #include "windows.h"
  4. bool win = true;
  5. #else
  6. bool win = false;
  7. sudo apt-get install beep
  8. #endif
  9. //#TPT-Directive ElementClass Element_BEEP PT_BEEP 179
  10. Element_BEEP::Element_BEEP()
  11. {
  12. Identifier = "DEFAULT_PT_BEEP";
  13. Name = "BEEP";
  14. Colour = PIXPACK(0x40A060);
  15. MenuVisible = 1;
  16. MenuSection = SC_ELEC;
  17. Enabled = 1;
  18.  
  19. Advection = 0.0f;
  20. AirDrag = 0.00f * CFDS;
  21. AirLoss = 0.90f;
  22. Loss = 0.00f;
  23. Collision = 0.0f;
  24. Gravity = 0.0f;
  25. Diffusion = 0.00f;
  26. HotAir = 0.000f * CFDS;
  27. Falldown = 0;
  28.  
  29. Flammable = 0;
  30. Explosive = 0;
  31. Meltable = 0;
  32. Hardness = 2;
  33.  
  34. Weight = 100;
  35.  
  36. Temperature = R_TEMP+0.0f +273.15f;
  37. HeatConduct = 0;
  38. Description = "Beep generator.";
  39.  
  40. State = ST_SOLID;
  41. Properties = TYPE_SOLID;
  42.  
  43. LowPressure = IPL;
  44. LowPressureTransition = NT;
  45. HighPressure = 15.0f;
  46. HighPressureTransition = PT_BRMT;
  47. LowTemperature = ITL;
  48. LowTemperatureTransition = NT;
  49. HighTemperature = ITH;
  50. HighTemperatureTransition = NT;
  51.  
  52. Update = &Element_BEEP::update;
  53. }
  54.  
  55. //#TPT-Directive ElementHeader Element_BEEP static int update(UPDATE_FUNC_ARGS)
  56. int Element_BEEP::update(UPDATE_FUNC_ARGS)
  57. {
  58. int r, rx, ry, rt;
  59. for (rx=-1; rx<2; rx++)
  60. for (ry=-1; ry<2; ry++)
  61. if (BOUNDS_CHECK)
  62. {
  63. r = sim->photons[y+ry][x+rx];
  64. if (!r)
  65. r = pmap[y+ry][x+rx];
  66. if (!r)
  67. continue;
  68. if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life==3)
  69. {
  70. if(win == true)
  71. {
  72. Beep(parts[i].tmp, parts[i].tmp2);
  73. break;
  74. }
  75. else
  76. {
  77. #ifdef WIN
  78. win = true;
  79. return 0;
  80. #else
  81. try:
  82. import winsound
  83. except ImportError:
  84. import os
  85. def playsound(frequency,duration):
  86. #apt-get install beep
  87. os.system('beep -f %s -l %s' % (frequency,duration))
  88. else:
  89. def playsound(frequency,duration):
  90. winsound.Beep(parts[i].tmp,parts[i].tmp2)
  91. #endif
  92. }
  93. }
  94. }
  95. return 0;
  96. }
  97.  
  98.  
  99. Element_BEEP::~Element_BEEP() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement