-
Posts
3,782 -
Joined
-
Last visited
-
Days Won
7
Rikifive's Achievements
Single Status Update
-
Ladies and gentlemen, Twilight talks for the first time in this game.
(It's still a work in progress)
- Show previous comments 17 more
-
Quote
At the very least I could reduce the hitbox a little bit, so that it wouldn't be that visible, but I don't plan to put that in game, so who cares.
Or you can do a simple:
relative_distance.x = laser_bream_point.x - boulder_center.x;
relative_distance.y = laser_bream_point.y - boulder_center.y;distance_squared = relative_distance.x * relative_distance.x + relative_distance.y * relative_distance.y;
boulder_radius_squared = boulder_radius * boulder_radius;
if (distance_squared <= boulder_radius_squared)
{
// Point inside radius!
}This skips the square root operation, by squaring the radius instead. You might want to put another check to make sure the relative distance X and Y are not too great, like about the size of the screen. But you might get away with that when the internal variables are floating point anyways.
-
Hmmm I see, I see, but...
...the engine has pre-made square / circle / diamond / pixel_perfect collisions, so if I want to use one of these shapes or pixel perfect, it's just dragging the borders within sprite settings and done.
It also nicely supports bunch of collision check functions afterwards, which saves a lot of time.
Previously I had to code stuff manually, here I can skip many things, so I'm kinda using these fancy things to help myself.
I mean, one can still code stuff totally manually and there's nothing wrong with that, but since these things were pre-coded, I'm going to assume they knew what they were doing and that it's optimized and stuff.
Here in this example I believe I didn't even bother configuring anything, as it's just for testing, so the collision probably is the whole square. (I don't even know at this time lmao)
Nevertheless yes, this is something worth keeping in mind, as something like this might be needed somewhere else perhaps.
-
I have come to learn that collision detection is pretty much part of the game experience. Take Street Fighter II, which got very popular in arcades. It uses only rectangular hit boxes, that are placed side by side approximately where the hcaracter is standing, and changes with each new animation frame. That kind of style is obsolete with today's 3D models and 3D hit detection, that Capcom modified Street Fighter IV (the 3D game) to have that newer collision style, but veteran Street Fighter players, professionals, they all complained something was wrong! So Capcom went back to the 2D hitbox of the past, so 3D graphics with 2D hitboxes was the way to go!
New Super Mario Bros has 3 styles of hitboxes: Rectangular, Circles, and Trapezoids. While the Circle collision works like the code I showed above, that is only for point inside circle. NSMB also has Rectandular over Circle collision, which is slightly more crazy.