Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Risen Phoenix on July 03, 2006, 09:43:00 am

Title: [83+ BASIC] Hp bar?
Post by: Risen Phoenix on July 03, 2006, 09:43:00 am
As I was working upon a program of mine (In Ti 83+ series Ti Basic) I found a difficult problem; how do you go about making an Hp or Life bar? Currently the formula I am using is
c1-->
CODE
ec1
ipart((pixel number)((current hp)/(total hp))
//followed by a for( loop to turn the pixels on or off.
c2
ec2
Which works okay until I try to increase the bar (healing) or decrease the bar (damage). It causes wacky results to say the least. :(sad.gif

Help would be greatly appreciated :)smile.gif
Title: [83+ BASIC] Hp bar?
Post by: Spellshaper on July 03, 2006, 10:00:00 am
how 'bout:

c1-->
CODE
ec1:line(A,D,A+E,D,0
:line(A,D,A+EB/C,Dc2
ec2
Where
A= X starting coordinate for teh bar
B= current mana/life value
C= max. mana/life value
D= Y coordiante for teh bar
E= width of teh bar

This first erases the bar, then draws the bar with new values.


Tis should work, assuming your window range is
Xmin=0
Xmax=94
Xscl=1
Ymin=-62
Ymax=0
Yscl=1
Xres=1
with these settings, always remember to input Y values (here: D) as negative numbers.

(a very useful setting, since one line( statement is faster than multiple Pixel( statements)

If you got any problems, feel free to ask!
/edit: I checked, and it workz.
Title: [83+ BASIC] Hp bar?
Post by: crzyrbl on July 03, 2006, 10:30:00 am
If you can post the exact code and window settings, that would help us even more.  make sure youre drawing on the screen ^.^
Title: [83+ BASIC] Hp bar?
Post by: tifreak on July 03, 2006, 03:50:00 pm
Hmm, I shall post my solution...

L1(1 is hp
L1(5 is max hp

L1(1)/L1(5->U
U*10->U
iPart(U->U
U/2->U
Line(90,11,90,U+9
Pt-On(91,10
Pt-On(91,U+10
Line(92,11,92,U+9

And this is with win set to:

Xmin/Ymin=0
Xmax = 94
Ymin = 62

You can do all kinds of things with that exact set up, changing the U/2 part to other numbers will also shorten the bar a bit, if you want.
Title: [83+ BASIC] Hp bar?
Post by: katmaster on July 03, 2006, 07:27:00 pm
@ tifreak: Why dont you just do:

c1-->
CODE
ec1(ipart(((L1(1)/L1(5))*100)))/2->U
c2
ec2

Wouldn't that be faster and smaller?
Title: [83+ BASIC] Hp bar?
Post by: kalan_vod on July 03, 2006, 07:46:00 pm
c1-->
CODE
ec1(ipart(((L1(1)/L1(5))*100)))/2->U
Title: [83+ BASIC] Hp bar?
Post by: katmaster on July 03, 2006, 08:31:00 pm
Wow, I suck at optimizing XDsmiley.gif
Title: [83+ BASIC] Hp bar?
Post by: DJ Omnimaga on July 04, 2006, 01:04:00 am
I need to post metriod code so kalan can optimize it completly (j/k)
Title: [83+ BASIC] Hp bar?
Post by: kalan_vod on July 04, 2006, 04:47:00 am
QuoteBegin-xlibman+Jul 4 2006, 07:04 AM-->
QUOTE (xlibman @ Jul 4 2006, 07:04 AM)
I need to post metriod code so kalan can optimize it completly (j/k)  

 I was able to look at some of the code which was posted on June third at Loki's forums, and it looks great. I would be able to give a hand in helping the size go down, and most likely the speed. Let me know if you would like some help with the task at hand.
Title: [83+ BASIC] Hp bar?
Post by: DJ Omnimaga on July 04, 2006, 05:50:00 am
kk, actually I know you are pretty busy lately with work and such (I assumed you had free day because Of july 4th ;)wink.gif ) kat helped a bit so far, but maybe there is still stuff that need optimization like the map programs or weapons. My code is VERY VERY VERY VERY VERY messy tho >.<
Title: [83+ BASIC] Hp bar?
Post by: katmaster on July 04, 2006, 07:41:00 pm
Just think.....if thats unoptimized and its running THAT fast, think how fast it'll be at it's full potential......crazyness.
Title: [83+ BASIC] Hp bar?
Post by: tifreak on July 05, 2006, 01:25:00 am
QuoteBegin-katmaster+Jul 4 2006, 06:27 AM-->
QUOTE (katmaster @ Jul 4 2006, 06:27 AM)
@ tifreak: Why dont you just do:

c1-->
CODE
ec1(ipart(((L1(1)/L1(5))*100)))/2->U
c2
ec2

Wouldn't that be faster and smaller?

Because, it worked, and wasn't slow. :Ptongue.gif

I had plans on optimizing it like that, once I got back to AODR, but for now, it is just one of those things on the todo list.


Anyways, mine works for any amount on the numbers. It will only mess up if hpmax>hp. Otherwise, this is a very dynamic routine.
Title: [83+ BASIC] Hp bar?
Post by: Dragon__lance on July 05, 2006, 02:55:00 pm
one thing i gotta caution about, whenever you make a routine, the simpler the better.Complicated=Slowdown.I like Spelli's routine for simpleness,but tifreak8x's works well for planned game storage. As for metroid2 code, i looked at it and i think you forgot some delvars and nots( :)smile.gif
Title: [83+ BASIC] Hp bar?
Post by: Risen Phoenix on July 05, 2006, 04:49:00 pm
Thank you all for your support :)smile.gif
After fiddlin' around using some of the methods provided, I found a method that works perfectly :)smile.gif

I wasn't actually using the graph commands though (Line, Pt-on,ect.), just pxl on and off, and For( loops (for ease of use) :lol:laugh.gif
Title: [83+ BASIC] Hp bar?
Post by: katmaster on July 05, 2006, 05:22:00 pm
Glad we could help :)smile.gif It's great to see awesome new programmers coming up. Can't wait to see your game!!!