tdog442

Fluid Electricity for Powder Toy

May 11th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #include "simulation/Elements.h"
  2. //#TPT-Directive ElementClass Element_FELE PT_FELE 174
  3. Element_FELE::Element_FELE()
  4. {
  5. Identifier = "DEFAULT_PT_FELE";
  6. Name = "FELE";
  7. Colour = PIXPACK(0xFFFFA0);
  8. MenuVisible = 1;
  9. MenuSection = SC_ELEC;
  10. Enabled = 1;
  11.  
  12. Advection = 0.4f;
  13. AirDrag = 0.01f * CFDS;
  14. AirLoss = 1.0f;
  15. Loss = 0.30f;
  16. Collision = 0.0f;
  17. Gravity = 0.1f;
  18. Diffusion = 0.0f;
  19. HotAir = 0.000f * CFDS;
  20. Falldown = 2;
  21.  
  22. Flammable = 0;
  23. Explosive = 0;
  24. Meltable = 0;
  25. Hardness = 0;
  26.  
  27. Weight = 1;
  28.  
  29. Temperature = R_TEMP+273.15f;
  30. HeatConduct = 1;
  31. Description = "Liquid Electricity.";
  32.  
  33. State = ST_LIQUID;
  34. Properties = TYPE_LIQUID|PROP_LIFE_KILL_DEC;
  35.  
  36. LowPressure = IPL;
  37. LowPressureTransition = NT;
  38. HighPressure = IPH;
  39. HighPressureTransition = NT;
  40. LowTemperature = ITL;
  41. LowTemperatureTransition = NT;
  42. HighTemperature = ITH;
  43. HighTemperatureTransition = NT;
  44.  
  45. Update = &Element_FELE::update;
  46. Graphics = &Element_FELE::graphics;
  47. }
  48.  
  49. //#TPT-Directive ElementHeader Element_FELE static int update(UPDATE_FUNC_ARGS)
  50. int Element_FELE::update(UPDATE_FUNC_ARGS)
  51. {
  52. int r, rx, ry, rt;
  53. for (rx=-2; rx<3; rx++)
  54. for (ry=-2; ry<3; ry++)
  55. if (BOUNDS_CHECK && (rx || ry))
  56. {
  57. r = pmap[y+ry][x+rx];
  58. if (!r)
  59. continue;
  60. rt = r&0xFF;
  61. if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0 && parts[r>>8].ctype!=PT_SPRK)
  62. {
  63. parts[r>>8].ctype = parts[r>>8].type;
  64. sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
  65. parts[r>>8].life = 4;
  66. }
  67.  
  68. if(parts[i].tmp==1 && (r&0xFF)==PT_SPRK && parts[r>>8].life==1)
  69. {
  70. sim->kill_part(i);
  71. }
  72.  
  73. if(parts[i].tmp2==1 && (r&0xFF)==PT_FELE)
  74. {
  75. parts[r>>8].vx += isign(rx);
  76. parts[r>>8].vy += isign(ry);
  77. }
  78. }
  79. return(0);
  80. }
  81.  
  82.  
  83. //#TPT-Directive ElementHeader Element_FELE static int graphics(GRAPHICS_FUNC_ARGS)
  84. int Element_FELE::graphics(GRAPHICS_FUNC_ARGS)
  85.  
  86. {
  87. *firea = 160;
  88. *fireg = 192;
  89. *fireb = 255;
  90. *firer = 144;
  91. *pixel_mode |= FIRE_ADD;
  92. return 1;
  93. }
  94.  
  95.  
  96. Element_FELE::~Element_FELE() {}
Advertisement
Add Comment
Please, Sign In to add comment