VBとDXとゲームdev愛好者雑談*RpgDIY CODE(部分)
■ このスレッドは過去ログ倉庫に格納されています
0001instemast
2006/07/19(水) 16:29:04また、僕がつくったこれ:
RpgDIY CODE(部分)
0002instemast
2006/07/19(水) 16:35:58On Error Resume Next
Dim i As Integer
Dim tmpr%(), tmpu%(), tmpi%()
Dim dltx As Double, dlty As Double, dx As Double, dy As Double, oldx As Integer, oldy As Integer
Dim sina As Double
For i = 1 To UBound(player)
If player(i).state = STATE_MOVE Then
dltx = player(i).tox - player(i).left
dlty = player(i).toy - player(i).top
ElseIf player(i).state = STATE_TOOBJECT Or player(i).state = STATE_TOCLICK Then
If player(i).toobjecttype = OBJECT_PLAYER Then
If player(i).plc = player(player(i).toobjectindex).plc Then
dltx = player(player(i).toobjectindex).left + player(player(i).toobjectindex).width * 0.5 - player(i).left - player(i).width * 0.5
dlty = player(player(i).toobjectindex).top + player(i).oy - player(i).top - player(i).oy
Else
player(i).state = STATE_STOP
End If
0003instemast
2006/07/19(水) 16:36:58If player(i).plc = map.mapindex Then
dltx = npc(player(i).toobjectindex).left + npc(player(i).toobjectindex).width * 0.5 - player(i).left - player(i).width * 0.5
dlty = npc(player(i).toobjectindex).top + npc(i).oy - player(i).top - player(i).oy
Else
player(i).state = STATE_STOP
End If
ElseIf player(i).toobjecttype = OBJECT_MOVEPOINT Then
If player(i).plc = map.mapindex Then
dltx = movepoint(player(i).toobjectindex).left + movepoint(player(i).toobjectindex).width * 0.5 - player(i).left - player(i).width * 0.5
dlty = movepoint(player(i).toobjectindex).top + movepoint(i).oy - player(i).top - player(i).oy
Else
player(i).state = STATE_STOP
End If
End If
End If
0004instemast
2006/07/19(水) 16:37:32dx = (dltx * player(i).vp) / (Sqr(dltx ^ 2 + dlty ^ 2))
dy = (dlty * player(i).vp) / (Sqr(dltx ^ 2 + dlty ^ 2))
oldleft = player(i).left
oldtop = player(i).top
player(i).left = player(i).left + dx
player(i).top = player(i).top + dy
If Sqr(dltx ^ 2 + dlty ^ 2) < player(i).vp + 2 Then '与目标的差很小很小时
If player(i).state = STATE_TOCLICK Then '有对象要点击,且与目标的差很小
player(i).state = STATE_STOP '到达了目标停止
Call clickobject(i, player(i).toobjecttype, player(i).toobjectindex, 1)
Else
player(i).state = STATE_STOP '到达了目标停止
End If
ElseIf istouch(i) Then
player(i).state = STATE_STOP '碰撞后停止
player(i).left = oldleft '碰撞后还原坐标
player(i).top = oldtop
ElseIf player(i).state = STATE_TOCLICK Then
If istouchobject(i, player(i).toobjecttype, player(i).toobjectindex) Then '有对象要点击,且碰撞
player(i).state = STATE_STOP '碰撞后停止
player(i).left = oldleft '碰撞后还原坐标
player(i).top = oldtop
Call clickobject(i, player(i).toobjecttype, player(i).toobjectindex, 1)
End If
End If
End If
0005instemast
2006/07/19(水) 16:39:36Private Sub DDrawReset()
Set NormalFont = New StdFont
Set TalkFont = New StdFont
Set PropFontA = New StdFont
Set PropFontB = New StdFont
NormalFont.Size = 8
PropFontB.Size = 12
PropFontA.Size = 9
TalkFont.Bold = True
TalkFont.Size = 16
ckey.low = 0
ckey.high = 0
Set dd = dx.DirectDrawCreate(vbNullString)
If settings.FullScreened <> 0 Then
dd.SetCooperativeLevel Form1.hwnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN Or DDSCL_ALLOWMODEX Or DDSCL_ALLOWREBOOT
dd.SetDisplayMode 640, 480, 16, 0, DDSDM_DEFAULT
ddmsurf_d.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
ddmsurf_d.lBackBufferCount = 1
ddmsurf_d.ddsCaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE
Set ddmsurf = dd.CreateSurface(ddmsurf_d)
ddbbuf_d.ddsCaps.lCaps = DDSCAPS_BACKBUFFER
Set ddbbuf = ddmsurf.GetAttachedSurface(ddbbuf_d.ddsCaps)
0006instemast
2006/07/19(水) 16:40:12dd.SetCooperativeLevel 0, DDSCL_NORMAL
ddmsurf_d.lFlags = DDSD_CAPS
ddmsurf_d.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
Set ddmsurf = dd.CreateSurface(ddmsurf_d)
ddbbuf_d.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
ddbbuf_d.lWidth = 640
ddbbuf_d.lHeight = 480
ddbbuf_d.ddsCaps.lCaps = settings.offcaps
Set ddbbuf = dd.CreateSurfaceFromFile(skin + "\tmp.bmp", ddbbuf_d)
aaa = aaa
End If
ReDim offplayer(0)
ReDim offnpc(0)
ReDim offmovepoint(0)
ReDim offthing(0)
End Sub
0007デフォルトの名無しさん
2006/07/19(水) 16:48:440008instemast
2006/07/19(水) 16:52:180009デフォルトの名無しさん
2006/07/19(水) 17:39:590010デフォルトの名無しさん
2006/07/19(水) 19:55:180011instemast
2006/07/21(金) 15:47:10コードは内緒だが。やや読ませてもいいのだな。
0012instemast
2006/07/21(金) 15:56:22'//input----p(i)=[p1(i),p2(i)]
'//*.VBSのファイルと保存して!
dim p1(8):dim p2(8):dim t(8)'//Training Series
for i=1 to 8
p1(i)=inputbox("input p1("+cstr(i)+")")
p2(i)=inputbox("input p2("+cstr(i)+")")
t(i)=inputbox("input t("+cstr(i)+")")
next'//start Training:
max=inputbox("最大迭代次数?")
for i=1 to max+1
cnt=cnt+1
if cnt>8 then
cnt=1:tmp=0
end if
'//a=hardlim(wp+b);e=t-a
e=t(cnt)-hardlim(w1*p1(cnt)+w2*p2(cnt)+b)
'//感知机学习规则:w_new=w_old+epT (有点不太好表记,pT是p的转置)
b_new=b_old+e
w1=w1+e*p1(cnt):w2=w2+e*p2(cnt):b=b+e
if e<>0 then tmp=1
if cnt=8 and tmp=0 then exit for
next
if i=max+1 then msgbox("在"+cstr(i)+"次迭代中没有收敛")
msgbox("w=["+cstr(w1)+","+cstr(w2)+"] b="+cstr(b)+" 迭代次数"+cstr(i))
msgbox("by instemast"+chr(10)+"qq544262895"+chr(10)+"[email protected]"+chr(10)+"instemast.tf168.com")
function hardlim(x)
if x>=0 then hardlim=1 else hardlim=0
end function
0013デフォルトの名無しさん
2006/07/21(金) 16:01:570014instemast
2006/07/21(金) 16:03:280015デフォルトの名無しさん
2006/08/01(火) 01:34:020016デフォルトの名無しさん
2006/08/01(火) 01:35:03■ このスレッドは過去ログ倉庫に格納されています