Starting with hitboxes

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Starting with hitboxes

Post by pacman »

Hello

I've finally made basic movement (I have stairs in my game \o/).
I started to think about spawning entities and stuff but it won't be that hard I belive.

The serious problem is concept of hitbox. I know how to check if rectangle is in another rectangle but I have no idea how to manage them.
How do I know which hitbox hit whatever it hits?
Do I check if player has been hit by a bullet or if bullet hit player?
Do I store hitboxes in another array and check them in every frame?
Will it be a little segment of code in every entity or huge hitbox system with Zordon inside?

I tried to find something usefull in google but I failed ; _ ;7
If anyone have some experience/opinion/concept/picture/idea about implementing hitboxes, please share <3
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Starting with hitboxes

Post by Plu »

I would suggest checking out Hardon Collider to manage this stuff for you. It's a cool little library for collision management.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Starting with hitboxes

Post by raidho36 »

This quesiton would normally have one single straightforward solution, the one you see right in front of you.

Supposedly, you know in advance which hitboxes are you checking.
Player check all bullets or all bullets check player is the same thing, therefore it's irrelevant.
You can only check them when motion happens, if that matters. You can store hitboxes in your entities' tables.
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: Starting with hitboxes

Post by substitute541 »

Plu wrote:I would suggest checking out Hardon Collider to manage this stuff for you. It's a cool little library for collision management.
I would suggest to post a link to Hardon Collider so he doesn't have to Google for it.
Currently designing themes for WordPress.

Sometimes lurks around the forum.
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Starting with hitboxes

Post by scutheotaku »

Also, bump.lua might be a useful, and simpler, alternative to HardonCollider:
https://love2d.org/wiki/bump.lua
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Starting with hitboxes

Post by pacman »

I'd rather write something on my own :) That way I won't be able to blame anyone else but myself :awesome:

After some thinking and looking at these libraries it came out that I'm overthinking pretty hard :)
Basically I need to check if "bad" things are hiting player and if player is hiting anything. Kinda... ekhm, simple :crazy:

But what should I do when I want to have delayed attack? Like in Castlevania - you must wait for the animation to reach certain point.
I'm not sure but I think there is no way to tell on which frame animation is currently on.
I'm using anim8.

Maybe there is some fancy trick or do I need to set timer for attack?
Something like:
0.8 second attack - searching for enemies to hit from 0.4
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests