Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

collision detection 1

Status
Not open for further replies.

shanley06

Programmer
Nov 26, 2002
101
US
I've figured out a cool way to do collision detection with the scenery. first you need to set up a screen mode with at least 2 pages. i used SCREEN 9,,0,1 (thanks to qbasicking for pointing screen mode 9 out to me). anyways, you need to make an outline of the level you have and makesure it is all one color. i used white. so you hve an outline for the level, say it looks like this

|
|
____________________|

now GET this outline using the GET command. now, you need to know how big your character is and what his coordinates are. pretend his coordinates are (x,y) and he is 2 pixels long and 2 pixels wide. now say the character is walking from the left to right. all you have to do to check the collision is

PUT (1,1),level.array%(0), xor
PUT (x,y), character.array%(0), xor
if point(x+3,y)=15 then
PUT (x,y), character.array%(0), xor
x=x-1
PUT (x,y), character.array%(0), xor
end if
PUT (1,1),level.array%(0)
PCOPY 0,1

i hope that wasn't too confusing. if it was tell me and i'll try and clear it up
 
Figured that little gem out a while ago. It is GREAT.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top