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.