Results 1 to 9 of 9

Thread: Passing a variable you don't understand.

  1. #1

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    Unhappy Passing a variable you don't understand.

    Ok now I'v come unstuck.

    My usuall learning method is think of an idea then search untill you have learned sufficient to have a good go at it.

    The problem is I've split up a sub from an example code and created 3 subs out of it.

    But I don't know what the STATIC is and does, my brillient wheeze has turned into a night mare because I don't know how to comunicate this local variable to the other three subs

    VB politly informs me static is only allowed locally in a sub

    Code:
    Private Sub MoveLR(LR As Integer)
    'Modify the positions.
      X = (X Mod ABBAckWidth) + 1   'static background moveing speed
      XBack1 = (XBack1 Mod Back1Width) + 5 ' moveing background
      XFore = (XFore Mod ForeWidth) + 25 'foreground
       
    End Sub
    
    Private Sub UpDateKeys()
    Dim n As Integer
    If CheckRightKey Then n = 1
    If CheckLeftKey Then n = -1
    
    MoveLR (n)
    End Sub
    
    Private Sub gameloop()
    Const TickDifference As Long = 1
    'this will use the mesured ticks technique.
    Static X As Long, XBack1 As Long, XFore As Long
    Dim GlueWidth As Long, EndScroll As Long
    
    LastTick = GetTickCount()
    Do
        
        CurrentTick = GetTickCount()
           
        If CurrentTick - LastTick > TickDifference Then
            Update keys
            Me.Cls
            'do stuff
            
            LastTick = GetTickCount()    'reset tick
            
             
                
       
            'Draw the absolute background
            If X + ScrollWidth > ABBAckWidth Then
               GlueWidth = X + ScrollWidth - ABBAckWidth
               EndScroll = ScrollWidth - GlueWidth
        
    
    etc...
            
            
        ...end ifs
           Else
            
            'Don't do anything
            
        End If
        
        DoEvents
        
    Loop Until IsEscapePressed
    
    End Sub
    I've sliced out the bulk of the code because I know that it all works. It's the variables that are bothering me. My main problem is that I've never come across one of them (STATIC) ever before.
    ?
    'What's this bit for anyway?
    For Jono

  2. #2
    Zaei
    Guest
    You can also do:
    Code:
    Private Num as Long
    At the top of a private module. I dont see that much (dont know why, its what I use =). It's just like Dim inside of a module.

    Z.

  3. #3

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    no one wanna help me on this one then?

  4. #4

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    *wistles tunelessly*

  5. #5
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Well, it would be better if you posted the source code here
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  6. #6

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    wot all of it?

  7. #7
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Yeah, in a ZIP, it would be much easier to debug
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  8. #8
    Banned Motxopro's Avatar
    Join Date
    Dec 2001
    Posts
    57
    yeah he's right

  9. #9

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    okay

    will post it 2nite when I'm next online from my pc where I work on vb stuff
    ?
    'What's this bit for anyway?
    For Jono

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width