Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 Something a lot of people have been asking for is a Tutorial on Mouse Movement for walking.Here is a very QUICK tutorial on how to add Mouse Movement. It uses Right Click to Move, and Left click for targetting.ALL the changes are done on the CLIENT, requiring no modifications to the server.Step 1\. Open modGlobals on the Client, and Add the Following```'Players Current Position'These will store the players Current X/Y (values from GetPlayerX()/GetPlayerY())'February 1st, 2011 - Robert Janes (Samu Games)Public MyX As IntegerPublic MyY As IntegerPublic MouseMove As Boolean```Step 2\. Add this to the Beginning of Sub Main in modGeneral```' Set Default MouseMove Boolean to False' This will become True with Right Clicking and False with Mouse Up' February 1st, 2011 - Robert Janes (Samu Games)MouseMove = False```Step 3\. In Sub CheckInputKeys, in modInput, Just before it starts doing the checks for Moving Up/Down/Left/Right add```'Quickly Check to See if we are using MouseMovement, if so, exit sub and don't check Keyboard Movement If MouseMove = True Then Exit Sub End If```Step 4\. in frmMain, on picScreen MouseDown, Just after it checks vbKeyRightClick, just BEFORE the If ShiftDown, we add the following.```MouseMove = True 'Right Click Mouse Movement Here, Give MyX and MyY values for current Pos then compare MyX = GetPlayerX(MyIndex) MyY = GetPlayerY(MyIndex) 'Move Right If CurX > MyX Then DirUp = False DirDown = False DirLeft = False DirRight = True End If 'Move Left If CurX < MyX Then DirUp = False DirDown = False DirLeft = True DirRight = False End If 'Move Down If CurY > MyY Then DirUp = False DirDown = True DirLeft = False DirRight = False End If 'Move Up If CurY < MyY Then DirUp = True DirDown = False DirLeft = False DirRight = False End If```Step 5\. in frmMain on picScreen MOUSEUP, add```MouseMove = False```Step 6\. in modGameLogic, in the Sub GameLoop, comment out CheckKeys like so```' Call CheckKeys```We comment this out because the GameLoop calls this function to ensure they aren't doing anything like Auto Walking so if the Keyboard keys aren't pressed down, it stops the movent, this screws up mouse movement. It will not really affect your game in any way, as in CheckInputKeys, we already do a check to see if the key is pressed. So it's moot for movement. You could go into CheckKeys and just comment out the checks for the KeyUp, KeyRight, KeyLeft, KeyDown if you wanted.Viola!!!Mouse Movement! Enjoy! Link to comment Share on other sites More sharing options...
Yxxe Posted February 1, 2011 Share Posted February 1, 2011 Very good - nice and simple. :bstar: :bstar: :bstar: :bstar: :rstar: Link to comment Share on other sites More sharing options...
Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 You can add the actual movement part from MouseDown to MouseMouse on the frmMain picScreen object so that way if you're holding down the mouse and change direction it'll automatically update the movement direction. Link to comment Share on other sites More sharing options...
thezeus Posted February 1, 2011 Share Posted February 1, 2011 Samu, you had a typo that may confuse some people.You saidALL the changes are done on the server, requiring no modifications to the server.You meant all done to client, requiring no modification to the server Link to comment Share on other sites More sharing options...
Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 Fixed. Link to comment Share on other sites More sharing options...
chuchoide Posted February 1, 2011 Share Posted February 1, 2011 Cool tutorial, I will add it to my game soon.Very nice :) Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2011 Share Posted February 1, 2011 Will you change maps if you hit the maps edge or do you then have to use the arrows? Link to comment Share on other sites More sharing options...
Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 Will change maps. Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2011 Share Posted February 1, 2011 @SamuGames:> Will change maps.Nice, I'll give this a test run then. Thanks for all your good shares SamuGames. Link to comment Share on other sites More sharing options...
thezeus Posted February 1, 2011 Share Posted February 1, 2011 1 thing I noticed was it doesnt stop the movement on mouse up, even with MouseMove = False in picScreen Mouse Up. I've retried this a few times and it happens both times. Any clue as to why, or perhaps what I did wrong in testing it? Everything seems to work fine. Link to comment Share on other sites More sharing options...
leopoldobb Posted February 1, 2011 Share Posted February 1, 2011 Thanks man! =D Link to comment Share on other sites More sharing options...
Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 @Thezeus, sorry I gave you in correct information there, make sure it's setting the flag to false. Link to comment Share on other sites More sharing options...
thezeus Posted February 1, 2011 Share Posted February 1, 2011 I was gonna say, that edit wasn't correct haha. I was looking at it thinking, no thats not right at all. Link to comment Share on other sites More sharing options...
thezeus Posted February 1, 2011 Share Posted February 1, 2011 It still looks like its missing a check somewhere, here is my inputkeys``` If GetKeyState(vbKeyControl) < 0 Then ControlDown = True Else ControlDown = False End If 'Quickly Check to See if we are using MouseMovement, if so, exit sub and don't check Keyboard Movement If MouseMove = True Then Exit Sub End If 'Move Up If GetKeyState(vbKeyUp) < 0 Then DirUp = True DirDown = False DirLeft = False DirRight = False Exit Sub Else DirUp = False End If``` Link to comment Share on other sites More sharing options...
Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 @SamuGames:> Something a lot of people have been asking for is a Tutorial on Mouse Movement for walking.> > Here is a very QUICK tutorial on how to add Mouse Movement. It uses Right Click to Move, and Left click for targetting.> > ALL the changes are done on the CLIENT, requiring no modifications to the server.> > Step 1\. Open modGlobals on the Client, and Add the Following> ```> 'Players Current Position> 'These will store the players Current X/Y (values from GetPlayerX()/GetPlayerY())> 'February 1st, 2011 - Robert Janes (Samu Games)> Public MyX As Integer> Public MyY As Integer> Public MouseMove As Boolean> > ```> Step 2\. Add this to the Beginning of Sub Main in modGeneral> ```> ' Set Default MouseMove Boolean to False> ' This will become True with Right Clicking and False with Mouse Up> ' February 1st, 2011 - Robert Janes (Samu Games)> MouseMove = False> ```> Step 3\. In Sub CheckInputKeys, in modInput, Just before it starts doing the checks for Moving Up/Down/Left/Right add> ```> 'Quickly Check to See if we are using MouseMovement, if so, exit sub and don't check Keyboard Movement> If MouseMove = True Then> Exit Sub> End If> ```> Step 4\. in frmMain, on picScreen MouseDown, Just after it checks vbKeyRightClick, just BEFORE the If ShiftDown, we add the following.> ```> MouseMove = True> > 'Right Click Mouse Movement Here, Give MyX and MyY values for current Pos then compare> > MyX = GetPlayerX(MyIndex)> MyY = GetPlayerY(MyIndex)> > 'Move Right> If CurX > MyX Then> DirUp = False> DirDown = False> DirLeft = False> DirRight = True> End If> > 'Move Left> If CurX < MyX Then> DirUp = False> DirDown = False> DirLeft = True> DirRight = False> End If> > 'Move Down> If CurY > MyY Then> DirUp = False> DirDown = True> DirLeft = False> DirRight = False> End If> 'Move Up> If CurY < MyY Then> DirUp = True> DirDown = False> DirLeft = False> DirRight = False> End If> > ```> Step 5\. in frmMain on picScreen MOUSEUP, add> ```> MouseMove = False> DirUp = False> DirDown = False> DirLeft = False> DirRight = False> ```> Step 6\. in modGameLogic, in the Sub GameLoop, comment out CheckKeys like so> ```> ' Call CheckKeys> ```We comment this out because the GameLoop calls this function to ensure they aren't doing anything like Auto Walking so if the Keyboard keys aren't pressed down, it stops the movent, this screws up mouse movement. It will not really affect your game in any way, as in CheckInputKeys, we already do a check to see if the key is pressed. So it's moot for movement. You could go into CheckKeys and just comment out the checks for the KeyUp, KeyRight, KeyLeft, KeyDown if you wanted.> > Viola!!!> > Mouse Movement! Enjoy! Link to comment Share on other sites More sharing options...
thezeus Posted February 1, 2011 Share Posted February 1, 2011 For bug situations in mouseup, add DirUp = False DirDown=False DirRight=False DirLeft=False Link to comment Share on other sites More sharing options...
Rob Janes Posted February 1, 2011 Author Share Posted February 1, 2011 Fixed the Tutorial to include that as well,Thanks thezeus Link to comment Share on other sites More sharing options...
thezeus Posted February 1, 2011 Share Posted February 1, 2011 Great work brutha Link to comment Share on other sites More sharing options...
BugSICK Posted February 3, 2011 Share Posted February 3, 2011 cant find picScreen MOUSEUP, :sad: Link to comment Share on other sites More sharing options...
Rob Janes Posted February 3, 2011 Author Share Posted February 3, 2011 use the drop down on the top right when youre in PicScreen mouse down, and choose Mouse up Link to comment Share on other sites More sharing options...
Hugo Posted February 3, 2011 Share Posted February 3, 2011 SamuGames, you're a great man.Congratulations on the tutorial.Very good!:D Link to comment Share on other sites More sharing options...
BugSICK Posted February 11, 2011 Share Posted February 11, 2011 still i cant get this :sad:, and i cant find the mouse up, sorry im not got at vb just learning again. any help?by the way is the main post the fixed tutorial? Link to comment Share on other sites More sharing options...
Rob Janes Posted February 11, 2011 Author Share Posted February 11, 2011 yes, the main post is the proper tutorial, MouseUp is something you select in VB. Double click on the picScreen so it opens up the source code. At the top right hand side of what white Syntax Editor, you'll see a DropDown that will saypicScreen_ClickClick that drop down and select "MouseUp" Link to comment Share on other sites More sharing options...
BugSICK Posted February 11, 2011 Share Posted February 11, 2011 ok thanks got it, gonna test it now. thanks again. :cheesy: Link to comment Share on other sites More sharing options...
BugSICK Posted February 11, 2011 Share Posted February 11, 2011 its not working… XD Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now