#include "hsptv.as" #include "obaq.as" #define PARTICLE_MAX ( 40 ) mouse ; ; モジュール ; #module #deffunc Saturation var value, int min, int max if( value > max ){ value = max } if( value < min ){ value = min } return ; #deffunc DrawCircle double cx, double cy, int size, int mode circle cx - size, cy - size, cx + size, cy + size , mode return #deffunc MoveSometing int key, var x, var y if( key & 1 ){ x -= 2 } if( key & 4 ){ x += 2 } if( key & 2 ){ y -= 2 } if( key & 8 ){ y += 2 } return #global ; ; 定数・変数 ; screen 0 dim particle_id, PARTICLE_MAX dim pos_x, PARTICLE_MAX dim pos_y, PARTICLE_MAX mouse_enabled = 1 netabare = 0 key_mask = 0 pos 80, 0 objsize 160,20 chkbox "マウス移動(オフ:カーソルキー)", mouse_enabled objsize 100,20 pos 80, 20 button "ESCキー", *reset ;pos 80, 40 ;button "Zキー or 左クリック", *reset pos 500, 0 objsize 80,20 chkbox "ネタばれ", netabare var_damper = 6.0 var_friction = 10.0 target_id = 99 angle = 0 rot = 0 min = -7 max = 7 *start qreset frame=0 particle_num = 0 mr = 0.0 key = 0 target_x = 80 target_y = 100 qaddpoly target_id, 5, target_x,target_y,0,4,4,1 qdamper target_id,var_damper,var_friction qtype target_id, type_bind angle = 0 var_x = 0 var_y = 0 ;randomize gettime( 7 ) ; メインループ *main ; 緑のパーティクルを発生させる ; (最初の2つは目) if ( ( frame \ 20 ) == 0 && ( particle_num < PARTICLE_MAX ) ){ qaddpoly particle_id( particle_num ), 4, 80, 15, 0, 3, 3 if( particle_id( particle_num ) > 0 ){ qspeed particle_id( particle_num );, 0, 0, 0 particle_num ++ } } redraw 0 color 0, 0, 64 boxf ; gradf ,,,,1,0,128 ; 画面クリア qexec ; 各パーティクスの速度を取得 gosub *GetSpeed if( netabare ){ qdraw } else{ ; ターゲットの描画 gosub *DrawTarget ; 生物の描画 gosub *DrawParticleX } ; 操作方法の表示 gosub *DispHelp ; stick key, 0xFF ; キーの取得 if( key & 0x80 ){ goto *start } if( mouse_enabled ){ mx = mousex my = mousey qcnvaxis target_x, target_y, mx, my, 1 qpos target_id, target_x, target_y, mr } else{ MoveSometing key, target_x, target_y Saturation target_x, 0, 160 Saturation target_y, 0, 120 qpos target_id, target_x, target_y, mr } frame++ redraw 1 await 12 goto *main ; ; 各パーティクスの速度を取得 ; *GetSpeed for i, 0, particle_num, 1 qgetpos particle_id( i ), pos_x( i ), pos_y( i ), angle next for i, 0, particle_num, 1 add_x = 0.0 add_y = 0.0 dx = target_x - pos_x( i ) dy = target_y - pos_y( i ) ; 両目 if( i < 2 ){ dy *= 0.2 dy *= 0.2 } ; if( dx * dx + dy * dy < 10000 ){ add_x = 0.001 * dx add_y = 0.0001 * dy qspeed particle_id( i ), add_x, add_y, 0, 0 ; 両目 if( i < 2 ){ add_x *= 2 add_y *= 2 } } getkey p1, 90 getkey p2, 1 if( p1 || p2 ){ qspeed particle_id( i ), 0, -0.1, 0, 0 } next return ; ; ターゲットの描画 ; *DrawTarget qcnvaxis cx, cy, target_x, target_y, 0 color 255, 255, 255 DrawCircle cx-40, cy-3, 5, 1 DrawCircle cx-40, cy+3, 5, 1 DrawCircle cx+40, cy-3, 5, 1 DrawCircle cx+40, cy+3, 5, 1 boxf cx-40, cy-3, cx+40, cy+3 color 255, 128, 128 DrawCircle cx+10, cy, 20, 1 DrawCircle cx-10, cy, 20, 1 return ; ; 生物の描画 ; *DrawParticleX color 255,64 for i, 2, particle_num, 1 qcnvaxis cx, cy, pos_x( i ), pos_y( i ), 0 DrawCircle cx, cy, 24, 1 next color 255,255 for i, 2, particle_num, 1 qcnvaxis cx, cy, pos_x( i ), pos_y( i ), 0 circle cx - 20, cy - 20, cx + 20, cy + 20, 1 DrawCircle cx, cy, 20, 1 next eye = 2 if( eye > particle_num ){ eye = particle_num } ; 白目 color 32,32,32 for i, 0, eye, 1 qcnvaxis cx, cy, pos_x( i ), pos_y( i ), 0 DrawCircle cx, cy, 24, 1 next color 255,255,255 for i, 0, eye, 1 qcnvaxis cx, cy, pos_x( i ), pos_y( i ), 0 DrawCircle cx, cy, 20, 1 next ; 黒目 color for i, 0, eye, 1 eye_mv_x = target_x - pos_x( i ) Saturation eye_mv_x, min, max eye_mv_y = target_y - pos_y( i ) Saturation eye_mv_y, min, max qcnvaxis cx, cy, pos_x( i ), pos_y( i ), 0 DrawCircle cx + eye_mv_x, cy + eye_mv_y, 10, 1 next return ; ; 操作方法の表示 ; *DispHelp color 255, 255, 255 pos 0, 0 mes "移動 :" pos 0, 20 mes "リセット:" pos 0, 40 mes "ジャンプ:左クリック or Zキー" return *reset goto *start