?
Solved

Sprite collision detection

Posted on 1997-11-12
1
Medium Priority
?
205 Views
Last Modified: 2010-04-10
I'm currently writing a game in which you control a little
character with a gun.  But I was wondering how I could detect wether or not the character is standing next to a wall.  Right now, the character runs through the wall.  I've used the div function to check the sector next to the character to see if its blank, however, the character can move into the next sector before he is "in" the next sector and thus is drawn half way in the wall.  How can I detect if the character can walk to the right or left?
0
Comment
Question by:pbinsted
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1173106
Generally, two different objects cannot occupy the same position in space. One way to know if something is going to collide is to compare the two rectangles for the objects. If there is an intersection between the two rectangles, then there is a collision. To detect if something is going to collide, then you would use the imagined new positions for the moving objects and intersect them. If there is an intersection, then the new positions cannot happen.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question