Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How would you make a hitbox have attack points like in smash bros?
- Frioc
-
Scratcher
21 posts
How would you make a hitbox have attack points like in smash bros?
I wanted to make a smash bros type game, but idk to make the enemy sense when the other player uses a move. I mean, could I just make another sprite called “hurtbox” and have that go to the hitbox?
I looked at @Hobson-TV's famous Super Scratch Bros game and it was waaay to complex for me to understand, but I think it uses pen to draw the attacks hitbox
For reffernce I mean these
I looked at @Hobson-TV's famous Super Scratch Bros game and it was waaay to complex for me to understand, but I think it uses pen to draw the attacks hitbox
For reffernce I mean these
- ThreeLived
-
Scratcher
100+ posts
How would you make a hitbox have attack points like in smash bros?
From your source provided, it seems that its using a bunch of circles. I hope you already know about the Pythagorean theorem, because its really important here. For context, its often used in the distance formula for a circle.
If you want to make a scratch game using the system in your source, you could add a bunch of positions to a list (and include their size) and check if a given point is within it.
a simplified version might be creating a circle around the attack's area and seeing if it collides with the player's circle (just subtract the radius of the player's circle to get its distance to the attack's circle)
If you want to make a scratch game using the system in your source, you could add a bunch of positions to a list (and include their size) and check if a given point is within it.
a simplified version might be creating a circle around the attack's area and seeing if it collides with the player's circle (just subtract the radius of the player's circle to get its distance to the attack's circle)
- Frioc
-
Scratcher
21 posts
How would you make a hitbox have attack points like in smash bros?
I see how that could work, but what if the other players hitbox is a square not a circle? Also is it better to calculate the players hitboxes with code or with another sprite
- ThreeLived
-
Scratcher
100+ posts
How would you make a hitbox have attack points like in smash bros?
Using another sprite works… until it doesnt. If a sprite is offscreen or you plan to allow scrolling, sprites become awful.
As for squares, they are super simple.
They are literally just the x difference and y difference
it looks like this:
As for squares, they are super simple.
They are literally just the x difference and y difference
it looks like this:
set [distance v] to ( [abs v] (((attack x) - (player x)) + ((attack y) - (player y)))::operations)::operations //absolute value may not be needed. its just in case
Last edited by ThreeLived (Yesterday 22:26:23)
- Frioc
-
Scratcher
21 posts
How would you make a hitbox have attack points like in smash bros?
I'm probably wrong but Isn't that only the distance to one coordinate though? Like one pixel?
- ThreeLived
-
Scratcher
100+ posts
How would you make a hitbox have attack points like in smash bros?
it is. you just have to check if its less than the size of the hitbox
if <(distance_) < [hitbox size (you decide what it is)]> then
do something depending on what you want to do ::motion
end
- Spider-forge
-
Scratcher
13 posts
How would you make a hitbox have attack points like in smash bros?
You could maybe use a filled in box sprite with 100 percent ghost effect, then change a global variable of whether a specific attack is playing or not, then if it is playing and both people are in the hitbox, deal damage. Maybe this is too simple though?
Pseudocode:
Pseudocode:
set [Ghost] effect to (100)
forever
if <<(attack_playing) = [1]> and <touching [ sprite v] ?>> then
deal damage
end
end
- ThreeLived
-
Scratcher
100+ posts
How would you make a hitbox have attack points like in smash bros?
You could maybe use a filled in box sprite with 100 percent ghost effect, then change a global variable of whether a specific attack is playing or not, then if it is playing and both people are in the hitbox, deal damage. Maybe this is too simple though?I think this would work, but i tend to find sprite to sprite collisions unreliable. It only really becomes super relevant if you use camera controls (especially zoom, then it gets really bad), so it could work for OP's project depending on how its structured
Pseudocode:set [Ghost] effect to (100)
forever
if <<(attack_playing) = [1]> and <touching [ sprite v] ?>> then
deal damage
end
end
- Discussion Forums
- » Help with Scripts
-
» How would you make a hitbox have attack points like in smash bros?