Problem with rendering arrows

This is a weird problem because i just followed wabbits tutorial and converted it for EclipseVB2.2.

And now i have this to render:


' player Projectiles

Public Sub BltProjectile(ByVal Index As Long, ByVal PlayerProjectile As Long)

Dim x As Long, y As Long, PicNum As Long, i As Long

Dim rec As DxVBLib.RECT

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

' check for subscript error

If Index < 1 Or PlayerProjectile < 1 Or PlayerProjectile > MAX_PLAYER_PROJECTILES Then Exit Sub

' check to see if it's time to move the Projectile

If timeGetTime > Player(Index).ProjecTile(PlayerProjectile).TravelTime Then

	 With Player(Index).ProjecTile(PlayerProjectile)

		 ' set next travel time and the current position and then set the actual direction based on RMXP arrow tiles.

		 Select Case .Direction

			 ' down

			 Case 0

				 .y = .y + 1

				 ' check if they reached maxrange

				 If .y = (GetPlayerY(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub

			 ' up

			 Case 1

				 .y = .y - 1

				 ' check if they reached maxrange

				 If .y = (GetPlayerY(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub

			 ' right

			 Case 2

				 .x = .x + 1

				 ' check if they reached max range

				 If .x = (GetPlayerX(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub

			 ' left

			 Case 3

				 .x = .x - 1

				 ' check if they reached maxrange

				 If .x = (GetPlayerX(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub

		 End Select

		 .TravelTime = timeGetTime + .Speed

	 End With

End If

' set the x, y & pic values for future reference

x = Player(Index).ProjecTile(PlayerProjectile).x

y = Player(Index).ProjecTile(PlayerProjectile).y

PicNum = Player(Index).ProjecTile(PlayerProjectile).Pic

' check if left map

If x > Map.MaxX Or y > Map.MaxY Or x < 0 Or y < 0 Then

	 ClearProjectile Index, PlayerProjectile

	 Exit Sub

End If

' check if we hit a block

If Map.Tile(x, y).Type = TILE_TYPE_BLOCKED Then

	 ClearProjectile Index, PlayerProjectile

	 Exit Sub

End If

' check for player hit

For i = 1 To Player_HighIndex

	 If x = GetPlayerX(i) And y = GetPlayerY(i) Then

		 ' they're hit, remove it

		 If Not x = Player(MyIndex).x Or Not y = GetPlayerY(MyIndex) Then

			 ClearProjectile Index, PlayerProjectile

			 Exit Sub

		 End If

	 End If

Next

' check for npc hit

For i = 1 To MAX_MAP_NPCS

	 If x = MapNpc(i).x And y = MapNpc(i).y Then

		 ' they're hit, remove it

		 ClearProjectile Index, PlayerProjectile

		 Exit Sub

	 End If

Next

' if projectile is not loaded, load it, female dog.

If DDS_Projectile(PicNum) Is Nothing Then

	 Call InitDDSurf("animations\" & PicNum, DDSD_Projectile(PicNum), DDS_Projectile(PicNum))

End If

' get positioning in the texture

With rec

	 .top = 0

	 .Bottom = SIZE_Y

	 .Left = Player(Index).ProjecTile(PlayerProjectile).Direction * SIZE_X

	 .Right = .Left + SIZE_X

End With

' blt the projectile

Call Engine_BltFast(ConvertMapX(x * PIC_X), ConvertMapY(y * PIC_Y), DDS_Projectile(PicNum), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

' Error handler

Exit Sub

errorhandler:

HandleError "BltProjectile", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

But i don’t know whats wrong it says subscript out of range.

And i don’t know why (the image exists btw)

And btw it marks this:

If DDS_Projectile(PicNum) Is Nothing Then

And this is subscript out of range:

DDS_Projectile(PicNum)

Let me guess,

The DDS_Projectile is an array with LBound = 1 and UBound = the num of projectiles. And your telling VB6 to access an index of the array that is out of bounds. (ArrayIndexOutOfBoundsException)

TlDR:

Make sure PicNum is actually being passed a value that is within the bounds of the Array DDS_Projectile.

I completely followed wabbits tutorial i even checked everything i can’t find anything wrong :’(

And DDS_projectile is 47000 or something like that

And projectilenumber is 1

And the error is subscript out of range

So abhi for as far as i understand what you say i understand that my code is 100% correct

Could you link me to the tutorial?

Log in to reply