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,56 @@
1
+ module Stylet
2
+ module DrawSupport
3
+ # ベクトル確認用
4
+ # 開始地点のデフォルトは画面中央になる
5
+ # 開始地点がわかっている場合は origin を指定すること
6
+ #
7
+ # draw_vector(vec2[100, 0], :origin => vec2[50, 50], :label => "ok")
8
+ #
9
+ # p0 -----> p1 ok
10
+ #
11
+ # p0: origin オプションで指定(指定しないと画面中央)
12
+ # p1: 第一引数
13
+ #
14
+ def draw_vector(vec, options = {})
15
+ options = {
16
+ :origin => srect.center, # 原点を画面の真中にしておく
17
+ }.merge(options)
18
+
19
+ p1 = options[:origin] + vec
20
+ draw_arrow(options[:origin], p1, options)
21
+
22
+ if options[:label]
23
+ vputs options[:label], :vector => p1
24
+ end
25
+ end
26
+
27
+ # p0 から p1 へ矢印の描画
28
+ def draw_arrow(p0, p1, options = {})
29
+ d = p0 - p1
30
+ if d.x.nan? || d.y.nan?
31
+ return
32
+ end
33
+
34
+ options = {
35
+ :angle => Magic.r45, # 傘の開き
36
+ :arrow_size => p0.distance_to(p1) * 0.1, # 傘の大きさは線分の長さに比例
37
+ }.merge(options)
38
+
39
+ draw_line(p0, p1, options) # 線分の表示
40
+
41
+ # 傘の表示
42
+ a = p1.angle_to(p0)
43
+ draw_line(p1, p1 + Vector.angle_at(a + options[:angle]).scale(options[:arrow_size]), options)
44
+ draw_line(p1, p1 + Vector.angle_at(a - options[:angle]).scale(options[:arrow_size]), options)
45
+ end
46
+ end
47
+ end
48
+
49
+ if $0 == __FILE__
50
+ require_relative "../../stylet"
51
+ Stylet::Base.run do
52
+ draw_arrow(srect.center, srect.center + [50, 50])
53
+ draw_vector(vec2[100, -100], :origin => srect.center, :label => "ok")
54
+ draw_vector(vec2[100, 0], :origin => vec2[50, 50], :label => "ok")
55
+ end
56
+ end
@@ -0,0 +1,63 @@
1
+ #
2
+ # 円・三角形・四角形の描画(向きの指定可)
3
+ #
4
+ module Stylet
5
+ module DrawSupport
6
+ # 多角形の描画
7
+ # 四角形
8
+ # win.draw_circle(win.srect.center, :vertex => 4)
9
+ # 三角形で頂点の向きは時計の6時で半径256ピクセル
10
+ # win.draw_circle(win.srect.center, :vertex => 3, :angle => Magic.r90, :radius => 256)
11
+ def draw_circle(p0, options = {})
12
+ options = {
13
+ :radius => 64, # 半径
14
+ :vertex => 8, # n角形
15
+ :angle => Magic.r270, # 開始地点(初期値は時計の12時)
16
+ }.merge(options)
17
+
18
+ raise "options[:vertex] is not Integer" unless options[:vertex].is_a? Integer
19
+ raise "options[:vertex] >= 1" if options[:vertex].to_i.zero?
20
+ raise "zero vector" if options[:vertex].zero?
21
+
22
+ points = options[:vertex].times.collect do |i|
23
+ a = options[:angle] + 1.0 * i / options[:vertex]
24
+ p0 + Vector.angle_at(a) * options[:radius]
25
+ end
26
+ draw_polygon(points, options)
27
+ end
28
+
29
+ # 三角形版
30
+ def draw_triangle(p0, options = {})
31
+ draw_circle(p0, {:vertex => 3}.merge(options))
32
+ end
33
+
34
+ # 四角形版
35
+ def draw_square(p0, options = {})
36
+ draw_circle(p0, {:vertex => 4}.merge(options))
37
+ end
38
+
39
+ # 長方形
40
+ def draw_angle_rect(p0, options = {})
41
+ options = {
42
+ :radius => 64, # 半径
43
+ :angle => Magic.r270, # 長方形の細長い部分の方向
44
+ :edge => 1.0 / 16, # 長方形の細長い先っぽの面の大きさ(0なら一本線。0.125で正方形)
45
+ }.merge(options)
46
+ s = options[:edge]
47
+ points = [-s, s, 1.0 / 2 - s, 1.0 / 2 + s].collect do |rad|
48
+ p0 + Vector.angle_at(options[:angle] + rad) * options[:radius]
49
+ end
50
+ draw_polygon(points, options)
51
+ end
52
+ end
53
+ end
54
+
55
+ if $0 == __FILE__
56
+ require_relative "../../stylet"
57
+ Stylet::Base.run do
58
+ draw_circle(srect.center)
59
+ draw_triangle(srect.center)
60
+ draw_square(srect.center)
61
+ draw_angle_rect(srect.center)
62
+ end
63
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # 多角形描画
3
+ #
4
+ module Stylet
5
+ module DrawSupport
6
+ # 多角形描画
7
+ # draw_polygon([Vector.zero, vec2[0, 100], vec2[50, 50]])
8
+ def draw_polygon(points, options = {})
9
+ (points + points.take(1)).each_cons(2) {|a, b| draw_line(a, b, options) }
10
+ end
11
+ end
12
+ end
13
+
14
+ if $0 == __FILE__
15
+ require_relative "../../stylet"
16
+ Stylet::Base.run do
17
+ points = Array.new(3 + rand(3)) {vec2[rand(srect.w), rand(srect.h)]}
18
+ draw_polygon(points)
19
+ draw_polygon([Stylet::Vector.zero, vec2[0, 100], vec2[50, 50]])
20
+ sleep(0.25)
21
+ end
22
+ end
@@ -0,0 +1,172 @@
1
+ if $0 == __FILE__
2
+ require_relative "../stylet"
3
+ end
4
+
5
+ module Stylet
6
+ class FontList
7
+ include ApplicationMemoryRecord
8
+ memory_record Stylet.config.font_list
9
+
10
+ delegate :line_skip, :text_size, :drawBlendedUTF8, :to => :sdl_ttf
11
+
12
+ def initialize(*)
13
+ super
14
+ init
15
+ end
16
+
17
+ def init
18
+ @_sdl_ttf = nil
19
+ @char_width = nil
20
+ end
21
+
22
+ def char_width
23
+ @char_width ||= sdl_ttf.text_size("A").first
24
+ end
25
+
26
+ def close
27
+ if @_sdl_ttf
28
+ @_sdl_ttf.close
29
+ init
30
+ end
31
+ end
32
+
33
+ concerning :BoldMethods do
34
+ def bold
35
+ (sdl_ttf.style & SDL::TTF::STYLE_BOLD).nonzero?
36
+ end
37
+
38
+ def bold=(v)
39
+ if v
40
+ sdl_ttf.style |= SDL::TTF::STYLE_BOLD
41
+ else
42
+ sdl_ttf.style &= ~SDL::TTF::STYLE_BOLD
43
+ end
44
+ end
45
+
46
+ def bold_block(v)
47
+ return yield if v.nil?
48
+
49
+ bold_save = bold
50
+ self.bold = v
51
+ yield
52
+ self.bold = bold_save
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def sdl_ttf
59
+ unless @_sdl_ttf
60
+ if font_file = font_dir_list.collect {|e| Pathname(e) }.find {|e| e.exist? }
61
+ @_sdl_ttf = SDL::TTF.open(font_file.to_s, @attributes[:font_size])
62
+ Stylet.logger.debug "load: #{font_file} (#{@_sdl_ttf.family_name.inspect} #{@_sdl_ttf.style_name.inspect} #{@_sdl_ttf.height} #{@_sdl_ttf.line_skip} #{@_sdl_ttf.fixed_width?})" if Stylet.logger
63
+ if @attributes[:bold]
64
+ @_sdl_ttf.style |= SDL::TTF::STYLE_BOLD
65
+ end
66
+ end
67
+ end
68
+ @_sdl_ttf
69
+ end
70
+
71
+ def font_dir_list
72
+ [
73
+ @attributes[:path],
74
+ "#{__dir__}/../../assets/fonts/#{@attributes[:path]}",
75
+ "/Library/Fonts/Tahoma.ttf", # fallback font
76
+ ]
77
+ end
78
+ end
79
+
80
+ module Font
81
+ attr_reader :system_font
82
+ attr_reader :console_current_line
83
+
84
+ def run_initializers
85
+ super
86
+ init_on(:font) do
87
+ SDL::TTF.init
88
+ @system_font = FontList[Stylet.config.system_font_key]
89
+ @console_current_line = nil
90
+ end
91
+ end
92
+
93
+ def before_draw
94
+ super if defined? super
95
+ @console_current_line = 0
96
+ end
97
+
98
+ def after_run
99
+ super if defined? super
100
+ FontList.each(&:close)
101
+ end
102
+
103
+ def update
104
+ super
105
+ if Stylet.config.production_keys.any? {|key| key_down?(key) }
106
+ Stylet.production = !Stylet.production
107
+ end
108
+ end
109
+
110
+ def dputs(*args)
111
+ return if Stylet.production
112
+ vputs(*args)
113
+ end
114
+
115
+ #
116
+ # 文字列表示
117
+ #
118
+ # vputs "Hello" # 垂れ流し
119
+ # vputs "Hello", :vector => Vector[x, y] # 座標指定
120
+ # vputs "Hello", :vector => Vector[x, y], :align => :right # 座標指定(右寄せ)
121
+ # vputs "Hello", :vector => Vector[x, y], :align => :center # 座標指定(中央)
122
+ #
123
+ def vputs(str = "", vector: nil, color: :font, align: :left, font: @system_font, bold: nil)
124
+ str = str.to_s
125
+ font = FontList[font]
126
+ if vector
127
+ begin
128
+ x = vector.x
129
+ if [:center, :right].include?(align)
130
+ w = font.text_size(str).first
131
+ case align
132
+ when :right
133
+ x -= w
134
+ when :center
135
+ x -= w / 2
136
+ when :left
137
+ else
138
+ raise ArgumentError, align.inspect
139
+ end
140
+ end
141
+ font.bold_block(bold) do
142
+ font.drawBlendedUTF8(@screen, str, x, vector.y, *Palette.fetch(color))
143
+ end
144
+ rescue RangeError
145
+ end
146
+ else
147
+ if v = vputs_vector
148
+ vputs(str, vector: v, color: color, align: align, font: font, bold: bold)
149
+ @console_current_line += font.line_skip
150
+ end
151
+ end
152
+ end
153
+
154
+ def vputs_vector
155
+ if @console_current_line && @system_font
156
+ vec2[0, @console_current_line]
157
+ end
158
+ end
159
+ end
160
+ end
161
+
162
+ if $0 == __FILE__
163
+ # require_relative "../stylet"
164
+ # Stylet.config.font_name = "VeraMono.ttf"
165
+ # Stylet.config.font_size = 20
166
+ Stylet.run do
167
+ vputs [*"A".."Z"].join
168
+ vputs "left", :vector => srect.center + [0, 20*0], :align => :left
169
+ vputs "center", :vector => srect.center + [0, 20*1], :align => :center
170
+ vputs "right", :vector => srect.center + [0, 20*2], :align => :right
171
+ end
172
+ end
@@ -0,0 +1,23 @@
1
+ require "active_support/core_ext/module/delegation"
2
+
3
+ module Stylet
4
+ class FpsAdjust
5
+ delegate :fps, :to => "Stylet.config"
6
+
7
+ def initialize
8
+ @old_time = SDL.get_ticks
9
+ end
10
+
11
+ def delay
12
+ return unless fps
13
+
14
+ loop do
15
+ now = SDL.get_ticks
16
+ if now > @old_time + 1000.0 / fps
17
+ @old_time = now
18
+ break
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ module Stylet
2
+ # FPSの計測
3
+ #
4
+ # Example:
5
+ #
6
+ # obj = FpsStat.new
7
+ # loop do
8
+ # obj.update
9
+ # obj.fps # => 60
10
+ # screen.flip
11
+ # end
12
+ #
13
+ class FpsStat
14
+ attr_reader :fps
15
+
16
+ def initialize
17
+ @fps = 0
18
+ @counter = 0
19
+ @old_time = SDL.get_ticks
20
+ end
21
+
22
+ def update
23
+ @counter += 1
24
+ now = SDL.get_ticks
25
+ if now >= @old_time + 1000.0
26
+ @old_time = now
27
+ @fps = @counter
28
+ @counter = 0
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ if $0 == __FILE__
35
+ obj = Stylet::FpsStat.new
36
+ sleep(0.5)
37
+ obj.update
38
+ sleep(0.5)
39
+ obj.update
40
+ p obj.fps
41
+ end
@@ -0,0 +1,8 @@
1
+ # ・SDLとはほぼ無関係
2
+ # ・「入力」は「キーボード」を連想しがちだが入力は「思考ルーチン」と考える
3
+ # ・キーボード関連がでてくるのは思考ルーチンを省略するためのもの
4
+
5
+ require_relative "input/support"
6
+ require_relative "input/key_one"
7
+ require_relative "input/base"
8
+ require_relative "input/hardware_bindings"
@@ -0,0 +1,105 @@
1
+ require_relative "../axis_support"
2
+
3
+ module Stylet
4
+ module Input
5
+ # このモジュールをプレイヤーや人工無能相当に直接includeしてaxisとbuttonの情報を持たせるようにする
6
+ module Base
7
+ Axis = Struct.new(:up, :down, :left, :right)
8
+ Button = Struct.new(:btA, :btB, :btC, :btD)
9
+
10
+ attr_reader :axis, :button
11
+ attr_reader :key_objects
12
+
13
+ def initialize(*)
14
+ super if defined? super
15
+
16
+ @key_objects = []
17
+
18
+ @axis = Axis.new(*[
19
+ factory(name: "u", match_chars: "u", store_char: "u"),
20
+ factory(name: "d", match_chars: "d", store_char: "d"),
21
+ factory(name: "l", match_chars: "l", store_char: "l"),
22
+ factory(name: "r", match_chars: "r", store_char: "r"),
23
+ ])
24
+
25
+ @button = Button.new(*[
26
+ factory(:name => "A", :match_chars => "AL", store_char: "A"),
27
+ factory(:name => "B", :match_chars => "BR", store_char: "B"),
28
+ factory(:name => "C", :match_chars => "C", store_char: "C"),
29
+ factory(:name => "D", :match_chars => "D", store_char: "D"),
30
+ ])
31
+ end
32
+
33
+ def factory(attrs)
34
+ KeyOne.new(attrs.merge(:index => @key_objects.size)).tap do |e|
35
+ @key_objects << e
36
+ end
37
+ end
38
+
39
+ # レバーの更新前のビット状態を取得
40
+ # 更新前であることに注意
41
+ def axis_state_str
42
+ @axis.values.collect(&:state_to_s).join
43
+ end
44
+
45
+ def key_objs_dump
46
+ key_objects.inject(0) {|a, e| a + e.press_bit_value }
47
+ end
48
+
49
+ def key_objs_load(obj)
50
+ key_objects.each {|v| v << obj }
51
+ end
52
+
53
+ # def to_s
54
+ # key_objects.join
55
+ # end
56
+
57
+ # 左右の溜めが完了しているか?(次の状態から使えるか?)
58
+ def key_power_effective?(power_delay)
59
+ Input::Support.key_power_effective?(@axis.left, @axis.right, power_delay)
60
+ end
61
+
62
+ # ボタンとレバーのカウンタを更新する
63
+ # 実行後に state は false になる
64
+ def key_counter_update_all
65
+ key_objects.each(&:counter_update)
66
+ end
67
+
68
+ # レバーの状態から8方向の番号インデックスに変換
69
+ def axis_angle_index
70
+ AxisSupport.axis_angle_index(@axis)
71
+ end
72
+
73
+ # 8方向レバーの状態から一周を1.0としたときの方向を返す
74
+ def axis_angle
75
+ AxisSupport.axis_angle(@axis)
76
+ end
77
+ end
78
+
79
+ # ジョイスティックの上とかにあるボタン類
80
+ module ExtensionButton
81
+ Button = Struct.new(:btR1, :btR2, :btL1, :btL2, :btSelect, :btStart, :btPS)
82
+
83
+ attr_reader :ext_button
84
+
85
+ def initialize(*)
86
+ super if defined? super
87
+
88
+ @ext_button = Button.new(*[
89
+ factory(name: "R1", match_chars: nil, store_char: nil),
90
+ factory(name: "R2", match_chars: nil, store_char: nil),
91
+ factory(name: "L1", match_chars: nil, store_char: nil),
92
+ factory(name: "L2", match_chars: nil, store_char: nil),
93
+ factory(name: "SELECT", match_chars: nil, store_char: nil),
94
+ factory(name: "START", match_chars: nil, store_char: nil),
95
+ factory(name: "PS", match_chars: nil, store_char: nil),
96
+ ])
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ if $0 == __FILE__
103
+ require_relative "../../stylet"
104
+ Stylet.run
105
+ end