Menu

CurState

2004-12-12
2012-12-25
  • Nobody/Anonymous

    What are the values of .CurState?
    ex. 0(left drifting) 1(right drifting) etc..
    thank you

    -Cole

     
    • Benjamin Marty

      Benjamin Marty - 2004-12-13

      The states are numbered from 0 upward in the exact same order in which they appear in the combo box on the sprites dialog.  For example, an 8-state sprite goes like this:

      0 = Up
      1 = Up+Right
      2 = Right
      3 = Down+Right
      4 = Down
      5 = Down+Left
      6 = Left
      7 = Up+Left
      (and if there are separate drifting states)
      8 = Up Drifting
      9 = Up+Right Drifting
      10 = Right Drifting
      11 = Down+Right Drifting
      12 = Down Drifting
      13 = Down+Left Drifting
      14 = Left Drifting
      15 = Up+Left Drifting

       
    • Benjamin Marty

      Benjamin Marty - 2004-12-13

      Sorry, I had the drifting backwards.  The first states are drifting and the last states are accelerating.

       
    • Nobody/Anonymous

      thank you, i had a shield follow my character and i used .CurState but I was basing it on like jsut a left right state....that i selected for my character. Then i went from 0-4 for drifing and accelerating in order they are listed when you select them in the gamedev enviroment. Thats where i went wrong..
      Thanks again that has helped me alot.
      -Cole

       
    • Nobody/Anonymous

      ok....i have a game where the shield follows the player sprite. The shield has two states left and right. I want the shield to go into the right state when the player goes into the right drifitng or right accelerating state. Vice Versa. So here what i have or something....

      Sub Player_OnBeforeSpritesMove()
      With ProjectObj.GamePlayer.PlayerSprite
      If .CurState = 1 or 2 or 3 or 9 or 10 or 11 Then
      ShieldSpr.CurState = 2
      ShieldSpr.X = .X + 30: ShieldSpr.Y = .Y + 10
      End If

      'I did the same If-Then conditional for the left
      'state but used 5,6,7,13,14,15 instead. And of
      'course i lined up the shield differently...

      'The 2nd to last line is nothing more than to line up
      'the shield with the sprite when its in the right
      'state properly.

      If you could give me some advice as to why its not working..that would be helpful...

      -Cole

       
    • Ed

      Ed - 2004-12-18

      If the following line is directly copied from the script, then it's wrong.

      If .CurState = 1 or 2 or 3 or 9 or 10 or 11 Then

      That's basically testing to see whether (.CurState = 1) is true, or 2 is true, or 3 is true, or 9 is true, or 10 is true, or 11 is true.  Since all of these numbers are not zero, it will always evaluate to true.

      What you need to do is check each on individually, like this:

      If .CurState = 1 or .CurState = 2 or .CurState = 3 or .CurState = 9 or .CurState = 10 or .CurState = 11 Then

      Alternately, you could do this:

      Select Case .CurState
      Case 1 to 3, 9 to 11
         ShieldSpr.CurState = 2
         ShieldSpr.X = .X + 30: ShieldSpr.Y = .Y + 10
      End Select

       
    • Ed

      Ed - 2004-12-18

      Oh, or you could do the If statement like this:

      If (.CurState >= 1 And .CurState <= 3) Or (.CurState >=9 And .CurState <= 11) then

      Which way you do it is up to you really.

       
    • Ed

      Ed - 2004-12-18

      Or

      If Int(.CurState / 4) = 0 Or Int(.CurState / 4) = 2 And .CurState <> 0 And .CurState != 8 Then

      Of course, now I'm just being silly.  This method would be rather slow.  As you can see anyway, there are many ways to do it, and the way you chose was, unfortunately, not one of them :P

       
    • Ed

      Ed - 2004-12-18

      Sorry, one more:

      If Int((.CurState - 1) / 3) = 0 or Int(.CurState / 3) = 3 Then

       
    • Nobody/Anonymous

      Oh ok! Thank you. I didnt realize that. This is my first game and first time with VBScript. Im used to BASIC that I have been taking a class on, so its just a little bit different. Thank you very much.

       
    • Benjamin Marty

      Benjamin Marty - 2004-12-21

      Well, hopefully you will realize that even in BASIC you cant use the syntax you were using.  What Ed said about testing the expressions versus testing the numbers is true for VBScript and Visual Basic and all other forms of BASIC I know of.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.