View
previous topic :: View
next topic |
Author |
Message |
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Mon Jun 19,
2006 8:54 am
Post subject: Click to Move |
|
|
Click to Move Made by pingu
It has come to my attention that posting all
these tutorials is making you stupider. So, this is
going to be my first "figure-it-out-yourself" tutorial.
You actually have to think and I won't do it for you.
Many people have requested this since I took it
out of Diamond. You'll have to work to get it going.
Difficulty:
3/5 OMG! YOU HAVE TO THINK! Other than that,
it's EXTREMELY simple.
I'm doing this on a
highly modified source with multiple things added
already, namely directional movement. THAT MEANS THAT
THE CODE MAY NOT WORK FOR YOU AS I HAVE POSTED! You need
to figure it out yourself.
----------
Client Side
Only
----------
Find:
Code: |
Public MouseX As Long
Public MouseY As Long |
Under, add:
Code: |
Public XToGo As Long
Public YToGo As Long |
----------
Find:
Under, add:
Code: |
XToGo = -1
YToGo = -1 |
----------
Find:
Code: |
If (Button = 1 Or Button =
2) And InEditor = False
Then |
In that section, add in
something along the lines of:
Code: |
If Button = 1 Then
XToGo = (x + (NewPlayerX * PIC_X)) / PIC_X
YToGo = (y + (NewPlayerY * PIC_Y)) / PIC_Y
End
If |
----------
Find:
Code: |
If KeyCode = vbKeyUp
Then |
For all of those types of
conditions that apply to movement (not shift),
add:
Code: |
XToGo = -1
YToGo =
-1 |
----------
Find:
Code: |
' Check if player is trying
to move Call
CheckMovement |
Above, add:
Code: |
' Auto move
If XToGo <> -1 Or YToGo
<> -1 Then
Dim XDif As Long
Dim YDif As Long
XDif
= Abs(GetPlayerX(MyIndex) - XToGo)
YDif =
Abs(GetPlayerY(MyIndex) - YToGo)
If XToGo =
GetPlayerX(MyIndex) Or XToGo = -1 Then
XToGo = -1
XDif = 0
Else
XDif =
Abs(GetPlayerX(MyIndex) - XToGo)
End If
If YToGo =
GetPlayerY(MyIndex) Or YToGo = -1 Then
YToGo = -1
YDif = 0
Else
YDif =
Abs(GetPlayerY(MyIndex) - YToGo)
End If
Debug.Print
(XDif & " " & YDif)
If XDif > YDif Then
If GetPlayerX(MyIndex) - XToGo >
0 Then
DirLeft = True
Else
DirRight
= True
End If
End If
If YDif >
XDif Then
If GetPlayerY(MyIndex) -
YToGo > 0 Then
DirUp =
True
Else
DirDown
= True
End If
End If
If XDif = YDif
And XDif <> 0 And YDif <> 0 Then
' I'll be nice and give you the
non-directional movement code
'If
Int(Rnd * 2) = 0 Then
If
GetPlayerX(MyIndex) - XToGo > 0 Then
DirLeft = True
Else
DirRight = True
End If
' Else
If GetPlayerY(MyIndex) - YToGo >
0 Then
DirUp = True
Else
DirDown
= True
End If
'End If
End
If End
If |
----------
If you
figure it out, let others do the same by themselves,
okay?
I still need credit for this feature
mainly for the thing that calculates the direction. It
works almost as good as the long pet thing, but much,
much smaller. _________________
Last edited
by pingu on Sun Oct 08, 2006 7:16 pm; edited 1 time in
total | |
Back
to top |
|
|
figo566 Jr. Member
Joined: 25 Feb
2006 Posts: 93
Points
|
Posted: Mon Jun 19,
2006 9:32 am
Post subject: |
|
|
thank you for the
source pingu | |
Back
to top |
|
William Member
Joined: 23 Feb 2006 Posts:
198
Points
|
Posted: Mon Jun 19,
2006 9:56 am
Post subject: |
|
|
Nice Pingu, maybe I
should release my mouse movement code too. Which differs
everything from yours. _________________ 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 |
|
Nik0s Newcomer
Joined: 05 Mar 2006 Posts:
39
Points
|
Posted: Mon Jun 19,
2006 10:50 am
Post subject: |
|
|
I think the whole
"work it out your self" is silly. This isnt school,
if you dont like people using your "unique" code - dont
release it.
I personally am implimenting this
into my test now, and it is indeed easy to understand.
Good Job _________________ Your
Greatest Friend | |
Back
to top |
|
LordRaikan Member
Joined: 31 Mar
2006 Posts: 162
Points
|
Posted: Mon Jun 19,
2006 10:51 am
Post subject: |
|
|
direction movement?
do u mean diagonal
movement? _________________
| |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Mon Jun 19,
2006 10:55 am
Post subject: |
|
|
I wasn't the one
complaining.
However...
The intent of a
tutorial is to teach. This section isn't called
"Programming Recipes". The point is to teach people how
to code and not to be just a pick-and-go feature fest.
Many people can add great features and not know how a
single thing works. That isn't helping them make their
own stuff. _________________
| |
Back
to top |
|
LordRaikan Member
Joined: 31 Mar
2006 Posts: 162
Points
|
Posted: Mon Jun 19,
2006 10:59 am
Post subject: |
|
|
again, what do u mean
by directional movement? is it diagonal movement?
ps, me saving this right now, incase u
choose the william path _________________
| |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Mon Jun 19,
2006 11:01 am
Post subject: |
|
|
LordRaikan wrote: |
again, what do u mean by
directional movement? is it diagonal movement?
ps, me saving this right now, incase u
choose the william path |
I posted a tut on directional
movement, so you just need to know that I have that in
my source. You just need to uncomment some stuff if you
don't, I made it easy for you
guys. _________________
| |
Back
to top |
|
precrid Newcomer
Joined: 16 Jun
2006 Posts: 24
Points
|
Posted: Mon Jun 19,
2006 12:37 pm
Post subject: |
|
|
Wow man this is nice
pingu.
i think this is not the best way to learn
i think the best way to teach people how to code is
setting description in each new paragraph, maybe this
will cost more time but its better then
this. | |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Mon Jun 19,
2006 12:39 pm
Post subject: |
|
|
It's a simple thing
to add, so I'm hoping you can tell that "XToGo" is the x
coordinate you want to go
to. _________________
| |
Back
to top |
|
BeNjO Sr. Member
Joined: 28 May
2006 Posts: 418 Location:
York Points
|
Posted: Mon Jun 19,
2006 2:55 pm
Post subject: |
|
|
nice ang easy, i
might use this _________________
| |
Back
to top |
|
Foxodi Sr. Member
Joined: 21 Apr 2006 Posts:
314 Location: Sydney, Australia Points
|
Posted: Tue Jun 20,
2006 1:32 am
Post subject: |
|
|
I dont understand
where this whole 'thinking' part is.. It looks copy and
paste friendly to me _________________ You Can't
Regret It.... | |
Back
to top |
|
GoldXeta Sr. Member
Joined: 05 Apr 2006 Posts:
302
Points
|
Posted: Tue Jun 20,
2006 6:08 am
Post subject: lol |
|
|
*whistles* somone I
work with on *a* game was trying to make this RIGHT
before you posted this.... idea stealer :P
xD _________________
| |
Back
to top |
|
LordRaikan Member
Joined: 31 Mar
2006 Posts: 162
Points
|
Posted: Tue Jun 20,
2006 6:13 am
Post subject: |
|
|
Quote: |
Many people have requested
this since I took it out of Diamond. You'll have
to work to get it going.
|
lol, i'm also one of the "many"
people who requested it goldxeta , cuz i could never get ne of the formulas
right _________________
| |
Back
to top |
|
pingu "The Bird"
Joined: 23 Feb 2006 Posts:
3400 Location: Antartica Points
|
Posted: Tue Jun 20,
2006 8:09 am
Post subject: Re: lol |
|
|
GoldXeta wrote: |
*whistles* somone I work
with on *a* game was trying to make this RIGHT
before you posted this.... idea stealer :P
xD |
Ah, but you must not remember
that it was in Diamond until I replaced it with pets. I
got a bunch of people requesting I post up the already
deleted codee for them.
In the end, I wrote a
new, and much more efficient,
code. _________________
| |
Back
to top |
|
|
|