Solved

Sprite collision detection

Posted on 1997-11-12
1
200 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 100 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

Technology Partners: 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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

729 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