tulamide's Recent Forum Activity

  • What ever.

    Still say it's a better way. He just needs to get the value of the variable before he even thinks about setting the frame.

    Then there's the lerp method. You can use 1-10, 1-11, 5-20, and change the modifier to n*0.1.

    And if your terribly worried about returning a zero, all you have to do is change the always condition to a comparison making sure its greater than 0.

    I'm not concerned about lerp, but that we are not talking about one variable, but two. The 'health' value, as you called it, is not a fixed percentage. It is related to another value and both change during gameplay. health = 500 means 100% only if the second value is 500. If it is 800 then health = 500 means 62.5%. And that's not covered by your proposal.

  • Nice one, good work!

    And good luck for all those hot effects we can expect from you from now on

  • Actually, it's a bit more.

    numbers are rounded down to the next integer:

    int(3.2) = 3

    int(4) = 4

    int(5.892) = 5

    strings will be searched for numeric values at the beginning of the string, and the resulting number then rounded down to the next integer:

    int("20") = 20

    int("43.342") = 43

    int("51abcdefg") = 51

    int("51.56abcdefg") = 51

    ...

    and ... int("blah blah") = 0

    Btw, is there a difference between floor(3.2654) and int(3.2654) ?

    I can't really see one, because floor works exactly the same than int (edit: forgot a word) even on strings...

    Lets look at this in a more simplified way.

    If your max shield hp is 1000, and you have 10 different states, you can use that as a percentage.

    >always

    ->sprite set frame to int(shields('health')/100)

    Note:

    Frame 0 is not possible, but the system will use the closest to it frame 1.

    http://dl.dropbox.com/u/666516/framepercent.cap

    And while your looking at the system expressions take a look at lerp.

    int(lerp(1,10, Sprite.Value('hp')/1000))

    This is confusing more than helping. Please have a look at my long post about it. There are two variables that are related to each other and influence each other. Also, my expression never reaches frame 0, I think it is a better way to make sure you don't get unwanted values instead of hoping that Construct will catch the error.

  • What does the range 0 to 100 mean here? (What units are being used here?)

    What value in this range corresponds to the sound file being played at its original volume?

    Also, how do you access this particular variable using syntax? (XAudio2.??)

    Thanks.

    It's a percentage value. 100% should match 0 dB and 0% should match -inf dB. Original volume always is 0 dB, so 100% = original volume.

    Sadly there's only a setter for music volume, no getter. You have to create a pv or global and store/change the value there, then set the music volume to that pv/global.

  • and well... many my previous issues are left unasweared

    Yes, they are, but isn't it much better to work on only one problem until it is solved, then go on to the next, instead of getting information overkill?

    wow. everyday i learn something new. never knew about such thing. how weird is that simitation O.o like - it can easly count 2 + 2 but have troubles with 0,2 + 0,2?

    It can, but we the bad, mean humans limitate it. We only give him a limited number of bits. But with a floating point number there are occasions where those bits are not enough to exactly represent the number, and so the processor jumps to the nearest possible representation.

    also - what the heck is int expression??? i never seen that before on both expresions and system expresions pages on wiki.

    http://sourceforge.net/apps/mediawiki/construct/index.php?title=System_Expressions

    You will find it under part 9: System

    It converts a string or a float to an integer by rounding down.

    the problem is, last frame suppose to be 100% ShieldEnergy only, just the first frame 0% should be displayed only when ShieldsCurrent hits 0%. with this the last frame 100% is for some reason never played, or should i say - it is but if ShieldCurrent is about 100% (100,000001% for example).

    The formula I wrote down is designed to show the shield status 100% only, if EnergyCurrent matches exactly EnergyTotal. On the other hand it displays the 0% frame also up until a certain amount (when using 11 frames everything below 10%)

    If you want to tweak its behavior, just replace 'int' by 'round' or 'ceil'. Ceil rounds up to the next integer, and round rounds to the nearest integer [=> round(1.49) = 1, round(1.5) = 2]

    If you use 'ceil' instead of 'int', then the 0% frame is only shown, if EnergyCurrent is exactly 0, whereas the 100% frame will be shown for every value above 90%.

    why my method doesnt work and why your does.

    Just because I have a small lead over you in programming. Just keep on doing and you will solve such problems by yourself with ease. Promised.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It seems, you want to present some kind of a shield status display. This display has 11 frames, representing 11 states of the shield status. Something like this:

    xxxxxxxxxx -> shield 100%

    xxxxxooooo -> shield 50%

    oooooooooo -> shield 0%

    Am I right? If so, there is a much simpler way achieving this. You have two values, EnergyTotal and EnergyCurrent. The first one is a value depending on the ship and its equipment. It may be 300 for one ship and 500 for another. If it was 300, then EnergyCurrent would have a start value of 300 and then lower whenever energy is used. And if EnergyCurrent is 150 it is 50% of EnergyTotal. But if the player now enhances the ship, the EnergyTotal may raise to 500. In result the 150 of EnergyCurrent represent no longer 50%, but 30%.

    If all of these assumptions are right, then you only need to do the following:

    + Always
    -> EjectorShieldBar: Set animation frame to int((EjectorShieldBar.GetAnimationFrameCount - 1) / global('Spaceship - EnergyTotal') * global('Spaceship - EnergyCurrent')) + 1[/code:1fpmigt2]
    
    Yes, you only need one event for all of your animation frames. The expression
    
    int((EjectorShieldBar.GetAnimationFrameCount - 1) / global('Spaceship - EnergyTotal') * global('Spaceship - EnergyCurrent')) + 1
    
    automatically sets the right frame in relation to the percentage from EnergyCurrent to EnergyTotal.
    
    [h2]EnergyTotal = 300
    EnergyCurrent = 300
    EjectorShieldBar.GetAnimationFrameCount = 11
    --> frame = int((11 - 1) / 300 * 300) + 1 = int(10 / 300 * 300) + 1 = 10 + 1 = 11
    
    EnergyTotal = 300
    EnergyCurrent = 0
    EjectorShieldBar.GetAnimationFrameCount = 11
    --> frame = int((11 - 1) / 300 * 0) + 1 = int(10 / 300 * 0) + 1 = 0 + 1 = 1
    
    EnergyTotal = 300
    EnergyCurrent = 150
    EjectorShieldBar.GetAnimationFrameCount = 11
    --> frame = int((11 - 1) / 300 * 150) + 1 = int(10 / 300 * 150) + 1 = 5 + 1 = 6
    
    EnergyTotal = 500
    EnergyCurrent = 150
    EjectorShieldBar.GetAnimationFrameCount = 11
    --> frame = int((11 - 1) / 500 * 150) + 1 = int(10 / 500 * 150) + 1 = 3 + 1 = 4
    
    EnergyTotal = 500
    EnergyCurrent = 150
    EjectorShieldBar.GetAnimationFrameCount = 21
    --> frame = int((21 - 1) / 500 * 150) + 1 = int(20 / 500 * 150) + 1 = 6 + 1 = 7[/h2]
    
    You may change every value (including the number of frames you use in your animation to represent the status), it will always show the correct status of the ships shield.
  • whats wrong with this?

    clamp(global('Spaceship - EnergyTotal'),global('Spaceship - EnergyTotal')*0.6,global('Spaceship - EnergyTotal')*0.69)[/code:1v2oqfvx]
    

    There's nothing wrong with it. It just doesn't make sense. The returned value of this expression will always conform to global('Spaceship - EnergyTotal') * 0.69.

    clamp returns a bounded value. But, if you make the bounds relative to the value, it will always return the highest or lowest value, depending on the relation. Just replace global('Spaceship - EnergyTotal') with a value to see the problem. Let's say, global('Spaceship - EnergyTotal') equals 100:

    clamp(100,100*0.6,100*0.69)

    You're now ordering Construct to return 60, if the original value is lower than 60, to return the original number, if it is between 60 and 69, and to return 69, if the original value is greater than 69. But the original value always is 100, and so you are always getting 69.

    And now think of all the different values, global('Spaceship - EnergyTotal') may have. They all will be greater than global('Spaceship - EnergyTotal') * 0.69

    clamp(50,50*0.6,50*0.69) will return 34.5 (always and only)

    clamp(260,260*0.6,260*0.69) will return 179.4 (always and only)

    So, if you are comparing global('Spaceship - EnergyCurrent') with clamp(global('Spaceship - EnergyTotal'),global('Spaceship - EnergyTotal')*0.6,global('Spaceship - EnergyTotal')*0.69), you are comparing global('Spaceship - EnergyCurrent') with global('Spaceship - EnergyTotal')*0.69

    This comparison will only be successful, if global('Spaceship - EnergyCurrent') conforms exactly to global('Spaceship - EnergyTotal')*0.69, and not to a range of values.

    Don't make the bounds of clamp relative to its value. And, if you want global('Spaceship - EnergyCurrent') to be in a certain range for the condition to become true, do this:

    + Is global variable 'Spaceship - EnergyCurrent' greater or equal global('Spaceship - EnergyTotal') * 0.6
      Is global variable 'Spaceship - EnergyCurrent' less or equal global('Spaceship - EnergyTotal') * 0.69
    [/code:1v2oqfvx]
    That's two conditions in one event, meaning they both need to be true for the action to be performed. And they are both true for [i]every[/i] value between global('Spaceship - EnergyTotal') * 0.6 and global('Spaceship - EnergyTotal') * 0.69
  • actualy i was just an idiot and though that if i write % mark it would (just as using your calculator) divide. forgoten this obvious fact that 10% are in fact 0.10, and to get 10% of something i need it be multiply by 0.10.

    Don't be too harsh to yourself. It's just learning by doing, we all come to such points from time to time

    * off-topic *

    And here a description of the modulo operation:

      The percentage sign, when used outside of a string, is an operator, just like +, -, *, /, etc. And it does divide, but a modulo division, aka 'mod', giving the integer remainder of the division:
        13 % 5 = 3 -> can also be expressed by: 13 - floor(13 / 5) * 5 -> you can also do ((13 / 5) - floor(13 / 5)) * 5 -> it is just returning the decimal places of the division multiplied by the denominator
          13 / 5 = 2.6; 0.6 * 5 = 3
      Modulo is often used in programming to get a repeating list of ordered numbers. For example, the timer returns the milliseconds passed since start of the application. You want a sprite to constantly fade in and out repeatedly and every fade should last 1 second. But the sprite's opacity is expressed by a value ranging from 0 to 100. So what we need is converting the timer value in a way that we get a value repeatedly growing and shrinking between 0 and 100.
      • There are 1000 milliseconds in one second, but we need one second to be 100.
      • If doing 'timer % 100', the results returned will raise from 0 to 99, then immediatly fall back to 0 and raise again. [0, 1, 2, ..., 98, 99, 0, 1, 2, ...]
      The first issue is solved by floor-dividing timer by 10. The second issue is solved with two other tricks. First, we set the denominator to 201. This way the values returned will range from 0 to 200. Second, we make use of 'abs', which returns the absolute value of a number regardless of its sign (-4 and 4 both have the absolute value 4) The final expression now is: opacity = abs(100 - floor(Timer / 10) % 201) The returned values will be [100, 99, 98, ..., 2, 1, 0, 1, 2, ..., 98, 99, 100, 99, 98, ...] and every range 0-100 or 100-0 will last 1 second

    I just thought I explain it for those who are curious beginners. If it is inappropiate, I apologize.

  • You have two conditions on 6. Else means run if the tied condition is not met, so another condition saying not to run causes the error.

    Not necessarily, no. Something like this works fine:

    + n equals 6
    
    + else
       n equals 5
    
    + else
       n equals 4
    
    + else[/code:2uqm8xa8]
    
    But there is another possible problem. Are you trying to modulo divide by 0? That's not possible (although I expected Construct to catch such error)
  • Hmm, the message says "Cannot test...". So I would guess it has problems comparing the float Trail[CustomMovement].Speed against the int 1000

    Maybe just setting 1000.0 solves it? [Or int(Trail[CustomMovement].Speed), but then you're losing accuracy]

  • Yes.

    Just do the loop whenever you change the time scale.

  • This is one way. Assuming the player typed his/her name in "EditBox", then when clicked ok you could do this action:

    -> System: Save file AppPath & EditBox.Text & ".sav"[/code:2jvcl2jl]
    
    If the player typed "tulamide", then the file will be named "tulamide.sav" and stored in your app's folder. You may choose any extension you like, and you should make sure that the name typed conforms to the rules for file names (e.g. contains no backslash or colon)
tulamide's avatar

tulamide

Member since 11 Sep, 2009

Twitter
tulamide has 3 followers

Trophy Case

  • 15-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

17/44
How to earn trophies