I've actually read some of that guide the other day. Its very good. Anyway, thanks for the help so far. Any other recommendations?
And honestly, the only things to really change in that guide would be that instead of making it:
Code: Select all
Sub MoveCharacter(ByVal MX As Integer, ByVal MY As Integer)
' this procedure moves the character
' MX, MY are the mouse x,y when the map(form)was clicked
' step 1, calculate map offset from the mouse x,y
' since we know all the squares are 50x50 pixels, calculate the actual
' X,Y on the form
ClickedMapX% = Int(MX / 50) + DisplayXOffset%
ClickedMapY% = Int(MY / 50) + DisplayYOffset%
' step 2 - since the hero only moves 1 square at a time, calculate
' the adjacient square to the hero
DirText$ = "The hero walks"
If ClickedMapY% > Char.Y Then DY% = 1: DirText$ = DirText$ + " south"
If ClickedMapY% < Char.Y Then DY% = -1: DirText$ = DirText$ + " north"
If ClickedMapX% > Char.X Then DX% = 1: DirText$ = DirText$ + " east"
If ClickedMapX% < Char.X Then DX% = -1: DirText$ = DirText$ + " west"
' step 3 - check to see if its a legal move
LegalMove = True
If Char.X + DX% < 1 Or Char.X + DX% > 100 Then LegalMove = False 'cant go off the map
If Char.Y + DY% < 1 Or Char.Y + DY% > 100 Then LegalMove = False 'cant go off the map
If LegalMove = True Then ' only check if inside map otherwise may crash
' check to see if the desired square is blocked
If Map(Char.X + DX%, Char.Y + DY%, Char.MapNo).Blocked = True Then LegalMove = False
' check to see if there is a monster on that square,
' if there is then call the Attack routine and exit so the hero doesn't attack ALL
' monsters in a square and doesn't actually move
For X% = 1 To Universe.TotMonsters
If Monster(X%).X = Char.X + DX% And Monster(X%).Y = Char.Y + DY% And Monster(X%).StrMax > 0 Then
Call Attack(1, X%) ' 1=hero attacking, X% = monster number being attacked
Exit Sub
End If
Next X%
End If
' step 4 - if its a legal move, erase the character
' by drawing the ground where the hero is
If LegalMove = True Then
Call DrawASquare(Char.X, Char.Y, 1, Map(Char.X, Char.Y, Char.MapNo).icon)
' now draw an object if it was in that square
For X% = 1 To Universe.TotObjects
If Item(X%).X = Char.X And Item(X%).Y = Char.Y Then Call DrawASquare(Item(X%).X, Item(X%).Y, 1, Item(X%).icon)
Next X%
' now draw a Monster if it was in that square
For X% = 1 To Universe.TotMonsters
If Monster(X%).X = Char.X And Monster(X%).Y = Char.Y And Monster(X%).StrMax > 0 Then Call DrawASquare(Monster(X%).X, Monster(X%).Y, 2, Monster(X%).icon)
Next X%
' step 5 - update the heros location
Char.X = Char.X + DX%
Char.Y = Char.Y + DY%
Call DisplayMessage(DirText$) ' display action in text window
' step 6 - check to see if hero went off the screen
NeedToRedraw% = False 'set flag
If Char.X - DisplayXOffset% < 1 Then NeedToRedraw% = True
If Char.Y - DisplayYOffset% < 1 Then NeedToRedraw% = True
If Char.X - DisplayXOffset% >= NoOfXSqrCanSee% - 1 Then NeedToRedraw% = True
If Char.Y - DisplayYOffset% >= NoOfYSqrCanSee% - 1 Then NeedToRedraw% = True
' step 7 - draw either just hero or whole screen
If NeedToRedraw% = True Then
Call DrawMap 'draw whole map
Else
Call DrawASquare(Char.X, Char.Y, 3, 0) ' just draw hero
Form1.Refresh
End If
Call HeroWalkedOnSquare ' check to see if something happened when walked on square
End If
End Sub
You would need to make the ClickedMapY/X code associated with WASD or the Directional buttons on the keyboard. Now of course it's not as simple as it sounds (or is it?) I have no idea, seeing as all the code we've done in and out of class deals with the user Clicking with the mouse. All i know is that to really get the Directional pad working, you'd need to edit Chapter 10 a bit.
Doing the HUD will not be too hard, and since this project has already got a working Monster Overworld Battle "System/Module" working, it'd be only a few hours of work to edit it into a basic Zelda Sword battle.
Anyway, I'm learning more everyday. Getting away from those silly Dragon Fight applications for once sure feels great
EDIT: I got a Zelda style game working right now. All i really need now is to make the HUD and add Variables and code for HP and eventually Magic tracking. Well, off I go. Guides still will help me. You can never learn too much
