+ 2
Does avoiding the problem count as debuggin?
I started writing a Snake game in Java (I know, but I'm learning and it seemed easy enough for my skill level). after getting it up and running, I wrote a bit of code that calls gameover() if you hit a wall or yourself. walls work great. hitting myself crashes the game. after hours of looking thru code I came up with a solution. hitting myself sets xspeed=200 and it slams me into a wall instantly and then goes to gameover() perfectly. I am just curious if it's normal to give up on a bug and just avoid it.
2 Respuestas
+ 2
More of a hack or work around than debugging. Did you try setting break points and check the values of your variables, stack tracing the error etc to spot exactly what is going wrong? What type of error is being thrown? etc.
0
I'm not sure what error, that's the one thing I don't care for about Eclipse. it lead me to what line is throwing the error, which is the start of my enhanced for loop that I use to check if snake location is equal to snake body part location. it is just wierd, I looked thru my code for hours. 5 things trigger gameover() ..
x>600
x<0
y>600
y<0
snake.x==snake.x && snake.y==snake.y
they all call the same gameover() method resetting the game, score, snake length, player location, and set the speed to 0,0.. the first 4 call the method and it works great. the last one not so much. I removed each element of gameover 1 by 1 to find the problem and it changed nothing, even with everything gone it still crashed when it hits itself.. the wierd thing is if I remove gameover() from that if statement and change it to xspeed=200 it triggers that without a problem.
I will go back and find the problem, my ocd won't let me not.. First I am going to finish it. got the little woman hand drawing me a title banner for the top, have to implement a score: and a high score.. then a save for the high score.. maybe pretty up the side panels.. then I will go back to banging my head trying to figure it out.. need some wins on implementing featurs to keep me motivated if that makes any sense