wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes I can't check for collision Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I can Watch "I can New topic

I can't check for collision

Lamar Jared

Joined: Nov 20, 2008
Posts: 8
I have this snake game that almost works. I have three problems:
1. the head and the tail of the snake overlap each other. Meaning, the head is read and the tail(ball) is green. When is runs the head and tail share the same space.
2. the tail doesn't grow each time it eats an apple. It grows whether an apple was eaten or not.
3. when I run into the tail or the sides of the window it doesn't detect collision.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
just wanted to point out that this is wrong
public void paint(Graphics g) {

painting in swing is done by overriding paintComponent(..)
Lamar Jared

Joined: Nov 20, 2008
Posts: 8
so should I make a call to super in the paint method?
Lamar Jared

Joined: Nov 20, 2008
Posts: 8
Thanks Michael. I made the call to super. I don't have the tail trailing me. Collision detection is working now though. I'm sorry if these concerns are trivial but I'm really new to programing and I'm trying to learn for my job
[ December 23, 2008: Message edited by: Lamar Jared ]
I agree. Here's the link: http://aspose.com/file-tools
subject: I can't check for collision
Similar Threads
New to Java. Need some proformance suggestions
Messagebox with Mouseevent
Multithreading: bouncing balls problem
MouseDragged doesn't seem to be working