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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:02:27+00:00 2026-06-09T23:02:27+00:00

I have the collision detection down. Now, I need to find where to move

  • 0

I have the collision detection down. Now, I need to find where to move the player so that he is not clipping any blocks. Once I have the collision detection, I want to move the player to the nearest open space. Is there a way to do this easily? I know I need to find the overlapping rectangle, but I don’t know how to do that. If you have any information on this post it please!

  • 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-06-09T23:02:29+00:00Added an answer on June 9, 2026 at 11:02 pm

    A very common way is to try to move the player to a position, and then see if he’s actually colliding with anything. If he isn’t, move there, else, try another location. In pseudocode:

    temp_pos = player.pos + (-1, -1) #move downleft one block
    if player.pos != enemy.pos: #if the position is not occupied
        player.pos = temp_pos # move the player there.
    else:
        #move player to another location and try again
    

    Basically though, I’d have a list to off all the spaces (or available directions) around the player, and loop over that, instead of hard coding all the direction by hand.

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

Sidebar

Related Questions

I need to implement 2D collision detection by arc. I have player(black dot) and
i have 2 sprites that moving horizontly and i need them to fall down
I have a collision detection and its working fine, the problem is, that whenever
Why is it that most, if not all collision detection algorithms today require each
I have a collision detection class that works by finding the distance between the
For my collision detection I need to check of the ball rect intersects any
Alright, so I have this collision detection code, and I'm trying to push the
I have been reading about collision detection in games on stackoverflow and other sites.
I am writting a collision detection engine for my game and I have some
I am working on understanding collision detection and have decided to create a program

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.