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
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# 円の移動の定石
|
3
|
+
#
|
4
|
+
require_relative "helper"
|
5
|
+
|
6
|
+
class App < Stylet::Base
|
7
|
+
include Helper::CursorWithObjectCollection
|
8
|
+
|
9
|
+
setup do
|
10
|
+
self.title = "円の移動の定石"
|
11
|
+
@pA = srect.center.clone
|
12
|
+
@sA = vec2.angle_at(Stylet::Magic.clock(8))
|
13
|
+
@radius = 50
|
14
|
+
@vertex = 32
|
15
|
+
end
|
16
|
+
|
17
|
+
update do
|
18
|
+
# 操作
|
19
|
+
# AとBで速度ベクトルの反映
|
20
|
+
@pA += @sA.scale(button.btA.repeat_0or1) + @sA.scale(-button.btB.repeat_0or1)
|
21
|
+
# Cボタンおしっぱなし + マウスで自機位置移動
|
22
|
+
if button.btC.press?
|
23
|
+
@pA = cursor.point.clone
|
24
|
+
end
|
25
|
+
# Dボタンおしっぱなし + マウスで自機角度変更
|
26
|
+
if button.btD.press?
|
27
|
+
if cursor.point != @pA
|
28
|
+
@sA = (cursor.point - @pA).normalize * @sA.magnitude
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
draw_circle(@pA, :vertex => @vertex, :radius => @radius)
|
33
|
+
draw_vector(@sA.scale(@radius), :origin => @pA)
|
34
|
+
end
|
35
|
+
|
36
|
+
run
|
37
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# 等速移動
|
3
|
+
#
|
4
|
+
# いろんな多角形が落ちてくるだけ
|
5
|
+
#
|
6
|
+
require_relative "helper"
|
7
|
+
|
8
|
+
class Ball
|
9
|
+
include Stylet::Delegators
|
10
|
+
delegate :objects, :to => "Stylet.context"
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@gravity = vec2[0, 0.05]
|
14
|
+
|
15
|
+
@vertex = 3 + rand(3)
|
16
|
+
@radius = 2 + rand(24)
|
17
|
+
@arrow = rand(2).zero? ? 1 : -1
|
18
|
+
|
19
|
+
@pos = vec2[rand(srect.w), srect.min_y - @radius * 2]
|
20
|
+
@speed = vec2.angle_at(Stylet::Magic.clock(rand(5.5..6.5))).scale(rand(1.0..1.5))
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
@pos += @speed
|
25
|
+
|
26
|
+
# 落ちたら死ぬ
|
27
|
+
max = srect.max_y + @radius * 2
|
28
|
+
if @pos.y > max
|
29
|
+
objects.delete(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
draw_circle(@pos, :radius => @radius, :vertex => @vertex, :angle => 1.0 / 256 * (@speed.magnitude + frame_counter) * @arrow)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class App < Stylet::Base
|
37
|
+
include Helper::CursorWithObjectCollection
|
38
|
+
|
39
|
+
setup do
|
40
|
+
cursor.display = false
|
41
|
+
self.title = "等速落下"
|
42
|
+
end
|
43
|
+
|
44
|
+
update do
|
45
|
+
if frame_counter.modulo(4).zero?
|
46
|
+
@objects << Ball.new
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
run
|
51
|
+
end
|
data/examples/00500_/345/212/240/351/200/237/346/224/276/347/211/251/347/267/232_parabora_volcano.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# 放物線デモ(火山)
|
3
|
+
#
|
4
|
+
# ・Zでスピード反転
|
5
|
+
# ・Xでスピード二倍
|
6
|
+
# ・Cでマウスの位置にセット
|
7
|
+
# ・Vで速度ベクトルの向きをマウスの向きへ
|
8
|
+
#
|
9
|
+
require_relative "helper"
|
10
|
+
|
11
|
+
class Ball
|
12
|
+
include Stylet::Delegators
|
13
|
+
|
14
|
+
delegate :objects, :button, :cursor, :to => "Stylet.context"
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@vertex = 3 + rand(3) # 物体は何角形か
|
18
|
+
@radius = 2 + rand(24) # 物体の大きさ
|
19
|
+
@arrow = rand(2).zero? ? 1 : -1 # どっち向きに回転するか
|
20
|
+
@reflect = 0
|
21
|
+
|
22
|
+
@pos = vec2[srect.center.x, srect.max_y + @radius * 2] # 物体初期位置
|
23
|
+
@speed = vec2[rand(-2.0..2.0), rand(-15.0..-12)] # 速度ベクトル
|
24
|
+
@gravity = vec2[0, 0.220] # 重力
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
# 操作
|
29
|
+
begin
|
30
|
+
# Aボタンでスピード反転
|
31
|
+
if button.btA.trigger?
|
32
|
+
@speed = @speed.scale(-1)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Bボタンでスピード2倍
|
36
|
+
if button.btB.trigger?
|
37
|
+
@speed = @speed.scale(2)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Cボタンおしっぱなし + マウスで位置移動
|
41
|
+
if button.btC.press?
|
42
|
+
@pos = Stylet.context.cursor.point.clone
|
43
|
+
end
|
44
|
+
|
45
|
+
# Dボタンおしっぱなし + マウスで角度変更
|
46
|
+
if button.btD.press?
|
47
|
+
if cursor.point != @pos
|
48
|
+
# @speed = (Stylet.context.cursor.point - @pos).normalize * @speed.magnitude
|
49
|
+
@speed = (cursor.point - @pos).normalize * @speed.magnitude
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
@speed += @gravity # 加速
|
55
|
+
@pos += @speed # 進む
|
56
|
+
|
57
|
+
# 画面下で弾ける
|
58
|
+
if @reflect == 0
|
59
|
+
max = (srect.max_y - @radius)
|
60
|
+
if @pos.y > max && @speed.y >= 1
|
61
|
+
@speed.y = -@speed.y
|
62
|
+
@speed = @speed.scale(0.5)
|
63
|
+
if @speed.magnitude < 1.0
|
64
|
+
@reflect += 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# 完全に落ちてしまったら死ぬ
|
70
|
+
max = srect.max_y + @radius * 2
|
71
|
+
if @pos.y > max && @speed.y >= 1
|
72
|
+
objects.delete(self)
|
73
|
+
end
|
74
|
+
|
75
|
+
draw_circle(@pos, :radius => @radius, :vertex => @vertex, :angle => 1.0 / 256 * (@speed.magnitude + frame_counter) * @arrow)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class App < Stylet::Base
|
80
|
+
include Helper::CursorWithObjectCollection
|
81
|
+
|
82
|
+
setup do
|
83
|
+
cursor.display = false
|
84
|
+
self.title = "加速・放物線・バウンド"
|
85
|
+
end
|
86
|
+
|
87
|
+
update do
|
88
|
+
if frame_counter.modulo(4).zero?
|
89
|
+
@objects << Ball.new
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
run
|
94
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# 3D
|
3
|
+
#
|
4
|
+
require_relative "helper"
|
5
|
+
|
6
|
+
class App < Stylet::Base
|
7
|
+
include Helper::CursorWithObjectCollection
|
8
|
+
include Helper::MovablePoint
|
9
|
+
|
10
|
+
setup do
|
11
|
+
@points = []
|
12
|
+
|
13
|
+
@points << vec3[-200, +200, 75]
|
14
|
+
@points << vec3[+200, +200, 75]
|
15
|
+
@points << vec3[+200, -200, 75]
|
16
|
+
@points << vec3[-200, -200, 75]
|
17
|
+
|
18
|
+
@points << vec3[-200, +200, 50]
|
19
|
+
@points << vec3[+200, +200, 50]
|
20
|
+
@points << vec3[+200, -200, 50]
|
21
|
+
@points << vec3[-200, -200, 50]
|
22
|
+
|
23
|
+
@ridges = [
|
24
|
+
[0, 1],
|
25
|
+
[1, 2],
|
26
|
+
[2, 3],
|
27
|
+
[3, 0],
|
28
|
+
|
29
|
+
[4, 5],
|
30
|
+
[5, 6],
|
31
|
+
[6, 7],
|
32
|
+
[7, 4],
|
33
|
+
|
34
|
+
[0, 4],
|
35
|
+
[1, 5],
|
36
|
+
[2, 6],
|
37
|
+
[3, 7],
|
38
|
+
]
|
39
|
+
|
40
|
+
@depth = 25
|
41
|
+
end
|
42
|
+
|
43
|
+
update do
|
44
|
+
@depth += axis.down.repeat - axis.up.repeat
|
45
|
+
points2 = @points.collect {|p| vec2[p.x.to_f * @depth / p.z, p.y.to_f * @depth / p.z] }
|
46
|
+
points3 = points2.collect {|p| srect.center + vec2[p.x, -p.y] }
|
47
|
+
@ridges.each {|a, b| draw_line(points3[a], points3[b]) }
|
48
|
+
points3.each_with_index {|p0, index| vputs index, :vector => p0 }
|
49
|
+
vputs "depth: #{@depth}"
|
50
|
+
end
|
51
|
+
|
52
|
+
run
|
53
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# PSPやPS3やトルネのインターフェイスでありがちなメニューの動き
|
3
|
+
#
|
4
|
+
require_relative "helper"
|
5
|
+
|
6
|
+
class Ball
|
7
|
+
include Stylet::Delegators
|
8
|
+
|
9
|
+
delegate :axis, :button, :objects, :to => "Stylet.context"
|
10
|
+
|
11
|
+
def initialize(index)
|
12
|
+
@name = index.to_s
|
13
|
+
@index = index
|
14
|
+
|
15
|
+
@vertex = 16
|
16
|
+
@radius = 48
|
17
|
+
@everyone_radius = 80 * 2
|
18
|
+
@arrow = rand(2).zero? ? 1 : -1 # どっち向きに回転するか
|
19
|
+
|
20
|
+
@pos = vec2[rand(srect.w), rand(srect.h)] # 物体初期位置
|
21
|
+
|
22
|
+
@state = State.new(:state1)
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
if axis.up.press? || axis.down.press? || axis.right.press? || axis.left.press? || button.btA.trigger?
|
27
|
+
@index += axis.down.repeat + axis.right.repeat
|
28
|
+
@index -= axis.up.repeat + axis.left.repeat
|
29
|
+
@state.jump_to :state1
|
30
|
+
end
|
31
|
+
if button.btB.trigger?
|
32
|
+
@state.jump_to :state3
|
33
|
+
end
|
34
|
+
|
35
|
+
@state.loop_in do
|
36
|
+
case @state.key
|
37
|
+
when :state1
|
38
|
+
# 自分の位置に戻る
|
39
|
+
@target = srect.center + vec2.angle_at((1.0 / objects.size * @index)) * @everyone_radius
|
40
|
+
@pos += (@target - @pos).scale(0.2)
|
41
|
+
|
42
|
+
if (@target - @pos).magnitude < 1.0
|
43
|
+
@pos = @target
|
44
|
+
@state.jump_to :state2
|
45
|
+
end
|
46
|
+
when :state2
|
47
|
+
# しばらく時間がたったら
|
48
|
+
if @state.start?
|
49
|
+
end
|
50
|
+
if @state.counter >= 30 * 1 || button.btB.trigger?
|
51
|
+
@state.jump_to :state3
|
52
|
+
end
|
53
|
+
when :state3
|
54
|
+
# 勝手に動きだす
|
55
|
+
if @state.start?
|
56
|
+
@speed = vec2[rand(-1.5..1.5), rand(-1.0..1.0)]
|
57
|
+
end
|
58
|
+
@pos += @speed
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
draw_circle(@pos, :radius => @radius, :vertex => @vertex, :angle => 1.0 / 256 * frame_counter)
|
63
|
+
vputs @name, :vector => @pos
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class App < Stylet::Base
|
68
|
+
include Helper::CursorWithObjectCollection
|
69
|
+
|
70
|
+
setup do
|
71
|
+
self.title = "トルネ風メニュー(PSのシステムにありがちな動き)"
|
72
|
+
cursor.display = false
|
73
|
+
@objects = Array.new(8) {|i| Ball.new(i) }
|
74
|
+
end
|
75
|
+
|
76
|
+
run
|
77
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative "bezier"
|
2
|
+
|
3
|
+
class App
|
4
|
+
include LineCollision
|
5
|
+
|
6
|
+
def collection
|
7
|
+
[
|
8
|
+
[
|
9
|
+
srect.center + vec2[-srect.w / 4, srect.h / 4],
|
10
|
+
srect.center + vec2[0, -srect.h / 4],
|
11
|
+
srect.center + vec2[srect.w / 4, srect.h / 4],
|
12
|
+
], [
|
13
|
+
srect.center + vec2[-100, +100],
|
14
|
+
srect.center + vec2.zero,
|
15
|
+
srect.center + vec2[+100, -100],
|
16
|
+
],
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
# 二次ベジェ曲線
|
21
|
+
#
|
22
|
+
# p0: 開始座標
|
23
|
+
# p1: 制御座標
|
24
|
+
# p2: 終了座標
|
25
|
+
#
|
26
|
+
# p1
|
27
|
+
# p0 ------------------- p2
|
28
|
+
#
|
29
|
+
# 用途
|
30
|
+
# ・少し曲げたい
|
31
|
+
# ・終了座標を必ず通る必要がある
|
32
|
+
# ・計算量をなるべく少なくしたい
|
33
|
+
# ・クロスしなくてよい
|
34
|
+
#
|
35
|
+
def bezier_curve(p0, p1, p2, t)
|
36
|
+
o = vec2.zero
|
37
|
+
o += p0.scale((1 - t) * (1 - t))
|
38
|
+
o += p1.scale(2 * t * (1 - t))
|
39
|
+
o += p2.scale(t * t)
|
40
|
+
end
|
41
|
+
|
42
|
+
run
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "bezier"
|
2
|
+
|
3
|
+
class App
|
4
|
+
def collection
|
5
|
+
[
|
6
|
+
[
|
7
|
+
vec2[srect.min_x + srect.w / 8, srect.hy], # 開始
|
8
|
+
vec2[srect.min_x + srect.w / 4, srect.hy - srect.h / 4], # 制御(右)
|
9
|
+
vec2[srect.max_x - srect.w / 4, srect.hy - srect.h / 4], # 制御(左)
|
10
|
+
vec2[srect.max_x - srect.w / 8, srect.hy], # 終了
|
11
|
+
]
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
# 三次ベジェ曲線
|
16
|
+
#
|
17
|
+
# p0: 開始
|
18
|
+
# p1: 制御
|
19
|
+
# p2: 制御
|
20
|
+
# p3: 終了
|
21
|
+
#
|
22
|
+
# p1 p2
|
23
|
+
# p0 ------------------- p3
|
24
|
+
#
|
25
|
+
# 用途
|
26
|
+
# ・激しく曲げたい
|
27
|
+
# ・終了座標を必ず通る必要がある
|
28
|
+
# ・計算量をまーまー少なくしたい
|
29
|
+
# ・クロスさせたい
|
30
|
+
#
|
31
|
+
def bezier_curve(p0, p1, p2, p3, d)
|
32
|
+
o = vec2.zero
|
33
|
+
o += p0.scale((1 - d) * (1 - d) * (1 - d))
|
34
|
+
o += p1.scale(3 * d * (1 - d) * (1 - d))
|
35
|
+
o += p2.scale(3 * d * d * (1 - d))
|
36
|
+
o += p3.scale(d * d * d)
|
37
|
+
end
|
38
|
+
|
39
|
+
run
|
40
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative "bezier"
|
2
|
+
|
3
|
+
class App
|
4
|
+
def collection
|
5
|
+
list = []
|
6
|
+
|
7
|
+
# 横に配置
|
8
|
+
n = 2
|
9
|
+
a = []
|
10
|
+
a += Array.new(n + 1) {|i|
|
11
|
+
x = (srect.width * 0.1) + ((srect.width * 0.8) / n * i)
|
12
|
+
y = srect.hy
|
13
|
+
vec2[x, y]
|
14
|
+
}
|
15
|
+
list << a
|
16
|
+
|
17
|
+
# 円状に配置
|
18
|
+
n = 5
|
19
|
+
r = srect.hy * 0.9
|
20
|
+
a = []
|
21
|
+
a += Array.new(n) {|i| srect.center + vec2.angle_at(1.0 / n * i).scale(r) }
|
22
|
+
|
23
|
+
list << a
|
24
|
+
|
25
|
+
list
|
26
|
+
end
|
27
|
+
|
28
|
+
update do
|
29
|
+
unless @points.empty?
|
30
|
+
if button.btB.trigger?
|
31
|
+
# 最後に制御点の追加
|
32
|
+
@points = [
|
33
|
+
@points.first(@points.size - 1),
|
34
|
+
@points.last + vec2[-30, 0],
|
35
|
+
@points.last,
|
36
|
+
].flatten
|
37
|
+
end
|
38
|
+
if button.btC.trigger?
|
39
|
+
# 最後の制御点を削除
|
40
|
+
if @points.size >= 3
|
41
|
+
@points[-2] = nil
|
42
|
+
@points.compact!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
vputs "#{@points.size} (B+ C-)"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# N次ベジェ曲線
|
50
|
+
#
|
51
|
+
# p1 p2 p3 p4
|
52
|
+
# p0 ------------------- p5
|
53
|
+
#
|
54
|
+
# 用途
|
55
|
+
# ・めちゃくちゃ激しく曲げたい
|
56
|
+
# ・終了座標を必ず通る必要がある
|
57
|
+
# ・どんだけ計算量がかかってもよい
|
58
|
+
# ・クロスしまくりたい
|
59
|
+
#
|
60
|
+
def bezier_curve(*points, d)
|
61
|
+
o = vec2.zero
|
62
|
+
|
63
|
+
points.size.times {|i|
|
64
|
+
p = points[i]
|
65
|
+
v = 1.0
|
66
|
+
a = points.size - 1
|
67
|
+
b = i
|
68
|
+
c = a - b
|
69
|
+
loop do
|
70
|
+
if a > 1
|
71
|
+
v *= a
|
72
|
+
a -= 1
|
73
|
+
else
|
74
|
+
break
|
75
|
+
end
|
76
|
+
if b > 1
|
77
|
+
v /= b
|
78
|
+
b -= 1
|
79
|
+
end
|
80
|
+
if c > 1
|
81
|
+
v /= c
|
82
|
+
c -= 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
v *= (d**i) * ((1 - d)**((points.size - 1) - i))
|
86
|
+
o += p.scale(v)
|
87
|
+
}
|
88
|
+
o
|
89
|
+
end
|
90
|
+
|
91
|
+
run
|
92
|
+
end
|