Useless Scripts/Programs

i'm not either··· worst part is that what i just wrote looks like it IS supposed to be working, but somehow it just isn't··· really makes me wonder what i'm missing here
 
No idea what it is. Move 2 random objects made of cubes through a space. That's 2 3d arrays. At the moment 1 cell of both is the same (x,y,z) position, we have a collision. Then you need the 2 vectors before the collision to calculate some kind of physics effect. The objects bouncing back at angles or breaking in fragments. But that's not it probably.
 
nah 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)
 
nah 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)
time to break out clang -fsanitize=address and/or lldb ;)
 
ok it rather seems that when ncurses deletes a window it doesn't get marked as 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 properly
 
here's where the error occurs, it checks for nullity and nulls tgt if it isn't
1776873269806.png


but
1776873285138.png
 
also somehow the bug where it'd display the Killed! message only when the bullet passed thru the enemy's row is no longer here, so now there's only that and the fact the terminal gets all fucked when you exit the program
 
when you set `tgt` to null you're only setting the local copy of that pointer inside `collide`. you either need to change it to 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 better
 
oh shit, changing collide() to bool was one of my first approaches, i really just missed that part then
i did suspect that the value change only applied to collide()'s scope but- well i guess i should have followed that suspicion 🥀
 
i have NO idea why but the hitbox bug just started happening again after i made that change··· and i still segfault after killing the thing once, and GDB shows that it comes from the same werase() as before, so what the hell could i be missing this time (updated the code on git so that you can see it)
 
oh my fucking Arceus, i had to make the target window NULL OUTSIDE shoot(), tgt is still shoot()'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···
 
oh my fucking Arceus, i had to make the target window NULL OUTSIDE shoot(), tgt is still shoot()'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···
oh 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 SHIT, turns out i could actually leave collide() as void and do the return thing under shoot() 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···
 
OH SHIT, turns out i could actually leave collide() as void and do the return thing under shoot() 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···
very few things could make us happier than helping someone understand how to do shooty games in ncurses in c, tbh
 
Back
Top