|
-
Apr 27th, 2001, 05:22 PM
#1
Thread Starter
Hyperactive Member
A problem
Good evnin' layds and gents
Tonight, I want to relieve myself from my incridibly boring question. However, it goes a little something like this:
I am making a game, consisting of a man, and a dragon. I've declared 'Dragon' as an object with several properties, and a method called 'move' which I'm going to use with a timer. I also hav a regular module, just to keep me NOT confused. The only thing that makes this program unique is that you need to press a button in order to surprisingly be attacked by enemies. When you click the command button, an enemy appears, as a dragon, of course. But, my problem is...
NB. Just watch out cause a lot of variables is written in norwegian...
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This is inside the regular module
Public Sub GenDrage() '(GenDrage=Generate Dragon)
Dim Bkst(5) As String, Navn As String 'Bkst(short for 'Bokstaver', means letters(as in a, b or c, etc)
Dim Drag As New Drage 'Drage is my Class Module
Randomize 'Here, I will just give my animal a random name
For I = 0 To 5
Bkst(I) = Chr((Rnd * 25) + Asc("A"))
Next I
Navn = Bkst(0) & LCase(Bkst(1)) & LCase(Bkst(2)) & LCase(Bkst(3))_& LCase(Bkst(4)) & LCase(Bkst(5))
Drag.Name = Navn
frmBane.MonNavn.Caption = Drag.Name 'and here the naming bits end
With Drag
.Name = Navn
.Pic1 = "\drageh1.gif" 'it's supposed to be an animation...
.Pic2 = "\drageh2.gif"
.StartPosL = 360
.StartPosT = 360
.Speed = 120
.Speed = Int(Rnd * 5) + 1
.DestL = 9840
.DestT = 360
End With
Dim Monster1 As Image
Set Monster1 = frmBane.Img
With Monster1
.Picture = LoadPicture(App.Path & Drag.Pic1)
.Left = Drag.StartPosL
.Top = Drag.StartPosT
End With
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
I am making my 'Drag As New Drage' inside this sub, which means I can only use the variable 'Drag' within this procedure. However, It would be nice to be able to use that keyword in other subs...for example the Move Method I created...
HOW DO I DO IT? How can I declare my variabled 'Drag' and be able to use it in all the procedures I want? Or at least some of them...Dim Drag As New Drage
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
|