あぁできた!できました!最初に作ったときの考えにとらわれすぎていたようです。
ありがとうございます!
戒めのソース
#include "hspsock.as"
onexit *exit
screen 0,100,ginfo_dispy,0,0,0
title "サーバー"
#define Client_MAX 8 //クライアント台数
#define Free_Port 2000 //クライアント受付用ポート
ipget:Server_IP = refstr //サーバーIP
dim on_cl , Client_MAX
dim pr , Client_MAX
ddim px , Client_MAX
ddim py , Client_MAX
repeat
client_id=-1
repeat Client_MAX
if(on_cl(cnt)==0){client_id=cnt:break}
loop
if(client_id==-1){ goto*exit }
sockmake 0, Free_Port
repeat
sockwait 0, client_id+1
if(stat == 0){
on_cl(client_id)=1
sockputc client_id , client_id+1
break
}
repeat Client_MAX
if(on_cl(cnt)==1){
sockcheck cnt+1
if(stat==0){
r=0
sockgetc r, 1 + cnt
m=0
sockgetc m, 1 + cnt
pr(cnt)+=r
r=deg2rad(360*pr(cnt)/255)
px(cnt)+=sin(r)*m
py(cnt)+=cos(r)*m
if (stat!=0){ on_cl(cnt)=0 }
}
if (stat>=2){goto*exit}
}
loop
//
repeat Client_MAX
if(on_cl(cnt)==1){
s=""
repeat Client_MAX
if(on_cl(cnt)==1){
s+=""+cnt+"|"+int(px(cnt))+","+int(py(cnt))+";"
}
loop
sockput s, cnt+1
}
loop
redraw 0
color 255,255,255:boxf
color : pos 0,0
repeat Client_MAX
mes "ID"+cnt+" = "+on_cl(cnt)
loop
redraw 1
await 0
loop
loop
*exit
repeat Client_MAX
if(on_cl(cnt)==1){
sockput "end", cnt+1
}
loop
sockclose 0
end
クライアント戒め
#include "hspsock.as"
onexit *exit
screen 0,300,300,0,100+300,0
title "クライアント"
#define Client_MAX 8 //クライアント台数
#define Free_Port 2000 //クライアント受付用ポート
Server_IP="0.0.0.0" //サーバーIP
sockopen 0, Server_IP, Free_Port : if(stat != 0) { goto *exit }
repeat
sockcheck 0
if(stat==0){ break }
loop
on_c=0
dim on_cl , Client_MAX
ddim pr , Client_MAX
dim px , Client_MAX
dim py , Client_MAX
sockgetc My_ID, 0
repeat
sockcheck 0
if(stat==0){
p=""
sockget p,14*16, 0
if (stat != 0 || instr(p,0,"end")!=-1) { goto *exit }
repeat Client_MAX
on_cl(cnt)=0
loop
repeat
if (instr(p,0,";")!=-1){
on_c = int( strmid(p,0 ,instr(p,0,"|")-0 ) )
on_cl(on_c) = 1
px(on_c) = int( strmid(p,instr(p,0,"|")+1 ,instr(p,0,",")-(instr(p,0,"|")+1) ) )
py(on_c) = int( strmid(p,instr(p,0,",")+1 ,instr(p,0,";")-(instr(p,0,",")+1) ) )
p = strmid(p,instr(p,0,";")+1,strlen(p))
}else{
break
}
loop
}
getkey keyup, 38
getkey keydw, 40
getkey keyri, 39
getkey keyle, 37
r=keyri-keyle
m=keydw-keyup
sockputc r,0
sockputc m,0
redraw 0
color 255,255,255:boxf
color 0,0,0
pos 0,0
mes "mine : "+strf("%x",My_ID)+";"
repeat Client_MAX
if (on_cl(cnt)==1){
x=px(cnt)
y=py(cnt)
boxf x-5,y-5,x+5,y+5
}
loop
mes p
redraw 1
await 16
loop
*exit
sockputc 99,0
end