stylet 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +4 -0
- data/.yardopts +2 -0
- data/Gemfile +16 -0
- data/README.org +19 -0
- data/Rakefile +17 -0
- data/bin/setup +63 -0
- data/bin/stylet +8 -0
- data/examples/.ruby-version +1 -0
- data/examples/00100_lib_hello_world.rb +8 -0
- data/examples/00110_lib_sge_check.rb +6 -0
- 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
- data/examples/00130_lib_window_title.rb +8 -0
- data/examples/00140_lib_callbacks.rb +8 -0
- data/examples/00150_lib_vector.rb +5 -0
- data/examples/00160_lib_run.rb +4 -0
- data/examples/00170_lib_frame.rb +4 -0
- data/examples/00180_lib_config/347/242/272/350/252/215.rb +7 -0
- 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
- 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
- data/examples/00210_lib_delegators.rb +7 -0
- data/examples/00220_lib_template_method.rb +13 -0
- 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
- 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
- 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
- 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
- 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
- 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
- data/examples/00290_lib_/350/203/214/346/231/257/350/211/262/345/244/211/346/233/264.rb +5 -0
- 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
- 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
- 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
- data/examples/00330_joystick.rb +5 -0
- 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
- 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
- data/examples/00360_lib_mouse.rb +5 -0
- data/examples/00370_lib_input.rb +29 -0
- data/examples/00380_lib_vputs_align.rb +8 -0
- data/examples/00390_/343/203/225/343/202/251/343/203/263/343/203/210/344/270/200/350/246/247.rb +15 -0
- data/examples/00400_lib_draw_circle.rb +8 -0
- 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
- data/examples/00420_circle_on_circle.rb +10 -0
- data/examples/00430_rotate.rb +16 -0
- data/examples/00440_draw_triangle.rb +7 -0
- data/examples/00450_parabora_triangle.rb +37 -0
- data/examples/00460_ice_hockey.rb +88 -0
- data/examples/00470_collision_block_vs_block.rb +120 -0
- data/examples/00480_simple_circle_controll.rb +37 -0
- data/examples/00490_/347/255/211/351/200/237/347/247/273/345/213/225_uniform_velocity_rain.rb +51 -0
- data/examples/00500_/345/212/240/351/200/237/346/224/276/347/211/251/347/267/232_parabora_volcano.rb +94 -0
- data/examples/00510_3d.rb +53 -0
- 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
- 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
- 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
- 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
- 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
- data/examples/00570_/345/206/206/351/201/213/345/213/225_circle_jet_coaster.rb +52 -0
- 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
- 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
- data/examples/00600_/346/214/257/343/202/212/345/255/220_swing.rb +145 -0
- data/examples/00610_/345/206/205/347/251/215/343/201/250/345/244/226/347/251/215_inner_product.rb +36 -0
- data/examples/00620_/346/263/225/347/267/232/343/203/231/343/202/257/343/203/210/343/203/253.rb +23 -0
- 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
- 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
- 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
- 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
- data/examples/00670_/343/203/251/343/202/244/343/203/225/343/202/262/343/203/274/343/203/240.rb +86 -0
- 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
- 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
- data/examples/00700_/343/202/263/343/203/203/343/203/233/346/233/262/347/267/232.rb +79 -0
- 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
- data/examples/00720_/343/202/267/343/203/200/346/244/215/347/211/251.rb +44 -0
- 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
- 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
- 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
- data/examples/00760_/347/201/253/350/212/261.rb +42 -0
- data/examples/00770_atan/343/201/247atan2/343/202/222/346/233/270/343/201/217.rb +26 -0
- 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
- 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
- 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
- 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
- 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
- data/examples/00830_/350/247/222/345/272/246/345/267/256.rb +36 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- data/examples/00930_/345/212/271/346/236/234/351/237/263.rb +17 -0
- 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
- 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
- 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
- data/examples/00970_observer_/343/201/235/343/201/2561_/347/233/264/346/216/245.rb +28 -0
- 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
- data/examples/00990_observer_/343/201/235/343/201/2563_SimpleDelegator/347/211/210.rb +28 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- data/examples/01110_lib_contrib_menu.rb +19 -0
- data/examples/01120_/351/233/233/345/236/213_2P/345/257/276/346/210/246/351/242/250STG.rb +109 -0
- data/examples/01130_/351/233/233/345/236/213_/346/210/246/350/273/212/345/257/276/346/210/246.rb +396 -0
- data/examples/01140_/351/233/233/345/236/213_2P/345/257/276/346/210/246.rb +60 -0
- 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
- 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
- data/examples/01170_stackprof.rb +10 -0
- 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
- 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
- data/examples/01200_lib_OpenGL.rb +55 -0
- data/examples/bezier.rb +202 -0
- data/examples/cursor.rb +50 -0
- data/examples/helper.rb +38 -0
- data/examples/lifegame_patterns.rb +102 -0
- data/examples/movable_point.rb +64 -0
- data/examples/mtx33.rb +294 -0
- data/examples/setup.rb +5 -0
- data/examples/stage_infos.rb +1 -0
- data/examples/start.sh +2 -0
- data/examples/test_all.rb +5 -0
- data/examples/testgl.rb +228 -0
- data/examples/trash/__0060_shooting2.rb +37 -0
- data/examples/trash/__0090_collision_circle1.rb +50 -0
- data/examples/trash/__0125_circle_collision.rb +103 -0
- data/examples/trash/__0130_circle_collision2.rb +60 -0
- data/examples/trash/__0270_circle_cycle_shift.rb +29 -0
- data/examples/trash/__bullet_algos.rb +224 -0
- data/examples/trash/gunship.rb +39 -0
- 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
- data/lib/stylet.rb +1 -0
- data/lib/stylet/application_memory_record.rb +33 -0
- data/lib/stylet/audio.rb +455 -0
- data/lib/stylet/axis_support.rb +62 -0
- data/lib/stylet/base.rb +76 -0
- data/lib/stylet/callbacks.rb +62 -0
- data/lib/stylet/cli.rb +54 -0
- data/lib/stylet/collision_support.rb +56 -0
- data/lib/stylet/config.rb +39 -0
- data/lib/stylet/contrib/menu.rb +508 -0
- data/lib/stylet/contrib/shared_pad.rb +32 -0
- data/lib/stylet/contrib/sprity.rb +149 -0
- data/lib/stylet/core.rb +118 -0
- data/lib/stylet/cpu_stat.rb +58 -0
- data/lib/stylet/delegators.rb +54 -0
- data/lib/stylet/draw.rb +256 -0
- data/lib/stylet/draw_support/arrow.rb +56 -0
- data/lib/stylet/draw_support/circle.rb +63 -0
- data/lib/stylet/draw_support/polygon.rb +22 -0
- data/lib/stylet/font.rb +172 -0
- data/lib/stylet/fps_adjust.rb +23 -0
- data/lib/stylet/fps_stat.rb +41 -0
- data/lib/stylet/input.rb +8 -0
- data/lib/stylet/input/base.rb +105 -0
- data/lib/stylet/input/hardware_bindings.rb +65 -0
- data/lib/stylet/input/key_one.rb +162 -0
- data/lib/stylet/input/support.rb +72 -0
- data/lib/stylet/joystick.rb +31 -0
- data/lib/stylet/joystick_adapter.rb +130 -0
- data/lib/stylet/joystick_adapters/buffalo_snes_adapter.rb +47 -0
- data/lib/stylet/joystick_adapters/elecom_usb_pad_adapter.rb +30 -0
- data/lib/stylet/joystick_adapters/hori_rap_v3_sa_adapter.rb +46 -0
- data/lib/stylet/joystick_adapters/ps3_standard_adapter.rb +40 -0
- data/lib/stylet/joystick_adapters/unknown_adapter.rb +13 -0
- data/lib/stylet/keyboard.rb +15 -0
- data/lib/stylet/logger.rb +12 -0
- data/lib/stylet/mouse.rb +58 -0
- data/lib/stylet/palette.rb +17 -0
- data/lib/stylet/rect.rb +113 -0
- data/lib/stylet/shortcut.rb +8 -0
- data/lib/stylet/state.rb +87 -0
- data/lib/stylet/stylet.rb +44 -0
- data/lib/stylet/system_pause.rb +24 -0
- data/lib/stylet/version.rb +3 -0
- data/log/.gitkeep +0 -0
- data/stylet.gemspec +31 -0
- data/test/test_helper.rb +6 -0
- data/test/test_input_base.rb +12 -0
- data/test/test_input_key_one.rb +43 -0
- data/test/test_input_support.rb +47 -0
- data/test/test_sample.rb +13 -0
- data/test/test_state.rb +26 -0
- data/tips.org +16 -0
- metadata +391 -0
data/examples/helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "./setup"
|
2
|
+
|
3
|
+
require_relative "cursor"
|
4
|
+
|
5
|
+
module Helper
|
6
|
+
|
7
|
+
module ObjectCollection
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
attr_reader :objects
|
12
|
+
|
13
|
+
setup do
|
14
|
+
@objects = []
|
15
|
+
end
|
16
|
+
|
17
|
+
update do
|
18
|
+
@objects.each(&:update)
|
19
|
+
@objects.reject! {|e| e.respond_to?(:screen_out?) && e.screen_out? }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module CursorWithObjectCollection
|
25
|
+
extend ActiveSupport::Concern
|
26
|
+
include ObjectCollection
|
27
|
+
include Cursor
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
require_relative "movable_point"
|
32
|
+
|
33
|
+
if $0 == __FILE__
|
34
|
+
Class.new(Stylet::Base) do
|
35
|
+
include Helper::CursorWithObjectCollection
|
36
|
+
run
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
LifegamePatterns = [
|
2
|
+
"
|
3
|
+
.........................o
|
4
|
+
.......................o.o
|
5
|
+
.............oo......oo............oo
|
6
|
+
............o...o....oo............oo
|
7
|
+
.oo........o.....o...oo
|
8
|
+
.oo........o...o.oo....o.o
|
9
|
+
...........o.....o.......o
|
10
|
+
............o...o
|
11
|
+
.............oo
|
12
|
+
",
|
13
|
+
"
|
14
|
+
.............
|
15
|
+
.............
|
16
|
+
..oooooo.oo..
|
17
|
+
..oooooo.oo..
|
18
|
+
.........oo..
|
19
|
+
..oo.....oo..
|
20
|
+
..oo.....oo..
|
21
|
+
..oo.....oo..
|
22
|
+
..oo.........
|
23
|
+
..oo.oooooo..
|
24
|
+
..oo.oooooo..
|
25
|
+
.............
|
26
|
+
.............
|
27
|
+
",
|
28
|
+
"
|
29
|
+
.......o.........
|
30
|
+
........o........
|
31
|
+
....o...o........
|
32
|
+
.....oooo........
|
33
|
+
.................
|
34
|
+
.................
|
35
|
+
.................
|
36
|
+
....o............
|
37
|
+
.....oo..........
|
38
|
+
......o..........
|
39
|
+
......o..........
|
40
|
+
.....o...........
|
41
|
+
.................
|
42
|
+
.................
|
43
|
+
.......o.........
|
44
|
+
........o........
|
45
|
+
....o...o........
|
46
|
+
.....oooo........
|
47
|
+
.................
|
48
|
+
",
|
49
|
+
"
|
50
|
+
□□□□□□□□□□□□□□□□□
|
51
|
+
□□□□□□□□□□□■■□□□□
|
52
|
+
□□□□□□□□■■■□■■□□□
|
53
|
+
□□□□□□□□■■■■■□□□□
|
54
|
+
□□□□□□□□□■■■□□□□□
|
55
|
+
□□□□□□□□□□□□□□□□□
|
56
|
+
□□□□□□□□□□□□□□□□□
|
57
|
+
□□□□□□□□■■■■■■■■□
|
58
|
+
□■□□□■□□□□□□□□□■□
|
59
|
+
□■□□□■□□□□□□□□□■□
|
60
|
+
□■□□□■□□□□□□□□■□□
|
61
|
+
□□□□□□□□□□□□□□□□□
|
62
|
+
□■□□□■□□□□□□□□■□□
|
63
|
+
□■□□□■□□□□□□□□□■□
|
64
|
+
□■□□□■□□□□□□□□□■□
|
65
|
+
□□□□□□□□■■■■■■■■□
|
66
|
+
□□□□□□□□□□□□□□□□□
|
67
|
+
□□□□□□□□□□□□□□□□□
|
68
|
+
□□□□□□□□□■■■□□□□□
|
69
|
+
□□□□□□□□■■■■■□□□□
|
70
|
+
□□□□□□□□■■■□■■□□□
|
71
|
+
□□□□□□□□□□□■■□□□□
|
72
|
+
□□□□□□□□□□□□□□□□□
|
73
|
+
",
|
74
|
+
# Puff suppressor
|
75
|
+
"
|
76
|
+
....................O............
|
77
|
+
...................O.OO..........
|
78
|
+
.................O...OO..........
|
79
|
+
...........O.....O.OO...O........
|
80
|
+
.O.O.......OOOO...OO.OOOO........
|
81
|
+
.O..O.O.....OOO....O......O......
|
82
|
+
....O..O....O...O...OOOOOOO......
|
83
|
+
..O....OO.O.O...O..OO......O.O...
|
84
|
+
...O........OO..O.....OOOOOOOOO..
|
85
|
+
O..O...OOOO.OO.O..............OO.
|
86
|
+
...O.O..O...O..........O.OO....OO
|
87
|
+
O..O.O.O......OOO........O....OO.
|
88
|
+
..OO....O......OO......O.........
|
89
|
+
O..O.O.O......OOO........O....OO.
|
90
|
+
...O.O..O...O..........O.OO....OO
|
91
|
+
O..O...OOOO.OO.O..............OO.
|
92
|
+
...O........OO..O.....OOOOOOOOO..
|
93
|
+
..O....OO.O.O...O..OO......O.O...
|
94
|
+
....O..O....O...O...OOOOOOO......
|
95
|
+
.O..O.O.....OOO....O......O......
|
96
|
+
.O.O.......OOOO...OO.OOOO........
|
97
|
+
...........O.....O.OO...O........
|
98
|
+
.................O...OO..........
|
99
|
+
...................O.OO..........
|
100
|
+
....................O............
|
101
|
+
",
|
102
|
+
]
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
|
3
|
+
module Helper
|
4
|
+
module MovablePoint
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
attr_accessor :dragging_current
|
8
|
+
|
9
|
+
def update_movable_points(points, options = {})
|
10
|
+
options = {
|
11
|
+
:origin => vec2.zero,
|
12
|
+
:radius => 2, # ドットの大きさ
|
13
|
+
:collision_radius => 8, # 当り判定の広さ
|
14
|
+
}.merge(options)
|
15
|
+
|
16
|
+
mpoint = mouse.point - options[:origin]
|
17
|
+
|
18
|
+
unless @dragging_current
|
19
|
+
if button.btA.trigger?
|
20
|
+
if v = points.find {|e|Stylet::CollisionSupport.squire_collision?(e, mpoint, :radius => options[:collision_radius])}
|
21
|
+
@dragging_current = v
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if @dragging_current
|
27
|
+
if button.btA.free?
|
28
|
+
@dragging_current = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if @dragging_current
|
33
|
+
@dragging_current.replace(mpoint)
|
34
|
+
end
|
35
|
+
|
36
|
+
if @dragging_current
|
37
|
+
draw_circle(options[:origin] + @dragging_current, :radius => options[:collision_radius], :vertex => 32)
|
38
|
+
end
|
39
|
+
|
40
|
+
points.each {|e| draw_circle(options[:origin] + e, :radius => options[:radius]) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if $0 == __FILE__
|
46
|
+
class App < Stylet::Base
|
47
|
+
include Helper::CursorWithObjectCollection
|
48
|
+
include Helper::MovablePoint
|
49
|
+
|
50
|
+
setup do
|
51
|
+
@points = []
|
52
|
+
@points << srect.center + vec2[-srect.w / 4, srect.h / 4]
|
53
|
+
@points << srect.center + vec2[0, -srect.h / 4]
|
54
|
+
@points << srect.center + vec2[srect.w / 4, srect.h / 4]
|
55
|
+
end
|
56
|
+
|
57
|
+
update do
|
58
|
+
update_movable_points(@points)
|
59
|
+
@points.each_with_index {|e, i| vputs("#{i}", :vector => e) }
|
60
|
+
end
|
61
|
+
|
62
|
+
run
|
63
|
+
end
|
64
|
+
end
|
data/examples/mtx33.rb
ADDED
@@ -0,0 +1,294 @@
|
|
1
|
+
# メソッド一覧
|
2
|
+
#
|
3
|
+
# Mtx33.create ; 単位行列作成
|
4
|
+
# Mtx33.translate(x, y) ; 平行行列作成
|
5
|
+
# Mtx33.translate_pref(x, y, m) ; 平行行列 * m
|
6
|
+
# Mtx33.translate_post(x, y, m) ; m * 平行行列
|
7
|
+
# Mtx33.rotate(rot) ; 回転行列生成
|
8
|
+
# Mtx33.rotate_pref(rot, m) ; 回転行列 * m
|
9
|
+
# Mtx33.rotate_post(rot, m) ; m * 回転行列
|
10
|
+
# Mtx33.scale(x, y) ; 拡縮行列
|
11
|
+
# Mtx33.scale_pref(x, y, m) ; 拡縮行列 * m
|
12
|
+
# Mtx33.scale_post(x, y, m) ; m * 拡縮行列
|
13
|
+
# Mtx33.transform(*args) ; 行列 * 行列
|
14
|
+
# Mtx33.invert_ortho_normal(m) ; 正規直交行列の逆行列
|
15
|
+
# Mtx33.invert(m) ; 逆行列
|
16
|
+
# Mtx33.vec2_transform_point(x, y, m) ; 座標の投影変換
|
17
|
+
# Mtx33.vec2_transform_vector(x, y, m) ; ベクトルの投影変換
|
18
|
+
#
|
19
|
+
# _pref, _post は高速化のためだけにあるので transform を使った方がわかりやすい
|
20
|
+
#
|
21
|
+
# 参照
|
22
|
+
#
|
23
|
+
# ■Flashゲーム講座&ASサンプル集【2Dアフィン変換を使ってみよう】
|
24
|
+
# http://hakuhin.jp/as/mtx_2d.html
|
25
|
+
#
|
26
|
+
# ■2D用の3行3列のマトリックスの関数
|
27
|
+
# http://hakuhin.jp/as/matrix_33.html
|
28
|
+
#
|
29
|
+
if $0 == __FILE__
|
30
|
+
$LOAD_PATH << "../stylet_support/lib"
|
31
|
+
end
|
32
|
+
|
33
|
+
require "stylet/vector"
|
34
|
+
|
35
|
+
module Stylet
|
36
|
+
class Mtx33
|
37
|
+
class << self
|
38
|
+
# 単位行列作成
|
39
|
+
def create
|
40
|
+
{
|
41
|
+
a: 1.0, b: 0.0,
|
42
|
+
c: 0.0, d: 1.0,
|
43
|
+
tx: 0.0, ty: 0.0,
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# 平行行列作成
|
48
|
+
def translate(x, y)
|
49
|
+
{
|
50
|
+
a: 1.0, b: 0.0,
|
51
|
+
c: 0.0, d: 1.0,
|
52
|
+
tx: x, ty: y,
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
# 平行行列 * m
|
57
|
+
def translate_pref(x, y, m)
|
58
|
+
{
|
59
|
+
a: m[:a],
|
60
|
+
b: m[:b],
|
61
|
+
c: m[:c],
|
62
|
+
d: m[:d],
|
63
|
+
tx: x * m[:a] + y * m[:c] + m[:tx],
|
64
|
+
ty: x * m[:b] + y * m[:d] + m[:ty],
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# m * 平行行列
|
69
|
+
def translate_post(x, y, m)
|
70
|
+
{
|
71
|
+
a: m[:a],
|
72
|
+
b: m[:b],
|
73
|
+
c: m[:c],
|
74
|
+
d: m[:d],
|
75
|
+
tx: m[:tx] + x,
|
76
|
+
ty: m[:ty] + y,
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
# 回転行列生成
|
81
|
+
def rotate(rot)
|
82
|
+
rad = rot * Math::PI / 180
|
83
|
+
cos = Math.cos(rad)
|
84
|
+
sin = Math.sin(rad)
|
85
|
+
{
|
86
|
+
a: cos, b: sin,
|
87
|
+
c: -sin, d: cos,
|
88
|
+
tx: 0, ty: 0,
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
# 回転行列 * m
|
93
|
+
def rotate_pref(rot, m)
|
94
|
+
rad = rot * Math::PI / 180
|
95
|
+
cos = Math.cos(rad)
|
96
|
+
sin = Math.sin(rad)
|
97
|
+
{
|
98
|
+
a: cos * m[:a] + sin * m[:c],
|
99
|
+
b: cos * m[:b] + sin * m[:d],
|
100
|
+
c: -sin * m[:a] + cos * m[:c],
|
101
|
+
d: -sin * m[:b] + cos * m[:d],
|
102
|
+
tx: m[:tx],
|
103
|
+
ty: m[:ty],
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
# m * 回転行列
|
108
|
+
def rotate_post(rot, m)
|
109
|
+
rad = rot * Math::PI / 180
|
110
|
+
cos = Math.cos(rad)
|
111
|
+
sin = Math.sin(rad)
|
112
|
+
{
|
113
|
+
a: m[:a] * cos + m[:b] * -sin,
|
114
|
+
b: m[:a] * sin + m[:b] * cos,
|
115
|
+
c: m[:c] * cos + m[:d] * -sin,
|
116
|
+
d: m[:c] * sin + m[:d] * cos,
|
117
|
+
tx: m[:tx] * cos + m[:ty] * -sin,
|
118
|
+
ty: m[:tx] * sin + m[:ty] * cos,
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
# 拡縮行列
|
123
|
+
def scale(x, y)
|
124
|
+
{
|
125
|
+
a: x, b: 0,
|
126
|
+
c: 0, d: y,
|
127
|
+
tx: 0, ty: 0,
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
# 拡縮行列 * m
|
132
|
+
def scale_pref(x, y, m)
|
133
|
+
{
|
134
|
+
a: x * m[:a],
|
135
|
+
b: x * m[:b],
|
136
|
+
c: y * m[:c],
|
137
|
+
d: y * m[:d],
|
138
|
+
tx: m[:tx],
|
139
|
+
ty: m[:ty],
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
# m * 拡縮行列
|
144
|
+
def scale_post(x, y, m)
|
145
|
+
{
|
146
|
+
a: m[:a] * x,
|
147
|
+
b: m[:b] * y,
|
148
|
+
c: m[:c] * x,
|
149
|
+
d: m[:d] * y,
|
150
|
+
tx: m[:tx] * x,
|
151
|
+
ty: m[:ty] * y,
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
# 行列 * 行列
|
156
|
+
def transform(*args)
|
157
|
+
args.inject {|m1, m2| __transform(m1, m2) }
|
158
|
+
end
|
159
|
+
|
160
|
+
def __transform(m1, m2)
|
161
|
+
{
|
162
|
+
a: m1[:a] * m2[:a] + m1[:b] * m2[:c],
|
163
|
+
b: m1[:a] * m2[:b] + m1[:b] * m2[:d],
|
164
|
+
c: m1[:c] * m2[:a] + m1[:d] * m2[:c],
|
165
|
+
d: m1[:c] * m2[:b] + m1[:d] * m2[:d],
|
166
|
+
tx: m1[:tx] * m2[:a] + m1[:ty] * m2[:c] + m2[:tx],
|
167
|
+
ty: m1[:tx] * m2[:b] + m1[:ty] * m2[:d] + m2[:ty],
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
# 正規直交行列の逆行列
|
172
|
+
def invert_ortho_normal(m)
|
173
|
+
{
|
174
|
+
a: m[:a],
|
175
|
+
b: m[:c],
|
176
|
+
c: m[:b],
|
177
|
+
d: m[:d],
|
178
|
+
tx: -m[:tx] * m[:a] + -m[:ty] * m[:b],
|
179
|
+
ty: -m[:tx] * m[:c] + -m[:ty] * m[:d],
|
180
|
+
}
|
181
|
+
end
|
182
|
+
|
183
|
+
# 逆行列
|
184
|
+
def invert(m)
|
185
|
+
o = {
|
186
|
+
a: 1.0, b: 0.0,
|
187
|
+
c: 0.0, d: 1.0,
|
188
|
+
tx: 0.0, ty: 0.0,
|
189
|
+
}
|
190
|
+
|
191
|
+
_01 = m[:b]
|
192
|
+
_11 = m[:d]
|
193
|
+
_21 = m[:ty]
|
194
|
+
|
195
|
+
if m[:a].nonzero?
|
196
|
+
o[:a] /= m[:a]
|
197
|
+
_01 /= m[:a]
|
198
|
+
end
|
199
|
+
_11 -= m[:c] * _01
|
200
|
+
o[:c] -= m[:c] * o[:a]
|
201
|
+
_21 -= m[:tx] * _01
|
202
|
+
o[:tx] -= m[:tx] * o[:a]
|
203
|
+
|
204
|
+
if _11.nonzero?
|
205
|
+
o[:c] /= _11
|
206
|
+
end
|
207
|
+
o[:tx] -= _21 * o[:c]
|
208
|
+
o[:a] -= _01 * o[:c]
|
209
|
+
|
210
|
+
_01 = m[:b]
|
211
|
+
_11 = m[:d]
|
212
|
+
_21 = m[:ty]
|
213
|
+
|
214
|
+
if m[:a].nonzero?
|
215
|
+
o[:b] /= m[:a]
|
216
|
+
_01 /= m[:a]
|
217
|
+
end
|
218
|
+
_11 -= m[:c] * _01
|
219
|
+
o[:d] -= m[:c] * o[:b]
|
220
|
+
_21 -= m[:tx] * _01
|
221
|
+
o[:ty] -= m[:tx] * o[:b]
|
222
|
+
|
223
|
+
if _11.nonzero?
|
224
|
+
o[:d] /= _11
|
225
|
+
end
|
226
|
+
o[:ty] -= _21 * o[:d]
|
227
|
+
o[:b] -= _01 * o[:d]
|
228
|
+
|
229
|
+
o
|
230
|
+
end
|
231
|
+
|
232
|
+
# 座標の投影変換
|
233
|
+
def vec2_transform_point(x, y, m)
|
234
|
+
Stylet::Vector[
|
235
|
+
x * m[:a] + y * m[:c] + m[:tx],
|
236
|
+
x * m[:b] + y * m[:d] + m[:ty],
|
237
|
+
]
|
238
|
+
end
|
239
|
+
|
240
|
+
# ベクトルの投影変換
|
241
|
+
def vec2_transform_vector(x, y, m)
|
242
|
+
Stylet::Vector[
|
243
|
+
x * m[:a] + y * m[:c],
|
244
|
+
x * m[:b] + y * m[:d],
|
245
|
+
]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
if $0 == __FILE__
|
251
|
+
# 単位行列作成
|
252
|
+
m = Mtx33.create # => {:a=>1.0, :b=>0.0, :c=>0.0, :d=>1.0, :tx=>0.0, :ty=>0.0}
|
253
|
+
# 平行行列作成
|
254
|
+
m1 = Mtx33.translate(1, 2) # => {:a=>1.0, :b=>0.0, :c=>0.0, :d=>1.0, :tx=>1, :ty=>2}
|
255
|
+
# 平行行列 * m
|
256
|
+
Mtx33.translate_pref(1, 2, m) # => {:a=>1.0, :b=>0.0, :c=>0.0, :d=>1.0, :tx=>1.0, :ty=>2.0}
|
257
|
+
# m * 平行行列
|
258
|
+
Mtx33.translate_post(1, 2, m) # => {:a=>1.0, :b=>0.0, :c=>0.0, :d=>1.0, :tx=>1.0, :ty=>2.0}
|
259
|
+
# 回転行列生成
|
260
|
+
m2 = Mtx33.rotate(45) # => {:a=>0.7071067811865476, :b=>0.7071067811865475, :c=>-0.7071067811865475, :d=>0.7071067811865476, :tx=>0, :ty=>0}
|
261
|
+
# 回転行列 * m
|
262
|
+
Mtx33.rotate_pref(45, m) # => {:a=>0.7071067811865476, :b=>0.7071067811865475, :c=>-0.7071067811865475, :d=>0.7071067811865476, :tx=>0.0, :ty=>0.0}
|
263
|
+
# m * 回転行列
|
264
|
+
Mtx33.rotate_post(45, m) # => {:a=>0.7071067811865476, :b=>0.7071067811865475, :c=>-0.7071067811865475, :d=>0.7071067811865476, :tx=>0.0, :ty=>0.0}
|
265
|
+
# 拡縮行列
|
266
|
+
Mtx33.scale(1.2, 3.4) # => {:a=>1.2, :b=>0, :c=>0, :d=>3.4, :tx=>0, :ty=>0}
|
267
|
+
# 拡縮行列 * m
|
268
|
+
Mtx33.scale_pref(1.2, 3.4, m) # => {:a=>1.2, :b=>0.0, :c=>0.0, :d=>3.4, :tx=>0.0, :ty=>0.0}
|
269
|
+
# m * 拡縮行列
|
270
|
+
Mtx33.scale_post(1.2, 3.4, m) # => {:a=>1.2, :b=>0.0, :c=>0.0, :d=>3.4, :tx=>0.0, :ty=>0.0}
|
271
|
+
# 座標の投影変換
|
272
|
+
Mtx33.vec2_transform_point(1, 2, m) # => [1.0, 2.0]
|
273
|
+
# ベクトルの投影変換
|
274
|
+
Mtx33.vec2_transform_vector(1, 2, m) # => [1.0, 2.0]
|
275
|
+
# 行列 * 行列
|
276
|
+
Mtx33.transform(m1, m2) # => {:a=>0.7071067811865476, :b=>0.7071067811865475, :c=>-0.7071067811865475, :d=>0.7071067811865476, :tx=>-0.7071067811865474, :ty=>2.121320343559643}
|
277
|
+
# 正規直交行列の逆行列
|
278
|
+
Mtx33.invert_ortho_normal(m) # => {:a=>1.0, :b=>0.0, :c=>0.0, :d=>1.0, :tx=>-0.0, :ty=>-0.0}
|
279
|
+
# 逆行列
|
280
|
+
Mtx33.invert(m) # => {:a=>1.0, :b=>0.0, :c=>0.0, :d=>1.0, :tx=>0.0, :ty=>0.0}
|
281
|
+
|
282
|
+
m = Mtx33.translate(10, 20)
|
283
|
+
Mtx33.vec2_transform_point(100, 100, m) # => [110.0, 120.0]
|
284
|
+
m = Mtx33.rotate(1)
|
285
|
+
Mtx33.vec2_transform_point(100, 100, m) # => [98.23952887191078, 101.73001015936748]
|
286
|
+
m = Mtx33.scale(1.1, 1.1)
|
287
|
+
Mtx33.vec2_transform_point(100, 100, m) # => [110.00000000000001, 110.00000000000001]
|
288
|
+
|
289
|
+
m1 = Mtx33.translate(10, 20)
|
290
|
+
m2 = Mtx33.rotate(1)
|
291
|
+
m3 = Mtx33.transform(m1, m2)
|
292
|
+
Mtx33.vec2_transform_point(100, 100, m3) # => [107.88895769472902, 121.90148812686814]
|
293
|
+
end
|
294
|
+
end
|