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 6783727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:54:17+00:00 2026-05-26T16:54:17+00:00

Ok so I have developed a 2d side scroller (platformer) and it is pretty

  • 0

Ok so I have developed a 2d side scroller (platformer) and it is pretty darn efficient IMO, uses 1 timer, and im trying to make moving platforms possible. Here is what i tried and am debugging with

 Private Sub Timer1_Timer()
'moving platforms
For f = 0 To Platform.Count - 1
    If Platform(f).Tag = "moving" Then
        For j = 0 To Platform.Count - 1
            If Collision(Platform(f), Platform(j)) And j <> f Then
                Speed(f) = Speed(f) * -1
            End If
        Next j
        Platform(f).Left = Platform(f).Left + Speed(f)
    End If
Next f

Basically, here iswhat the code does:
For all the platforms, it checks which platform has the tag “moving”, if it does have that tag, move it, but before moving it, see if it needs to have a direction change, so it loops through all the platforms again to see if it needs to change again, and should do so if it needs to, but in this code it doesnt work 🙁

What could be the problem? The intial value of all the Speeds is 1, and I have scalemode to pixel, thats why its so small. Any help is appreciated

Collision function:

Public Function Collision(Shape1 As Control, Shape2 As Control) 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 + Shape1.Height) < Shape2.Top + Shape2.Height Then
    Collision = True
Else
    Collision = False
End If
End Function
  • 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-26T16:54:18+00:00Added an answer on May 26, 2026 at 4:54 pm

    Alrighty, the problem has been solved. Observe this Collision function:

    Public Function Collision(Shape1 As Control, Shape2 As Control) 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 + Shape1.Height) < Shape2.Top + Shape2.Height Then
            Collision = True
        Else
            Collision = False
        End If
    End Function
    

    Notice the problem? The 2 platforms I am testing for collision for, in this case, are at the same height. Think about it, if you see in that collision function, the last condition:

    (Shape1.Top + Shape1.Height) < Shape2.Top + Shape2.Height
    

    Since Shape1 has the same Top as Shape2, this condition is false because I sued the less than sign, and not the less than or EQUAL to sign. To make sure there is no problem, I replaced all my signs with or equal to ones.

    Public Function Collision(Shape1 As Control, Shape2 As Control) 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 + Shape1.Height) <= Shape2.Top + Shape2.Height Then
            Collision = True
        Else
            Collision = False
        End If
    

    End Function

    Would you look at that! A moving platform that bounces between the platforms beside it. Beautiful.

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

Sidebar

Related Questions

I have developed a WCF WebService. On client side they are unable to send
We have developed a website that uses MVC, C#, and jQuery. In one of
I have a server-side project which must be developed on .Net platform, but I
We currently have developed an application using WCF. Our clients make connections to different
I have developed web application which uses JasperReports for reporting purpose. In that I
I have developed a simple application that uses APNS. The app runs fine and
I have developed a web application for mobile phones that uses JavaScript Google API.
I have been developed a web application using java servlet at server side and
I have developed some classes with similar behavior, they all implement the same interface.
I have developed some custom DAO-like classes to meet some very specialized requirements for

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.