HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2014
0914
イヤホン[OBAQ]安定しない、qgetcol2が効かない原因がわからなくなってしまった。6解決


イヤホン

リンク

2014/9/14(Sun) 22:54:57|NO.64947

私はOBAQを使用したSTGを作っていたのですが、四半年ほどあるバグに悩まされています。
ランダム性を出すために53行目に randomize を入れたいのですが入れるとかなりの確率で動作が停止します。
また、オブジェクトが衝突したら消滅する仕様にするように692-711行目にプログラムを仕込んでいるのですが、qgetcol2が効かないために、この仕掛も発動しません。
私は何が悪いのか分からなくなってしまったので、ここに投稿することにしました。
何が↑2、3を引き起こしているのでしょうか。
協力してください。お願いします。

#define wxs 760.0 ; wxs = 画面の横の長さ #define wys 400.0 ; wys = 画面の縦の長さ #define cxs 32.0 ; cxs = 画像を縦に分割する長さ #define cys 32.0 ; cys = 画像を横に分割する長さ #define pie M_PI ;pie = 円周率 //活動限界[outside](オブジェクト全て) //内訳  //(0) = オブジェクトの活動限界値(上 //(1) = オブジェクトの活動限界値(下 //(2) = オブジェクトの活動限界値(左 //(3) = オブジェクトの活動限界値(右 objlim_out = -4.0 ,185.0 ,3.0 ,97.0 //活動限界[inner](本体、補助機) //内訳  //(0) = オブジェクトの活動限界値(上 //(1) = オブジェクトの活動限界値(下 //(2) = オブジェクトの活動限界値(左 //(3) = オブジェクトの活動限界値(右 pslim_in = 6 ,89 ,6 ,94 //活動限界[inner](敵機) //内訳  //(0) = オブジェクトの活動限界値(上 //(1) = オブジェクトの活動限界値(下 //(2) = オブジェクトの活動限界値(左 //(3) = オブジェクトの活動限界値(右 elim_in = 100 ,183 ,6 ,94 //弾丸削除条件(本体、補助機) //x軸方向にここまで来ると弾が消える pst_lim = 190.0 //弾丸削除条件(敵機) //x軸方向にここまで来ると弾が消える et_lim = 0.0 //ステータス画面1 screen 0 ,350 ,40 ,0 ,5 ,5 : title "Status Window(player)" //ステータス画面2 screen 3 ,350 ,240 ,0 ,0 ,77 : title "Status Window(player_tama)" //ステータス画面3 screen 4 ,350 ,40 ,0 ,0 ,354 : title "Status Window(subplayer)" //ステータス画面4 screen 5 ,350 ,240 ,0 ,0 ,426 : title "Status Window(subplayer_tama)" //ステータス画面5 screen 6 ,350 ,240 ,0 ,1140 ,0 : title "Status Window(enemy)" //ステータス画面6 screen 7 ,350 ,240 ,0 ,1140 ,277 : title "Status Window(enemy_tama)" //obaq画面 screen 2 ,wxs ,wys ,0 ,365 ,0 : title "obaq Window" RANDOMIZE ;------------------------------------安定しないのはなぜですか ////本体 //変数初期化 px = 160 : py = 80 ; 赤い点のオブジェクトの座標 px_e = 0.0 : py_e = 0.0 ; オブジェクト座標変換用 pspeed = 0.3 ; pspeed = 本体の速さ //オブジェクト管理用変数 //内訳  //(0) = フラグ //(1) = オブジェクトID //(2) = 座標x(画面) //(3) = 座標y(画面) //(4) = 角度(内部) //(5) = 傾き //(6) = 弾の種類 ddim obj ,7 ,16 repeat length2(obj) obj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 loop ////補助機 //変数初期化 sx = rnd(wxs) : sy = rnd(wys) ; 赤い点のオブジェクトの座標 sx_e = 0.0 : sy_e = 0.0 ; オブジェクト座標変換用 Sspeed = double( rnd(10) /10 ) ; Sspeed = 本体の速さ subt_speed = 1.5 ;弾速(弾速) //オブジェクト管理用変数 //内訳 //(0) = フラグ //(1) = オブジェクトID //(2) = 座標x(画面) //(3) = 座標y(画面) //(4) = 角度(内部) ddim subtobj ,5 ,16 repeat length2(subtobj) subtobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 loop ////敵機 //変数初期化 eneobj_max = 10 ; eneobj_max = 敵の数 EneFre = 100 ; EneFre = 弾を撃つ頻度 dim eneobj ,eneobj_max ;敵 dim ex ,eneobj_max : dim ey ,eneobj_max ;敵の座標 ddim ex_e ,eneobj_max : ddim ey_e ,eneobj_max ;敵の座標(変換用) ddim Espeed ,eneobj_max ;(敵の速さ) ddim Espeedx ,eneobj_max : ddim Espeedy ,eneobj_max ;(敵の速さ) startet = 0 ;弾を発射する機体を決める repeat eneobj_max ex(cnt) = wxs/2 +rnd(wxs/2) : ey(cnt) = wys/2 +rnd(wys/2) ; 赤い点のオブジェクトの座標 ex_e(cnt) = 0.0 : ey_e(cnt) = 0.0 ; オブジェクト座標変換用 Espeed(cnt) = double( rnd(100) ) /200.0 + 0.01 ; Espeed = 本体の速さ Espeedx(cnt) = 0.0 : Espeedy(cnt) = 0.0 ; Espeedx = 速さの代入値 (x) : Espeedy = 速さの代入値 (y) loop //オブジェクト管理用変数 //内訳 //(0) = フラグ //(1) = オブジェクトID //(2) = 座標x(画面) //(3) = 座標y(画面) //(4) = 角度(内部) ddim enetobj ,5 ,16 repeat length2(enetobj) enetobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 loop //変数初期化(弾の速さ = 1.5) ddim enet_speed ,length2(enetobj) repeat length2(enetobj) enet_speed(cnt) = 1.5 loop //////obaqゾーン #include "obaq.as" ////obaq システム設定  qreset qborder -106.0 ,-51.0 ,106.0 ,51.0 ; 横幅のみサイズ可変( 192.0 ,102.0 基準 ) qgravity 0.0 ,0.0 ////出現(プログラムにおける位置は「obaq システム設定」より後に記述しなければならない) //赤いオブジェクト(発射地点表示) 本体 qcnvaxis px_e ,py_e ,px ,py ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly mainobj ,4 ,px_e ,py_e ,0.0 ,5.0 ,5.0 ,0 ,1 ,30 qtype mainobj ,type_bindR //黄色いオブジェクト(発射地点表示) 補助機 qcnvaxis sx_e ,sy_e ,sx ,sy ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly subobj ,4 ,sx_e ,sy_e ,0.0 ,5.0 ,5.0 ,0 ,8 ,33 qtype subobj ,type_bindR //水色オブジェクト(発射地点表示) 敵機 repeat eneobj_max qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly eneobj(cnt) ,4 ,ex_e(cnt) ,ey_e(cnt) ,0.0 ,5.0 ,5.0 ,colsw_none ,32 ,9 qtype eneobj(cnt) ,type_bindR loop //メインループ開始 *main //情報検出 本機 qgetpos mainobj ,px ,py ,pr qcnvaxis px_e ,py_e ,px ,py ,1 qgetspeed mainobj ,pxsp ,pysp ,prsp //情報検出 補助機 qgetpos subobj ,sx ,sy ,sr qcnvaxis sx_e ,sy_e ,sx ,sy ,1 //情報検出 敵機 repeat length(eneobj) qgetpos eneobj(cnt) ,ex(cnt) ,ey(cnt) ,er(cnt) qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 loop //オブジェクト移動処理 gosub *p_move gosub *s_move gosub *e_move //オブジェクトから発射 if ((ky&16)!0)&(time\20 = 0) { gosub *p_objcreate } if (time\30 = 0) { gosub *s_objcreate } if (time\( EneFre/ (eneobj_max) ) = 0) { gosub *e_objcreate } //オブジェクト範囲外処理 gosub *p_object_out_of_range gosub *mainobject_out_of_range gosub *s_object_out_of_range gosub *e_object_out_of_range //オブジェクト削除処理 gosub *p_delete gosub *s_delete gosub *e_delete //オブジェクト傾き処理 gosub *mainobject_slope qexec gosub *ObjectExec //オブジェクトデータ管理更新 //データ更新 gosub *status_player_window_redraw gosub *status_playertama_window_redraw gosub *status_subplayer_window_redraw gosub *status_subplayertama_window_redraw gosub *status_enemy_window_redraw gosub *status_enemytama_window_redraw redraw 0 color : boxf qdraw 0 redraw 1 time++ await 16 goto *main //プレイヤー移動処理 *p_move pspeedx = 0.0 : pspeedy = 0.0 : pspeed = 0.3 ;毎時動く距離と速さ //shift入力時の速度制限 getkey shift ,16 if shift ! 0 { pspeed = pspeed/2.0 } //各種方向キーの対応 stick ky,31 if ky&128 { qterm : end } if px >= pslim_in(0) : if ky&1 { pspeedx - cos(pr)*pspeed } if px <= pslim_in(1) : if ky&4 { pspeedx + cos(pr)*pspeed } if py >= pslim_in(2) : if ky&2 { pspeedy - cos(pr)*pspeed } if py <= pslim_in(3) : if ky&8 { pspeedy + cos(pr)*pspeed } //実行 qspeed mainobj ,pspeedx ,pspeedy ,0.0 ,1 return *s_move if time\30 = 0 { gosub *s_AI } //移動距離の指定 if (sx >= pslim_in(0))&(sx <= pslim_in(1)) { Sspeedx = Sspeed * cos( sdeg ) }else{ repeat gosub *s_AI if ( sx + Sspeedx *10 >= pslim_in(0))&( sx + Sspeedx *10 <= pslim_in(1)) { break } loop } if (sy >= pslim_in(2))&(sy <= pslim_in(3)) { Sspeedy = Sspeed * sin( sdeg ) }else{ repeat gosub *s_AI if ( sy + Sspeedy *10 >= pslim_in(2))&( sy + Sspeedy *10 <= pslim_in(3)) { break } loop } //実行 qspeed subobj ,Sspeedx ,Sspeedy ,0.0 ,1 return *s_AI Sspeedx = 0.0 : Sspeedy = 0.0 : Sspeed = 0.15 ;毎時動く距離と速さ //角度について if (sx >= pslim_in(0)-10 ) { sdegrnd = double( rnd(180) + 90 )/180.0 } if (sx <= pslim_in(1)+10 ) { sdegrnd = double( rnd(180) + 270 )/180.0 } if (sy >= pslim_in(2)-10 ) { sdegrnd = double( rnd(180) )/180.0 } if (sy <= pslim_in(3)+10 ) { sdegrnd = double( rnd(180) + 180 )/180.0 } sdeg += sdegrnd*pie repeat if sdeg > 2.0*pie { sdeg -= 2.0*pie }else{ break } loop Sspeedx = Sspeed * cos( sdeg ) Sspeedy = Sspeed * sin( sdeg ) return *e_move repeat eneobj_max ecnt = cnt if (time\10) = 0 { gosub *e_AI } //移動距離の指定 if (ex(ecnt) <= elim_in(0)-10 )&(ex(ecnt) >= elim_in(1)+10 )&(ey(ecnt) <= elim_in(2)-10 )&(ey(ecnt) >= elim_in(3)+10 ){ gosub *e_AI } if (ex(ecnt) <= elim_in(0) ) { qpos eneobj(ecnt) ,elim_in(0) ,ey(ecnt) ,0.0 } else : if (ex(ecnt) >= elim_in(1) ) { qpos eneobj(ecnt) ,elim_in(1) ,ey(ecnt) ,0.0 } else : if (ey(ecnt) <= elim_in(2) ) { qpos eneobj(ecnt) ,ex(ecnt) ,elim_in(2) ,0.0 } else : if (ey(ecnt) >= elim_in(3) ) { qpos eneobj(ecnt) ,ex(ecnt) ,elim_in(3) ,0.0 } else { edegrnd(ecnt) = double( rnd(360) )/180.0 } //実行 qspeed eneobj(ecnt) ,Espeedx(ecnt) ,Espeedy(ecnt) ,0.0 ,1 loop return *e_AI //角度について if (ex(ecnt) <= elim_in(0)-10 ) { edegrnd(ecnt) = double( rnd(180) + 90 )/180.0 } else : if (ex(ecnt) >= elim_in(1)+10 ) { edegrnd(ecnt) = double( rnd(180) + 270 )/180.0 } else : if (ey(ecnt) <= elim_in(2)-10 ) { edegrnd(ecnt) = double( rnd(180) )/180.0 } else : if (ey(ecnt) >= elim_in(3)+10 ) { edegrnd(ecnt) = double( rnd(180) + 180 )/180.0 } else { edegrnd(ecnt) = double( rnd(360) )/180.0 } edeg(ecnt) = edegrnd(ecnt)*pie repeat if edeg(ecnt) > 2.0*pie { edeg(ecnt) -= 2.0*pie }else{ break } loop Espeedx(ecnt) = Espeed * cos( edeg(ecnt) ) Espeedy(ecnt) = Espeed * sin( edeg(ecnt) ) return //ステータスウィンドウ1の更新 *status_player_window_redraw gsel 0 redraw 0 color : boxf : color ,255 pos 0, 0 : mes"ID" pos 80 ,0 : mes"X座標" pos 170 ,0 : mes "Y座標" pos 260 ,0 : mes "角度(ラジアン)" line 0 ,18 ,350 ,18 pos 0,20 : mes "mainobj" pos 80,20 : mes px pos 170 ,20 : mes py pos 260 ,20 : mes 0.0 redraw 1 gsel 2 return //ステータスウィンドウ2の更新 *status_playertama_window_redraw gsel 3 redraw 0 color : boxf : color ,255 pos 0,0 : mes"ID" pos 80,0 : mes"X座標" pos 170,0 : mes "Y座標" pos 260,0 : mes "角度(ラジアン)" line 0,18,350,18 line 0,220,350,220 pos 0,222 : mes "オブジェクト管理有効最大数 : "+ActiveObjectMax+" ("+length2(obj)+")" chc = 0 repeat length2(obj) //表示の座標・角度はすべて内部座標です。 if ( obj(0,cnt) = -1) { continue } pos 0,chc*20+20 : mes "("+cnt+") : "+int(obj(1,cnt)) pos 80,chc*20+20 : mes ""+obj(2,cnt) pos 170,chc*20+20 : mes ""+obj(3,cnt) pos 260,chc*20+20 : mes ""+obj(4,cnt) chc++ if chc >= 10 { break } loop redraw 1 gsel 2 return //ステータスウィンドウ3の更新 *status_subplayer_window_redraw gsel 4 redraw 0 color : boxf : color ,255 pos 0, 0 : mes"ID" pos 80 ,0 : mes"X座標" pos 170 ,0 : mes "Y座標" pos 260 ,0 : mes "角度(ラジアン)" line 0 ,18 ,350 ,18 pos 0,20 : mes "subplayer" pos 80,20 : mes sx pos 170 ,20 : mes sy pos 260 ,20 : mes 0.0 redraw 1 gsel 2 return //ステータスウィンドウ4の更新 *status_subplayertama_window_redraw gsel 5 redraw 0 color : boxf : color ,255 pos 0,0 : mes"ID" pos 80,0 : mes"X座標" pos 170,0 : mes "Y座標" pos 260,0 : mes "角度(ラジアン)" line 0,18,350,18 line 0,220,350,220 pos 0,222 : mes "オブジェクト管理有効最大数 : "+SubActiveObjectMax+" ("+length2(subtobj)+")" chc = 0 repeat length2(subtobj) //表示の座標・角度はすべて内部座標です。 if ( subtobj(0,cnt) = -1) { continue } pos 0,chc*20+20 : mes "("+cnt+") : "+int(subtobj(1,cnt)) pos 80,chc*20+20 : mes ""+subtobj(2,cnt) pos 170,chc*20+20 : mes ""+subtobj(3,cnt) pos 260,chc*20+20 : mes ""+subtobj(4,cnt) chc++ if chc >= 10 { break } loop redraw 1 gsel 2 return //ステータスウィンドウ5の更新 *status_enemy_window_redraw gsel 6 redraw 0 color : boxf : color ,255 pos 0, 0 : mes"ID" pos 80 ,0 : mes"X座標" pos 170 ,0 : mes "Y座標" pos 260 ,0 : mes "角度(ラジアン)" line 0 ,18 ,350 ,18 repeat length(eneobj) pos 0,20 + (cnt *20) : mes "enemy" + (cnt) pos 80,20 + (cnt *20) : mes ex(cnt) pos 170 ,20 + (cnt *20) : mes ey(cnt) pos 260 ,20 + (cnt *20) : mes 0.0 loop redraw 1 gsel 2 return //ステータスウィンドウ6の更新 *status_enemytama_window_redraw gsel 7 redraw 0 color : boxf : color ,255 pos 0,0 : mes"ID" pos 80,0 : mes"X座標" pos 170,0 : mes "Y座標" pos 260,0 : mes "角度(ラジアン)" line 0,18,350,18 line 0,220,350,220 pos 0,222 : mes "オブジェクト管理有効最大数 : "+EneActiveObjectMax+" ("+length2(enetobj)+")" chc = 0 repeat length2(enetobj) //表示の座標・角度はすべて内部座標です。 if ( enetobj(0,cnt) = -1) { continue } pos 0,chc*20+20 : mes "("+cnt+") : "+int(enetobj(1,cnt)) pos 80,chc*20+20 : mes ""+enetobj(2,cnt) pos 170,chc*20+20 : mes ""+enetobj(3,cnt) pos 260,chc*20+20 : mes ""+enetobj(4,cnt) chc++ if chc >= 10 { break } loop redraw 1 gsel 2 return //オブジェクト管理データを更新 *ObjectExec ActiveObjectMax = 0 ;今objが画面上で動いてる数 SubActiveObjectMax = 0 ;今subtobjが画面上で動いてる数 EneActiveObjectMax = 0 ;今enetobjが画面上で動いてる数 repeat length2(obj) if ( obj(0,cnt) = -1.0 ) { continue } qgetpos int(obj(1,cnt)) ,obj(2,cnt) ,obj(3,cnt) ,obj(4,cnt) ActiveObjectMax++ loop repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0 ) { continue } qgetpos int(subtobj(1,cnt)) ,subtobj(2,cnt) ,subtobj(3,cnt) ,subtobj(4,cnt) SubActiveObjectMax++ loop repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0 ) { continue } qgetpos int(enetobj(1,cnt)) ,enetobj(2,cnt) ,enetobj(3,cnt) ,enetobj(4,cnt) EneActiveObjectMax++ loop return //オブジェクト管理から空きを探す *p_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(obj) if ( obj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る obj(0,length2(obj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(obj) - 1 ;総数の確認 return //オブジェクト管理から空きを探す *s_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る subtobj(0,length2(subtobj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(subtobj) - 1 ;総数の確認 return //オブジェクト管理から空きを探す *e_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る enetobj(0,length2(enetobj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(enetobj) - 1 ;総数の確認 return //緑のオブジェクトの生成と発射処理 *p_objcreate gosub *p_ObjectEmpty ;空きの確認 qcnvaxis px_e ,py_e ,px ,py ,1 _TempObj = -1 qaddpoly _TempObj ,4 ,px ,py , ,5 ,5 , ,2 ,29 ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } obj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,px_e ,py_e ,0.0 //Zキー入力時の処理 getkey z ,90 if z ! 0 { obj( 6 ,TrueEmpty ) = 1.0 ;弾の種類 qdel _TempObj qaddpoly _TempObj ,4 ,px ,py , ,5 ,5 , ,4 ,29 ; 出現処理(チェックを含む為、一時的にIDを格納) } //弾の傾き obj( 5 ,TrueEmpty ) = double( p_slope ) //弾のタイプ qtype int(obj ( 1 ,TrueEmpty ) ) ,type_bindY qtype int(obj ( 1 ,TrueEmpty ) ) ,type_bindR //実行 if obj( 6 ,TrueEmpty ) = 0.0 { qpush int(obj(1,TrueEmpty)) , , ,7.5 ,0 } if obj( 6 ,TrueEmpty ) ! 0.0 { qpush int(obj(1,TrueEmpty)) , , ,7.5/2.0 ,0 } return //水色のオブジェクトの生成と発射処理 *s_objcreate gosub *s_ObjectEmpty ;空きの確認 qcnvaxis sx_e ,sy_e ,sx ,sy ,1 _TempObj = -1 qaddpoly _TempObj ,4 ,sx ,sy , ,5 ,5 , ,16 ,15 ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } subtobj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,sx_e ,sy_e ,0.0 //弾のタイプ qtype int(subtobj ( 1 ,TrueEmpty ) ) ,type_bindR //角度 subtdeg = double( rnd(90) + 240 )/180.0 //実行 qpush int(subtobj(1,TrueEmpty)) , , ,sin(subtdeg)*pie*subt_speed ,cos(subtdeg)*pie*subt_speed return //??色のオブジェクトの生成と発射処理 *e_objcreate gosub *e_ObjectEmpty ;空きの確認 //どこから発射するか repeat startet = rnd(length(eneobj) ) if eneobj(startet) ! -1.0 { break } loop //把握 repeat length(eneobj) : qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 : loop _TempObj = -1 qaddpoly _TempObj ,4 ,ex(startet) ,ey(startet) , ,5 ,5 , ,64 ,54 ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } enetobj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,ex_e(startet) ,ey_e(startet) ,0.0 //弾のタイプ qtype int(enetobj ( 1 ,TrueEmpty ) ) ,type_bindR //角度 enetdeg = double( rnd(90) + 800 )/180.0 //実行 qpush int(enetobj(1,TrueEmpty)) , , ,sin(enetdeg)*pie*enet_speed ,cos(enetdeg)*pie*enet_speed return //範囲外処理 *p_object_out_of_range repeat length2(obj) if ( obj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos obj(1,cnt) ,obj(2,cnt) ,obj(3,cnt) ,obj(4,cnt) ;情報入手 //削除実行 if ( obj(2,cnt) >= pst_lim ) { qdel int(obj(1,cnt)) obj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 } loop return *s_object_out_of_range repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos subtobj(1,cnt) ,subtobj(2,cnt) ,subtobj(3,cnt) ,subtobj(4,cnt) ;情報入手 //削除実行 if ( subtobj(2,cnt) >= pst_lim ) { qdel int(subtobj(1,cnt)) subtobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 } loop return *e_object_out_of_range repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos enetobj(1,cnt) ,enetobj(2,cnt) ,enetobj(3,cnt) ,enetobj(4,cnt) ;情報入手 //削除実行 if ( enetobj(2,cnt) <= et_lim ) { qdel int(enetobj(1,cnt)) enetobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 } loop return ////範囲外処理 *mainobject_out_of_range if ( px < objlim_out(0) ) { qpos mainobj ,objlim_out(0) ,py ,0.0 } if ( px > objlim_out(1) ) { qpos mainobj ,objlim_out(1) ,py ,0.0 } if ( py < objlim_out(2) ) { qpos mainobj ,px ,objlim_out(2) ,0.0 } if ( py > objlim_out(3) ) { qpos mainobj ,px ,objlim_out(3) ,0.0 } return *subobject_out_of_range if ( sx < objlim_out(0) ) { qpos subobj ,objlim_out(0) ,sy ,0.0 } if ( sx > objlim_out(1) ) { qpos subobj ,objlim_out(1) ,sy ,0.0 } if ( sy < objlim_out(2) ) { qpos subobj ,sx ,objlim_out(2) ,0.0 } if ( sy > objlim_out(3) ) { qpos subobj ,sx ,objlim_out(3) ,0.0 } return *eneobject_out_of_range if ( ex < objlim_out(0) ) { qpos eneobj ,objlim_out(0) ,ey ,0.0 } if ( ex > objlim_out(1) ) { qpos eneobj ,objlim_out(1) ,ey ,0.0 } if ( ey < objlim_out(2) ) { qpos eneobj ,ex ,objlim_out(2) ,0.0 } if ( ey > objlim_out(3) ) { qpos eneobj ,ex ,objlim_out(3) ,0.0 } return //オブジェクト削除 *p_delete qcollision mainobj qgetcol dummy ,dummy ,dummy qgetcol2 p_depth ,dummy ,dummy ;--------------------------qgetclo2が効かない if (p_depth!0.0) { qdel mainobj } ;衝突の深さが0以外ならmainobjを削除 return *s_delete qcollision subobj qgetcol dummy ,dummy ,dummy qgetcol2 s_depth ,dummy ,dummy ;--------------------------qgetclo2が効かない if (s_depth!0.0) { qdel subobj } ;衝突の深さが0以外ならsubobjを削除 return *e_delete repeat eneobj_max qcollision eneobj(cnt) qgetcol dummy ,dummy ,dummy qgetcol2 e_depth(cnt) ,dummy ,dummy ;--------------------------qgetclo2が効かない if (e_depth(cnt)!0.0) { qdel eneobj(cnt) } ;衝突の深さが0以外ならeneobjを削除 loop return //本体の傾き *mainobject_slope stick ky ,10 if ( ( ky&2 ) ! 0 )&( p_slope < 4 ) { p_slope++ } ;↑ if ( ( ky&8 ) ! 0 )&( p_slope > 0 ) { p_slope-- } ;↓ if ( ( ky&2 ) = 0 )&( ( ky&8 ) = 0 ){ ;not↑↓ if p_slope > 2 { p_slope-- } if p_slope < 2 { p_slope++ } } //Zキー入力時、傾斜軽減 getkey shift ,16 if shift ! 0 { if p_slope < 1 { p_slope = 1 } if p_slope > 3 { p_slope = 3 } } return



この記事に返信する


KA

リンク

2014/9/14(Sun) 23:01:10|NO.64948

まず、再現出来る最小限のスクリプトにしてみましょう。
その過程で解決する場合も多々有ります。



イヤホン

リンク

2014/9/14(Sun) 23:19:09|NO.64949

最小限にしたつもりです
このソースでは安定性に関する問題は起こりませんが、qgetcol2が効かない問題がまだ残ってます。


#define wxs 760.0 ; wxs = 画面の横の長さ #define wys 400.0 ; wys = 画面の縦の長さ #define cxs 32.0 ; cxs = 画像を縦に分割する長さ #define cys 32.0 ; cys = 画像を横に分割する長さ #define pie M_PI ;pie = 円周率 //活動限界[outside](オブジェクト全て) //内訳  //(0) = オブジェクトの活動限界値(上 //(1) = オブジェクトの活動限界値(下 //(2) = オブジェクトの活動限界値(左 //(3) = オブジェクトの活動限界値(右 objlim_out = -4.0 ,185.0 ,3.0 ,97.0 //活動限界[inner](本体、補助機) //内訳  //(0) = オブジェクトの活動限界値(上 //(1) = オブジェクトの活動限界値(下 //(2) = オブジェクトの活動限界値(左 //(3) = オブジェクトの活動限界値(右 pslim_in = 6 ,89 ,6 ,94 //活動限界[inner](敵機) //内訳  //(0) = オブジェクトの活動限界値(上 //(1) = オブジェクトの活動限界値(下 //(2) = オブジェクトの活動限界値(左 //(3) = オブジェクトの活動限界値(右 elim_in = 100 ,183 ,6 ,94 //弾丸削除条件(本体、補助機) //x軸方向にここまで来ると弾が消える pst_lim = 190.0 //弾丸削除条件(敵機) //x軸方向にここまで来ると弾が消える et_lim = 0.0 //obaq画面 screen 2 ,wxs ,wys ,0 ,365 ,0 : title "obaq Window" ////本体 //変数初期化 px = 160 : py = 80 ; 赤い点のオブジェクトの座標 px_e = 0.0 : py_e = 0.0 ; オブジェクト座標変換用 //オブジェクト管理用変数 //内訳  //(0) = フラグ //(1) = オブジェクトID //(2) = 座標x(画面) //(3) = 座標y(画面) //(4) = 角度(内部) //(5) = 傾き //(6) = 弾の種類 ddim obj ,7 ,16 repeat length2(obj) obj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 loop ////補助機 //変数初期化 sx = rnd(wxs) : sy = rnd(wys) ; 赤い点のオブジェクトの座標 sx_e = 0.0 : sy_e = 0.0 ; オブジェクト座標変換用 subt_speed = 1.5 ;弾速(弾速) //オブジェクト管理用変数 //内訳 //(0) = フラグ //(1) = オブジェクトID //(2) = 座標x(画面) //(3) = 座標y(画面) //(4) = 角度(内部) ddim subtobj ,5 ,16 repeat length2(subtobj) subtobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 loop ////敵機 //変数初期化 eneobj_max = 10 ; eneobj_max = 敵の数 EneFre = 100 ; EneFre = 弾を撃つ頻度 dim eneobj ,eneobj_max ;敵 dim ex ,eneobj_max : dim ey ,eneobj_max ;敵の座標 ddim ex_e ,eneobj_max : ddim ey_e ,eneobj_max ;敵の座標(変換用) startet = 0 ;弾を発射する機体を決める repeat eneobj_max ex(cnt) = wxs/2 +rnd(wxs/2) : ey(cnt) = wys/2 +rnd(wys/2) ; 赤い点のオブジェクトの座標 ex_e(cnt) = 0.0 : ey_e(cnt) = 0.0 ; オブジェクト座標変換用 loop //オブジェクト管理用変数 //内訳 //(0) = フラグ //(1) = オブジェクトID //(2) = 座標x(画面) //(3) = 座標y(画面) //(4) = 角度(内部) ddim enetobj ,5 ,16 repeat length2(enetobj) enetobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 loop //変数初期化(弾の速さ = 1.5) ddim enet_speed ,length2(enetobj) repeat length2(enetobj) enet_speed(cnt) = 1.5 loop //////obaqゾーン #include "obaq.as" ////obaq システム設定  qreset qborder -106.0 ,-51.0 ,106.0 ,51.0 ; 横幅のみサイズ可変( 192.0 ,102.0 基準 ) qgravity 0.0 ,0.0 ////出現(プログラムにおける位置は「obaq システム設定」より後に記述しなければならない) //赤いオブジェクト(発射地点表示) 本体 qcnvaxis px_e ,py_e ,px ,py ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly mainobj ,4 ,px_e ,py_e ,0.0 ,5.0 ,5.0 ,0 ,1 ,30 qtype mainobj ,type_bindR //黄色いオブジェクト(発射地点表示) 補助機 qcnvaxis sx_e ,sy_e ,sx ,sy ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly subobj ,4 ,sx_e ,sy_e ,0.0 ,5.0 ,5.0 ,0 ,8 ,33 qtype subobj ,type_bindR //水色オブジェクト(発射地点表示) 敵機 repeat eneobj_max qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly eneobj(cnt) ,4 ,ex_e(cnt) ,ey_e(cnt) ,0.0 ,5.0 ,5.0 ,colsw_none ,32 ,9 qtype eneobj(cnt) ,type_bindR loop //メインループ開始 *main //情報検出 本機 qgetpos mainobj ,px ,py ,pr qcnvaxis px_e ,py_e ,px ,py ,1 //情報検出 補助機 qgetpos subobj ,sx ,sy ,sr qcnvaxis sx_e ,sy_e ,sx ,sy ,1 //情報検出 敵機 repeat length(eneobj) qgetpos eneobj(cnt) ,ex(cnt) ,ey(cnt) ,er(cnt) qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 loop //オブジェクトから発射 if ((ky&16)!0)&(time\20 = 0) { gosub *p_objcreate } if (time\30 = 0) { gosub *s_objcreate } if (time\( EneFre/ (eneobj_max) ) = 0) { gosub *e_objcreate } //オブジェクト範囲外処理 gosub *p_object_out_of_range gosub *mainobject_out_of_range gosub *s_object_out_of_range gosub *e_object_out_of_range //オブジェクト削除処理 gosub *p_delete gosub *s_delete gosub *e_delete qexec redraw 0 color : boxf qdraw 0 redraw 1 time++ await 16 goto *main //オブジェクト管理から空きを探す *p_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(obj) if ( obj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る obj(0,length2(obj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(obj) - 1 ;総数の確認 return //オブジェクト管理から空きを探す *s_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る subtobj(0,length2(subtobj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(subtobj) - 1 ;総数の確認 return //オブジェクト管理から空きを探す *e_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る enetobj(0,length2(enetobj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(enetobj) - 1 ;総数の確認 return //緑のオブジェクトの生成と発射処理 *p_objcreate gosub *p_ObjectEmpty ;空きの確認 qcnvaxis px_e ,py_e ,px ,py ,1 _TempObj = -1 qaddpoly _TempObj ,4 ,px ,py , ,5 ,5 , ,2 ,29 ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } obj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,px_e ,py_e ,0.0 //Zキー入力時の処理 getkey z ,90 if z ! 0 { obj( 6 ,TrueEmpty ) = 1.0 ;弾の種類 qdel _TempObj qaddpoly _TempObj ,4 ,px ,py , ,5 ,5 , ,4 ,29 ; 出現処理(チェックを含む為、一時的にIDを格納) } //弾の傾き obj( 5 ,TrueEmpty ) = double( p_slope ) //弾のタイプ qtype int(obj ( 1 ,TrueEmpty ) ) ,type_bindY qtype int(obj ( 1 ,TrueEmpty ) ) ,type_bindR //実行 if obj( 6 ,TrueEmpty ) = 0.0 { qpush int(obj(1,TrueEmpty)) , , ,7.5 ,0 } if obj( 6 ,TrueEmpty ) ! 0.0 { qpush int(obj(1,TrueEmpty)) , , ,7.5/2.0 ,0 } return //水色のオブジェクトの生成と発射処理 *s_objcreate gosub *s_ObjectEmpty ;空きの確認 qcnvaxis sx_e ,sy_e ,sx ,sy ,1 _TempObj = -1 qaddpoly _TempObj ,4 ,sx ,sy , ,5 ,5 , ,16 ,15 ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } subtobj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,sx_e ,sy_e ,0.0 //弾のタイプ qtype int(subtobj ( 1 ,TrueEmpty ) ) ,type_bindR //角度 subtdeg = double( rnd(90) + 240 )/180.0 //実行 qpush int(subtobj(1,TrueEmpty)) , , ,sin(subtdeg)*pie*subt_speed ,cos(subtdeg)*pie*subt_speed return //??色のオブジェクトの生成と発射処理 *e_objcreate gosub *e_ObjectEmpty ;空きの確認 //どこから発射するか repeat startet = rnd(length(eneobj) ) if eneobj(startet) ! -1.0 { break } loop //把握 repeat length(eneobj) : qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 : loop _TempObj = -1 qaddpoly _TempObj ,4 ,ex(startet) ,ey(startet) , ,5 ,5 , ,64 ,54 ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } enetobj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,ex_e(startet) ,ey_e(startet) ,0.0 //弾のタイプ qtype int(enetobj ( 1 ,TrueEmpty ) ) ,type_bindR //角度 enetdeg = double( rnd(90) + 800 )/180.0 //実行 qpush int(enetobj(1,TrueEmpty)) , , ,sin(enetdeg)*pie*enet_speed ,cos(enetdeg)*pie*enet_speed return //範囲外処理 *p_object_out_of_range repeat length2(obj) if ( obj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos obj(1,cnt) ,obj(2,cnt) ,obj(3,cnt) ,obj(4,cnt) ;情報入手 //削除実行 if ( obj(2,cnt) >= pst_lim ) { qdel int(obj(1,cnt)) obj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 } loop return *s_object_out_of_range repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos subtobj(1,cnt) ,subtobj(2,cnt) ,subtobj(3,cnt) ,subtobj(4,cnt) ;情報入手 //削除実行 if ( subtobj(2,cnt) >= pst_lim ) { qdel int(subtobj(1,cnt)) subtobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 } loop return *e_object_out_of_range repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos enetobj(1,cnt) ,enetobj(2,cnt) ,enetobj(3,cnt) ,enetobj(4,cnt) ;情報入手 //削除実行 if ( enetobj(2,cnt) <= et_lim ) { qdel int(enetobj(1,cnt)) enetobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 } loop return ////範囲外処理 *mainobject_out_of_range if ( px < objlim_out(0) ) { qpos mainobj ,objlim_out(0) ,py ,0.0 } if ( px > objlim_out(1) ) { qpos mainobj ,objlim_out(1) ,py ,0.0 } if ( py < objlim_out(2) ) { qpos mainobj ,px ,objlim_out(2) ,0.0 } if ( py > objlim_out(3) ) { qpos mainobj ,px ,objlim_out(3) ,0.0 } return *subobject_out_of_range if ( sx < objlim_out(0) ) { qpos subobj ,objlim_out(0) ,sy ,0.0 } if ( sx > objlim_out(1) ) { qpos subobj ,objlim_out(1) ,sy ,0.0 } if ( sy < objlim_out(2) ) { qpos subobj ,sx ,objlim_out(2) ,0.0 } if ( sy > objlim_out(3) ) { qpos subobj ,sx ,objlim_out(3) ,0.0 } return *eneobject_out_of_range if ( ex < objlim_out(0) ) { qpos eneobj ,objlim_out(0) ,ey ,0.0 } if ( ex > objlim_out(1) ) { qpos eneobj ,objlim_out(1) ,ey ,0.0 } if ( ey < objlim_out(2) ) { qpos eneobj ,ex ,objlim_out(2) ,0.0 } if ( ey > objlim_out(3) ) { qpos eneobj ,ex ,objlim_out(3) ,0.0 } return //オブジェクト削除 *p_delete qcollision mainobj qgetcol dummy ,dummy ,dummy qgetcol2 p_depth ,dummy ,dummy if (p_depth!0.0) { qdel mainobj } ;衝突の深さが0以外ならmainobjを削除 return *s_delete qcollision subobj qgetcol dummy ,dummy ,dummy qgetcol2 s_depth ,dummy ,dummy if (s_depth!0.0) { qdel subobj } ;衝突の深さが0以外ならsubobjを削除 return *e_delete repeat eneobj_max qcollision eneobj(cnt) qgetcol dummy ,dummy ,dummy qgetcol2 e_depth(cnt) ,dummy ,dummy if (e_depth(cnt)!0.0) { qdel eneobj(cnt) } ;衝突の深さが0以外ならeneobjを削除 loop return



イヤホン

リンク

2014/9/14(Sun) 23:28:11|NO.64950

あ、安定性の問題はなんか解決しそうな気がしてきた。
AIを作ってるところに問題がありそうです。
お騒がせして申し訳ありませんでした。
ということで
本件はなぜqgetcol2が効かないのか
という問題を解決するスレに変更させてもらいます。
本当に申し訳ございませんでした。



あり

リンク

2014/9/15(Mon) 01:16:19|NO.64951

qcollisionでコリジョン情報を取得するならqcollisionを使うオブジェクトに
qaddpolyかqgroupでコリジョンログを作成するグループを設定しておく必要があります。

またqgetcolで衝突しているオブジェクトIDが取得できるので
当り判定だけでいいならqgetcol2を使う必要はありません。



あり

リンク

2014/9/15(Mon) 09:49:41|NO.64963

とりあえずqcollisionとqgetcolが正しく動くようには作ってみましたが
他の部分は弄っていないのでオブジェクトが消えても弾は出続けます。
(一部不要な処理とコメントは削除してます)
そのまま使うには不便な点が多いので
あくまで処理の参考程度に捉えてください。

#define wxs 760.0 ; wxs = 画面の横の長さ #define wys 400.0 ; wys = 画面の縦の長さ #define cxs 32.0 ; cxs = 画像を縦に分割する長さ #define cys 32.0 ; cys = 画像を横に分割する長さ #define pie M_PI ;pie = 円周率 objlim_out = -4.0 ,185.0 ,3.0 ,97.0 pslim_in = 6 ,89 ,6 ,94 elim_in = 100 ,183 ,6 ,94 //弾丸削除条件(本体、補助機) //x軸方向にここまで来ると弾が消える pst_lim = 190.0 //弾丸削除条件(敵機) //x軸方向にここまで来ると弾が消える et_lim = 0.0 //obaq画面 screen 2 ,wxs ,wys ,0 ,365 ,0 : title "obaq Window" ////本体 //変数初期化 px = 160 : py = 80 ; 赤い点のオブジェクトの座標 px_e = 0.0 : py_e = 0.0 ; オブジェクト座標変換用 //オブジェクト管理用変数 ddim obj ,7 ,16 repeat length2(obj) obj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 loop ////補助機 //変数初期化 sx = rnd(wxs) : sy = rnd(wys) ; 赤い点のオブジェクトの座標 sx_e = 0.0 : sy_e = 0.0 ; オブジェクト座標変換用 subt_speed = 1.5 ;弾速(弾速) //オブジェクト管理用変数 ddim subtobj ,5 ,16 repeat length2(subtobj) subtobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 loop ////敵機 //変数初期化 eneobj_max = 10 ; eneobj_max = 敵の数 EneFre = 100 ; EneFre = 弾を撃つ頻度 dim eneobj ,eneobj_max ;敵 dim ex ,eneobj_max : dim ey ,eneobj_max ;敵の座標 ddim ex_e ,eneobj_max : ddim ey_e ,eneobj_max ;敵の座標(変換用) startet = 0 ;弾を発射する機体を決める repeat eneobj_max ex(cnt) = wxs/2 +rnd(wxs/2) : ey(cnt) = wys/2 +rnd(wys/2) ; 赤い点のオブジェクトの座標 ex_e(cnt) = 0.0 : ey_e(cnt) = 0.0 ; オブジェクト座標変換用 loop //オブジェクト管理用変数 ddim enetobj ,5 ,16 repeat length2(enetobj) enetobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 loop //変数初期化(弾の速さ = 1.5) ddim enet_speed ,length2(enetobj) repeat length2(enetobj) enet_speed(cnt) = 1.5 loop //////obaqゾーン #include "obaq.as" //コリジョングループの定義 #const col_main 1 ; 自機のコリジョングループ #const col_sub 2 ; 補助機のコリジョングループ #const col_mblt 4 ; 自機弾のコリジョングループ #const col_sblt 8 ; 補助機弾のコリジョングループ #const col_ene 16 ; 敵機のコリジョングループ #const col_eblt 32 ; 敵弾のコリジョングループ #const ocol_main col_sub|col_mblt|col_sblt ; 自機から除外するコリジョングループ #const ocol_sub col_main|col_mblt|col_sblt ; 補助機から除外するコリジョングループ #const ocol_mblt col_main|col_sub|col_mblt|col_sblt|col_eblt ; 自機弾から除外するコリジョングループ #const ocol_sblt col_main|col_sub|col_mblt|col_sblt|col_eblt ; 補助機弾から除外するコリジョングループ #const ocol_ene col_ene|col_eblt ; 敵機から除外するコリジョングループ #const ocol_eblt col_mblt|col_sblt|col_ene|col_eblt ; 敵弾から除外するコリジョングループ #const hcol_main col_ene|col_eblt ; 自機がコリジョンログを作成するグループ #const hcol_sub col_ene|col_eblt ; 補助機がコリジョンログを作成するグループ #const hcol_ene col_mblt|col_sblt ; 敵機がコリジョンログを作成するグループ ////obaq システム設定  qreset qborder -106.0 ,-51.0 ,106.0 ,51.0 ; 横幅のみサイズ可変( 192.0 ,102.0 基準 ) qgravity 0.0 ,0.0 ////出現(プログラムにおける位置は「obaq システム設定」より後に記述しなければならない) //赤いオブジェクト(発射地点表示) 本体 qcnvaxis px_e ,py_e ,px ,py ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly mainobj ,8 ,px_e ,py_e ,0.0 ,5.0 ,5.0 ,0 ,col_main ,ocol_main, hcol_main qtype mainobj ,type_bindR //黄色いオブジェクト(発射地点表示) 補助機 qcnvaxis sx_e ,sy_e ,sx ,sy ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly subobj ,6 ,sx_e ,sy_e ,0.0 ,5.0 ,5.0 ,0 ,col_sub ,ocol_sub, hcol_sub qtype subobj ,type_bindR //水色オブジェクト(発射地点表示) 敵機 repeat eneobj_max qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 //座標変換 : 画面座標から obaq 座標に変換 qaddpoly eneobj(cnt) ,3 ,ex_e(cnt) ,ey_e(cnt) ,0.0 ,5.0 ,5.0 ,colsw_none ,col_ene ,ocol_ene, hcol_ene qtype eneobj(cnt) ,type_bindR loop //メインループ開始 *main //情報検出 本機 qgetpos mainobj ,px ,py ,pr qcnvaxis px_e ,py_e ,px ,py ,1 //情報検出 補助機 qgetpos subobj ,sx ,sy ,sr qcnvaxis sx_e ,sy_e ,sx ,sy ,1 //情報検出 敵機 repeat length(eneobj) qgetpos eneobj(cnt) ,ex(cnt) ,ey(cnt) ,er(cnt) qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 loop //オブジェクトから発射 if (time\30 = 0) { gosub *s_objcreate } if (time\( EneFre/ (eneobj_max) ) = 0) { gosub *e_objcreate } //オブジェクト範囲外処理 gosub *p_object_out_of_range gosub *mainobject_out_of_range gosub *s_object_out_of_range gosub *e_object_out_of_range //オブジェクト削除処理 gosub *p_delete gosub *s_delete gosub *e_delete qexec redraw 0 color : boxf qdraw 0 redraw 1 time++ await 16 goto *main //オブジェクト管理から空きを探す *p_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(obj) if ( obj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る obj(0,length2(obj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(obj) - 1 ;総数の確認 return //オブジェクト管理から空きを探す *s_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る subtobj(0,length2(subtobj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(subtobj) - 1 ;総数の確認 return //オブジェクト管理から空きを探す *e_ObjectEmpty TrueEmpty = -1 //フラグ確認 repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0 ) { TrueEmpty = cnt : break } loop if ( TrueEmpty != -1 ) { return } ;フラグがある場合帰る enetobj(0,length2(enetobj)) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ;空きチェストへの代入 TrueEmpty = length2(enetobj) - 1 ;総数の確認 return //水色のオブジェクトの生成と発射処理 オプション弾 *s_objcreate gosub *s_ObjectEmpty ;空きの確認 qcnvaxis sx_e ,sy_e ,sx ,sy ,1 _TempObj = -1 qaddpoly _TempObj ,10 ,sx ,sy , ,5 ,5 , ,col_sblt ,ocol_sblt, hcol_sblt ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } subtobj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,sx_e ,sy_e ,0.0 //弾のタイプ qtype int(subtobj ( 1 ,TrueEmpty ) ) ,type_bindR //角度 subtdeg = double( rnd(90) + 240 )/180.0 //実行 qpush int(subtobj(1,TrueEmpty)) , , ,sin(subtdeg)*pie*subt_speed ,cos(subtdeg)*pie*subt_speed return //??色のオブジェクトの生成と発射処理 敵弾 *e_objcreate gosub *e_ObjectEmpty ;空きの確認 //どこから発射するか repeat startet = rnd(length(eneobj) ) if eneobj(startet) ! -1.0 { break } loop //把握 repeat length(eneobj) : qcnvaxis ex_e(cnt) ,ey_e(cnt) ,ex(cnt) ,ey(cnt) ,1 : loop _TempObj = -1 qaddpoly _TempObj ,5 ,ex(startet) ,ey(startet) , ,5 ,5 , ,col_eblt ,ocol_eblt, hcol_eblt ; 出現処理(チェックを含む為、一時的にIDを格納) if _TempObj < 0 { return } enetobj( 0 ,TrueEmpty ) = 1.0 ,double(_TempObj) ,ex_e(startet) ,ey_e(startet) ,0.0 //弾のタイプ qtype int(enetobj ( 1 ,TrueEmpty ) ) ,type_bindR //角度 enetdeg = double( rnd(90) + 800 )/180.0 //実行 qpush int(enetobj(1,TrueEmpty)) , , ,sin(enetdeg)*pie*enet_speed ,cos(enetdeg)*pie*enet_speed return //範囲外処理 *p_object_out_of_range repeat length2(obj) if ( obj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos obj(1,cnt) ,obj(2,cnt) ,obj(3,cnt) ,obj(4,cnt) ;情報入手 //削除実行 if ( obj(2,cnt) >= pst_lim ) { qdel int(obj(1,cnt)) obj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 ,2.0 ,0.0 } loop return *s_object_out_of_range repeat length2(subtobj) if ( subtobj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos subtobj(1,cnt) ,subtobj(2,cnt) ,subtobj(3,cnt) ,subtobj(4,cnt) ;情報入手 //削除実行 if ( subtobj(2,cnt) >= pst_lim ) { qdel int(subtobj(1,cnt)) subtobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 } loop return *e_object_out_of_range repeat length2(enetobj) if ( enetobj(0,cnt) = -1.0) { continue } ;存在しないオブジェクト処理の省略 qgetpos enetobj(1,cnt) ,enetobj(2,cnt) ,enetobj(3,cnt) ,enetobj(4,cnt) ;情報入手 //削除実行 if ( enetobj(2,cnt) <= et_lim ) { qdel int(enetobj(1,cnt)) enetobj(0,cnt) = -1.0 ,0.0 ,0.0 ,0.0 ,0.0 } loop return ////範囲外処理 *mainobject_out_of_range if ( px < objlim_out(0) ) { qpos mainobj ,objlim_out(0) ,py ,0.0 } if ( px > objlim_out(1) ) { qpos mainobj ,objlim_out(1) ,py ,0.0 } if ( py < objlim_out(2) ) { qpos mainobj ,px ,objlim_out(2) ,0.0 } if ( py > objlim_out(3) ) { qpos mainobj ,px ,objlim_out(3) ,0.0 } return *subobject_out_of_range if ( sx < objlim_out(0) ) { qpos subobj ,objlim_out(0) ,sy ,0.0 } if ( sx > objlim_out(1) ) { qpos subobj ,objlim_out(1) ,sy ,0.0 } if ( sy < objlim_out(2) ) { qpos subobj ,sx ,objlim_out(2) ,0.0 } if ( sy > objlim_out(3) ) { qpos subobj ,sx ,objlim_out(3) ,0.0 } return *eneobject_out_of_range if ( ex < objlim_out(0) ) { qpos eneobj ,objlim_out(0) ,ey ,0.0 } if ( ex > objlim_out(1) ) { qpos eneobj ,objlim_out(1) ,ey ,0.0 } if ( ey < objlim_out(2) ) { qpos eneobj ,ex ,objlim_out(2) ,0.0 } if ( ey > objlim_out(3) ) { qpos eneobj ,ex ,objlim_out(3) ,0.0 } return //オブジェクト削除 *p_delete qcollision mainobj qgetcol hitid ,dummy ,dummy if hitid ! -1 { qdel mainobj qdel hitid ; 当った弾も削除 } return *s_delete qcollision subobj qgetcol hitid ,dummy ,dummy if hitid ! -1 { qdel subobj qdel hitid ; 当った弾も削除 } return *e_delete repeat eneobj_max qcollision eneobj(cnt) qgetcol hitid ,dummy ,dummy if hitid ! -1 { qdel eneobj(cnt) qdel hitid ; 当った弾も削除 } loop return



イヤホン

リンク

2014/9/15(Mon) 12:10:52|NO.64972

ありさん、ありがとうございます。
これでまた前へ進めそうな気がします。



ONION software Copyright 1997-2023(c) All rights reserved.