View
previous topic :: View
next topic |
Author |
Message |
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Sun May 28,
2006 2:19 pm
Post subject: Diagonal Movement |
|
|
Diagonal Movement
Made by
pingu
That's right, suck it bitches. I
spent most of today getting it to work, but I think I
spent more time writing the actual text below than I
spent coding.
I suggest you do this if you know
how to code, because I might of missed a few simple
things. I'd test it on a blank copy, but it's too long
for me right now. I already spent enough of my time.
However, if others seem to have it working, you should
then try it.
Please, post any errors you may get
while doing this tutorial.
Keep this tutorial on
ES.
Tutorial Difficulty:
5/5 Concept
Difficulty: 2/5
All Client
Side
------
Find:
Code: |
MaxSP As Long
XOffset As Integer
YOffset As Integer Moving
As Byte |
Replace With:
Code: |
MaxSP As Long
XOffset As Integer
YOffset As Integer
MovingH As Integer MovingV As
Integer |
------
Find:
Code: |
Sub
ProcessMovement |
Replace With:
Code: |
Sub ProcessMovement(ByVal
Index As Long) If
GetPlayerAccess(Index) > 0 Then
If Player(Index).MovingV
<> 0 Then Player(Index).YOffset =
Player(Index).YOffset +
(GM_WALK_SPEED *
Player(Index).MovingV)
If Player(Index).MovingH <> 0 Then
Player(Index).XOffset = Player(Index).XOffset +
(GM_WALK_SPEED * Player(Index).MovingH)
Else
If Player(Index).MovingV <> 0 Then
Player(Index).YOffset = Player(Index).YOffset +
(WALK_SPEED * Player(Index).MovingV)
If
Player(Index).MovingH <> 0 Then
Player(Index).XOffset = Player(Index).XOffset +
(WALK_SPEED * Player(Index).MovingH)
End If
' Check if completed walking
over to the next tile If
Player(Index).XOffset = 0 Then
Player(Index).MovingH = 0
End If If
Player(Index).YOffset = 0 Then
Player(Index).MovingV = 0
End If End Sub |
------
Find:
Replace Whole Sub With:
Code: |
Sub CheckInput(ByVal
KeyState As Byte, ByVal KeyCode As Integer, ByVal
Shift As Integer) If GettingMap
= False Then If
KeyState = 1 Then
If KeyCode = vbKeyReturn Then
Call CheckMapGetItem
End If
If
KeyCode = vbKeyControl Then
ControlDown = True
End If
If KeyCode = vbKeyUp Then
DirUp = True
DirDown
= False
End If
If KeyCode = vbKeyDown Then
DirUp = False
DirDown
= True
End If
If KeyCode = vbKeyLeft Then
DirLeft = True
DirRight
= False
End If
If KeyCode = vbKeyRight Then
DirLeft = False
DirRight
= True
End If
If KeyCode = vbKeyShift Then
ShiftDown = True
End If
Else
If KeyCode = vbKeyUp Then
DirUp = False
DirDown
= False
End If
If KeyCode = vbKeyDown Then
DirUp = False
DirDown
= False
End If
If KeyCode = vbKeyLeft Then
DirRight = False
DirLeft
= False
End If
If KeyCode = vbKeyRight Then
DirRight = False
DirLeft
= False
End If
If KeyCode = vbKeyShift Then
ShiftDown = False
If KeyCode = vbKeyControl Then
ControlDown = False
End If End If End
Sub |
------
Find:
Code: |
' Make sure
they aren't trying to move when they are already
moving If Player(MyIndex).Moving
<> 0 Then
CanMove = False
Exit Function End
If |
Replace With:
Code: |
' Make sure
they aren't trying to move when they are already
moving If
Player(MyIndex).MovingH <> 0 And
Player(MyIndex).MovingV <> 0 Then
CanMove = False
Exit Function
End If |
------
Find:
Under, Add:
Code: |
If Player(MyIndex).MovingV <> 0 Then
CanMove = False
Exit Function
End If |
------
Find:
Code: |
Else
' Check if they can warp to a new map
If
Map(GetPlayerMap(MyIndex)).Up > 0 Then
Call SendPlayerRequestNewMap
GettingMap = True
End If
CanMove = False
Exit
Function End
If |
Under, Add:
------
Find:
Under, Add:
Code: |
If Player(MyIndex).MovingV <> 0 Then
CanMove = False
Exit Function
End If |
------
Find:
Code: |
Else
' Check if they can warp to a new map
If
Map(GetPlayerMap(MyIndex)).Down > 0 Then
Call SendPlayerRequestNewMap
GettingMap = True
End If
CanMove = False
Exit
Function End
If |
Under, Add:
------
Find:
Under, Add:
Code: |
If Player(MyIndex).MovingH <> 0 Then
CanMove = False
Exit Function
End If |
------
Find:
Code: |
Else
' Check if they can warp to a new map
If
Map(GetPlayerMap(MyIndex)).Left > 0 Then
Call SendPlayerRequestNewMap
GettingMap = True
End If
CanMove = False
Exit
Function End
If |
Under, Add:
------
Find:
Under, Add:
Code: |
If Player(MyIndex).MovingH <> 0 Then
CanMove = False
Exit Function
End If |
------
Find:
Code: |
Else
' Check if they can warp to a new map
If
Map(GetPlayerMap(MyIndex)).Right > 0 Then
Call SendPlayerRequestNewMap
GettingMap = True
End If
CanMove = False
Exit
Function End
If |
Under, Add:
------
Find:
Code: |
If (Parse(0) =
"playermove") Then |
Replace the whole if statement
with:
Code: |
If (Parse(0) =
"playermove") Then
I = Val(Parse(1))
x = Val(Parse(2))
y = Val(Parse(3))
Direction = Val(Parse(4))
n = Val(Parse(5))
If Direction < DIR_UP Or
Direction > DIR_RIGHT Then Exit Sub
Call
SetPlayerX(I, x)
Call SetPlayerY(I, y)
Call SetPlayerDir(I, Direction)
Select Case GetPlayerDir(I)
Case DIR_UP
Player(I).YOffset = PIC_Y
Player(I).MovingV = -n
Case DIR_DOWN
Player(I).YOffset = PIC_Y * -1
Player(I).MovingV = n
Case DIR_LEFT
Player(I).XOffset = PIC_X
Player(I).MovingH = -n
Case DIR_RIGHT
Player(I).XOffset = PIC_X * -1
Player(I).MovingH = n
End Select
Exit Sub End
If |
------
Find:
Code: |
Sub
SendPlayerMove() |
Replace Whole Sub With:
Code: |
Sub SendPlayerMove() Dim
Packet As String If
GetPlayerDir(MyIndex) = DIR_LEFT Or
GetPlayerDir(MyIndex) = DIR_RIGHT Then
Packet = "playermove" &
SEP_CHAR & GetPlayerDir(MyIndex) &
SEP_CHAR &
Abs(Player(MyIndex).MovingH) &
SEP_CHAR & END_CHAR Else
Packet =
"playermove" & SEP_CHAR &
GetPlayerDir(MyIndex) & SEP_CHAR &
Abs(Player(MyIndex).MovingV) &
SEP_CHAR & END_CHAR End If
Call SendData(Packet) End
Sub |
------
Find (there are two, do
both):
Code: |
If Player(MyIndex).Moving =
0 Then |
Replace With:
Code: |
If Player(MyIndex).MovingH =
0 And Player(MyIndex).MovingV = 0
Then |
------
Find:
Code: |
If Player(MyIndex).Moving =
NO Then |
Replace With:
Code: |
If Player(MyIndex).MovingH =
NO And Player(MyIndex).MovingV = NO
Then |
------
Find:
Code: |
Player(Index).YOffset = 0
Player(Index).Moving = 0 |
Replace With:
Code: |
Player(Index).YOffset = 0
Player(Index).MovingH = 0
Player(Index).MovingV = 0 |
------
Find:
Code: |
' Speed moving vars
Public Const WALK_SPEED = 4 Public Const
RUN_SPEED = 8 Public Const GM_WALK_SPEED = 4
Public Const GM_RUN_SPEED = 8 'Set the
variable to your desire, '32 is a safe and
recommended setting |
Replace With:
Code: |
' Speed moving vars
Public Const WALK_SPEED = 4 Public Const
GM_WALK_SPEED = 4 |
------
Find (there are two, do
both):
Code: |
GetPlayerDir(Index) =
DIR_DOWN And Player(Index).Moving >
0 |
Replace With:
Code: |
GetPlayerDir(Index) =
DIR_DOWN And Player(Index).MovingV <>
0 |
------
Find (make sure you do the
step above first) (there are four of these, do
all):
Code: |
Player(Index).Moving >
0 |
Replace With:
Code: |
Player(Index).MovingH
<> 0 |
------
(fix some error I
found, unrelated) Find:
Code: |
' Make sure they aren't walking
Player(I).Moving = 0
Player(I).XOffset = 0
Player(I).YOffset
= 0
' Make sure their pet isn't
walking
Player(I).Pet.Moving = 0
Player(I).Pet.XOffset = 0
Player(I).Pet.YOffset =
0 |
Replace With:
Code: |
' Make sure their pet isn't walking
Player(I).Pet.Moving = 0
Player(I).Pet.XOffset = 0
Player(I).Pet.YOffset =
0 |
------
Find (there are a few, make
sure you do the above first):
Code: |
Player(I).Moving =
0 |
Replace With:
Code: |
Player(I).MovingH = 0
Player(I).MovingV = 0 |
------
Find:
Replace whole sub with:
Code: |
Sub CheckMovement()
If GettingMap = False Then
If IsTryingToMove
Then
If CanMove Then
Select Case
GetPlayerDir(MyIndex)
Case DIR_UP
If ShiftDown Then
Player(MyIndex).MovingV =
-MOVING_RUNNING
Else
Player(MyIndex).MovingV =
-MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).YOffset =
PIC_Y
Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)
Case
DIR_DOWN
If ShiftDown Then
Player(MyIndex).MovingV =
MOVING_RUNNING
Else
Player(MyIndex).MovingV =
MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).YOffset =
PIC_Y * -1
Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)
Case
DIR_LEFT
If ShiftDown Then
Player(MyIndex).MovingH =
-MOVING_RUNNING
Else
Player(MyIndex).MovingH =
-MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).XOffset =
PIC_X
Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)
Case
DIR_RIGHT
If ShiftDown Then
Player(MyIndex).MovingH =
MOVING_RUNNING
Else
Player(MyIndex).MovingH =
MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).XOffset =
PIC_X * -1
Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)
End Select
' Gotta check
:)
If
Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex),
GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP Then
GettingMap = True
End If
End If
End If End If
End Sub |
Did I win
yet? _________________
Last edited
by pingu on Wed May 31, 2006 7:31 am; edited 1 time in
total | |
Back
to top |
|
|
DELTA Jr. Member
Joined: 30 Apr 2006 Posts:
60
Points
|
Posted: Sun May 28,
2006 4:14 pm
Post subject: |
|
|
screenies?I cant add
this in because I dont have vb so can you show us a
screenie? _________________
[url=http://splamm.com/elysium/forums/viewtopic.php?t=3233]
[/url] | |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Sun May 28,
2006 4:40 pm
Post subject: |
|
|
It allows you to move
up/down and left/right at the same time. You kind of
curve around when walking and it makes it more
realistic. Instead of just walking one tile forward in
one direction, you can walk a tile forward in one
direction and a tile forward in another direction. You
don't need to do both at once, so it creates a cool
effect.
Somebody tell me if you get it working.
It's huge, so I might have messed
up. _________________
| |
Back
to top |
|
Damien Sr. Member
Joined: 24 Feb 2006 Posts:
673
Points
|
Posted: Sun May 28,
2006 4:43 pm
Post subject: |
|
|
Let me break it down
what pingu is trying to say... You ever seen the matrix?
It’s like creating all your characters into lil neos...
all his super shifty moves rolled into 1! aww I had to say that... I am joking
kidos! | |
Back
to top |
|
BeNjO Sr. Member
Joined: 28 May
2006 Posts: 418 Location:
York Points
|
Posted: Mon May 29,
2006 5:06 pm
Post subject: |
|
|
hmm i followd your
Very long tut and as i got to over half way i couldnt
find 2 parts i had to replace ( sorry i forgot wich ) so
overall the code didnt work and it just kept on giving
my code errors about moving. might need to recheck it
pingu
Ben _________________
| |
Back
to top |
|
mateo Newcomer
Joined: 09 Apr
2006 Posts: 16 Location:
london Points
|
Posted: Mon May 29,
2006 5:15 pm
Post subject: |
|
|
Quote: |
Find (make sure you do
the step above first) (there are four of these, do
all):
Code: |
Player(Index).Moving >
0 | |
I cant find this
!!! _________________ Cilck | |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Mon May 29,
2006 5:19 pm
Post subject: |
|
|
There are two in the
BltPlayer sub and there are two in the BltPlayerTop sub.
Look for the part that has "DIR_LEFT" or
"DIR_RIGHT" as part of the if
statement. _________________
| |
Back
to top |
|
mateo Newcomer
Joined: 09 Apr
2006 Posts: 16 Location:
london Points
|
Posted: Tue May 30,
2006 5:29 am
Post subject: |
|
|
OK i found them and
added everything on the top and i tryed to fix the
errors below to make it work. tell me if i fixed them
right and hwo to fix the last error.
[Edit] I think there needs to be some
server side codeing[/edit] _________________ Cilck | |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Tue May 30,
2006 2:18 pm
Post subject: |
|
|
For the first
problem...
Find
(there are a
few, make sure you do the above first):
Code: |
Player(I).Moving =
0 |
Replace With:
Code: |
Player(I).MovingH = 0
Player(I).MovingV = 0 |
You just didn't read properly.
For the second problem, I forgot to post the
code for that sub. I'll post it when I can
(soon). _________________
| |
Back
to top |
|
William Member
Joined: 23 Feb 2006 Posts:
198
Points
|
Posted: Tue May 30,
2006 2:51 pm
Post subject: |
|
|
Wow, very nice Pingu,
I was struggeling with this some weeks back. And I just
got this massive errors because you could walk out of
the screens and such =/.
But thanks, this is
very usefull _________________ Phoenix Engine: www.key2heaven.net/phoenix
pingu
wrote: |
I kind of suggest you make
sure it works for Diamond before throwing it out
there for all types of noobs to mess up their
programs with. | | |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Wed May 31,
2006 7:30 am
Post subject: |
|
|
Thing I forgot to
add.
Find:
Replace whole sub with:
Code: |
Sub CheckMovement()
If GettingMap = False Then
If IsTryingToMove
Then
If CanMove Then
Select Case
GetPlayerDir(MyIndex)
Case DIR_UP
If ShiftDown Then
Player(MyIndex).MovingV =
-MOVING_RUNNING
Else
Player(MyIndex).MovingV =
-MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).YOffset =
PIC_Y
Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)
Case
DIR_DOWN
If ShiftDown Then
Player(MyIndex).MovingV =
MOVING_RUNNING
Else
Player(MyIndex).MovingV =
MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).YOffset =
PIC_Y * -1
Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)
Case
DIR_LEFT
If ShiftDown Then
Player(MyIndex).MovingH =
-MOVING_RUNNING
Else
Player(MyIndex).MovingH =
-MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).XOffset =
PIC_X
Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)
Case
DIR_RIGHT
If ShiftDown Then
Player(MyIndex).MovingH =
MOVING_RUNNING
Else
Player(MyIndex).MovingH =
MOVING_WALKING
End If
Call SendPlayerMove
Player(MyIndex).XOffset =
PIC_X * -1
Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)
End Select
' Gotta check
:)
If
Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex),
GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP Then
GettingMap = True
End If
End If
End If End If
End Sub | _________________
| |
Back
to top |
|
William Member
Joined: 23 Feb 2006 Posts:
198
Points
|
Posted: Wed May 31,
2006 8:26 am
Post subject: |
|
|
I havnt checked the
code somuch yet, but it should work fine for a MS source
with some modifications? _________________ Phoenix Engine: www.key2heaven.net/phoenix
pingu
wrote: |
I kind of suggest you make
sure it works for Diamond before throwing it out
there for all types of noobs to mess up their
programs with. | | |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Wed May 31,
2006 8:28 am
Post subject: |
|
|
You'll have to skip a
bunch of steps and edit it to work with
MS. _________________
| |
Back
to top |
|
William Member
Joined: 23 Feb 2006 Posts:
198
Points
|
Posted: Wed May 31,
2006 9:23 am
Post subject: |
|
|
Okay, cant be that
hard thought. Thanks _________________ Phoenix Engine: www.key2heaven.net/phoenix
pingu
wrote: |
I kind of suggest you make
sure it works for Diamond before throwing it out
there for all types of noobs to mess up their
programs with. | | |
Back
to top |
|
BeNjO Sr. Member
Joined: 28 May
2006 Posts: 418 Location:
York Points
|
Posted: Wed May 31,
2006 7:24 pm
Post subject: |
|
|
hey iv done the code
into my source, and it says "Run Time Error 6" "Over
Flow"
i click Debug and it high lights
Code: |
Sub SetPlayerY(ByVal Index
As Long, ByVal y As Long)
Player(Index).y = y <-- this part
End Sub |
the game actually loads but when
i try and move any drection it says overflow, any ideas?
Ben _________________
| |
Back
to top |
|
|
|