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,5 @@
1
+ $LOAD_PATH.unshift "#{__dir__}/../lib"
2
+ require "stylet"
3
+ require "observer"
4
+ require "stylet/contrib/menu"
5
+ require "active_support/core_ext/benchmark"
@@ -0,0 +1 @@
1
+ {2 => {:world_wh => [1280, 960], :positions => {"Mario" => [[288, 904]], "Luigi" => [[334, 904]], "SoftBlock" => [[80, 560], [112, 560], [144, 560], [176, 560], [48, 624], [80, 624], [112, 624], [144, 624], [176, 624], [208, 624], [208, 656], [208, 688], [176, 720], [144, 752], [112, 752], [80, 752], [272, 560], [304, 560], [336, 560], [368, 560], [400, 560], [432, 560], [464, 560], [464, 592], [464, 624], [464, 656], [432, 688], [400, 720], [368, 752], [336, 752], [624, 560], [656, 560], [528, 624], [560, 624], [592, 624], [560, 560], [592, 560], [688, 560], [624, 624], [656, 624], [688, 624], [720, 624], [720, 656], [720, 688], [688, 720], [656, 752], [624, 752], [592, 752], [784, 656], [816, 656], [848, 624], [880, 592], [912, 560], [944, 560], [880, 624], [880, 656], [880, 688], [880, 720], [848, 752], [1008, 560], [1040, 560], [1104, 560], [1072, 560], [1136, 560], [1168, 560], [1168, 592], [1168, 624], [1168, 656], [1136, 688], [1104, 720], [1072, 752], [1040, 752], [1232, 560], [1232, 592], [1232, 624], [1232, 656], [1232, 688], [1232, 752], [80, 80], [112, 80], [144, 80], [176, 80], [176, 112], [80, 112], [80, 144], [80, 176], [112, 176], [144, 176], [176, 240], [176, 272], [144, 272], [112, 272], [80, 272], [80, 240], [176, 208], [176, 176], [368, 80], [368, 112], [368, 144], [368, 208], [368, 240], [368, 272], [368, 176], [400, 176], [432, 176], [432, 208], [432, 240], [432, 272], [624, 272], [624, 240], [624, 208], [624, 176], [656, 176], [688, 176], [688, 208], [688, 240], [688, 272], [656, 272], [752, 80], [752, 112], [752, 144], [752, 176], [752, 208], [752, 240], [752, 272], [816, 336], [848, 336], [880, 336], [848, 368], [848, 400], [848, 432], [848, 464], [816, 464], [976, 400], [1008, 400], [1008, 368], [1008, 336], [976, 336], [944, 336], [944, 368], [944, 400], [944, 432], [944, 464], [976, 464], [1008, 464], [1136, 368], [1136, 336], [1104, 336], [1072, 336], [1072, 368], [1072, 400], [1072, 432], [1072, 464], [1104, 464], [1136, 432], [1136, 464], [1232, 464], [1232, 432], [1232, 400], [1232, 368], [1232, 336], [1200, 336], [1264, 336], [848, 112], [848, 144], [848, 176], [848, 80], [880, 80], [912, 80], [944, 80], [976, 80], [1008, 80], [1040, 80], [1072, 80], [1232, 80], [1200, 80], [1168, 80], [1136, 80], [1104, 80], [1264, 80], [1264, 112], [1264, 144], [1264, 176], [1264, 208], [1264, 240], [1264, 272], [1232, 272], [1200, 272], [1168, 272], [1136, 272], [1104, 272], [1072, 272], [1040, 272], [1008, 272], [976, 272], [944, 272], [912, 272], [880, 272], [848, 272], [848, 240], [848, 208], [240, 144], [272, 144], [304, 144], [304, 176], [240, 176], [240, 208], [240, 240], [240, 272], [272, 272], [304, 272], [304, 240], [496, 176], [560, 176], [528, 176], [496, 208], [496, 240], [496, 272], [528, 272], [560, 272], [560, 240], [560, 208], [1104, 496], [1168, 496], [752, 432], [752, 400], [720, 400], [688, 400], [688, 432], [688, 464], [720, 464], [752, 464], [624, 464], [592, 432], [560, 400], [560, 368], [560, 336], [592, 336], [624, 336], [624, 368], [624, 400], [592, 400], [560, 432], [560, 464], [496, 368], [496, 336], [464, 336], [432, 336], [432, 368], [432, 400], [432, 432], [432, 464], [464, 400], [496, 400], [368, 336], [368, 368], [368, 400], [368, 432], [368, 464], [304, 400], [304, 432], [304, 464], [272, 464], [240, 464], [240, 432], [240, 400], [272, 400], [176, 336], [176, 368], [176, 400], [176, 432], [176, 464], [144, 464], [112, 464], [112, 432], [112, 400], [144, 400], [48, 336], [48, 400], [48, 432], [48, 464], [16, 944], [16, 944], [48, 944], [80, 944], [112, 944], [144, 944], [176, 944], [208, 944], [240, 944], [272, 944], [304, 944], [336, 944], [368, 944], [400, 944], [432, 944], [464, 944], [496, 944], [528, 944], [560, 944], [592, 944], [624, 944], [656, 944], [688, 944], [720, 944], [752, 944], [784, 944], [816, 944], [848, 944], [880, 944], [912, 944], [944, 944], [976, 944], [1008, 944], [1040, 944], [1072, 944], [1104, 944], [1136, 944], [1168, 944], [1200, 944], [1232, 944], [1264, 944]], "Coin" => [[80, 528], [112, 528], [144, 528], [176, 528], [592, 720], [624, 720], [656, 720], [688, 688], [1168, 464], [1232, 528], [1136, 656], [1104, 688], [1072, 720], [432, 656], [400, 688], [432, 624], [432, 592], [368, 720], [80, 656], [112, 656], [144, 656], [176, 656], [112, 720], [144, 720], [560, 528], [624, 528], [688, 528], [656, 592], [592, 592], [656, 656], [592, 656], [624, 656], [688, 656], [1136, 592], [1136, 624], [1104, 592], [1072, 592], [1040, 592], [1008, 592], [880, 112], [912, 112], [944, 112], [976, 112], [1008, 112], [1040, 112], [1072, 112], [1104, 112], [1136, 112], [1168, 112], [1200, 112], [1232, 112], [1232, 144], [1200, 144], [1168, 144], [1136, 144], [1104, 144], [1072, 144], [1040, 144], [1008, 144], [976, 144], [944, 144], [912, 144], [880, 176], [880, 208], [880, 240], [912, 240], [944, 240], [976, 240], [1008, 240], [1040, 240], [1072, 240], [1104, 240], [1136, 240], [1168, 240], [1200, 240], [1232, 240], [1232, 208], [1232, 176], [1200, 176], [1200, 208], [1168, 208], [1136, 208], [1104, 208], [1072, 208], [1040, 208], [1008, 208], [976, 208], [944, 208], [912, 208], [912, 176], [944, 176], [976, 176], [1008, 176], [1040, 176], [1072, 176], [1104, 176], [1136, 176], [1168, 176], [400, 144], [432, 144], [624, 144], [656, 144], [688, 144], [656, 208], [656, 240], [112, 112], [144, 112], [144, 144], [112, 144], [880, 144], [848, 48], [1264, 48], [1232, 48], [1200, 48], [1168, 48], [1136, 48], [1104, 48], [1072, 48], [1040, 48], [1008, 48], [976, 48], [944, 48], [912, 48], [880, 48], [752, 48], [560, 144], [528, 144], [496, 144], [368, 48], [304, 112], [272, 112], [240, 112], [176, 48], [144, 48], [112, 48], [80, 48], [144, 208], [112, 208], [112, 240], [144, 240], [144, 336], [112, 336], [112, 368], [144, 368], [240, 368], [240, 336], [272, 336], [272, 368], [304, 368], [304, 336], [464, 368], [592, 368], [720, 432], [976, 368], [1104, 368], [1104, 400], [1104, 432], [1136, 400], [1168, 528], [1136, 528], [1104, 528], [1072, 528], [1040, 528], [1008, 528], [944, 528], [912, 528], [880, 528], [880, 560], [848, 592], [816, 592], [816, 624], [784, 624], [272, 528], [304, 528], [336, 528], [368, 528], [400, 528], [432, 528], [464, 528]], "HardBlock" => [[16, 848], [48, 848], [272, 848], [304, 848], [496, 848], [528, 848], [752, 848], [784, 848], [1040, 848], [1008, 848], [976, 848], [1200, 848], [1264, 848], [1232, 848]]}}, 3 => {:world_wh => [1280, 960], :positions => {"Mario" => [[288, 896]], "Luigi" => [[352, 896]], "WhiteBlock" => [[80, 624], [112, 624], [144, 624], [176, 624], [208, 624], [176, 656], [144, 688], [176, 720], [208, 752], [368, 624], [336, 656], [304, 688], [304, 720], [272, 752], [304, 752], [336, 752], [368, 720], [400, 752], [432, 752], [464, 752], [528, 624], [528, 656], [528, 688], [528, 720], [528, 752], [560, 752], [592, 752], [624, 752], [624, 624], [624, 688], [688, 688], [720, 656], [752, 624], [720, 720], [752, 752]], "SoftBlock" => [[80, 528], [112, 528], [144, 528], [176, 528], [208, 528], [240, 528], [272, 528], [304, 528], [336, 528], [368, 528], [400, 528], [432, 528], [464, 528], [496, 528], [528, 528], [560, 528], [592, 528], [624, 528], [656, 528], [688, 528], [720, 528], [752, 528], [784, 528], [816, 528], [848, 528], [848, 560], [848, 592], [848, 624], [848, 656], [848, 688], [848, 720], [848, 752], [848, 784], [848, 816], [816, 816], [784, 816], [752, 816], [720, 816], [688, 816], [656, 816], [624, 816], [592, 816], [560, 816], [528, 816], [496, 816], [464, 816], [432, 816], [400, 816], [368, 816], [336, 816], [304, 816], [272, 816], [240, 816], [208, 816], [176, 816], [144, 816], [112, 816], [80, 816], [48, 816], [16, 816], [16, 784], [16, 752], [16, 720], [16, 688], [16, 656], [16, 624], [16, 592], [16, 560], [16, 528], [48, 528]], "Coin" => [[16, 496], [48, 496], [80, 496], [112, 496], [144, 496], [176, 496], [208, 496], [240, 496], [272, 496], [304, 496], [336, 496], [368, 496], [400, 496], [432, 496], [464, 496], [496, 496], [528, 496], [560, 496], [592, 496], [624, 496], [656, 496], [688, 496], [720, 496], [752, 496], [784, 496], [816, 496], [848, 496]], "HardBlock" => [[880, 560], [912, 592], [944, 624], [976, 656], [1008, 688], [1040, 720], [1072, 752], [1104, 784], [1136, 816], [1168, 848]]}}}
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ bundle exec rsdl 0900_スーパーマリオ的な何か.rb -f -s 640x480
@@ -0,0 +1,5 @@
1
+ require "pathname"
2
+ Pathname.glob("[0-9]*").sort.each do |file|
3
+ puts "#{"-" * 70} #{file}"
4
+ system("rsdl #{file} --shutdown=1")
5
+ end
@@ -0,0 +1,228 @@
1
+ require "sdl"
2
+ require "pathname"
3
+ require "opengl"
4
+
5
+ SDL.init(SDL::INIT_VIDEO)
6
+ SDL::GL.set_attr(SDL::GL_RED_SIZE, 5)
7
+ SDL::GL.set_attr(SDL::GL_GREEN_SIZE, 5)
8
+ SDL::GL.set_attr(SDL::GL_BLUE_SIZE, 5)
9
+ SDL::GL.set_attr(SDL::GL_DEPTH_SIZE, 16)
10
+ SDL::GL.set_attr(SDL::GL_DOUBLEBUFFER, 1)
11
+ SDL::Screen.open(640, 480, 16, SDL::OPENGL)
12
+
13
+ GL::Viewport(0, 0, 640, 480)
14
+ GL::MatrixMode(GL::PROJECTION)
15
+ GL::LoadIdentity()
16
+
17
+ GL::MatrixMode(GL::MODELVIEW)
18
+ GL::LoadIdentity()
19
+
20
+ GL::Enable(GL::DEPTH_TEST)
21
+ GL::DepthFunc(GL::LESS)
22
+ GL::ShadeModel(GL::SMOOTH)
23
+
24
+ loop do
25
+ sleep(0.01)
26
+
27
+ while event = SDL::Event2.poll
28
+ case event
29
+ when SDL::Event2::Quit
30
+ exit
31
+ when SDL::Event2::KeyDown
32
+ if event.sym == SDL::Key::ESCAPE || event.sym == SDL::Key::Q
33
+ exit
34
+ end
35
+ end
36
+ end
37
+
38
+ GL.ClearColor(0.0, 0.0, 0.2, 0.0) # 背景色の設定(最後の1.0はなんだろう?)
39
+ GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT)
40
+
41
+ GL::Begin(GL::QUADS) # 4つの点があることを宣言
42
+
43
+ GL::Color([1.0, 0.0, 0.0]) # 右上
44
+ GL::Vertex([0.75, 0.75, -0.75]) # 右上の点の位置(1.0にすると画面最大になる)
45
+ GL::Color([0.0, 1.0, 0.0]) # 右下
46
+ GL::Vertex([0.75, -0.75, -0.75])
47
+ GL::Color([0.0, 0.0, 1.0]) # 左下
48
+ GL::Vertex([-0.75, -0.75, -0.75])
49
+ GL::Color([0.0, 1.0, 1.0]) # 左上
50
+ GL::Vertex([-0.75, 0.75, -0.75])
51
+
52
+ GL::End() # 点の設定を終了
53
+
54
+ GL::MatrixMode(GL::MODELVIEW)
55
+ # GL::Rotate(0.5, 0.5, 0.5, 0.5) # ここを有効にするとなんか知らんが回転する
56
+
57
+ SDL::GL.swap_buffers
58
+ end
59
+ exit
60
+
61
+ # # a sample with ruby-opengl and Ruby/SDL
62
+ # require 'sdl'
63
+ # require 'gl'
64
+ #
65
+ # include Gl
66
+ #
67
+ # # initialize SDL and opengl
68
+ # SDL.init SDL::INIT_VIDEO
69
+ # SDL::GL.set_attr SDL::GL_RED_SIZE,5
70
+ # SDL::GL.set_attr SDL::GL_GREEN_SIZE,5
71
+ # SDL::GL.set_attr SDL::GL_BLUE_SIZE,5
72
+ # SDL::GL.set_attr SDL::GL_DEPTH_SIZE,16
73
+ # SDL::GL.set_attr SDL::GL_DOUBLEBUFFER,1
74
+ # SDL::Screen.open 640,400,16,SDL::OPENGL
75
+ #
76
+ # glViewport( 0, 0, 640, 400 );
77
+ # glMatrixMode( GL_PROJECTION );
78
+ # glLoadIdentity( );
79
+ #
80
+ # glMatrixMode( GL_MODELVIEW );
81
+ # glLoadIdentity( );
82
+ #
83
+ # glEnable(GL_DEPTH_TEST);
84
+ #
85
+ # glDepthFunc(GL_LESS);
86
+ #
87
+ # glShadeModel(GL_SMOOTH);
88
+ #
89
+ # shadedCube=true
90
+ #
91
+ # color =
92
+ # [[ 1.0, 1.0, 0.0],
93
+ # [ 1.0, 0.0, 0.0],
94
+ # [ 0.0, 0.0, 0.0],
95
+ # [ 0.0, 1.0, 0.0],
96
+ # [ 0.0, 1.0, 1.0],
97
+ # [ 1.0, 1.0, 1.0],
98
+ # [ 1.0, 0.0, 1.0],
99
+ # [ 0.0, 0.0, 1.0]]
100
+ #
101
+ # cube =
102
+ # [[ 0.5, 0.5, -0.5],
103
+ # [ 0.5, -0.5, -0.5],
104
+ # [-0.5, -0.5, -0.5],
105
+ # [-0.5, 0.5, -0.5],
106
+ # [-0.5, 0.5, 0.5],
107
+ # [ 0.5, 0.5, 0.5],
108
+ # [ 0.5, -0.5, 0.5],
109
+ # [-0.5, -0.5, 0.5]]
110
+ #
111
+ #
112
+ # loop do
113
+ #
114
+ # while event = SDL::Event2.poll
115
+ # case event
116
+ # when SDL::Event2::Quit, SDL::Event2::KeyDown
117
+ # exit
118
+ # end
119
+ # end
120
+ #
121
+ # glClearColor(0.0, 0.0, 0.0, 1.0);
122
+ # glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
123
+ #
124
+ #
125
+ # glBegin(GL_QUADS)
126
+ #
127
+ # if shadedCube then
128
+ # glColor(color[0]);
129
+ # glVertex(cube[0]);
130
+ # glColor(color[1]);
131
+ # glVertex(cube[1]);
132
+ # glColor(color[2]);
133
+ # glVertex(cube[2]);
134
+ # glColor(color[3]);
135
+ # glVertex(cube[3]);
136
+ #
137
+ # glColor(color[3]);
138
+ # glVertex(cube[3]);
139
+ # glColor(color[4]);
140
+ # glVertex(cube[4]);
141
+ # glColor(color[7]);
142
+ # glVertex(cube[7]);
143
+ # glColor(color[2]);
144
+ # glVertex(cube[2]);
145
+ #
146
+ # glColor(color[0]);
147
+ # glVertex(cube[0]);
148
+ # glColor(color[5]);
149
+ # glVertex(cube[5]);
150
+ # glColor(color[6]);
151
+ # glVertex(cube[6]);
152
+ # glColor(color[1]);
153
+ # glVertex(cube[1]);
154
+ #
155
+ # glColor(color[5]);
156
+ # glVertex(cube[5]);
157
+ # glColor(color[4]);
158
+ # glVertex(cube[4]);
159
+ # glColor(color[7]);
160
+ # glVertex(cube[7]);
161
+ # glColor(color[6]);
162
+ # glVertex(cube[6]);
163
+ #
164
+ # glColor(color[5]);
165
+ # glVertex(cube[5]);
166
+ # glColor(color[0]);
167
+ # glVertex(cube[0]);
168
+ # glColor(color[3]);
169
+ # glVertex(cube[3]);
170
+ # glColor(color[4]);
171
+ # glVertex(cube[4]);
172
+ #
173
+ # glColor(color[6]);
174
+ # glVertex(cube[6]);
175
+ # glColor(color[1]);
176
+ # glVertex(cube[1]);
177
+ # glColor(color[2]);
178
+ # glVertex(cube[2]);
179
+ # glColor(color[7]);
180
+ # glVertex(cube[7]);
181
+ #
182
+ # else
183
+ # glColor(1.0, 0.0, 0.0);
184
+ # glVertex(cube[0]);
185
+ # glVertex(cube[1]);
186
+ # glVertex(cube[2]);
187
+ # glVertex(cube[3]);
188
+ #
189
+ # glColor(0.0, 1.0, 0.0);
190
+ # glVertex(cube[3]);
191
+ # glVertex(cube[4]);
192
+ # glVertex(cube[7]);
193
+ # glVertex(cube[2]);
194
+ #
195
+ # glColor(0.0, 0.0, 1.0);
196
+ # glVertex(cube[0]);
197
+ # glVertex(cube[5]);
198
+ # glVertex(cube[6]);
199
+ # glVertex(cube[1]);
200
+ #
201
+ # glColor(0.0, 1.0, 1.0);
202
+ # glVertex(cube[5]);
203
+ # glVertex(cube[4]);
204
+ # glVertex(cube[7]);
205
+ # glVertex(cube[6]);
206
+ #
207
+ # glColor(1.0, 1.0, 0.0);
208
+ # glVertex(cube[5]);
209
+ # glVertex(cube[0]);
210
+ # glVertex(cube[3]);
211
+ # glVertex(cube[4]);
212
+ #
213
+ # glColor(1.0, 0.0, 1.0);
214
+ # glVertex(cube[6]);
215
+ # glVertex(cube[1]);
216
+ # glVertex(cube[2]);
217
+ # glVertex(cube[7]);
218
+ #
219
+ # end
220
+ #
221
+ # glEnd()
222
+ #
223
+ # glMatrixMode(GL_MODELVIEW);
224
+ # glRotate(5.0, 1.0, 1.0, 1.0);
225
+ #
226
+ # SDL::GL.swap_buffers
227
+ #
228
+ # end
@@ -0,0 +1,37 @@
1
+ $LOAD_PATH << ".." if $0 == __FILE__
2
+ require "shooting"
3
+
4
+ module BulletTrigger
5
+ def compute
6
+ super
7
+ dir = Magic.angle(@x, @y, @target.x, @target.y)
8
+ if joy && joy.button(0)
9
+ if @frame_counter.modulo(60 / 6).zero?
10
+ @win.bullets << Bullet.new(@win, @x, @y, dir, 3.00)
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ class GunShipA < GunShip1
17
+ include BulletTrigger
18
+ end
19
+
20
+ class GunShipB < GunShip2
21
+ include BulletTrigger
22
+ end
23
+
24
+ class Application < WarSpace
25
+ def initialize
26
+ super
27
+ @draw_inst = Stylet::Sdl::Draw.instance
28
+ ship1 = GunShipA.new(self, @draw_inst.width / 2, @draw_inst.height / 8 * 1)
29
+ ship2 = GunShipB.new(self, @draw_inst.width / 2, @draw_inst.height / 8 * 7)
30
+ ship1.target = ship2
31
+ ship2.target = ship1
32
+ @ships << ship1
33
+ @ships << ship2
34
+ end
35
+ end
36
+
37
+ Application.new.run
@@ -0,0 +1,50 @@
1
+ #
2
+ # 円同士の当り判定(従来の方法)
3
+ #
4
+ require_relative "helper"
5
+
6
+ class Ball
7
+ def initialize(win, pos)
8
+ @win = win
9
+ @pos = pos
10
+ @radius = 64
11
+ end
12
+
13
+ def update
14
+ distance = @pos.distance_to(@win.cursor.point)
15
+ radius2 = @radius + @win.cursor.radius
16
+ if distance < radius2
17
+ @win.draw_line(@pos, @win.cursor.point)
18
+ @win.vputs "COLLISION"
19
+
20
+ if @win.button.btA.press?
21
+ # カーソルの方向から円の位置の方向に一方的に移動させる
22
+ dir = @win.cursor.point.angle_to(@pos)
23
+ @pos.x = @win.cursor.point.x + Stylet::Magic.rcos(dir) * radius2
24
+ @pos.y = @win.cursor.point.y + Stylet::Magic.rsin(dir) * radius2
25
+ end
26
+ end
27
+ @win.draw_polygon(@pos, :radius => @radius, :vertex => 32)
28
+ if @win.frame_counter.modulo(5) == 0
29
+ @win.draw_line(@pos, @win.cursor.point)
30
+ end
31
+ @win.vputs "radius2=#{radius2}"
32
+ @win.vputs "distance=#{distance}"
33
+ end
34
+
35
+ def screen_out?
36
+ false
37
+ end
38
+ end
39
+
40
+ class App < Stylet::Base
41
+ include Helper::CursorWithObjectCollection
42
+
43
+ setup do
44
+ @objects << Ball.new(self, srect.center.clone)
45
+ @cursor.radius = 64
46
+ @cursor.vertex = 32
47
+ end
48
+
49
+ run
50
+ end
@@ -0,0 +1,103 @@
1
+ #
2
+ # 円同士の当り判定
3
+ #
4
+ require_relative "helper"
5
+
6
+ class Ball
7
+ def initialize(win, cpos)
8
+ @win = win
9
+ @cpos = cpos
10
+ @pos = @cpos.clone
11
+ @radius = 64
12
+ @vr = 0
13
+ @r = 0
14
+ @dir = 0
15
+ end
16
+
17
+ def update
18
+ dx = (@pos.x - @win.mouse.point.x).abs
19
+ dy = (@pos.y - @win.mouse.point.y).abs
20
+ distance = Math.sqrt((dx**2) + (dy**2))
21
+ @win.vputs(distance)
22
+ radius_plus = @radius + @win.radius
23
+ gap = radius_plus - distance
24
+ if gap > 0
25
+ @dir = Stylet::Magic.angle(@win.mouse.point.x, @win.mouse.point.y, @pos.x, @pos.y)
26
+ @cpos = @pos.clone
27
+ @r = 0
28
+ @vr = gap
29
+ end
30
+ @vr -= 0.01
31
+ if @vr < 0
32
+ @vr = 0
33
+ end
34
+ @r += @vr
35
+ @pos.x = @cpos.x + Stylet::Magic.rcos(@dir) * @r
36
+ @pos.y = @cpos.y + Stylet::Magic.rsin(@dir) * @r
37
+ @win.draw_polygon(@pos, :radius => @radius, :vertex => 32)
38
+ end
39
+
40
+ def screen_out?
41
+ false
42
+ end
43
+ end
44
+
45
+ module Helper
46
+ module HandCursor
47
+ include Stylet::Input::Base
48
+ include Stylet::Input::StandardKeybordBind
49
+ include Stylet::Input::JoystickBindMethod
50
+ include Stylet::Input::MouseButtonBind
51
+
52
+ setup do
53
+ super if defined? super
54
+ @cursor.point = @mouse.point.clone
55
+ @cursor.speed = 5
56
+ @objects = []
57
+ end
58
+
59
+ def update
60
+ super if defined? super
61
+
62
+ if joy = joys.first
63
+ bit_update_by_joy(joy)
64
+ end
65
+ key_bit_update_all
66
+ key_counter_update_all
67
+
68
+ if mouse.moved?
69
+ @cursor.point = @mouse.point.clone
70
+ end
71
+
72
+ if dir = axis_angle
73
+ @cursor.point.x += Stylet::Magic.rcos(dir) * @cursor.speed
74
+ @cursor.point.y += Stylet::Magic.rsin(dir) * @cursor.speed
75
+ end
76
+
77
+ vputs @mouse.point.to_a
78
+ vputs mouse.moved?
79
+
80
+ vputs @objects.size
81
+ @objects.each(&:update)
82
+ @objects.reject!(&:screen_out?)
83
+ draw_polygon(@cursor.point, :radius => 16, :vertex => 3, :angle => 1.0 / 64 * @frame_counter)
84
+ end
85
+ end
86
+ end
87
+
88
+ class App < Stylet::Base
89
+ include Helper::CursorWithObjectCollection
90
+
91
+ attr_reader :radius
92
+
93
+ setup do
94
+ @objects << Ball.new(self, srect.center)
95
+ @radius = 64
96
+ end
97
+
98
+ update do
99
+ draw_polygon(@mouse.point, :radius => @radius, :vertex => 32)
100
+ end
101
+
102
+ run
103
+ end
@@ -0,0 +1,60 @@
1
+ #
2
+ # 円同士の当り判定
3
+ #
4
+ require_relative "helper"
5
+
6
+ class Ball
7
+ def initialize(win, cpos)
8
+ @win = win
9
+ @cpos = cpos
10
+ @radius = 64
11
+ @r = 0
12
+ @vr = 4.0
13
+ @ar = -0.01
14
+ @dir = 0.0
15
+ end
16
+
17
+ def update
18
+ @win.objects.each {|object|
19
+ next if object == self
20
+
21
+ dx = (@pos.x - object.pos.x).abs
22
+ dy = (@pos.y - object.pos.y).abs
23
+ distance = Math.sqrt((dx**2) + (dy**2))
24
+ @win.vputs(distance)
25
+ distance_min = @radius + @win.radius
26
+ if distance < distance_min
27
+ dir = Stylet::Magic.angle(object.pos.x, object.pos.y, @pos.x, @pos.y)
28
+ @pos.x = object.pos.x + Stylet::Magic.rcos(dir) * distance_min
29
+ @pos.y = object.pos.y + Stylet::Magic.rsin(dir) * distance_min
30
+ end
31
+ }
32
+ @pos.x += Stylet::Magic.rcos(@dir) * @r
33
+ @pos.y += Stylet::Magic.rsin(@dir) * @r
34
+ @win.draw_polygon(@pos, :radius => @radius, :vertex => 32)
35
+ end
36
+
37
+ def screen_out?
38
+ false
39
+ end
40
+ end
41
+
42
+ class App < Stylet::Base
43
+ include Helper::CursorWithObjectCollection
44
+
45
+ attr_reader :objects
46
+
47
+ setup do
48
+ 4.times do
49
+ @objects << Ball.new(self, srect.center)
50
+ end
51
+ end
52
+
53
+ update do
54
+ if object = @objects.first
55
+ object.pos = @mouse.point.clone
56
+ end
57
+ end
58
+ end
59
+
60
+ App.run