'Python Debugger Freezing After 5 Lines of Code
What to do when the python debugger seems to get stuck after running the first few (five) lines of code?
I have been using Python for quite a while, but starting yesterday, I have not been able to use the debugger. Whenever i try to run the debugger, it just displays the first 5 lines of the script and then stops.
If I then try to exit out of the debugger, it just displayer --KeyboardInterrupt-- but it does not terminate the process.
I am running Python 3.9 with Spyder, and have tried fixing it by restarting, resetting to factory setting, installing into a new environment, as well as a total uninstall and clear, and then installing from scratch, but nothing seems to work.
Even when i try running really basic scripts (like the images below) the result is the same
Solution 1:[1]
Answered my own question. I solved this problem by updtating the collsion code and using a different script. I threw out scr_player_orient and replaced it with scr_player_dir using the following code.
Updated collsion code in enemy object
ar get_enemy_loc, player_side, col
get_enemy_loc = scr_enemy_pos(obj_scorpion)
player_side = scr_player_dir(get_enemy_loc[0],get_enemy_loc[1])
col = scr_check_block(get_enemy_loc[0],get_enemy_loc[1])
show_debug_message("Player X")
show_debug_message(obj_player.x)
show_debug_message("Player Y")
show_debug_message(obj_player.y)
show_debug_message("Enemy X")
show_debug_message(get_enemy_loc[0])
show_debug_message("Enemy Y")
show_debug_message(get_enemy_loc[1])
if player_side[0] = true and col[1] = false{
scr_shift_player(2)
}
else{
scr_shift_player(4)
}
if player_side[1] = true and col[0] = false{
scr_shift_player(4)
}
else{
scr_shift_player(2)
}
if player_side[2] = true and col[2] = false{
scr_shift_player(2)
}
else{
scr_shift_player(3)
}
if player_side[3] = true and col[3] = false{
scr_shift_player(3)
}
else{
scr_shift_player(2)
}
And used this new script -- scr_player_dir
function scr_player_dir(enemy_x, enemy_y){
var left,right,up,down,comb
left = false
right = false
down = false
up = false
if enemy_x < obj_player.x{
right = true && left = false
}
else{
right = false && left = true
}
if enemy_y < obj_player.x{
down = true && up = false
}
else{
down = false && up = true
}
comb[0] = right
comb[1] = left
comb[2] = up
comb[3] = down
return comb
}
I hope this helps someone with the same problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alex Hine |
