time to break outnah it's a lot simpler than that, i meant the bullet hitting the opponent and how that would be handled
now i've finally made some progress, for some reason it detects the bullet hitting anywhere in the line where the opponent is as a hit, but when you get both the line and column right the opponent disappears like it's intended to, however if you fire again pointing at that same exact location the program will segfault (this shit keeps haunting me)
clang -fsanitize=address and/or lldb NULL, but because it got deleted interacting with its pointer results in a segfault, so i have to find another approach to checking whether the enemy's window (hitbox) got hit in order to make it die properlyfrom: https://pubs.opengroup.org/onlinepubs/7908799/xcurses/endwin.htmlThe endwin() function does not free storage associated with a screen, so delscreen() should be called after endwin() if a particular screen is no longer needed.
screen actually refers to the terminal it's running, it's the entire program rather than the window fraction of ityou need to take a pointer to the pointer to null it at the higher level.here's where the error occurs, it checks for nullity and nullstgtif it isn't
View attachment 26012
but
View attachment 26013
bool collide(WINDOW* tgt) and return true to signal to the caller that it collided, and the caller can null it out there, or collide needs to take a pointer to a pointer to a window. probably changing to a bool is betterwerase() as before, so what the hell could i be missing this time (updated the code on git so that you can see it)NULL OUTSIDE shoot(), tgt is still shoot()'s scope only so it has to act as a signaler for actually killing the windowoh you're cleaning up the value too early. you probably need some way of signaling extra data with your window, indicating "collided", and then clean those up next frame.oh my fucking Arceus, i had to make the target windowNULLOUTSIDEshoot(),tgtis stillshoot()'s scope only so it has to act as a signaler for actually killing the window
the hitbox bug remains however··· but i guess it's not crashing now at least
EDIT: turns out it's even worse, if the bullet hits outside the target's X position hitbox it works, but then if it hits it in the very spot it's intended to hit the segfault happens the same way as before··· this shit is frying me···
collide() as void and do the return thing under shoot() instead, because that's where the main game loop actually gets data fromvery few things could make us happier than helping someone understand how to do shooty games in ncurses in c, tbhOH SHIT, turns out i could actually leavecollide()asvoidand do the return thing undershoot()instead, because that's where the main game loop actually gets data from
THANK YOU very much, now i have to do the same for the player ship when it gets shot or collides with the opponent's···