You are viewing our Forum Archives. To view or take place in current topics click here.
Barriers for a game.
Posted:

Barriers for a game.Posted:

Gavin-
  • Ninja
Status: Offline
Joined: Nov 02, 201310Year Member
Posts: 4,340
Reputation Power: 1865
Status: Offline
Joined: Nov 02, 201310Year Member
Posts: 4,340
Reputation Power: 1865
So I am currently making a snake game and what I was is when the snake goes outside the box the game will just exit.


Is there any code I could use to put on my Jframe/Jpanel.

Thanks.

If you need more info comment below.
#2. Posted:
SovietRussia
  • Ninja
Status: Offline
Joined: Mar 17, 201113Year Member
Posts: 3,910
Reputation Power: 236
Status: Offline
Joined: Mar 17, 201113Year Member
Posts: 3,910
Reputation Power: 236
I would take the coordinates from the head of the snake and make a collision function that exits the game loop when they (the head's coordinates) share the coords with the border. I haven't taken java so I can't help with that part sadly.
#3. Posted:
ip
  • Christmas!
Status: Offline
Joined: Dec 30, 201211Year Member
Posts: 3,778
Reputation Power: 3016
Status: Offline
Joined: Dec 30, 201211Year Member
Posts: 3,778
Reputation Power: 3016
I would do what SovietRussia did as it would be the best way for a simple snake game. Or if you don't want to fully hard code the snake and everything, just make objects, it would be a lot simpler.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.