Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Making Diagonal Movement EE2.7


moshu
 Share

Recommended Posts

Moshu MSN: [email protected]
Hello all, I haven't used a forum in forever so if I am posting wrong plz let me know. I am trying to earn a title on this forum. I will mostly post in source edits. I just downloaded EE2.7 and VB6 two days ago. I have never coded using vb6 just the vb.net, C#/XNA, C++, GML, etc.

I was watching the code run in debug, and found out that when the player moves its xOffset and yOffset are set to the  +/- value of  PIC_X ad PIC_Y. PIC_X & Y are 32 and also represent width and height of the tile system.

Each step your speed is add/subtracted from X & Y offsets. Once it hits zero you have moved to the next tile. So i just added in a extra offset to each move to make diagonal movement. GM speed is 4 so each step player moves +/- 4 from offset. also to note that the up/down keys -/+ X & Y values the same so if speed is 4 X & Y offset both get -/+ 4\. left/right keys will do opposite operations to X & Y offset one gets added to one subtracted from.

***Known Bugs Working On Fixing****LOOKING FOR HELP ON HOW TO FIX THIS
1\. Once camera is away from edge of map and then meets edge of map again it will cause a small jump with player.
2\. ~~If player touches Top,Left, or Right edge of map it will cause a lil jump.~~ Fixed 2/20/09  :cheesy:
3\. ~~Run needs to be coded its right below walk code alter the same way the walk i upload a version that has run coded in also. If you run now u will keep going.~~ Fixed
4\. Correct player jump when online with diagonal code. Added 2/21/09

I wanted to go ahead and post it cuz i can't work on it today =( maybe someone can help save some time=). I know bugs are related to camera movement and player movement so I should fix it soon.

**ctrl + F = find text, in vb6 you can search all the code for a certain string**

Where I put my name as a comment is where I have changed the source code
I can't make exe's for some reason so you have to use vb6 to see diagonal movement

Download my source Here–--->[Click Me - Updated 2/20/09](http://www.filefactory.com/file/af1hega/n/fixedwallbounce_rar)

Hope this will impress you guys if not I tried haha always looking for Rep++

Now to the code
STEP 1-Open **modGameLogic**.bas(solution explorer>modules) in VB6 and Find sub CheckMovement Cut and paste my sub from below.
```
Sub CheckMovement()
    If Not GettingMap Then
        If IsTryingToMove Then
            If CanMove Then
                ' Check if player has the shift key down for running
                If ShiftDown Then
                    Player(MyIndex).Moving = MOVING_RUNNING
                Else
                    Player(MyIndex).Moving = MOVING_WALKING
                End If

                Select Case GetPlayerDir(MyIndex)
                    Case DIR_UP
                        Call SendPlayerMove
                        Player(MyIndex).yOffset = PIC_Y
                        Player(MyIndex).xOffset = PIC_X 'Moshu-----------
                        Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)
                        Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1) 'Moshu-----------

                    Case DIR_DOWN
                        Call SendPlayerMove
                        Player(MyIndex).yOffset = PIC_Y * -1
                        Player(MyIndex).xOffset = PIC_X * -1 'Moshu-----------
                        Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)
                        Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1) 'Moshu-----------

                    Case DIR_LEFT
                        Call SendPlayerMove
                        Player(MyIndex).xOffset = PIC_X
                        Player(MyIndex).yOffset = PIC_Y * -1 'Moshu-----------
                        Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)
                        Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1) 'Moshu-----------

                    Case DIR_RIGHT
                        Call SendPlayerMove
                        Player(MyIndex).xOffset = PIC_X * -1
                        Player(MyIndex).yOffset = PIC_Y 'Moshu-----------
                        Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)
                        Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1) 'Moshu-----------

                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

```Step 2:
Next find **ProcessMovement** sub its in the same module **modGameLogic**
cut and paste my sub from below.
```
Sub ProcessMovement(ByVal Index As Long)
    ' Check if player is walking, and if so process moving them over
    If Player(Index).Moving = MOVING_WALKING Then
        If Player(Index).Access > 0 Then
            If SS_WALK_SPEED <> 0 Then
                Select Case GetPlayerDir(Index)
                    Case DIR_UP
                        Player(Index).yOffset = Player(Index).yOffset - SS_WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset - SS_WALK_SPEED 'Moshu
                    Case DIR_DOWN
                        Player(Index).yOffset = Player(Index).yOffset + SS_WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset + SS_WALK_SPEED 'Moshu
                    Case DIR_LEFT
                        Player(Index).xOffset = Player(Index).xOffset - SS_WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset + SS_WALK_SPEED 'Moshu
                    Case DIR_RIGHT
                        Player(Index).xOffset = Player(Index).xOffset + SS_WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset - SS_WALK_SPEED 'Moshu
                End Select
            Else
                Select Case GetPlayerDir(Index)
                    Case DIR_UP
                        Player(Index).yOffset = Player(Index).yOffset - GM_WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset - GM_WALK_SPEED 'Moshu
                    Case DIR_DOWN
                        Player(Index).yOffset = Player(Index).yOffset + GM_WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset + GM_WALK_SPEED 'Moshu
                    Case DIR_LEFT
                        Player(Index).xOffset = Player(Index).xOffset - GM_WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset + GM_WALK_SPEED 'Moshu
                    Case DIR_RIGHT
                        Player(Index).xOffset = Player(Index).xOffset + GM_WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset - GM_WALK_SPEED 'Moshu
                End Select
            End If
        Else
            If SS_WALK_SPEED <> 0 Then
                Select Case GetPlayerDir(Index)
                    Case DIR_UP
                        Player(Index).yOffset = Player(Index).yOffset - SS_WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset - SS_WALK_SPEED 'Moshu
                    Case DIR_DOWN
                        Player(Index).yOffset = Player(Index).yOffset + SS_WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset + SS_WALK_SPEED 'Moshu
                    Case DIR_LEFT
                        Player(Index).xOffset = Player(Index).xOffset - SS_WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset + SS_WALK_SPEED 'Moshu
                    Case DIR_RIGHT
                        Player(Index).xOffset = Player(Index).xOffset + SS_WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset - SS_WALK_SPEED 'Moshu
                End Select
            Else
                Select Case GetPlayerDir(Index)
                    Case DIR_UP
                        Player(Index).yOffset = Player(Index).yOffset - WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset - WALK_SPEED 'Moshu
                    Case DIR_DOWN
                        Player(Index).yOffset = Player(Index).yOffset + WALK_SPEED
                        Player(Index).xOffset = Player(Index).xOffset + WALK_SPEED 'Moshu
                    Case DIR_LEFT
                        Player(Index).xOffset = Player(Index).xOffset - WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset + WALK_SPEED 'Moshu
                    Case DIR_RIGHT
                        Player(Index).xOffset = Player(Index).xOffset + WALK_SPEED
                        Player(Index).yOffset = Player(Index).yOffset - WALK_SPEED 'Moshu
                End Select
            End If
        End If

```Step3:
Now open module **HandleData** and Ctrl + F and search for this string –> Player movement packet
This is not a sub or function its a IF statement so make sure you cut and paste it in like it is in file=)
Next cut and paste my code from below
```
    ' ::::::::::::::::::::::::::::
    ' :: Player movement packet ::
    ' ::::::::::::::::::::::::::::
    If (casestring = "playermove") Then
        i = Val(parse(1))
        X = Val(parse(2))
        y = Val(parse(3))
        Dir = Val(parse(4))
        n = Val(parse(5))

        If Dir < DIR_UP Or Dir > DIR_RIGHT Then
            Exit Sub
        End If

        Call SetPlayerX(i, X)
        Call SetPlayerY(i, y)
        Call SetPlayerDir(i, Dir)

        Player(i).xOffset = 0
        Player(i).yOffset = 0
        Player(i).Moving = n

        ' Replaced with the one from TE.
        Select Case GetPlayerDir(i)
            Case DIR_UP
                Player(i).yOffset = PIC_Y
                Player(i).xOffset = PIC_X 'Moshu-----
            Case DIR_DOWN
                Player(i).yOffset = PIC_Y * -1
                Player(i).xOffset = PIC_X * -1 'Moshu-----
            Case DIR_LEFT
                Player(i).xOffset = PIC_X
                Player(i).yOffset = PIC_Y 'Moshu-----
            Case DIR_RIGHT
                Player(i).xOffset = PIC_X * -1
                Player(i).yOffset = PIC_Y * -1 'Moshu-----
        End Select

        Exit Sub
    End If

```Wall bounce fix 4 lines of code total =) Locate the **CanMove** function in **modGameLogic** cut/paste code below this will be at top of function you will see it.
```
    X = GetPlayerX(MyIndex)
    y = GetPlayerY(MyIndex)

    If DirUp Then
        Call SetPlayerDir(MyIndex, DIR_UP)
        X = X - 1 'moshu This lines here fix the wall bounce caused when play walks down map wall
        y = y - 1
    ElseIf DirDown Then
        Call SetPlayerDir(MyIndex, DIR_DOWN)
        y = y + 1
        X = X + 1 'moshu
    ElseIf DirLeft Then
        Call SetPlayerDir(MyIndex, DIR_LEFT)
        X = X - 1
        y = y + 1 'moshu
    Else
        Call SetPlayerDir(MyIndex, DIR_RIGHT)
        X = X + 1
        y = y - 1 'moshu
    End If

```
Download my source Here–--->[Click Me - Updated 2/20/09](http://www.mediafire.com/?m4kyeei1ydi)
Thats it for now I will post updated verison of it later I will always try to work from a unedited source of EE2.7 that tut's are ez to follow.
Moshu MSN: [email protected]
Link to comment
Share on other sites

Ok editing my post, I didnt really play with it before I posted..

Pros' = * Good for an Iso game in EE2.7

Cons' = * No more Up down Left Right,  - left is diagonal down etc… so it replaces the current movement system which would suk arse for a 2d topdown.
* When you move Right, it jumps tiles as he mentioned... just not playable like that. But thanks for the source, these are small issues that wont be hard to resolve.

Oh and Marsh, no the NPCs still move like normal.
Link to comment
Share on other sites

Thx Devogen, I posted it cuz I needed help weeding out camera jump and i am making npc's move
now.
Key's aren't final either really plus I was going to isolate diagonal movement so u could do both thus
making 8 way movement it can be done.

Its almost done I just need to figure out the wall jumping when u walk into it, and camera jump when it stops touching a map edge and then touches it again. I will be updating this as I work.
I have it pin pointed to the checkmovement or player move in game logic I could be wrong.
If you find a fix let me know I hope someone can help me with this one big thanks I'm out its 3 am =) thx for reply's
Link to comment
Share on other sites

sweet..

Im actually getting a big jump just moving to the right in any direction… Ive looked at the code and by all rights it should just mimmick what the left side does... but it doesnt... Im going to have a good crack at it tonight.

Good start tho :) I think seperating the two movements would be a good idea, i would like to even make it an option in data.ini, if EE3.0 is going to have an iso tile option it would be great to have an iso walk feature too.
Link to comment
Share on other sites

Ok I will keep grinding on it today, I will post npc diag movement and hopefully camera fix
thx for your help and I am excited if we can get this working eclipse will be a iso engine also sorta. I am happy to help you guys out I don't get to use my skills much where i live.  :P
Link to comment
Share on other sites

Ok news update, the Move Character Sub in modGameLogic is not used at all in the game so it is not the problem or the place to fix it. I gutted it out and client runs fine. Also when the tiles are blt to the screen or drawn to screen they use the newxoffset newyoffset values to draw tiles so I think since they are effected by xOffset and yOffset that they also need to be adjusted when player moves. Looking into it now. If I am wrong about move character being a junk sub plz let me know someone =)  I'm almost sure the key to this in the gameloop sub in modGameLogic where newx and newy offset values are assigned.
Link to comment
Share on other sites

I know its ez to move in diag the only problem is that the camera does this jump crap I have been beating my head trying to fix it but i already have npc's walking diag. but their also server side so I will wait till camera bug is fixed then everything else will be set to diag. I just need help fixing camera bug
Link to comment
Share on other sites

I am getting a new host the college server went down and omg thx so much devogen if u can msn me I have some new fix's I will upload fixes and new source today sorry for the broke link.  I fixed the bounce off of walls and almost got camera jump fixed. I have isolated the code responsible for the jump. Just got to brain storm on how to add to it to stop camera jump. Devogen thanks so much and Vb.net gurn thx too for help making this work. I knew if I showed you all the diag. code this could be a working system very soon and I will isolated diag. movement to be able to turn on and off or have both on at the same time. So eclipse will have three different movement systems.  :cheesy: MSN me can you post the complete npc code or let me add it to the top post of this I will credit you =) This forum rocks haha eclipse FTW

Ok this code is where the jump is happening so anyone that wants please help if you get it working post here it here I will add it to top and overall source. When player/tiles are blt to screen or drawn they use the New… variables here to position player/tiles. So since we are baiscly moving in two directions at once this needs to be modified to prevent camera jump... **!My thoughts only this is not modified or anything you shouldn't cut/paste into source just for brain storming thx!** Code is in **GameLoop** in **modGameLogic**
```
                'assign values 10 and 7 these related to screen width and height in tiles to players position i believe
                NewX = 10
                NewY = 7
                'New player cords are current cords minus newx or y
                NewPlayerY = Player(MyIndex).y - NewY
                NewPlayerX = Player(MyIndex).X - NewX
                'convert newX and y to pixels by times it by tile width and height
                NewX = NewX * PIC_X
                NewY = NewY * PIC_Y
                'capture players current offest
                NewXOffset = Player(MyIndex).xOffset
                NewYOffset = Player(MyIndex).yOffset

                'Here we check to see if player's camera is at the bounds of the map Top,bottom,left,right
                'The new variables declared above this get set here to be used to draw player in bltPlayer
                If Player(MyIndex).y - 7 < 1 Then 'Player is touching top of map
                    NewY = Player(MyIndex).y * PIC_Y + Player(MyIndex).yOffset
                    NewYOffset = 0
                    NewPlayerY = 0
                    If Player(MyIndex).y = 7 And Player(MyIndex).Dir = DIR_UP Then 'Player can see top Wall/Bounds jumps happen Here
                        NewPlayerY = Player(MyIndex).y - 7
                        NewY = 7 * PIC_Y
                        NewYOffset = Player(MyIndex).yOffset
                    End If
                ElseIf Player(MyIndex).y + 9 > MAX_MAPY + 1 Then 'Player Camera has touched bottom of map
                    NewY = (Player(MyIndex).y - (MAX_MAPY - 14)) * PIC_Y + Player(MyIndex).yOffset
                    NewYOffset = 0
                    NewPlayerY = MAX_MAPY - 14
                    If Player(MyIndex).y = MAX_MAPY - 7 And Player(MyIndex).Dir = DIR_DOWN Then 'Player can see bottom Wall/Bounds jumps happen Here
                        NewPlayerY = Player(MyIndex).y - 7
                        NewY = 7 * PIC_Y
                        NewYOffset = Player(MyIndex).yOffset
                    End If
                End If

                If Player(MyIndex).X - 10 < 1 Then 'Player has touched Left wall/bounds of map
                    NewX = Player(MyIndex).X * PIC_X + Player(MyIndex).xOffset
                    NewXOffset = 0
                    NewPlayerX = 0
                    If Player(MyIndex).X = 10 And Player(MyIndex).Dir = DIR_LEFT Then 'Player can see left Wall/Bounds jumps happen Here
                        NewPlayerX = Player(MyIndex).X - 10
                        NewX = 10 * PIC_X
                        NewXOffset = Player(MyIndex).xOffset
                    End If
                ElseIf Player(MyIndex).X + 11 > MAX_MAPX + 1 Then 'Player has touched right wall/bounds of map
                    NewX = (Player(MyIndex).X - (MAX_MAPX - 19)) * PIC_X + Player(MyIndex).xOffset
                    NewXOffset = 0
                    NewPlayerX = MAX_MAPX - 19
                    If Player(MyIndex).X = MAX_MAPX - 9 And Player(MyIndex).Dir = DIR_RIGHT Then 'Player can see right Wall/Bounds jumps happen Here
                        NewPlayerX = Player(MyIndex).X - 10
                        NewX = 10 * PIC_X
                        NewXOffset = Player(MyIndex).xOffset
                    End If
                End If

                ScreenX = GetScreenLeft(MyIndex)
                ScreenY = GetScreenTop(MyIndex)
                ScreenX2 = GetScreenRight(MyIndex)
                ScreenY2 = GetScreenBottom(MyIndex)

                If ScreenX < 0 Then
                    ScreenX = 0
                    ScreenX2 = 20
                ElseIf ScreenX2 > MAX_MAPX Then
                    ScreenX2 = MAX_MAPX
                    ScreenX = MAX_MAPX - 20
                End If

                If ScreenY < 0 Then
                    ScreenY = 0
                    ScreenY2 = 15
                ElseIf ScreenY2 > MAX_MAPY Then
                    ScreenY2 = MAX_MAPY
                    ScreenY = MAX_MAPY - 15
                End If

```
Link to comment
Share on other sites

  • 2 weeks later...
Sorry to let you down but I have started a new project inspired by the drive for a isometric game engine I have a working UDP server/client working for C#/XNA that uses isometric movement plus it has paperdolling, per pixel collision detection, XNA's PNG support, well the entire XNA framework, and much more its very beta and there isn't a demo yet but I will be posting one soon I hope someone can take my isometric movement code here and turn it into a working system for eclipse.                                        /bow
Link to comment
Share on other sites

@moshu:

> Sorry to let you down but I have started a new project inspired by the drive for a isometric game engine I have a working UDP server/client working for C#/XNA that uses isometric movement plus it has paperdolling, per pixel collision detection, XNA's PNG support, well the entire XNA framework, and much more its very beta and there isn't a demo yet but I will be posting one soon I hope someone can take my isometric movement code here and turn it into a working system for eclipse.                                        /bow

Instead of using XNA, you should use C++ with allegro and raknet, would be much better.
Link to comment
Share on other sites

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...