0

i got this code in the some video and made some few adjustment,
one of it is the size of the pixel or the drawings and the size of the tile/grid or map
i wish to use..... But it looks like i need to do more adjustment unlike following the one i am trying to copy because the size of his map and drawings are different for mine.
This is one of the machine problem and i dont know what is wrong with the following codes...

Dim tile(25, 25)    '0= clearspace 1=walsides 2= pellets 3= superpellets
Dim tileH(25, 25)   'horizontal graphics
Dim tileV(25, 25)   'vetical graphics

Dim h       'horizontal grid
Dim v       'vertical grid
Dim dir     'directions 1=right 2=down 3=left 4=up
Dim dir2    ' will unable other keys
Dim ani

Dim animate     'pacdrawings 0-3
Dim ghosth(4)
Dim ghostv(4)
Dim ghostdir(4)
Dim ghostanimate(4)
Dim ghoststatus(4)     ' 0=dead 1=alive

Dim score
Dim selectedh
Dim selectedv

Dim dying   '0=alive  @=dead animations
Dim starting    'countdown till ghost move
Dim super   'count till not supermode anymore


Private Sub Form_Load()
h = 13
v = 19
dir = 2
dir2 = 2 'desired destination
animation = 0 ' animation

picPacman.Width = 25 * 25 ' map size
picPacman.Height = 25 * 25
For ht = 1 To 25   'Hgraphic is height
For wd = 1 To 25     ' Wgraphic width
tile(ht, wd) = 0
tileH(ht, wd) = 1
tileV(ht, wd) = 0
Next wd
Next ht

Open "map.text" For Input As #1
For ht = 1 To 25   'Hgraphic is height
For wd = 1 To 25     ' Wgraphic width
Input #1, tile(ht, wd)
Input #1, tileH(ht, wd)
Input #1, tileV(ht, wd)
Next wd
Next ht
Close #1

tile(1, 10) = 0
tile(2, 10) = 0
tile(3, 10) = 0
tile(23, 10) = 0
tile(24, 10) = 0
tile(25, 10) = 0

End Sub

Public Sub Graphicscreen()
For ht = 1 To 25
For wd = 1 To 25
Call Graphictile(ht, wd)
Next wd
Next ht
End Sub

Public Sub Graphictile(ht, wd)
Call picPacman.PaintPicture(picDraw.Image, (ht - 1) * 25, (wd - 1) * 25, 25, 25, tileH(ht, wd) * 25, tileV(ht, wd) * 25, 25, 25)
If ht = selectedh And wd = selectedv Then
    picPacman.Line ((ht - 1) * 25, (wd - 1) * 25)-((ht) * 25, (wd) * 25), , B  ' will make a Box  when you select object
End If
End Sub

Private Sub OsenXPButton1_Click()
End
For ht = 1 To 25
For wd = 1 To 25
If tileH(ht, wd) = 1 And tileV(ht, wd) = 0 Then tile(ht, wd) = 0
Next wd
Next ht

Open "map.text" For Output As #1
For ht = 1 To 25   'Hgraphic is height
For wd = 1 To 25     ' Wgraphic width
Print #1, tile(ht, wd)
Print #1, tileH(ht, wd)
Print #1, tileV(ht, wd)
Next wd
Next ht
Close #1



End Sub

Private Sub picDraw_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
tileH(selectedh, selectedv) = Int(X / 25)
tileV(selectedh, selectedv) = Int(Y / 25)
tile(selectedh, selectedv) = 1 ' will draw the tile on the main grid when u click item in picdraw
Call Graphictile(selectedh, selectedv)
End Sub

Private Sub picPacman_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 37 Then dir2 = 3 '37 left arrow key
If KeyCode = 38 Then dir2 = 4    '38 up
If KeyCode = 39 Then dir2 = 1    '39 right
If KeyCode = 40 Then dir = 2   ' 40 down
End Sub

Private Sub picPacman_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
selectedh = Int(X / 25) + 1
selectedv = Int(Y / 25) + 1
Call Graphicscreen
End Sub

Private Sub picPacman_Paint()
Call Graphicscreen
End Sub

Private Sub Timer1_Timer()
'this will make the animation of pacman, opening and closing its mouth
animate = animate + 1
If animate = 4 Then animate = 0

'directions 1=right 2=down 3=left 4=up
If animate = 0 And dir = 1 Then h = h + 1
If animate = 0 And dir = 2 Then v = v + 1
If animate = 0 And dir = 3 Then h = h - 1
If animate = 0 And dir = 4 Then v = v - 1
If animate = 0 Then
    If dir2 = 1 And tile(h + 1, v) <> 1 Then dir = dir2
    If dir2 = 2 And tile(h, v + 1) <> 1 Then dir = dir2
    If dir2 = 3 And tile(h - 1, v) <> 1 Then dir = dir2
    If dir2 = 4 And tile(h, v - 1) <> 1 Then dir = dir2
End If
If animate = 0 Then
    If dir = 1 And tile(h + 1, v) = 1 Then
       If tile(h, v - 1) <> 1 Then dir = 4: dir2 = dir Else d = 2: dir2 = dir
    End If
    If dir = 3 And tile(h - 1, v) = 1 Then
        If tile(h - 1, v) <> 1 Then dir = 4: dir2 = dir Else d = 2: dir2 = dir
    End If
    If dir = 2 And tile(h, v + 1) = 1 Then
        If tile(h, v - 1) <> 1 Then dir = 3: dir2 = dir Else d = 1: dir2 = dir
    End If
    If dir = 4 And tile(h, v - 1) = 1 Then
        If tile(h - 1, v) <> 1 Then dir = 3: dir2 = dir Else d = 1: dir2 = dir
    End If
End If

Call Graphictile(h, v)
' changes the position of pacman
Call Graphictile(h, v)
If dir = 4 Then Call Graphictile(h, v - 1)
If dir = 2 Then Call Graphictile(h, v + 1)
If dir = 1 Then Call Graphictile(h - 1, v)
If dir = 3 Then Call Graphictile(h + 1, v)
If dir = 1 Then Call picPacman.PaintPicture(picDraw.Image, ((h - 1) * 25) + (animate * 6.25), ((v - 1) * 25), 25, 25, (dir - 1) * 25, (2 + animate) * 25, 25, 25)
If dir = 2 Then Call picPacman.PaintPicture(picDraw.Image, ((h - 1) * 25), ((v - 1) * 25) + (animate * 6.25), 25, 25, (dir - 1) * 25, (2 + animate) * 25, 25, 25)
If dir = 3 Then Call picPacman.PaintPicture(picDraw.Image, ((h - 1) * 25) - (animate * 6.25), ((v - 1) * 25), 25, 25, (dir - 1) * 25, (2 + animate) * 25, 25, 25)
If dir = 4 Then Call picPacman.PaintPicture(picDraw.Image, ((h - 1) * 25), ((v - 1) * 25) - (animate * 6.25), 25, 25, (dir - 1) * 25, (2 + animate) * 25, 25, 25)

End Sub

Im still half way before i finish the code.... I wish someone would help me figure this things out a.s.a.p. Thanks to all. God bless.

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jasneg
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.