Announcement

Collapse
No announcement yet.

Verticle Charge Bar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Verticle Charge Bar

    I have another question up for an answer, I have no idea how charge bars work, so could some1 explain how but verticle?

    Ex:
    |_|
    |::|
    |::|
    |::|

    And also i want a timer attached so the value increases, that should be very simple i just need to kno wat value to change.

    #2
    Oh this is on a Interaction, Mutator im working on, i was just checking i dont think it can be done but i may be rong.

    Comment


      #3
      Dunno about how you are going to implement it, but I did a verticle bar for asset/jetpack meters in Colossians, feel free to decompile and look.

      Dicky B (it's not the bestest code in the world, but it works, and yes, it was a pain in the ***)

      ps-it's in JHud.uc obviously.. heh

      Comment


        #4
        Uhh is it just a color bar or texture? cuz i need a custom texture or somehow make it color going from Red on bottom and Green on top.

        Comment


          #5
          That's *exactly* what the jetpack charge bar looks like. It's a texture.

          (well, sorta.. mine goes red->green->yellow [bottom to top], look at the colossians teaser to see if that's the kind of thing you're looking for)

          Comment


            #6
            The Lightning Gun has an example of a vertical charge bar. Should be easy enough to copy/paste it. Do ask if that's not clear, though.

            Comment


              #7
              Yes i see it, just need to figure out how to impliment it into a interaction or the inventory item, ill just change the texture to mine and check it out, thx for your help

              Comment


                #8
                Works just like a horizontal charge bar except the x and y coords are flipped, lol. It isnt hard really, once you know how to draw on the canvas (and find a good place to do so).

                Comment


                  #9
                  The thing was that the Regular charge bar was drawn using widgets and those are only in HUD im using Interaction

                  Comment


                    #10
                    Ok, DB, I almost have it working, just that the charge bar in the frame only shows when its full why?

                    Code: (Little modified to work for me)
                    Code:
                        SX = Canvas.ClipX / 1024.f;
                        SY = Canvas.ClipY / 768.f;
                    
                        CX = 128;
                        CY = 256;
                        ScaledX = CX * SX * 0.80;
                        ScaledY = CY * SY * 0.80;
                        CScale = 1.0;
                        XPos = (Canvas.ClipX) - (ScaledX * 0.1 * CScale);
                        YPos = Canvas.ClipY * 0.65;
                    
                        ctwid = Inv.Charge / Inv.MaxCharge;
                        Canvas.Style = 5;
                        Canvas.SetPos(XPos,YPos-(ScaledY*ctwid));
                        Canvas.DrawTile( Texture'<TexturePack>.ChargeTex', ScaledX*CScale, ScaledY*ctwid*CScale, 0, (CY-(CY*ctwid))*CScale, CX, CY*ctwid*CScale );
                        Canvas.SetPos( XPos,YPos-ScaledY );
                        Canvas.DrawTile( Texture'<TexturePack>.FrameTex', ScaledX*CScale, ScaledY*CScale, 0, 0, CX, CY );
                    Only Shows:
                    ._.
                    |::|
                    |::|
                    |::|
                    |::|

                    or

                    ._.
                    |_|
                    |_|
                    |_|
                    |_|

                    Comment


                      #11
                      ctwid = Inv.Charge / Inv.MaxCharge;

                      Thats probably where your problem lies. You didnt post enough code, we need data types. Make sure ctwid is a FLOAT and not an INT. Also make sure the other variables are floats.

                      Comment


                        #12
                        Sry here is the whole function:
                        Code:
                        function PostRender(Canvas Canvas)
                        {
                            local float CScale,CX,ScaledX,CY,ScaledY,SX,SY,ctwid,XPos,YPos;
                        
                            if ( ViewportOwner.Actor.Pawn == None || ViewportOwner.Actor.Pawn.Health <= 0
                        	     || (ViewportOwner.Actor.myHud != None && ViewportOwner.Actor.myHud.bShowScoreBoard) )
                        		return;
                        
                            if (Inv == None)
                                FindInv();
                            if (Inv == None)
                                return;
                        
                            SX = Canvas.ClipX / 1024.f;
                            SY = Canvas.ClipY / 768.f;
                        
                            CX = 128;
                            CY = 256;
                            ScaledX = CX * SX * 0.80;
                            ScaledY = CY * SY * 0.80;
                            CScale = 1.0;
                            XPos = (Canvas.ClipX) - (ScaledX * 0.85 * CScale);
                            YPos = Canvas.ClipY * 0.40;
                        
                            ctwid = Inv.Charge / Inv.MaxCharge;
                            Canvas.Style = 5;
                            Canvas.SetPos(XPos,YPos-(ScaledY*ctwid));
                            Canvas.DrawTile( Charge, ScaledX*CScale, ScaledY*ctwid*CScale, 0, (CY-(CY*ctwid))*CScale, CX, CY*ctwid*CScale );
                            Canvas.SetPos( XPos,YPos-ScaledY );
                            Canvas.DrawTile( Frame, ScaledX*CScale, ScaledY*CScale, 0, 0, CX, CY );
                        }
                        Let me check out a few things.

                        Comment


                          #13
                          Code:
                          if (DecalInv == None)
                          		FindDecalInv();
                          	if (DecalInv == None)
                          		return;
                          Do me a favor and fix this, lol. Make FindDecalInf() return a bool, true if it found one, false if not, and do this:

                          Code:
                          if (DecalInv == None && !FindDecalInv())
                          	return;
                          It just looks better, lol.

                          Otherwise, just make sure Inv.Charge is correctly set.

                          Comment


                            #14
                            Well, i used a bunch of code from RPG so im just gana leave that, i think the Charges are the rong thing to use

                            Comment


                              #15
                              Got it!

                              Code:
                              class myInv extends Inventory;
                              
                              var travel Amt, MaxAmt;
                              Code:
                              ctwid = (Inv.Amt) / (Inv.MaxAmt);


                              Thanks for help.

                              Comment

                              Working...
                              X