|
-
Dec 4th, 2001, 08:18 PM
#1
Thread Starter
Fanatic Member
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.
-
Dec 4th, 2001, 09:52 PM
#2
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.
-
Dec 5th, 2001, 07:13 PM
#3
Thread Starter
Fanatic Member
no one wanna help me on this one then?
-
Dec 7th, 2001, 09:37 PM
#4
Thread Starter
Fanatic Member
-
Dec 9th, 2001, 12:54 PM
#5
Frenzied Member
Well, it would be better if you posted the source code here
-
Dec 9th, 2001, 09:46 PM
#6
Thread Starter
Fanatic Member
-
Dec 11th, 2001, 06:49 PM
#7
Frenzied Member
Yeah, in a ZIP, it would be much easier to debug
-
Dec 11th, 2001, 07:20 PM
#8
Banned
-
Dec 19th, 2001, 10:25 AM
#9
Thread Starter
Fanatic Member
okay
will post it 2nite when I'm next online from my pc where I work on vb stuff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|