Author Topic: [83+ BASIC] Hp bar?  (Read 3739 times)

0 Members and 1 Guest are viewing this topic.

Risen Phoenix

  • Guest
[83+ BASIC] Hp bar?
« 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

Offline Spellshaper

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1690
  • Rating: +0/-0
  • This is me. Or maybe not.
    • View Profile
[83+ BASIC] Hp bar?
« Reply #1 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.

crzyrbl

  • Guest
[83+ BASIC] Hp bar?
« Reply #2 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 ^.^

Offline tifreak

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2708
  • Rating: +82/-3
  • My Kung Fu IS strong...
    • View Profile
    • TI-Freakware
[83+ BASIC] Hp bar?
« Reply #3 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.
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

katmaster

  • Guest
[83+ BASIC] Hp bar?
« Reply #4 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?

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
[83+ BASIC] Hp bar?
« Reply #5 on: July 03, 2006, 07:46:00 pm »
c1-->
CODE
ec1(ipart(((L1(1)/L1(5))*100)))/2->U

katmaster

  • Guest
[83+ BASIC] Hp bar?
« Reply #6 on: July 03, 2006, 08:31:00 pm »
Wow, I suck at optimizing XDsmiley.gif

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[83+ BASIC] Hp bar?
« Reply #7 on: July 04, 2006, 01:04:00 am »
I need to post metriod code so kalan can optimize it completly (j/k)
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
[83+ BASIC] Hp bar?
« Reply #8 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[83+ BASIC] Hp bar?
« Reply #9 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 >.<
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

katmaster

  • Guest
[83+ BASIC] Hp bar?
« Reply #10 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.

Offline tifreak

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2708
  • Rating: +82/-3
  • My Kung Fu IS strong...
    • View Profile
    • TI-Freakware
[83+ BASIC] Hp bar?
« Reply #11 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.
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

Dragon__lance

  • Guest
[83+ BASIC] Hp bar?
« Reply #12 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

Risen Phoenix

  • Guest
[83+ BASIC] Hp bar?
« Reply #13 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

katmaster

  • Guest
[83+ BASIC] Hp bar?
« Reply #14 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!!!