Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:25:23+00:00 2026-05-26T02:25:23+00:00

Ok so I am trying to make a third person game in VB6 for

  • 0

Ok so I am trying to make a third person game in VB6 for a class project, and when the person collides with a Wall (shape) then they shouldnt move. But the problem is, when the person collides into the wall, it stops, however now the wall is now stuck and wont scroll along with all the other walls. Here is my code:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyLeft Or vbKeyRight Or vbKeyUp Or vbKeyDown Then
        tmrMove.Enabled = True
    End If

    Select Case KeyCode
        Case vbKeyLeft
            XVel = 0 - Speed
            YVel = 0
        Case vbKeyRight
            XVel = Speed
            YVel = 0
        Case vbKeyUp
            YVel = 0 - Speed
            XVel = 0
        Case vbKeyDown
            YVel = Speed
            XVel = 0
    End Select

    Keys(KeyCode) = True
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    Keys(KeyCode) = False
    If Keys(vbKeyLeft) = False And Keys(vbKeyRight) = False And Keys(vbKeyUp) = False And Keys(vbKeyDown) = False Then
        XVel = 0
        YVel = 0
    End If
End Sub


Private Sub tmrMove_Timer()
    For i = 0 To (Wall.Count - 1)
        If Collision(Character, Wall(i)) = False Then
            Wall(i).Left = Wall(i).Left - XVel
            Wall(i).Top = Wall(i).Top - YVel
        End If
    Next i
End Sub


Public Function Collision(Shape1 As ShockwaveFlash, Shape2 As Shape) As Boolean
    If (Shape1.Left + Shape1.Width) > Shape2.Left And _
    Shape1.Left < (Shape2.Left + Shape2.Width) And _
    (Shape1.Top + Shape1.Height) > Shape2.Top And _
    Shape1.Top < (Shape2.Top + Shape2.Height) Then
        Collision = True
    Else
        Collision = False
    End If
End Function

Now as you can see, the problem is that when it collides, I dont know howto “uncollide” so the wall that we collided with becomes stuck and will not scroll with the rest of the things. It is confusing to explain hopefully you understand. Thanks

As you can see,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:25:23+00:00Added an answer on May 26, 2026 at 2:25 am

    The most straightforward way to fix your collision logic is to consider the questions:

    • Can I move up?
    • Can I move down?
    • Can I move left?
    • Can I move right?

    rather than the question “am I in a collision with the wall?”

    You answer those questions by comparing your post-move position to the limit imposed by the wall.

    Code example (be kind… I didn’t write VB6 for the last 10 years 😉

    Public Function CanMoveLeft(Shape1 As ShockwaveFlash, Shape2 As Shape) As Boolean
        If (Shape1.Left + Shape1.Width) > Shape2.Right) 
        Then
            CanMoveLeft = True
        Else
            CanMoveLeft = False
        End If
    End Function
    

    This example presumes you have already applied a proposed new position to Shape1. If you prefer, you can pass in the unmoved Shape1 along with the leftward velocity and modify the calculation accordingly. I think you probably want to compare the left edge of the shape to the right edge of the wall rather than the left edge of the wall in your code sample.

    Note that if your post-move position would place you inside the wall, you would want to adjust the actual position to be just inside the room (if you’re moving more than one pixel per frame, your velocity can put your current position inside or beyond the wall).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a 3d (first/third person) game and I'm trying to make it multiplayer
I am trying to make sure that in my memory game, once a person
I am trying to make a web service request call to a third part
I'm trying to make Paypal's sandbox API work and I'm using a sample project
I'm trying to make an NDK-based game work on Android ICS. It worked fine
I'm trying to make an arkanoid-like game, and now I'm facing a problem with
I'm trying to make my app more flexible. I'm using a third party component
I'm trying to make a small game using (free)GLUT. I know that it's old
I have a third-party class that I am trying to use in Hadoop, and
I am trying make long screen to vertical direction. So, I need a screen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.