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


HSPTV!掲示板


未解決 解決 停止 削除要請

2017
0409
Mixオンラインでのスコアボード0未解決


Mix

リンク

2017/4/9(Sun) 10:04:57|NO.79034

hspsockを使ってオンラインゲームを作りたいんです。
例えば、ローカルで今
1 aaa 20000
2 bbb 13000
3 ccc 10000
:
10 jjj 300
のようなスコアボードを作りたいです。
※ちなみに hsptv.as を使うとフリーズします。窓10です。
スクリプトです。

//拡張プラグインを読み込み #include "gdi32.as" #include "hspsock.as" #include "d3m.hsp" #uselib "user32" #cfunc GetSystemMenu "GetSystemMenu" int, nullptr #func GetClassLong "GetClassLongA" sptr,sptr #func SetClassLong "SetClassLongA" sptr,sptr,sptr #func SetWindowLong "SetWindowLongA" sptr,sptr,sptr #func SetWindowPosA "SetWindowPos" int, nullptr, nullptr, nullptr, nullptr, nullptr, int #func SetWindowPosB "SetWindowPos" sptr,sptr,sptr,sptr,sptr,sptr,sptr #func DeleteMenu "DeleteMenu" int, int, nullptr #func SystemParametersInfo "SystemParametersInfoA" sptr,sptr,sptr,sptr #define ctype RGB(%1,%2,%3) (%1 | %2 << 8 | %3 << 16) #define ctype limitFPS(%1, %2) 1000.0*%1/(%2*%2) //モジュール開始 #module #uselib "kernel32" #func GetNumberFormat "GetNumberFormatA" int, int, str, int, int, int #define ctype max( %1, %2 ) ( %1 )*( %1 > %2 ) + ( %2 )*( %1 <= %2 ) #define ctype min( %1, %2 ) ( %1 )*( %1 < %2 ) + ( %2 )*( %1 >= %2 ) #define bgrect(%1,%2,%3,%4) grect %1+%3/2,%2+%4/2,0,%3,%4 #const DEFAULT_R 20 #deffunc rboxf int _x1, int _y1, int _x2, int _y2, int _r x1 = min(_x1, _x2) : x2 = max(_x1, _x2) y1 = min(_y1, _y2) : y2 = max(_y1, _y2) box_width = x2 - x1 : box_height = y2 - y1 if ( _r <= 0 ) { r = DEFAULT_R } else { r = _r } r = min( r, min( box_width / 2, box_height / 2 ) ) boxf x1, y1+r, x2, y2-r boxf x1+r, y1, x2-r, y2 repeat 4 x = x1 + ( cnt \ 2 ) * ( box_width - r * 2 + 1) y = y1 + ( cnt / 2 ) * ( box_height - r * 2 + 1 ) circle x, y, x + r * 2, y + r * 2 loop return #deffunc DataSave str dataname, var datavar bload "data\\"+dataname+".dat",datavar return #deffunc DataLoad str dataname, var datavar exist "data\\"+dataname+".dat" if strsize != -1 : bload "data\\"+dataname+".dat",datavar return #defcfunc ThousandSep str p1 dim NUMBERFMT, 6 lpDecimalSep = "." : lpThousandSep = "," NUMBERFMT = 0, 0, 3, varptr(lpDecimalSep), varptr(lpThousandSep), 1 sdim lpNumberStr GetNumberFormat , , p1, varptr(NUMBERFMT), varptr(lpNumberStr), 64 return lpNumberStr #deffunc gboxf int bx1, int by1, int bx2, int by2, int cr, int cg, int cb gmode 3,0,0,128 : color cr,cg,cb bgrect bx1,by1,bx2,by2 gmode 0 return #deffunc acls onkey 0 onclick 0 mouse return //モジュール終了 #global //変数の宣言 dim hInput, 1 sdim word,1024 repeat 10 Nickname(cnt)="" loop myr = 0 myg = 128 myb = 255 //テスト時 ;goto *start//ゲーム開始前 //画面作成 screen 0,ginfo(20),ginfo(21),0,0,0 width 640,480,ginfo(20)/2-320,ginfo(21)/2-300 //タイトル名 title "CircleTraining ver1.0" *menustart //初期化 acls colorsw = 0 //絶対に必要な命令 oncmd gosub *ctlcoloredit, $133 onexit *exit //背景 color 10,10,50 : boxf //ニックネーム入力ボックス color 124,92,220 : Nickname="" rboxf ginfo_winx/2-120,ginfo_winy/2-40,ginfo_winx/2+130,ginfo_winy/2+20,100 font "游ゴシック",50,1 color 124,92,220 pos 160,50 : mes "Circle" color 0,255,128 pos 310,50 : mes "Training" font "游ゴシック",20,0 : objmode 2 pos ginfo_winx/2-97,ginfo_winy/2-23 : input Nickname,200,30,10 hInput.0 = objinfo(stat, 2) CreateSolidBrush RGB(124, 92, 220) hBrush.0 = stat SetWindowLong objinfo (0, 2), -20, $0 SetWindowPosA objinfo (0, 2), $27 //判定 repeat //描画開始 redraw 0 //初期化 acls //ボタン作成 if bflag = 0 : color 0,128,64 if bflag = 1 : color 0,255,128 rboxf ginfo_winx/2-50,ginfo_winy/2+40,ginfo_winx/2+75,ginfo_winy/2+80,100 if mousex >= ginfo_winx/2-50 & mousey >= ginfo_winy/2+40 && mousex <= ginfo_winx/2-100+176 && mousey <= ginfo_winy/2+80 : bflag = 1 : onclick *start : else : bflag = 0 color 255,255,255 font "游ゴシック",30,1 pos ginfo_winx/2-20,ginfo_winy/2+42 : mes "Play" if bflag1 = 0 : color myr,myg,myb if bflag1 = 1 : color myr+55,myg+55,myb+55 circle 50-40, 430-40, 50+40, 430+40 if( ( (50 - mousex) * (50 - mousex) + (430 - mousey)*(430 - mousey)) < 40*40 ) : onclick gosub *skin : bflag1 = 1 : else : bflag1 = 0 color 255,255,255 pos 17,ginfo_winy-67 : mes "Skin" if myr <= 55 : myr = 55 if myg <= 55 : myg = 55 if myb <= 55 : myb = 55 if myr >= 200 : myr = 200 if myg >= 200 : myg = 200 if myb >= 200 : myb = 200 //描画終了 redraw 1 //時間待ち await 1 loop //ゲーム開始準備 *start //初期化 acls cls 4 //常に最大化されているウィンドウを作成 fla=int((ginfo(10)-ginfo(12))/2) tit=ginfo(11)-ginfo(13)-fla dim u_zone,4 SystemParametersInfo $30,0,varptr(u_zone),0 max_wid=u_zone(2)-u_zone(0) max_hei=u_zone(3)-u_zone(1)-tit width max_wid,max_hei SetWindowPosB hwnd,0,u_zone(0)-fla,u_zone(1),0,0,$5 hSystemMenu = GetSystemMenu (hwnd) DeleteMenu hSystemMenu, $F010 //変数宣言 score = 10 speed = 2 randomize esa_max = 2500 LoadSocre = 60 repeat esa_max esar(cnt)=rnd(206)+50 esag(cnt)=rnd(206)+50 esab(cnt)=rnd(206)+50 esax(cnt)=rnd(20000)-10000 esay(cnt)=rnd(20000)-10000 esasize(cnt)=rnd(20) loop if myr <= 55 : myr = 55 if myg <= 55 : myg = 55 if myb <= 55 : myb = 55 if myr >= 200 : myr = 200 if myg >= 200 : myg = 200 if myb >= 200 : myb = 200 speed = 3 size = 5 lv = -10 repeat 10,0 Scoreboard(cnt) = 0 loop //メインループ *mainloop //描画開始 redraw 0 //初期化 acls //背景 color 10,10,50 : boxf //変数管理 randomize if score >= sizeupscore : size = size + 1 : sizeupscore = sizeupscore + score / 6 : lv = lv + 1 if mx*-1 >= 10000 : mx = -10000 if my*-1 >= 10000 : my = -10000 if mx*-1 <= -10000 : mx = 10000 if my*-1 <= -10000 : my = 10000 if size >= 250 : size = 250 LoadSocre = LoadSocre + 1 color 255,255,255 font "游ゴシック",15 pos ginfo_winx-80,ginfo_winy/2+200 : mes "FPS: "+d3getfps() ipget : pos ginfo_winx-134,ginfo_winy/2+220 : mes "IP: "+refstr pos ginfo_winx-188,ginfo_winy/2+240 : mes "X: "+mx*-1 pos ginfo_winx-98,ginfo_winy/2+240 : mes "Y: "+my*-1 getkey key,81 if key = 1 : cls : width 640,480,ginfo(20)/2-320,ginfo(21)/2-300 : goto *menustart //餌を描画 repeat esa_max color esar(cnt),esag(cnt),esab(cnt) circle esax(cnt)+mx,esay(cnt)+my,esax(cnt)+mx+(esasize(cnt)+5),esay(cnt)+my+(esasize(cnt)+5),1 if (ginfo_winx/2-(size+1)+2)<(esax(cnt)+mx)&&((ginfo_winy/2-(size+1))-12)<(esay(cnt)+my)&&(ginfo_winx/2+(size+1)+12)>(esax(cnt)+mx+(esasize(cnt)+5))&&(ginfo_winy/2+(size+1)-2)>(esay(cnt)+my+(esasize(cnt)+5)){ score = score + ((rnd(10) + 1) * (lv * 2)) * (esasize(cnt)+5) if score >= 999999999 : score = 999999999 } loop //自機描画 color 255,0,0 color myr,myg,myb circle ginfo_winx/2-(size+1)+2,(ginfo_winy/2-(size+1))-12,ginfo_winx/2+(size+1)+12,ginfo_winy/2+(size+1)-2,1 color 255,255,255 font "游ゴシック",20,1 moji = ThousandSep(""+score+"") msgx=ginfo_winx/2-(strlen(moji)*5)+7 msgy=ss pos msgx,ginfo_winy/2-20 mes moji if mousex>=ginfo_winx/2 : mx=mx-(1+speed) if mousex<=ginfo_winx/2 : mx=mx+(1+speed) if mousey>=ginfo_winy/2 : my=my-(1+speed) if mousey<=ginfo_winy/2 : my=my+(1+speed) if score < 10 : score = 10 //スコアボード表示 gboxf ginfo_winx-259,7,ginfo_winx,160,0,0,0 if LoadSocre \ 60 = 0{ Scoreboard = score } repeat 10,0 if NickName(cnt) = "" : NickName(cnt) = "" font "游ゴシック",13,0 : color 255,255,255 pos ginfo_winx-160,10 : mes "Scoreboard" pos ginfo_winx-245,(cnt+2)*13 : mes "#"+strf("%02d",(cnt+1)) pos ginfo_winx-215,(cnt+2)*13 : mes NickName(cnt) pos ginfo_winx-80,(cnt+2)*13 : mes " "+strf("%09d",Scoreboard(cnt)) loop //描画終了 redraw 1 //時間待ち await 1 //メインループへ goto *mainloop //スキンメニュー *skin dialog "",33 if stat = 0 : return myr = ginfo_r myg = ginfo_g myb = ginfo_b if myr < 55 : myr = 55 : colorsw = 1 if myg < 55 : myg = 55 : colorsw = 1 if myb < 55 : myb = 55 : colorsw = 1 if myr > 200 : myr = 200 : colorsw = 1 if myg > 200 : myg = 200 : colorsw = 1 if myb > 200 : myb = 200 : colorsw = 1 if colorsw = 1 { clrobj gboxf 0,0,ginfo_winx,ginfo_winy,0,0,0 color 128,0,0 rboxf 50,50,ginfo_winx-50,ginfo_winy-50 *msgmain redraw 0 acls if bflag3 = 0 : color 0,128,64 if bflag3 = 1 : color 0,255,128 rboxf ginfo_winx/2-50,ginfo_winy/2+110,ginfo_winx/2+75,ginfo_winy/2+150,100 if mousex >= ginfo_winx/2-50 & mousey >= ginfo_winy/2+110 && mousex <= ginfo_winx/2-100+176 && mousey <= ginfo_winy/2+150 : bflag3 = 1 : onclick *menustart : else : bflag3 = 0 color 255,255,255 font "游ゴシック",40,1 pos 85,75 : mes "CircleTraining Message" font "游ゴシック",20,1 pos 120,160 : mes "The value of R can be between 55〜200" pos 120,205 : mes "The value of G can be between 55〜200" pos 120,250 : mes "The value of B can be between 55〜200" pos 245,300 :mes "Please note that." font "游ゴシック",30,1 pos ginfo_winx/2-10,ginfo_winy/2+112 : mes "OK" colorsw = 0 redraw 1 await 1 goto *msgmain } goto *menustart //mesboxの色指定 *ctlcoloredit if hInput.0 = lparam { SetTextColor wparam, RGB($FF, $FF ,$FF) SetBkColor wparam, RGB(124, 92, 220) return hBrush.0 } return //終了時 *exit DeleteObject hBrush.0 end



この記事に返信する


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