Results 1 to 3 of 3

Thread: player wont move....

  1. #1

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Exclamation player wont move....

    player wont move on the X axis can anyone help me

    VB Code:
    1. Public Function Move(ByVal oMap As CMap, ByVal cDirection As DirectionConstants) As Boolean
    2.     If Direction <> cDirection Then
    3.         Let Direction = cDirection
    4.         Exit Function
    5.     End If
    6.    
    7.     If X <= 0 And Direction = DirectionLeft Then
    8.         Let X = 0
    9.         Exit Function
    10.     ElseIf X >= oMap.Width And Direction = DirectionRight Then
    11.         Let X = oMap.Width
    12.         Exit Function
    13.     End If
    14.    
    15.     If Y <= 0 And Direction = DirectionUp Then
    16.         Let Y = 0
    17.         Exit Function
    18.     ElseIf Y >= oMap.Height And Direction = DirectionDown Then
    19.         Let Y = oMap.Height
    20.         Exit Function
    21.     End If
    22.    
    23.     Select Case cDirection
    24.         Case DirectionDown
    25.             If Not oMap.Blocked(X, Y + 1) And Y + 1 >= 0 Then
    26.                 Let Move = True
    27.                 Let Y = Y + 1
    28.             End If
    29.             Exit Function
    30.            
    31.         Case DirectionLeft
    32.             If Not oMap.Blocked(X - 1, Y) And X - 1 >= oMap.Width Then
    33.                 Let Move = True
    34.                 Let X = X - 1
    35.             End If
    36.             Exit Function
    37.            
    38.         Case DirectionRight
    39.             If Not oMap.Blocked(X + 1, Y) And X + 1 >= oMap.Width Then
    40.                 Let Move = True
    41.                 Let X = X + 1
    42.             End If
    43.             Exit Function
    44.            
    45.         Case DirectionUp
    46.             If Not oMap.Blocked(X, Y - 1) And Y - 1 >= 0 Then
    47.                 Let Move = True
    48.                 Let Y = Y - 1
    49.             End If
    50.             Exit Function
    51.     End Select
    52. End Function
    Last edited by nareth; Jan 18th, 2005 at 11:45 AM.

  2. #2

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: player wont move....

    fixed

    VB Code:
    1. Public Function Move(ByVal oMap As CMap, ByVal cDirection As DirectionConstants) As Boolean
    2.     If Direction <> cDirection Then
    3.         Let Direction = cDirection
    4.         Exit Function
    5.     End If
    6.    
    7.     If X < 0 Then
    8.         Let X = 0
    9.     ElseIf X > oMap.Width Then
    10.         Let X = oMap.Width
    11.     End If
    12.    
    13.     If Y < 0 Then
    14.         Let Y = 0
    15.     ElseIf Y > oMap.Height Then
    16.         Let Y = oMap.Height
    17.     End If
    18.    
    19.     Select Case cDirection
    20.         Case DirectionDown
    21.             If Y + 1 <= oMap.Height Then
    22.                 If Not oMap.Blocked(X, Y + 1) Then
    23.                     Let Move = True
    24.                     Let Y = Y + 1
    25.                 End If
    26.             End If
    27.             Exit Function
    28.            
    29.         Case DirectionLeft
    30.             If X - 1 >= 0 Then
    31.                 If Not oMap.Blocked(X - 1, Y) Then
    32.                     Let Move = True
    33.                     Let X = X - 1
    34.                 End If
    35.             End If
    36.             Exit Function
    37.            
    38.         Case DirectionRight
    39.             If X + 1 <= oMap.Width Then
    40.                 If Not oMap.Blocked(X + 1, Y) Then
    41.                     Let Move = True
    42.                     Let X = X + 1
    43.                 End If
    44.             End If
    45.             Exit Function
    46.            
    47.         Case DirectionUp
    48.             If Y - 1 >= 0 Then
    49.                 If Not oMap.Blocked(X, Y - 1) Then
    50.                     Let Move = True
    51.                     Let Y = Y - 1
    52.                 End If
    53.             End If
    54.             Exit Function
    55.     End Select
    56. End Function

  3. #3

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: player wont move....

    the drawing doesnt go right though

    help
    VB Code:
    1. If Events(QS_INPUT) Then
    2.             DoEvents
    3.            
    4.             If Frame = 0 Then
    5.                 If KeyPressed(DIK_UP) Then
    6.                     Let Moving = Player.Move(Map, DirectionUp)
    7.                 ElseIf KeyPressed(DIK_RIGHT) Then
    8.                     Let Moving = Player.Move(Map, DirectionRight)
    9.                 ElseIf KeyPressed(DIK_DOWN) Then
    10.                     Let Moving = Player.Move(Map, DirectionDown)
    11.                 ElseIf KeyPressed(DIK_LEFT) Then
    12.                     Let Moving = Player.Move(Map, DirectionLeft)
    13.                 End If
    14.             End If
    15.         End If
    16.        
    17.         If Moving Then
    18.             If DX.TickCount - LastFrames >= 150 Then
    19.                 Let Frame = Frame + 1
    20.                 If Frame > 4 Then
    21.                     Let Frame = 0
    22.                     Let Moving = Not True
    23.                 End If
    24.                
    25.                 Select Case Player.Direction
    26.                     Case DirectionDown
    27.                         Let xPlr = xPlr - TileStepWidth
    28.                         Let yPlr = yPlr + TileStepHeight
    29.                        
    30.                     Case DirectionUp
    31.                         Let xPlr = xPlr + TileStepWidth
    32.                         Let yPlr = yPlr - TileStepHeight
    33.                        
    34.                     Case DirectionRight
    35.                         Let xPlr = xPlr + TileStepWidth
    36.                         Let yPlr = yPlr + TileStepHeight
    37.                        
    38.                     Case DirectionLeft
    39.                         Let xPlr = xPlr - TileStepWidth
    40.                         Let yPlr = yPlr - TileStepHeight
    41.                 End Select
    42.                
    43.                 Let LastFrames = DX.TickCount
    44.             End If
    45.         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
  •  



Click Here to Expand Forum to Full Width