java 2d games problem (collision, well prevention)

Reply

Join Date: Oct 2004
Posts: 44
Reputation: ultimate_fusion is an unknown quantity at this point 
Solved Threads: 0
ultimate_fusion ultimate_fusion is offline Offline
Light Poster

java 2d games problem (collision, well prevention)

 
0
  #1
Jun 21st, 2005
I am starting to make some java games and I think i have sorted out the collision side of things ( i have made a space invaders game) so i know how to shoot and kill enemies. I am now wanting to stop players/monsters going through walls etc?

p.s. what is the best way to do walls? (just paint() them)

thanks for you help
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 762
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: java 2d games problem (collision, well prevention)

 
0
  #2
Jun 21st, 2005
If you just have simple, axis-aligned walls, then just compare the distance between the enemy and wall with the size of the enemy. If the distance becomes less, then it has hit the wall. After that, just reverse the direction of the enemy. That's the most simple of collision methods. Others involve swept collisions, which work regardless of an object's speed.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 44
Reputation: ultimate_fusion is an unknown quantity at this point 
Solved Threads: 0
ultimate_fusion ultimate_fusion is offline Offline
Light Poster

Re: java 2d games problem (collision, well prevention)

 
0
  #3
Jun 22nd, 2005
problem solved
just stored the values like
GTC[0]=x;
GTC[1]=y;
before the collsion and where it collides
if (a instanceof Monster ) {
x = GTC[0];
y = GTC[1];
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC