Solved

Sprite collision detection

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now