earthquake.diff 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Joke mod that adds earthquake. By drummyfish, released under CC0 1.0, public
  2. domain.
  3. diff --git a/game.h b/game.h
  4. index 991058d..fdb53e8 100755
  5. --- a/game.h
  6. +++ b/game.h
  7. @@ -1272,6 +1272,14 @@ RCL_Unit SFG_movingWallHeight
  8. low + halfHeight + (RCL_sin(sinArg) * halfHeight) / RCL_UNITS_PER_SQUARE;
  9. }
  10. +RCL_Unit SFG_earthQuakeHeightAt(int16_t x, int16_t y)
  11. +{
  12. + return SFG_EARTHQUAKE_HEIGHT * (
  13. + RCL_sin((((x + y) * RCL_UNITS_PER_SQUARE) / SFG_EARTHQUAKE_WAVELENGTH +
  14. + (SFG_game.frameTime * RCL_UNITS_PER_SQUARE) / SFG_EARTHQUAKE_SPEED) %
  15. + RCL_UNITS_PER_SQUARE)) / RCL_UNITS_PER_SQUARE;
  16. +}
  17. +
  18. RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y)
  19. {
  20. uint8_t properties;
  21. @@ -1306,10 +1314,12 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y)
  22. return SFG_movingWallHeight(
  23. height,
  24. height + SFG_TILE_CEILING_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP,
  25. - SFG_game.frameTime - SFG_currentLevel.timeStart);
  26. + SFG_game.frameTime - SFG_currentLevel.timeStart) +
  27. + SFG_earthQuakeHeightAt(x,y);
  28. }
  29. -
  30. - return SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP - doorHeight;
  31. +
  32. + return SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP - doorHeight +
  33. + SFG_earthQuakeHeightAt(x,y);
  34. }
  35. /**
  36. @@ -1427,11 +1437,13 @@ RCL_Unit SFG_ceilingHeightAt(int16_t x, int16_t y)
  37. SFG_getMapTile(SFG_currentLevel.levelPointer,x,y,&properties);
  38. if (properties == SFG_TILE_PROPERTY_ELEVATOR)
  39. - return SFG_CEILING_MAX_HEIGHT;
  40. + return SFG_CEILING_MAX_HEIGHT + SFG_earthQuakeHeightAt(x,y);
  41. uint8_t height = SFG_TILE_CEILING_HEIGHT(tile);
  42. - return properties != SFG_TILE_PROPERTY_SQUEEZER ?
  43. + return SFG_earthQuakeHeightAt(x,y) +
  44. + (
  45. + properties != SFG_TILE_PROPERTY_SQUEEZER ?
  46. (
  47. height != SFG_TILE_CEILING_MAX_HEIGHT ?
  48. ((SFG_TILE_FLOOR_HEIGHT(tile) + height) * SFG_WALL_HEIGHT_STEP) :
  49. @@ -1441,7 +1453,8 @@ RCL_Unit SFG_ceilingHeightAt(int16_t x, int16_t y)
  50. SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP,
  51. (SFG_TILE_CEILING_HEIGHT(tile) + SFG_TILE_FLOOR_HEIGHT(tile))
  52. * SFG_WALL_HEIGHT_STEP,
  53. - SFG_game.frameTime - SFG_currentLevel.timeStart);
  54. + SFG_game.frameTime - SFG_currentLevel.timeStart)
  55. + );
  56. }
  57. /**
  58. diff --git a/settings.h b/settings.h
  59. index a0d8c1f..16674a2 100644
  60. --- a/settings.h
  61. +++ b/settings.h
  62. @@ -343,6 +343,27 @@
  63. #define SFG_BACKGROUND_BLUR 0
  64. #endif
  65. +/**
  66. + Specifies the amplitude of eartquake, in RCL_Units.
  67. +*/
  68. +#ifndef SFG_EARTHQUAKE_HEIGHT
  69. + #define SFG_EARTHQUAKE_HEIGHT 256
  70. +#endif
  71. +
  72. +/**
  73. + Specifies eartquake wavelength, in game tiles.
  74. +*/
  75. +#ifndef SFG_EARTHQUAKE_WAVELENGTH
  76. + #define SFG_EARTHQUAKE_WAVELENGTH 8
  77. +#endif
  78. +
  79. +/**
  80. + Specifies eartquake speen in the wave time period in milliseconds.
  81. +*/
  82. +#ifndef SFG_EARTHQUAKE_SPEED
  83. + #define SFG_EARTHQUAKE_SPEED 1024
  84. +#endif
  85. +
  86. /**
  87. Defines the period, in ms, of things that blink, such as text.
  88. */