[gameprogrammer] Re: subscript out of range?
- From: "Chris Schnurr" <chris.schnurr@xxxxxxxxxx>
- To: <gameprogrammer@xxxxxxxxxxxxx>
- Date: Tue, 1 Feb 2005 15:50:23 -0000
couple of things I'd look for :
the for next loops above the one that fail , obvously work :-
so this line:
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Icon = 2
works for
range of X = 1 to 10
range of Y = 1 to 10
but the (almost) same line in the loop that fails does not work:
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).icon = 1
fails when X = 5 (X always is 5 for this loop?)
and Y1 range is 5 to 11
Whats the upper bounds on your Map (X,Y,Z) object?
And what is the value of X, Y, and Y1 when the error occurs ( Debug...Add
Watch )
C
-----Original Message-----
From: gameprogrammer-bounce@xxxxxxxxxxxxx
[mailto:gameprogrammer-bounce@xxxxxxxxxxxxx]On Behalf Of Daniel Greeson
Sent: 01 February 2005 15:36
To: gameprogrammer@xxxxxxxxxxxxx
Subject: [gameprogrammer] Re: subscript out of range?
Hey, first off I want to thank you and everyone else for being helpful it is
good to know that you have somewhere to go if you need help, very helpful
when just start out aswell and you are still green. The error actually
isn't in the new procedure that was added, it is a different procedure it
just appeared after i added the new one.
this is the procedure that the error occurs:
Sub FillMap()
' this routine fills the Map array with the data from the Room array
For X% = 0 To 9
For Y% = 0 To 9
If Room(X%, Y%).Visited = True Then 'make it a "room"
' first fill in center with "floor"
For X1% = 2 To 9
For Y1% = 2 To 9
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).icon = 1
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Blocked = False
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
Next X1%
' now make the surrounding walls
Thickness = Int(Rnd * 3) + 1
For X1% = 1 To 10 ' make "North" wall
For Y1% = 1 To Thickness
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).icon = 2
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Blocked = True
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
Next X1%
Thickness = Int(Rnd * 3) + 7
For X1% = 1 To 10 ' make "South" wall
For Y1% = Thickness To 10
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).icon = 2
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Blocked = True
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
Next X1%
For X1% = Int(Rnd * 3) + 7 To 10 ' make "East" wall
For Y1% = 1 To 10
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).icon = 2
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Blocked = True
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
Next X1%
For X1% = 1 To Int(Rnd * 3) + 1 ' make "West" wall
For Y1% = 1 To 10
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).icon = 2
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Blocked = True
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
Next X1%
' now cut out any "exits"
If Room(X%, Y%).NorthExit = True Then ' there is a north exit
For Y1% = 1 To 5 ' draw exit north
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).icon = 1
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).Blocked = False
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
End If
If Room(X%, Y%).SouthExit = True Then ' there is a south exit
For Y1% = 5 To 10 ' draw exit south
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).icon = 1
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).Blocked = False
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
End If
If Room(X%, Y%).EastExit = True Then ' there is a east exit
For X1% = 5 To 10 ' draw exit east
Map(X% * 10 + X1%, Y% * 10 + 5, 2).icon = 1
Map(X% * 10 + X1%, Y% * 10 + 5, 2).Blocked = False
Map(X% * 10 + X1%, Y% * 10 + 5, 2).Visible = False
Next X1%
End If
If Room(X%, Y%).WestExit = True Then ' there is a west exit
For X1% = 1 To 5 ' draw exit east
Map(X% * 10 + X1%, Y% * 10 + 5, 2).icon = 1
Map(X% * 10 + X1%, Y% * 10 + 5, 2).Blocked = False
Map(X% * 10 + X1%, Y% * 10 + 5, 2).Visible = False
Next X1%
End If
Else ' not used, fill with "walls"
For X1% = 1 To 10
For Y1% = 1 To 10
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).icon = 2
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Blocked = True
Map(X% * 10 + X1%, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
Next X1%
End If
Next Y%
Next X%
' force an entrance to the dungeon!
X% = 5 ' starting square
Y% = 9
For Y1% = 5 To 11 ' draw exit south
the error happens on this line =>Map(X% * 10 + 5, Y% * 10 + Y1%, 2).icon = 1
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).Blocked = False
Map(X% * 10 + 5, Y% * 10 + Y1%, 2).Visible = False
Next Y1%
End Sub
hopefully that is enough if not let me know and again I can supply whatever
is needed.
thanks,
~Draven~
Evan Stone <recombinantstudios@xxxxxxxxxxx> wrote:
> I am using VB ver. 5 I believe, what parts would you like to see and i can
supply them.
OK... how about the part that you're getting the error in:
When you get an error while running in the VB5 IDE it should show you where
the problem is, so you might want to post that part.
I presume it's the "graphics portion" you mention in your original message:
> I am having a problem I keep getting a subscript
> out of range error. I just added a graphics portion
> to my source code and this error is popping up I
> was wondering if anyone could give me some
> information about this error.
-Evan
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
---------------------------------
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Re: subscript out of range?
- From: Daniel Greeson
Other related posts:
- » [gameprogrammer] subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- [gameprogrammer] Re: subscript out of range?
- From: Daniel Greeson