Need help with game code
Need help with game code
Need help with game code
Need help with game code
Need help with game code
Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code
Need help with game code Need help with game code
Need help with game code
Go Back  Xtreme Visual Basic Talk > > > Need help with game code


Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2010, 05:14 AM
Rott Rott is offline
Newcomer
 
Join Date: Nov 2009
Posts: 1
Default Need help with game code


ok so first time posting hope this is the right right place for this anyway
I'm working on a 2d game and it uses free walking rather then tiles and how I handle collisions is a box map holding collisions and special boxes for game stuff now the the problem is client side collision system works great but on the server the code is practically identical and it doesn't work
this is the npc movement procedure that I'm having trouble with
Code:
Public Sub NpcMove(MapN As Long, index As Long, Dir As Byte, DestX As Long, DestY As Long)
Dim I As Long
Dim N As Long
Dim ColRect As RECT
Dim DiffRect As RECT



If DestX < Map(MapN).Npc(index).X Then
ColRect.Left = (DestX - 8)
ColRect.Right = Map(MapN).Npc(index).X + 8
Else
ColRect.Left = Map(MapN).Npc(index).X - 8
ColRect.Right = (DestX + 8)
End If

If DestY < Map(MapN).Npc(index).Y Then
ColRect.Top = (DestY - 12)
ColRect.Bottom = Map(MapN).Npc(index).Y + 4
Else
ColRect.Top = Map(MapN).Npc(index).Y - 12
ColRect.Bottom = (DestY + 4)
End If

With Map(MapN)
If .Boxes Then
For I = 1 To .Boxes

N = IntersectRect(DiffRect, .Box(I).Bound, ColRect)


If N <> 0 Then
'future put them where they should stop but for now this works
Exit Sub
End If


Next I
End If

End With

Map(MapN).Npc(index).DestX = DestX
Map(MapN).Npc(index).DestY = DestY

Call SendDataToMap(MapN, "MOVE" & Sep_Char & 1 & Sep_Char & index & Sep_Char & Dir & Sep_Char & Map(MapN).Npc(index).X & Sep_Char & Map(MapN).Npc(index).Y & Sep_Char & DestX & Sep_Char & DestY & Sep_Char & End_Char)
End Sub
it seems that "intersectrect" with start returning false results for sum reason even if I attempt to check a rectangle for a collision with itself it will return 0
I would really appreciate help with this cause my game can't get any further if this problem isn't fixed

Last edited by Rott; 07-12-2010 at 09:58 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Need help with game code
Need help with game code
Need help with game code Need help with game code
Need help with game code
Need help with game code
Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code Need help with game code
Need help with game code
Need help with game code
 
Need help with game code
Need help with game code
 
-->