Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
I had the a very close problem once a while ago.
I don't know how movement in SDL works, but did you think about making a very basic collision handling? If you know the position, height and width of every object, in a very simple case you only have to check in the player movement routine if the next step collided with one of these objects. This should work and be only a couple of lines of code.
If you then wanted to optimise it, you could try to only check objects that are currently visible or near to the player.
MrHallows401y@Benedikt Well, I keep thinking that it might partly be due to the placement of my movement/collision code within the codebase, too. The GameObject base class is structured with the HandleInput > Update > Render pattern and I guess I'm not exactly sure how to properly handle the code for input, movement and collision detection/resolution separately. In the hustle and bustle of trying to make it work, the "complexity" of the code tends to increase, but I always feel like it should be short, simple and succinct, but I just don't know how to execute it correctly. Do you know what I mean?
Hazarth11411y@MrHallows I dont know what you have, but you should have a World singleton somewhere (or passed in some kind of context). Or even a message passing/event system that lets the colliding object know what it collided with, and how far inside the other thing it is. After that you just need to pull it back by that much. This is trivial for circular and AABB collisions. Much harder for polygons, keep it simple for now as platforms dont need a super precise collision. Maybe if you can be more specific about your architecture and whats breaking I could help more.
Nanos94821yEven worse then there are bugs in the compiler/language itself and it isn't your fault..
As such you have to discover these and find workarounds.
I suggest starting from the very very beginning of your code and comment out everything but one task at a time, watch it run, study it, see if there is a memory leak.
If there is, and you can't figure out why, rewrite the code to do the same task in a different way, and see if you still get the memory leak.
Yes it can take an absolute forever to achieve a perfect working piece of software this way, but you can do it. :-)
You can also cheat and include memory clearing up routines to fix the issue from the other side of the fence so to speak.
It's a very slow process and folk ask me why it might take me a month to code a simple function when they can do the same thing in an hour.
Yes, but mine is perfect, your's crashes on 10% of users machines in the first hour..
Nanos94821y2D collision detection pixel perfect ?
Eg. checking if pixel from object A is in the same place as pixel from object B ?
Or the, circle around object A overlaps circle around object B approach ? (I prefer pixel perfect, so it is more realistic and you can miss collisions by a gnats whisker !)
Library routines ?
pfs5381yWhat problems are you having exactly? I have some experience coding 2d platformer engines ;)
xjose97x15Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
sam966912Hats off to this lady .... I would have just flipped the machine