if box a maximum x smaller than box b minimum x
OR
if box a minimum x larger than box b maximum x
the boxes are away from each others, collision false;
if box a maximum y smaller than box b minimum y
OR
if box a minimum y larger than box b maximum y
the boxes are away from each others, collision false;
if we are here, we have only one case left, collision detected, because the minimum x or maximum x is between the minimum and maximum x and the minimum y or maximum y is between the minimum and maximum y
how this looks as code? (just quickly, i hope its correct xD)
@BitAssembly
I wrote a 2d/3d library for practice years ago, so I had everything to make my own engine. I call it Code Pony game engine, and try to make it modifiable.
Drawing: OpenGL, sound: OpenAL + vorbisfile. Own math library and own physics, pathfinding: a-star algorythm implementation, own path map and a.i. implementation.
I recruit 2D artists, and a music producer in a hungarian group now, the following roles are open yet:
-artists / animator
-someone responsible for collecting sounds
-dialogue writer (and deg / using ocs)
-music producer
-mapper
@Background Pony #5F93
Its a complex question, First I save the positions, i detect separated the 2 axises (x,y), first trying to move at x, if i detect hit, i replace the x value by the wall and the players x volume. Same for the y axis.
I made different cases when the “box” y velocity is + (it goes up) or -, (it goes down) so i know if the player hits the ground or the ceiling.
Then i apply onGround to the character if hits the ground. canJump=true, etc.
This repeats in normalized steps while the velocity x and y (separated) > 0
The engine is written in c____.
(i hope its clear, my english is bad, i learned it from video games.)
I have a question. How do you handle hit detection? I’m budding programmer trying my hand at coding and I’m wondering how you in particular deal with hit and ground detection.
(be sure to make the enemies at least a little bit slower than the player)
it can do odd things in the wrong hands.
Excellent!
Thanks for the help.
if box a maximum x smaller than box b minimum x
OR
if box a minimum x larger than box b maximum x
the boxes are away from each others, collision false;
if box a maximum y smaller than box b minimum y
OR
if box a minimum y larger than box b maximum y
the boxes are away from each others, collision false;
if we are here, we have only one case left, collision detected, because the minimum x or maximum x is between the minimum and maximum x and the minimum y or maximum y is between the minimum and maximum y
how this looks as code? (just quickly, i hope its correct xD)
class vec2
{
public:
float x;
float y;
};
class box
{
public:
vec2 pos;
vec2 vol;
};
bool interBoxes(box _a,box _b)
{
if( _a.pos.x___a.vol.x<=_b.pos.x
_b.vol.x||_a.pos.x_a.vol.x>=_b.pos.x___b.vol.x )return false;
if( _a.pos.y___a.vol.y<=_b.pos.y
_b.vol.y||_a.pos.y_a.vol.y>=_b.pos.y___b.vol.y )return false;
return true;
}
Well, I’m starting out and I have no idea of how to make collisions
for example? :)
Omg, c____? I would like some tips!
Nice to hear you’re using A* for pathfinding.
Keep up the good work!
I wrote a 2d/3d library for practice years ago, so I had everything to make my own engine. I call it Code Pony game engine, and try to make it modifiable.
Drawing: OpenGL, sound: OpenAL + vorbisfile. Own math library and own physics, pathfinding: a-star algorythm implementation, own path map and a.i. implementation.
I recruit 2D artists, and a music producer in a hungarian group now, the following roles are open yet:
-artists / animator
-someone responsible for collecting sounds
-dialogue writer (and deg / using ocs)
-music producer
-mapper
the project is non-profit.
Its a complex question, First I save the positions, i detect separated the 2 axises (x,y), first trying to move at x, if i detect hit, i replace the x value by the wall and the players x volume. Same for the y axis.
I made different cases when the “box” y velocity is + (it goes up) or -, (it goes down) so i know if the player hits the ground or the ceiling.
Then i apply onGround to the character if hits the ground. canJump=true, etc.
This repeats in normalized steps while the velocity x and y (separated) > 0
The engine is written in c____.
(i hope its clear, my english is bad, i learned it from video games.)