
Advertisement
Sign in to follow this
Followers
0

entries
4 
comments
13 
views
808
About this blog
Indie game presentation, and technical information journal.
Entries in this blog
More collisions and little physics
Min collisions
I have been busy lately, still learning more about OpenGL and of course my work. I should accelerate a little bit now. Now I added a collision engine, very basic at the moment. it is about detecting if a point is inside a platform rotated or not. plus solve the deformation on rotations in the previous entry. Also updated the math functions. Collision: Nothing very fancy, just check if the point is inside the bouncing box if the platform is not rotated it will return collision detected. if the platform has rotated then the point will be rotated opposite angle to go back to the previous situation and do the same check. int bkp_physics_inPlatform2D(BKP_VEC3 point, BKP_Entity_Platform * p) { float X = point.x; float Y = point.y; if(X > p>bbox.x && X < p>bbox.x + p>bbox.w && Y > p>bbox.y && Y < p>bbox.y + p>bbox.h) { if( p>isrotated == BKP_TRUE) { X = X  p>rotate.center.x; Y = Y  p>rotate.center.y; float x = p>rotate.center.x + X * p>cos_a  Y * ( p>sin_a); float y = p>rotate.center.y + X * ( p>sin_a) + Y * p>cos_a; if(x > p>x && x < p>x + p>w && y > p>y && y < p>y + p>h) return BKP_TRUE; } else return BKP_TRUE; } return BKP_FALSE; } Notice that the cos and sin are precalculated each team the platform if it rotates only. avoiding to use too much expensive cos and sin. You can see on the video the mouse cursor becoming red each time it is inside a platform.You can also see on the sprite 8 points that I will be used to make the collision detection. Gravity: on this other video, I activated gravity. but no collision. it is possible to jump in the air to test the effect of jump Well, that's all done for now. I will unify collision detection and gravity, add some penetration resolution and we will see a first step done. next step will be more about game play.
Let's start
Sign in to follow this
Followers
0

Advertisement