I Need An Algorithm For The Fight Bar

undertale

#1

Hi!

You might have seen my project called Undertale: :smiling_imp: Boss (which you can view here). As you might have noticed, the fight bar is broken. Can someone figure out how to make it so when the stick is towards the middle and you hit, it gives you more points, but when it's towards the red zone, it gives you less points?

I know @oio and @Stradyvarious might be able to help me with this! :slightly_smiling:


#2

@Follow4LikesOfficial, you liked in less than 5 seconds on a newly created topic! Impressive! :smiley:


#3

Hey, my record is less than 2!

On topic, @oio would probably know how! (I haven't studied how to do this yet)


#4

Ooh!
Their is lots of conditionals!


#5

Sam saying we like and post [too] fast tho XD

BOT: I'll try something out...I dunno


#6

you have two choices, use the x^2 block with values or many check onces.


#7

I'll suggest something, but you can decide whether to actually try it, after I've had a chance to look at the code. I don't want to come-in and take from you the satisfaction of putting the last touch on your own project, which is probably really close to working perfectly, save for one thing. My first impression is just to immediately look at the absolute value (square root of square) of the distance of the vertical bar from the screen center, when you press "Hit". That said, I need to go look at what you're doing now.

EDIT: You know what? It's such a jumble of stuff in there (inside the code), that I think it would be helpful, if you explained what's going on and said something about where the current method evaluates the position of the bar, when the hit happens. What are you currently doing?


#8

If you go into this text and this rule,

You'll see the current code. Also, feel free to replace these blocks with the backup ability to see the old one.

@Kiwicute2016 or anyone else, what exactly does the square root do? It can't decrease a value, can it?


#9

The square root tells you what number has to be multiplied by itself to get the number you gave it. You have to multiply 5 times itself to get 25. So, the square root of 25 is 5.

Further, if you take a number (positive or negative) and square it (in other words, multiply it by itself) and take the square root of the result, you get what's called the "absolute value" of the original number. It's always going to be a positive quantity, like a distance. You seem to want a distance from the center in this code, so if you take (x position - 512) and square that and then take the square root, you'll get the distance from the center, regardless of whether you're on the left of 512 or on the right of 512.


#10

I'll look in your code. I think you'd need to calculate distance...


#11

Well, I know what the square root and a power is, but how does it contribute to the fight bar?


#12

Distance Formula maybe?

sqrt(((x2-x1)²)+(y2-y1)²)

Is that the formula? My algebra's rusty ._.

I didn't wanna read oio's post so idk XD


#13

Maybe he's giving you a hint but not telling you the answer so you can have some fun coding? Idk ask @oio


#14

Likes to @CreativeCoder and @Follow4LikesOfficial! :heart::heart:


#15

Of course. So, I hit the reply button, before I had finished. What it seems you want to do is to get that distance and to have your code calculate the "points" or whatever based upon that distance. A larger distance means a smaller score, I gather. So you'd do something like "Increase Score by___" where the quantity in the blank would be some maximum score, minus the distance (or whatever). You can decide how to scale it, really.


#16

He doesn't seem to have any y-values in the problem. The whole solution seems to depend on where the bar is in x at the moment the "Hit" text is hit. Honestly, I don't know... I'm still stuck on the whole "sins crawling on [my] back" thing. :grimacing:


#17

Oh yeah...hm. Gimme a few minutes...

And that's part of the dialogue from one of Undertale's genocide battles. Sounds like fun, huh? :laughing:


#18


#19

Yep.

Okay...so literally all it says is abs(a-b). That's going to help. Thanks.

I'm going to take another look at the code.


#20

It's a reference to the game Undertale. It's one of the quotes from where you fight the final boss fight. :sweat_smile::yum: