stylet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +4 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +16 -0
  6. data/README.org +19 -0
  7. data/Rakefile +17 -0
  8. data/bin/setup +63 -0
  9. data/bin/stylet +8 -0
  10. data/examples/.ruby-version +1 -0
  11. data/examples/00100_lib_hello_world.rb +8 -0
  12. data/examples/00110_lib_sge_check.rb +6 -0
  13. data/examples/00120_lib_/343/202/254/343/203/263/343/203/236/345/200/244/343/201/256/345/244/211/346/233/264.rb +22 -0
  14. data/examples/00130_lib_window_title.rb +8 -0
  15. data/examples/00140_lib_callbacks.rb +8 -0
  16. data/examples/00150_lib_vector.rb +5 -0
  17. data/examples/00160_lib_run.rb +4 -0
  18. data/examples/00170_lib_frame.rb +4 -0
  19. data/examples/00180_lib_config/347/242/272/350/252/215.rb +7 -0
  20. data/examples/00190_lib_/343/201/231/343/201/271/343/201/246/345/220/214/343/201/230/343/202/252/343/203/226/343/202/270/343/202/247/343/202/257/343/203/210.rb +10 -0
  21. data/examples/00200_lib_/343/203/254/343/202/267/343/203/274/343/203/220/343/203/274/343/202/222/347/234/201/347/225/245/343/201/231/343/202/213/346/226/271/346/263/225/343/201/256/343/203/206/343/202/271/343/203/210.rb +28 -0
  22. data/examples/00210_lib_delegators.rb +7 -0
  23. data/examples/00220_lib_template_method.rb +13 -0
  24. data/examples/00230_lib_/350/203/214/346/231/257/347/224/273/345/203/217/350/241/250/347/244/272.rb +9 -0
  25. data/examples/00240_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2171_/351/273/222/343/201/256/344/270/212/343/201/253/350/203/214/346/231/257.rb +18 -0
  26. data/examples/00250_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2172_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222.rb +17 -0
  27. data/examples/00260_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/207/215/343/201/204.rb +27 -0
  28. data/examples/00270_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/253/230/351/200/237/345/214/226.rb +44 -0
  29. data/examples/00280_lib_/347/211/271/345/256/232/343/201/256/343/202/250/343/203/252/343/202/242/343/201/240/343/201/221/345/276/220/343/200/205/343/201/253/346/266/210/343/201/231.rb +26 -0
  30. data/examples/00290_lib_/350/203/214/346/231/257/350/211/262/345/244/211/346/233/264.rb +5 -0
  31. data/examples/00300_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/202/222/350/241/250/347/244/272/343/201/231/343/202/213/344/276/213.rb +17 -0
  32. data/examples/00310_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/201/256/343/202/242/343/203/213/343/203/241/343/203/274/343/202/267/343/203/247/343/203/263.rb +18 -0
  33. data/examples/00320_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/346/213/241/345/244/247/347/270/256/345/260/217/345/233/236/350/273/242.rb +21 -0
  34. data/examples/00330_joystick.rb +5 -0
  35. data/examples/00340_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/345/213/225/343/201/215/343/201/214/345/206/205/351/203/250/343/201/247/343/201/257/345/233/233/350/247/222.rb +30 -0
  36. data/examples/00350_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/350/252/277/346/225/264/346/270/210/343/201/277/343/203/231/343/202/257/343/203/210/343/203/253.rb +12 -0
  37. data/examples/00360_lib_mouse.rb +5 -0
  38. data/examples/00370_lib_input.rb +29 -0
  39. data/examples/00380_lib_vputs_align.rb +8 -0
  40. data/examples/00390_/343/203/225/343/202/251/343/203/263/343/203/210/344/270/200/350/246/247.rb +15 -0
  41. data/examples/00400_lib_draw_circle.rb +8 -0
  42. data/examples/00410_SDL/343/201/256draw_rect/343/201/2571/343/203/224/343/202/257/343/202/273/343/203/253/344/275/231/345/210/206/343/201/253/346/217/217/347/224/273/343/201/225/343/202/214/343/202/213/343/201/256/343/201/247/346/263/250/346/204/217.rb +7 -0
  43. data/examples/00420_circle_on_circle.rb +10 -0
  44. data/examples/00430_rotate.rb +16 -0
  45. data/examples/00440_draw_triangle.rb +7 -0
  46. data/examples/00450_parabora_triangle.rb +37 -0
  47. data/examples/00460_ice_hockey.rb +88 -0
  48. data/examples/00470_collision_block_vs_block.rb +120 -0
  49. data/examples/00480_simple_circle_controll.rb +37 -0
  50. data/examples/00490_/347/255/211/351/200/237/347/247/273/345/213/225_uniform_velocity_rain.rb +51 -0
  51. data/examples/00500_/345/212/240/351/200/237/346/224/276/347/211/251/347/267/232_parabora_volcano.rb +94 -0
  52. data/examples/00510_3d.rb +53 -0
  53. data/examples/00520_/343/203/210/343/203/253/343/203/215/343/201/256/343/203/241/343/203/213/343/203/245/343/203/274/351/242/250/343/201/256/345/213/225/343/201/215.rb +77 -0
  54. data/examples/00530_curve_2/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232/343/201/250/347/233/264/347/267/232/343/201/250/343/201/256/344/272/244/347/202/271.rb +43 -0
  55. data/examples/00540_curve_3/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +40 -0
  56. data/examples/00550_curve_N/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +92 -0
  57. data/examples/00560_curve_/343/202/271/343/203/227/343/203/251/343/202/244/343/203/263/346/233/262/347/267/232.rb +113 -0
  58. data/examples/00570_/345/206/206/351/201/213/345/213/225_circle_jet_coaster.rb +52 -0
  59. data/examples/00580_/345/206/206/343/202/222/346/212/274/343/201/231/343/201/262/343/201/243/343/201/261/343/202/213_collision_circle_vs_circle_push_or_pull.rb +56 -0
  60. data/examples/00590_/350/212/213/350/231/253/343/202/264/343/203/240/347/264/220/343/203/207/343/203/242_collision_demo_circle_worm.rb +104 -0
  61. data/examples/00600_/346/214/257/343/202/212/345/255/220_swing.rb +145 -0
  62. data/examples/00610_/345/206/205/347/251/215/343/201/250/345/244/226/347/251/215_inner_product.rb +36 -0
  63. data/examples/00620_/346/263/225/347/267/232/343/203/231/343/202/257/343/203/210/343/203/253.rb +23 -0
  64. data/examples/00630_/345/206/206/343/201/250/345/206/206/343/201/256/345/217/215/345/260/204_collision_reflect_circle_vs_circle.rb +222 -0
  65. data/examples/00640_/347/202/271/343/201/250/347/267/232/345/210/206/343/201/256/344/272/244/345/267/256/345/210/244/345/256/232_collision_ray_circle_vs_line.rb +261 -0
  66. data/examples/00650_/345/206/206/343/201/250/347/202/271/343/201/256/345/217/215/345/260/204_collision_circle_vs_dot.rb +36 -0
  67. data/examples/00660_/345/206/206/343/201/250/345/206/206/343/201/250/347/267/232/345/210/206/343/201/256/345/217/215/345/260/204/343/203/207/343/203/242_collision_demo.rb +305 -0
  68. data/examples/00670_/343/203/251/343/202/244/343/203/225/343/202/262/343/203/274/343/203/240.rb +86 -0
  69. data/examples/00680_2/347/202/271/343/202/222/351/200/232/343/202/213/347/233/264/347/267/232/343/201/256/346/226/271/347/250/213/345/274/217.rb +81 -0
  70. data/examples/00690_/343/203/222/343/203/253/343/203/231/343/203/253/343/203/210/346/233/262/347/267/232.rb +77 -0
  71. data/examples/00700_/343/202/263/343/203/203/343/203/233/346/233/262/347/267/232.rb +79 -0
  72. data/examples/00710_/343/202/267/343/202/260/343/203/242/343/202/244/343/203/211/346/233/262/347/267/232.rb +40 -0
  73. data/examples/00720_/343/202/267/343/203/200/346/244/215/347/211/251.rb +44 -0
  74. data/examples/00730_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/345/237/272/346/234/254.rb +29 -0
  75. data/examples/00740_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/346/224/271/350/211/257_/350/211/262/344/273/230/343/201/215.rb +68 -0
  76. data/examples/00750_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/343/203/211/343/203/274/343/203/212/343/203/204/345/236/213.rb +44 -0
  77. data/examples/00760_/347/201/253/350/212/261.rb +42 -0
  78. data/examples/00770_atan/343/201/247atan2/343/202/222/346/233/270/343/201/217.rb +26 -0
  79. data/examples/00780_/346/250/231/346/272/226/343/203/251/343/202/244/343/203/226/343/203/251/343/203/252/343/201/256atan2_sin_cos/343/202/222/344/275/277/343/201/206.rb +15 -0
  80. data/examples/00790_/350/247/222/345/272/246/343/201/250/343/203/251/343/202/270/343/202/242/343/203/263/343/201/256/347/233/270/344/272/222/345/244/211/346/217/233.rb +22 -0
  81. data/examples/00800_/347/220/203/343/201/214/347/233/264/347/267/232/347/232/204/343/201/253/345/213/225/343/201/204/343/201/246/343/201/204/343/202/213/343/201/240/343/201/221/343/201/247/345/233/236/350/273/242/343/201/227/343/201/246/343/201/204/343/202/213/343/202/210/343/201/206/343/201/253/350/246/213/343/201/210/343/202/213.rb +27 -0
  82. data/examples/00810_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/350/273/212.rb +75 -0
  83. data/examples/00820_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/346/210/246/350/273/212.rb +90 -0
  84. data/examples/00830_/350/247/222/345/272/246/345/267/256.rb +36 -0
  85. data/examples/00840_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/346/231/202/351/226/223/345/233/272/345/256/232.rb +61 -0
  86. data/examples/00850_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/350/247/222/345/272/246/345/233/272/345/256/232.rb +84 -0
  87. data/examples/00860_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/351/200/237/345/272/246/345/233/272/345/256/232.rb +66 -0
  88. data/examples/00870_/350/247/222/345/272/246/350/243/234/346/255/243_/345/212/240/351/200/237/343/203/237/343/202/265/343/202/244/343/203/253.rb +60 -0
  89. data/examples/00880_/345/210/235/351/200/237/343/201/214/351/200/237/343/201/204/343/203/237/343/202/265/343/202/244/343/203/253.rb +51 -0
  90. data/examples/00890_/346/255/243/350/246/217/344/271/261/346/225/260/343/201/250/346/250/231/346/272/226/345/201/217/345/267/256/343/201/256/345/217/257/350/246/226/345/214/226.rb +72 -0
  91. data/examples/00900_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/350/247/222/345/272/2460/345/272/246/343/201/213/343/202/211/343/200/221.rb +23 -0
  92. data/examples/00910_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/344/273/273/346/204/217/343/201/256/350/247/222/345/272/246/343/201/213/343/202/211/343/200/221.rb +33 -0
  93. data/examples/00920_/343/203/236/343/203/252/343/202/252/343/203/226/343/203/251/343/202/266/343/203/274/343/202/272/351/242/250/343/201/253/347/224/273/351/235/242/344/270/241/347/253/257/343/201/214/347/271/213/343/201/243/343/201/246/343/201/204/343/202/213/344/276/213.rb +29 -0
  94. data/examples/00930_/345/212/271/346/236/234/351/237/263.rb +17 -0
  95. data/examples/00940_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/343/203/236/343/203/203/343/203/227/351/205/215/347/275/256.rb +71 -0
  96. data/examples/00950_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/350/241/250/347/244/272/344/276/213.rb +28 -0
  97. data/examples/00960_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/250/345/215/230/344/270/200/347/224/273/345/203/217/343/201/256/351/201/225/343/201/204/343/202/222/345/220/270/345/217/216/343/201/231/343/202/213/344/276/213.rb +47 -0
  98. data/examples/00970_observer_/343/201/235/343/201/2561_/347/233/264/346/216/245.rb +28 -0
  99. data/examples/00980_observer_/343/201/235/343/201/2562_/346/231/256/351/200/232/343/201/253Singleton/347/211/210.rb +30 -0
  100. data/examples/00990_observer_/343/201/235/343/201/2563_SimpleDelegator/347/211/210.rb +28 -0
  101. data/examples/01000_observer_/343/201/235/343/201/2564_/351/200/206/343/201/253/343/203/253/343/203/274/343/203/227/344/270/273/345/260/216.rb +28 -0
  102. data/examples/01010_observer_/343/201/235/343/201/2565_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/202/223/343/201/247/343/201/204/343/202/213/343/201/221/343/201/251Singleton/343/201/252/343/201/256/343/201/247/345/256/211/345/205/250.rb +37 -0
  103. data/examples/01020_observer_/343/201/235/343/201/2566_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/201/266/345/240/264/345/220/210callbacks/343/202/222/344/275/277/343/202/217/343/201/252/343/201/204/343/202/210/343/201/206/343/201/253.rb +30 -0
  104. data/examples/01030_observer_/343/201/235/343/201/2567_/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/343/202/277/343/202/271/343/202/257/343/202/222/345/233/236/343/201/231/344/276/213.rb +57 -0
  105. data/examples/01040_/343/203/236/343/202/246/343/202/271/343/201/256/344/275/215/347/275/256/343/201/253/343/203/224/343/202/257/343/202/273/343/203/253/343/202/222/346/211/223/343/201/244.rb +18 -0
  106. data/examples/01050_/343/203/224/343/202/257/343/202/273/343/203/253/345/205/250/344/275/223/343/202/222/346/233/270/343/201/215/350/276/274/343/202/200.rb +27 -0
  107. data/examples/01060_effect_/347/224/273/345/203/217/343/201/256/343/202/263/343/203/263/343/203/234/343/203/252/343/203/245/343/203/274/343/203/210/346/263/225/343/201/253/343/202/210/343/202/213/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/345/207/246/347/220/206.rb +116 -0
  108. data/examples/01070_effect_FF7/343/201/256/346/210/246/351/227/230/343/201/253/345/205/245/343/202/213/343/201/250/343/201/215/343/201/256/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210.rb +33 -0
  109. data/examples/01080_effect_/350/203/214/346/231/257/343/202/222/347/267/251/343/201/217/346/266/210/343/201/227/343/201/246/343/201/204/343/201/217/343/201/250/343/202/271/343/203/240/343/203/274/343/202/272/343/201/253/343/201/252/343/202/213.rb +16 -0
  110. data/examples/01090_/347/224/273/345/203/217/343/201/256/343/202/257/343/203/255/343/202/271/343/203/225/343/202/247/343/203/274/343/203/211.rb +37 -0
  111. data/examples/01100_/343/202/271/343/202/257/343/203/252/343/203/274/343/203/263/346/203/205/345/240/261.rb +8 -0
  112. data/examples/01110_lib_contrib_menu.rb +19 -0
  113. data/examples/01120_/351/233/233/345/236/213_2P/345/257/276/346/210/246/351/242/250STG.rb +109 -0
  114. data/examples/01130_/351/233/233/345/236/213_/346/210/246/350/273/212/345/257/276/346/210/246.rb +396 -0
  115. data/examples/01140_/351/233/233/345/236/213_2P/345/257/276/346/210/246.rb +60 -0
  116. data/examples/01150_/351/233/233/345/236/213_/343/202/271/343/203/274/343/203/221/343/203/274/343/203/236/343/203/252/343/202/252/351/242/250/343/202/242/343/202/257/343/202/267/343/203/247/343/203/263.rb +1251 -0
  117. data/examples/01160_2D/343/202/242/343/203/225/343/202/243/343/203/263/345/244/211/346/217/233.rb +40 -0
  118. data/examples/01170_stackprof.rb +10 -0
  119. data/examples/01180_sdl_/343/202/242/343/203/253/343/203/225/343/202/241/343/203/226/343/203/254/343/203/263/343/203/207/343/202/243/343/203/263/343/202/260/343/201/247/351/207/215/343/201/255/345/220/210/343/201/233/345/241/227/343/202/212/346/275/260/343/201/227.rb +11 -0
  120. data/examples/01190_/343/203/221/343/203/274/343/203/206/343/202/243/343/202/257/343/203/253/345/220/214/345/243/253/343/201/247/344/270/255/345/244/256/343/201/253/345/220/221/343/201/213/343/201/206.rb +79 -0
  121. data/examples/01200_lib_OpenGL.rb +55 -0
  122. data/examples/bezier.rb +202 -0
  123. data/examples/cursor.rb +50 -0
  124. data/examples/helper.rb +38 -0
  125. data/examples/lifegame_patterns.rb +102 -0
  126. data/examples/movable_point.rb +64 -0
  127. data/examples/mtx33.rb +294 -0
  128. data/examples/setup.rb +5 -0
  129. data/examples/stage_infos.rb +1 -0
  130. data/examples/start.sh +2 -0
  131. data/examples/test_all.rb +5 -0
  132. data/examples/testgl.rb +228 -0
  133. data/examples/trash/__0060_shooting2.rb +37 -0
  134. data/examples/trash/__0090_collision_circle1.rb +50 -0
  135. data/examples/trash/__0125_circle_collision.rb +103 -0
  136. data/examples/trash/__0130_circle_collision2.rb +60 -0
  137. data/examples/trash/__0270_circle_cycle_shift.rb +29 -0
  138. data/examples/trash/__bullet_algos.rb +224 -0
  139. data/examples/trash/gunship.rb +39 -0
  140. data/examples//343/203/227/343/203/255/343/202/270/343/202/247/343/202/257/343/202/277/343/203/274/343/201/253/350/241/250/347/244/272/343/201/231/343/202/213/343/201/250/343/201/215.sh +2 -0
  141. data/lib/stylet.rb +1 -0
  142. data/lib/stylet/application_memory_record.rb +33 -0
  143. data/lib/stylet/audio.rb +455 -0
  144. data/lib/stylet/axis_support.rb +62 -0
  145. data/lib/stylet/base.rb +76 -0
  146. data/lib/stylet/callbacks.rb +62 -0
  147. data/lib/stylet/cli.rb +54 -0
  148. data/lib/stylet/collision_support.rb +56 -0
  149. data/lib/stylet/config.rb +39 -0
  150. data/lib/stylet/contrib/menu.rb +508 -0
  151. data/lib/stylet/contrib/shared_pad.rb +32 -0
  152. data/lib/stylet/contrib/sprity.rb +149 -0
  153. data/lib/stylet/core.rb +118 -0
  154. data/lib/stylet/cpu_stat.rb +58 -0
  155. data/lib/stylet/delegators.rb +54 -0
  156. data/lib/stylet/draw.rb +256 -0
  157. data/lib/stylet/draw_support/arrow.rb +56 -0
  158. data/lib/stylet/draw_support/circle.rb +63 -0
  159. data/lib/stylet/draw_support/polygon.rb +22 -0
  160. data/lib/stylet/font.rb +172 -0
  161. data/lib/stylet/fps_adjust.rb +23 -0
  162. data/lib/stylet/fps_stat.rb +41 -0
  163. data/lib/stylet/input.rb +8 -0
  164. data/lib/stylet/input/base.rb +105 -0
  165. data/lib/stylet/input/hardware_bindings.rb +65 -0
  166. data/lib/stylet/input/key_one.rb +162 -0
  167. data/lib/stylet/input/support.rb +72 -0
  168. data/lib/stylet/joystick.rb +31 -0
  169. data/lib/stylet/joystick_adapter.rb +130 -0
  170. data/lib/stylet/joystick_adapters/buffalo_snes_adapter.rb +47 -0
  171. data/lib/stylet/joystick_adapters/elecom_usb_pad_adapter.rb +30 -0
  172. data/lib/stylet/joystick_adapters/hori_rap_v3_sa_adapter.rb +46 -0
  173. data/lib/stylet/joystick_adapters/ps3_standard_adapter.rb +40 -0
  174. data/lib/stylet/joystick_adapters/unknown_adapter.rb +13 -0
  175. data/lib/stylet/keyboard.rb +15 -0
  176. data/lib/stylet/logger.rb +12 -0
  177. data/lib/stylet/mouse.rb +58 -0
  178. data/lib/stylet/palette.rb +17 -0
  179. data/lib/stylet/rect.rb +113 -0
  180. data/lib/stylet/shortcut.rb +8 -0
  181. data/lib/stylet/state.rb +87 -0
  182. data/lib/stylet/stylet.rb +44 -0
  183. data/lib/stylet/system_pause.rb +24 -0
  184. data/lib/stylet/version.rb +3 -0
  185. data/log/.gitkeep +0 -0
  186. data/stylet.gemspec +31 -0
  187. data/test/test_helper.rb +6 -0
  188. data/test/test_input_base.rb +12 -0
  189. data/test/test_input_key_one.rb +43 -0
  190. data/test/test_input_support.rb +47 -0
  191. data/test/test_sample.rb +13 -0
  192. data/test/test_state.rb +26 -0
  193. data/tips.org +16 -0
  194. metadata +391 -0
@@ -0,0 +1,113 @@
1
+ #
2
+ # スプラインの描画
3
+ #
4
+ # Flashゲーム講座&ASサンプル集【曲線について】
5
+ # http://hakuhin.jp/as/curve.html#CURVE_04
6
+ #
7
+ require_relative "helper"
8
+
9
+ class SprineApp < Stylet::Base
10
+ include Helper::CursorWithObjectCollection
11
+ include Helper::MovablePoint
12
+
13
+ setup do
14
+ self.title = "スプライン曲線"
15
+ @points = 5.times.collect { srect.center + vec2.rand * srect.height * 0.5}
16
+ end
17
+
18
+ update do
19
+ a = spline_stream(@points, 256) # 点と点の間をN分割する
20
+ a.each_cons(2) {|a, b| draw_line(a, b) }
21
+ update_movable_points(@points)
22
+ @points.each_with_index {|e, i| vputs("#{i}", :vector => e) }
23
+ ship(a)
24
+ end
25
+
26
+ def ship(a)
27
+ # 区間をN分割なので角に来るとブレーキがかかる感じになる
28
+ t0 = 0.5 + (Stylet::Magic.rsin(1.0 / 256 / 4 * (frame_counter + 0)) * 0.5) # 現在の位置(0.0〜1.0)
29
+ t1 = 0.5 + (Stylet::Magic.rsin(1.0 / 256 / 4 * (frame_counter + 16)) * 0.5) # 現在の位置(0.0〜1.0)
30
+ p0 = a[((a.size - 1).to_f * t0).to_i] # 現在の座標
31
+ p1 = a[((a.size - 1).to_f * t1).to_i] # 現在の座標
32
+ draw_triangle(p0, :angle => p0.angle_to(p1), :vertex => 3)
33
+ end
34
+
35
+ # a-b-c の場合 a-b b-c 区間をそれぞれ interpolate 分割する
36
+ def spline_stream(points, interpolate)
37
+ num = points.length
38
+ l = []
39
+ _a = []
40
+ _b = []
41
+ _c = []
42
+
43
+ (num - 1).times {|i|
44
+ p0 = points[i]
45
+ p1 = points[i + 1]
46
+ l[i] = Math.sqrt((p0.x - p1.x) * (p0.x - p1.x) + (p0.y - p1.y) * (p0.y - p1.y))
47
+ }
48
+
49
+ _a[0] = [0, 1, 0.5]
50
+ _b[0] = (points[1] - points[0]) * (3.0 / (2 * l[0]))
51
+
52
+ _a[num - 1] = [1, 2, 0]
53
+ _b[num - 1] = (points[num - 1] - points[num - 2]) * (3.0 / l[num - 2])
54
+
55
+ (1...(num - 1)).each do |i|
56
+ a = l[i - 1]
57
+ b = l[i]
58
+ _a[i] = [b, 2.0 * (b + a), a]
59
+ _b[i] = (((points[i + 1] - points[i]) * 3.0 * a * a) + ((points[i] - points[i - 1]) * 3.0 * b * b)) / (b * a)
60
+ end
61
+ (1...num).each do |i|
62
+ d = _a[i - 1][1] / _a[i][0]
63
+
64
+ _a[i] = [0, _a[i][1] * d - _a[i - 1][2], _a[i][2] * d]
65
+ _b[i] = (_b[i] * d) - _b[i - 1]
66
+
67
+ _a[i][2] /= _a[i][1]
68
+ _b[i].x /= _a[i][1]
69
+ _b[i].y /= _a[i][1]
70
+ _a[i][1] = 1
71
+ end
72
+
73
+ _c[num - 1] = _b[num - 1]
74
+ j = num - 1
75
+ while j > 0
76
+ # ベクトル同士のかけ算のメソッドを用意してないためこれでいい
77
+ _c[j - 1] = vec2[
78
+ _b[j - 1].x - _a[j - 1][2] * _c[j].x,
79
+ _b[j - 1].y - _a[j - 1][2] * _c[j].y,
80
+ ]
81
+ j -= 1
82
+ end
83
+
84
+ out = []
85
+ frame_counter = 0
86
+ (num - 1).times do |i|
87
+ a = l[i]
88
+ _v00 = points[i].x
89
+ _v01 = _c[i].x
90
+ _v02 = (points[i + 1].x - points[i].x) * 3 / (a * a) - (_c[i + 1].x + 2 * _c[i].x) / a
91
+ _v03 = (points[i + 1].x - points[i].x) * (-2 / (a * a * a)) + (_c[i + 1].x + _c[i].x) * (1 / (a * a))
92
+ _v10 = points[i].y
93
+ _v11 = _c[i].y
94
+ _v12 = (points[i + 1].y - points[i].y) * 3 / (a * a) - (_c[i + 1].y + 2 * _c[i].y) / a
95
+ _v13 = (points[i + 1].y - points[i].y) * (-2 / (a * a * a)) + (_c[i + 1].y + _c[i].y) * (1 / (a * a))
96
+
97
+ t = 0.0
98
+ interpolate.times {
99
+ out << vec2[
100
+ ((_v03 * t + _v02) * t + _v01) * t + _v00,
101
+ ((_v13 * t + _v12) * t + _v11) * t + _v10,
102
+ ]
103
+ t += a / interpolate
104
+ }
105
+ end
106
+
107
+ out << points.last
108
+
109
+ out
110
+ end
111
+
112
+ run
113
+ end
@@ -0,0 +1,52 @@
1
+ #
2
+ # ギャラガの敵の動き
3
+ #
4
+ require_relative "helper"
5
+
6
+ class Ball
7
+ include Stylet::Delegators
8
+
9
+ delegate :xc, :yc, :to => "Stylet.context"
10
+
11
+ def initialize(index)
12
+ @index = index
13
+ end
14
+
15
+ def update
16
+ p0 = pos_new(frame_counter) # 現在の位置を取得
17
+ p1 = pos_new(frame_counter.next) # 次のフレームの位置を取得
18
+ dir = p0.angle_to(p1) # 現在の位置から見て未来の角度を取得
19
+ draw_circle(p0, :radius => 20, :vertex => 3, :angle => dir) # 次に進む方向に向けて三角を表示
20
+ end
21
+
22
+ #
23
+ # countフレーム地点の位置を取得
24
+ #
25
+ def pos_new(frame_counter)
26
+ srect.center + vec2[
27
+ Stylet::Magic.rcos(1.0 / 512 * (frame_counter * xc + @index * 24)) * srect.w * 0.4,
28
+ Stylet::Magic.rsin(1.0 / 512 * (frame_counter * yc + @index * 24)) * srect.h * 0.4,
29
+ ]
30
+ end
31
+ end
32
+
33
+ class App < Stylet::Base
34
+ include Helper::CursorWithObjectCollection
35
+
36
+ attr_reader :xc, :yc
37
+
38
+ setup do
39
+ cursor.display = false
40
+ @objects += Array.new(16) {|i|Ball.new(i)}
41
+ @xc = 3.5
42
+ @yc = 4.0
43
+ end
44
+
45
+ update do
46
+ @xc += 0.5 * (@button.btA.repeat + -@button.btB.repeat)
47
+ @yc += 0.5 * (@button.btC.repeat + -@button.btD.repeat)
48
+ vputs [@xc, @yc]
49
+ end
50
+
51
+ run
52
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # 円同士の当り判定(ベクトルを使った方法)
3
+ #
4
+ require_relative "helper"
5
+
6
+ class App < Stylet::Base
7
+ include Helper::CursorWithObjectCollection
8
+
9
+ setup do
10
+ self.title = "円の押し引き"
11
+
12
+ # カーソルを円として使う
13
+ cursor.radius = 100
14
+ cursor.vertex = 32
15
+
16
+ @pos = srect.center.clone
17
+ @radius = 100
18
+ end
19
+
20
+ update do
21
+ a = cursor.point
22
+ ar = cursor.radius
23
+
24
+ b = @pos
25
+ br = @radius
26
+
27
+ r2 = ar + br
28
+ if a != b
29
+ diff = b - a
30
+ rdiff = r2 - diff.magnitude
31
+ if button.btA.press?
32
+ vputs "PUSH"
33
+ if rdiff > 0
34
+ # a = b + diff.normalize * r2 # Bを基点に押し出す
35
+ b += diff.normalize * rdiff # Aを基点に押し出す
36
+ end
37
+ end
38
+ if button.btB.press?
39
+ vputs "PULL"
40
+ if rdiff < 0
41
+ # a = b + diff.normalize * r2 # Bを基点に戻す
42
+ b += diff.normalize * rdiff # Aを基点に戻す
43
+ end
44
+ end
45
+ vputs "DIFF=#{diff.magnitude}"
46
+ vputs "RDIFF=#{rdiff}"
47
+ end
48
+
49
+ @pos = b
50
+
51
+ draw_line(@pos, cursor.point)
52
+ draw_circle(@pos, :radius => @radius, :vertex => 32)
53
+ end
54
+
55
+ run
56
+ end
@@ -0,0 +1,104 @@
1
+ #
2
+ # 芋虫・多関節・ゴム・紐
3
+ #
4
+ require_relative "helper"
5
+
6
+ class Joint
7
+ include Stylet::Delegators
8
+ attr_accessor :p0
9
+
10
+ def initialize(index, p0)
11
+ @index = index # 自分の番号
12
+ @p0 = p0 # 間接の位置
13
+ end
14
+
15
+ def update
16
+ # 次の位置の間接を取得
17
+ @target = Stylet.context.objects[@index.next]
18
+
19
+ if @target
20
+ distance = @p0.distance_to(@target.p0)
21
+ gap = distance - Stylet.context.magnitude
22
+ if gap > 0
23
+ # 相手の方から自分の方へ移動する
24
+ # そのときの移動量を Stylet.context.hard_level で調整する
25
+ # 1.0 なら相手との間隔をすべて埋めることになるので紐になる
26
+ # 0.1 ならゆっくりと自分に近付いてくる
27
+ len = gap * Stylet.context.hard_level
28
+ dir = @target.p0.angle_to(@p0)
29
+ @target.p0 += vec2.angle_at(dir) * len
30
+
31
+ # 固さ 1.0 のときは次のように p0 の方から相手をひっぱる方法でもよいが前者の方が、ゆっくり移動させるなど応用が効く
32
+ # dir = @p0.angle_to(@target.p0)
33
+ # @target.p0 += vec2.angle_at(dir) * Stylet.context.magnitude
34
+ end
35
+ end
36
+
37
+ # 頭だけカーソルで動かす
38
+ if @index.zero?
39
+ @p0 = Stylet.context.cursor.point
40
+ end
41
+
42
+ # 次の間接まで線を引く
43
+ if @target
44
+ Stylet.context.draw_line(@p0, @target.p0)
45
+ end
46
+
47
+ # 胴体の表示
48
+ if Stylet.context.body_display
49
+ Stylet.context.draw_circle(@p0, :radius => Stylet.context.magnitude / 2, :vertex => 16)
50
+ end
51
+ end
52
+ end
53
+
54
+ class App < Stylet::Base
55
+ include Helper::CursorWithObjectCollection
56
+
57
+ attr_reader :body_display
58
+ attr_reader :magnitude
59
+ attr_reader :hard_level
60
+
61
+ setup do
62
+ @objects = Array.new(42) {|i|Joint.new(i, srect.center.clone)}
63
+ @cursor.display = false # 三角カーソル非表示
64
+
65
+ @body_display = true # 胴体描画モード
66
+ @magnitude = 32 # 線と線の間
67
+ @hard_level = 1.0 # 幼虫の間接の伸び(堅い1.0〜柔らか0.1)
68
+
69
+ self.title = "芋虫・多関節・ゴム・紐"
70
+ end
71
+
72
+ update do
73
+ # 操作
74
+ begin
75
+ # 間接と間接の距離の調整
76
+ @magnitude += (@button.btA.repeat - @button.btB.repeat)
77
+ @magnitude = Stylet::Chore.clamp(@magnitude, (1..80))
78
+
79
+ # 固さ調整
80
+ @hard_level += (@button.btC.repeat - @button.btD.repeat) * 0.1
81
+ @hard_level = Stylet::Chore.clamp(@hard_level, 0.0..1.0)
82
+
83
+ # 円の表示トグル
84
+ if key_down?(SDL::Key::A)
85
+ @body_display = !@body_display
86
+ end
87
+ end
88
+
89
+ # 操作説明
90
+ vputs "A:body_display"
91
+ vputs "Z:len++ X:len-- C:hard_level++ V:hard_level--"
92
+ vputs "magnitude=#{@magnitude}"
93
+ vputs "hard_level=#{@hard_level}"
94
+
95
+ # 固さ1.0なら紐モード表示
96
+ if @hard_level == 1.0
97
+ vputs "string mode"
98
+ else
99
+ vputs "worm mode"
100
+ end
101
+ end
102
+
103
+ run
104
+ end
@@ -0,0 +1,145 @@
1
+ #
2
+ # 振り子のアルゴリズム
3
+ #
4
+ # 円の中心
5
+ # p0 ----- pA (鉄球) ----> dir1 (pAの方向)
6
+ # \ ↓
7
+ # \ ↓
8
+ # \ ↓gravity (重力)
9
+ # \ ↓
10
+ # \ ↓
11
+ # pB (重力を反映した座標) ※仮想鉄球
12
+ # \
13
+ # dir2 (pBの方向)
14
+ #
15
+ require_relative "helper"
16
+
17
+ class App < Stylet::Base
18
+ include Helper::CursorWithObjectCollection
19
+
20
+ setup do
21
+ self.title = "振り子"
22
+
23
+ @p0 = srect.center + vec2[0, -srect.h * 0] # 円の中心
24
+ @dir1 = Stylet::Magic.clock(1) # 角度
25
+ @speed = 0 # 角速度
26
+ @friction = 0.0 # 摩擦(0.0:なし 1.0:最大)
27
+ @radius = srect.hy * 0.5 # 糸の長さ
28
+ @ball_radius = 32 # 鉄球自体の半径
29
+ @dir2 = nil # 振り子の中心(p0)からの重力反映座標(pB)の角度
30
+ @gravity = vec2[0, 1] # 重力加速度(整数で指定すること)
31
+ @debug_mode = false
32
+ end
33
+
34
+ update do
35
+ begin
36
+ if button.btA.press? || button.btB.press?
37
+ # 重力調整
38
+ @gravity += @gravity.normalize.scale(button.btA.repeat) + @gravity.normalize.scale(-button.btB.repeat)
39
+ @gravity.y = Stylet::Chore.clamp(@gravity.y, (1..@radius))
40
+ @speed = 0
41
+ end
42
+
43
+ # Aボタンが押されているときだけ鉄球の位置をカーソルの方向に向ける
44
+ if button.btD.press?
45
+ @dir1 = @p0.angle_to(cursor.point)
46
+ @speed = 0
47
+ end
48
+
49
+ if button.btC.trigger?
50
+ @debug_mode = !@debug_mode
51
+ end
52
+ end
53
+
54
+ # 鉄球の座標(pA)を求める
55
+ @pA = @p0 + vec2.angle_at(@dir1).scale(@radius)
56
+
57
+ # 鉄球の座標から重力を反映した座標(pB)を求める(pBを経由しなくてもpCは求まる)
58
+ @pB = @pA + @gravity
59
+
60
+ # 鉄球の座標から重力を反映した座標(pC)を求める(これはどういう数式?)
61
+ v = @pA - @p0
62
+ t = -(v.y * @gravity.y) / (v.x**2 + v.y**2)
63
+ @pC = @pA + @gravity + v.scale(t)
64
+
65
+ # 振り子の中心(p0)から重力反映座標(pC)の角度(@dir2)を求める
66
+ @dir2 = @p0.angle_to(@pC)
67
+
68
+ # 鉄球の角度が dir1=0.9 (時計の14分の角度)
69
+ # 仮想鉄球の角度が dir2=0.1 (時計の16分の角度)の場合、
70
+ # 差分は正になるべきなのだけど
71
+ # 差分を求めるために 0.1 - 0.9 をすると -0.8 になってしまい
72
+ # 15分のあたりにいるのに逆向きに進もうとしてしまう。
73
+ # これは15分の位置が一周の基点になっているためのおこる。
74
+ # 対策として右半分にいるときかつ @dir2 の方が小さいとき @dir2 は一周したことにする
75
+ # ただ 1.0 するのではなく @dir1 が進みすぎて一周したということにしたいので @dir1.round を加算してみたが、これはおかしくなる
76
+ # 1.0 加算するのが正解っぽい
77
+ if Stylet::Magic.cright?(@dir1)
78
+ if @dir2 < @dir1
79
+ @dir2 += 1.0
80
+ end
81
+ end
82
+
83
+ # 仮想鉄球の角度と現在の角度の差を求める
84
+ @diff = @dir2 - @dir1
85
+ # @diff = (@pC - @pA).magnitude
86
+ # vputs @diff
87
+
88
+ # 加速
89
+ @speed += @diff
90
+ # 摩擦によって減速
91
+ @speed *= (1.0 - @friction)
92
+ # 進む
93
+ @dir1 += @speed
94
+
95
+ # 中心と鉄球の線
96
+ draw_line(@p0, @pA)
97
+
98
+ # 鉄球
99
+ draw_circle(@pA, :radius => @ball_radius, :vertex => 16)
100
+
101
+ # デバッグモード
102
+ if @debug_mode || button.btD.press?
103
+ # 仮想鉄球への紐
104
+ draw_line(@p0, @pA)
105
+
106
+ # 実鉄球から仮想鉄球への線
107
+ # draw_line(@p0, @pB)
108
+ draw_line(@p0, @pC) # 振り子の中心(p0)から重力反映座標(pC)への線を表示確認
109
+ draw_line(@pA, @pB)
110
+ draw_line(@pB, @pC)
111
+ draw_line(@pA, @pC)
112
+ vputs "P", :vector => @p0
113
+ vputs "A", :vector => @pA
114
+ vputs "B", :vector => @pB
115
+ vputs "C", :vector => @pC
116
+
117
+ # 90度ずらした線を引く
118
+ rad90_line
119
+
120
+ # 軌道の円周
121
+ draw_circle(@p0, :radius => @radius, :vertex => 32)
122
+
123
+ # draw_line(@pB, @pB + (@pA - @pB).scale(2))
124
+ end
125
+
126
+ vputs "dir1: #{@dir1}"
127
+ vputs "dir2: #{@dir2}"
128
+ vputs "diff: #{@diff}"
129
+ vputs "speed: #{@speed}"
130
+ vputs "gravity: #{@gravity.magnitude}"
131
+
132
+ vputs "Z:g++ X:g-- C:debug V:drag"
133
+ end
134
+
135
+ # 90度ずらした線を引く
136
+ def rad90_line
137
+ # draw_line(@pB, @pC)
138
+ # _r = 256
139
+ # p2 = @pA + vec2.angle_at(@dir1 - Stylet::Magic.r90) * _r
140
+ # p3 = @pA + vec2.angle_at(@dir1 + Stylet::Magic.r90) * _r
141
+ # draw_line(p2, p3)
142
+ end
143
+
144
+ run
145
+ end