Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Elysium Source Forum Index » Approved Tutorials

Post new topic   Reply to topic
Click to Move Goto page 1, 2, 3  Next
View previous topic :: View next topic  
Author Message
pingu
"The Bird"


Joined: 23 Feb 2006
Posts: 3400
Location: Antartica
Points

PostPosted: Mon Jun 19, 2006 8:54 am    Post subject: Click to Move Reply with quote

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:
Code:
PlayerBuffer = ""


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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
figo566
Jr. Member


Joined: 25 Feb 2006
Posts: 93

Points

PostPosted: Mon Jun 19, 2006 9:32 am    Post subject: Reply with quote

thank you for the source pingu
Back to top
View user's profile Send private message
William
Member


Joined: 23 Feb 2006
Posts: 198

Points

PostPosted: Mon Jun 19, 2006 9:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Nik0s
Newcomer


Joined: 05 Mar 2006
Posts: 39

Points

PostPosted: Mon Jun 19, 2006 10:50 am    Post subject: Reply with quote

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. Very Happy

Good Job Very Happy
_________________
Your Greatest Friend
Back to top
View user's profile Send private message
LordRaikan
Member


Joined: 31 Mar 2006
Posts: 162

Points

PostPosted: Mon Jun 19, 2006 10:51 am    Post subject: Reply with quote

direction movement? do u mean diagonal movement?
_________________
Back to top
View user's profile Send private message
pingu
"The Bird"


Joined: 23 Feb 2006
Posts: 3400
Location: Antartica
Points

PostPosted: Mon Jun 19, 2006 10:55 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
LordRaikan
Member


Joined: 31 Mar 2006
Posts: 162

Points

PostPosted: Mon Jun 19, 2006 10:59 am    Post subject: Reply with quote

again, what do u mean by directional movement? is it diagonal movement?


ps, me saving this right now, incase u choose the william path Wink
_________________
Back to top
View user's profile Send private message
pingu
"The Bird"


Joined: 23 Feb 2006
Posts: 3400
Location: Antartica
Points

PostPosted: Mon Jun 19, 2006 11:01 am    Post subject: Reply with quote

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 Wink


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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
precrid
Newcomer


Joined: 16 Jun 2006
Posts: 24

Points

PostPosted: Mon Jun 19, 2006 12:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
pingu
"The Bird"


Joined: 23 Feb 2006
Posts: 3400
Location: Antartica
Points

PostPosted: Mon Jun 19, 2006 12:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
BeNjO
Sr. Member


Joined: 28 May 2006
Posts: 418
Location: York
Points

PostPosted: Mon Jun 19, 2006 2:55 pm    Post subject: Reply with quote

nice ang easy, i might use this Razz
_________________
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Foxodi
Sr. Member


Joined: 21 Apr 2006
Posts: 314
Location: Sydney, Australia
Points

PostPosted: Tue Jun 20, 2006 1:32 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
GoldXeta
Sr. Member


Joined: 05 Apr 2006
Posts: 302

Points

PostPosted: Tue Jun 20, 2006 6:08 am    Post subject: lol Reply with quote

*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
View user's profile Send private message
LordRaikan
Member


Joined: 31 Mar 2006
Posts: 162

Points

PostPosted: Tue Jun 20, 2006 6:13 am    Post subject: Reply with quote

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 Laughing , cuz i could never get ne of the formulas right Sad
_________________
Back to top
View user's profile Send private message
pingu
"The Bird"


Joined: 23 Feb 2006
Posts: 3400
Location: Antartica
Points

PostPosted: Tue Jun 20, 2006 8:09 am    Post subject: Re: lol Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Elysium Source Forum Index » Approved Tutorials All times are GMT - 5 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional