|
-
Jan 15th, 2005, 10:50 AM
#1
Thread Starter
Banned
player wont move....
player wont move on the X axis can anyone help me
VB Code:
Public Function Move(ByVal oMap As CMap, ByVal cDirection As DirectionConstants) As Boolean
If Direction <> cDirection Then
Let Direction = cDirection
Exit Function
End If
If X <= 0 And Direction = DirectionLeft Then
Let X = 0
Exit Function
ElseIf X >= oMap.Width And Direction = DirectionRight Then
Let X = oMap.Width
Exit Function
End If
If Y <= 0 And Direction = DirectionUp Then
Let Y = 0
Exit Function
ElseIf Y >= oMap.Height And Direction = DirectionDown Then
Let Y = oMap.Height
Exit Function
End If
Select Case cDirection
Case DirectionDown
If Not oMap.Blocked(X, Y + 1) And Y + 1 >= 0 Then
Let Move = True
Let Y = Y + 1
End If
Exit Function
Case DirectionLeft
If Not oMap.Blocked(X - 1, Y) And X - 1 >= oMap.Width Then
Let Move = True
Let X = X - 1
End If
Exit Function
Case DirectionRight
If Not oMap.Blocked(X + 1, Y) And X + 1 >= oMap.Width Then
Let Move = True
Let X = X + 1
End If
Exit Function
Case DirectionUp
If Not oMap.Blocked(X, Y - 1) And Y - 1 >= 0 Then
Let Move = True
Let Y = Y - 1
End If
Exit Function
End Select
End Function
Last edited by nareth; Jan 18th, 2005 at 11:45 AM.
-
Jan 15th, 2005, 02:28 PM
#2
Thread Starter
Banned
Re: player wont move....
fixed
VB Code:
Public Function Move(ByVal oMap As CMap, ByVal cDirection As DirectionConstants) As Boolean
If Direction <> cDirection Then
Let Direction = cDirection
Exit Function
End If
If X < 0 Then
Let X = 0
ElseIf X > oMap.Width Then
Let X = oMap.Width
End If
If Y < 0 Then
Let Y = 0
ElseIf Y > oMap.Height Then
Let Y = oMap.Height
End If
Select Case cDirection
Case DirectionDown
If Y + 1 <= oMap.Height Then
If Not oMap.Blocked(X, Y + 1) Then
Let Move = True
Let Y = Y + 1
End If
End If
Exit Function
Case DirectionLeft
If X - 1 >= 0 Then
If Not oMap.Blocked(X - 1, Y) Then
Let Move = True
Let X = X - 1
End If
End If
Exit Function
Case DirectionRight
If X + 1 <= oMap.Width Then
If Not oMap.Blocked(X + 1, Y) Then
Let Move = True
Let X = X + 1
End If
End If
Exit Function
Case DirectionUp
If Y - 1 >= 0 Then
If Not oMap.Blocked(X, Y - 1) Then
Let Move = True
Let Y = Y - 1
End If
End If
Exit Function
End Select
End Function
-
Jan 18th, 2005, 10:51 AM
#3
Thread Starter
Banned
Re: player wont move....
the drawing doesnt go right though
help
VB Code:
If Events(QS_INPUT) Then
DoEvents
If Frame = 0 Then
If KeyPressed(DIK_UP) Then
Let Moving = Player.Move(Map, DirectionUp)
ElseIf KeyPressed(DIK_RIGHT) Then
Let Moving = Player.Move(Map, DirectionRight)
ElseIf KeyPressed(DIK_DOWN) Then
Let Moving = Player.Move(Map, DirectionDown)
ElseIf KeyPressed(DIK_LEFT) Then
Let Moving = Player.Move(Map, DirectionLeft)
End If
End If
End If
If Moving Then
If DX.TickCount - LastFrames >= 150 Then
Let Frame = Frame + 1
If Frame > 4 Then
Let Frame = 0
Let Moving = Not True
End If
Select Case Player.Direction
Case DirectionDown
Let xPlr = xPlr - TileStepWidth
Let yPlr = yPlr + TileStepHeight
Case DirectionUp
Let xPlr = xPlr + TileStepWidth
Let yPlr = yPlr - TileStepHeight
Case DirectionRight
Let xPlr = xPlr + TileStepWidth
Let yPlr = yPlr + TileStepHeight
Case DirectionLeft
Let xPlr = xPlr - TileStepWidth
Let yPlr = yPlr - TileStepHeight
End Select
Let LastFrames = DX.TickCount
End If
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|