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

3-Frame Movement in one line of Code


balliztik1
 Share

Recommended Posts

**Please note: I did this just as a joke, to show it was possible. It should not be used by a serious game.**

Yes, one. One line of code. I have developed a system of 3-frame movement that utilizes just one line of code.

Open up the client and view modGameLogic. Find this chunk of code in Sub BltPlayer:

```
            Select Case GetPlayerDir(Index)
                Case DIR_UP
                    If (Player(Index).yOffset < PIC_Y / 2) Then
                        Anim = 1
                    End If
                Case DIR_DOWN
                    If (Player(Index).yOffset < PIC_Y / 2 * -1) Then
                        Anim = 1
                    End If
                Case DIR_LEFT
                    If (Player(Index).xOffset < PIC_Y / 2) Then
                        Anim = 1
                    End If
                Case DIR_RIGHT
                    If (Player(Index).xOffset < PIC_Y / 2 * -1) Then
                        Anim = 1
                    End If
            End Select
```
Replace it with this bad boy:

```
Anim = (((Abs(Player(Index).yOffset + Player(Index).xOffset) - 1) \ 8)) Mod 2 + ((Abs(Player(Index).yOffset + Player(Index).xOffset) - 1) \ 16) * ((((Abs(Player(Index).yOffset + Player(Index).xOffset) - 1) \ 8)) Mod 2)
```
You now have three frame movement. If you're using 32x64 sprites, you'll have to do the same thing to the BltPlayerTop sub, though. Two lines of code, if you want to be like that.

This makes the walking animation change to (Attack, Stand, Step, Stand) instead of (Step, Stand). This merely alters the blitting order. This adds no new frames. If you want to add a completely new frame for walking, separate from attacking, modifications will be needed.
Link to comment
Share on other sites

Yes. This formula just sets up the "Anim" variable. All the rest is generated later based off this number. Everything that normally works in Eclipse still works, except with 3 frames for movement now.

The same thing could be done for NPCs, too. Instead of "Player(index).xoffset)" and such, you'd just use the corresponding MapNpc values.

Now, I'm not exactly sure if this is more efficient, though. It's very math-heavy, and that might be a source of lag. Honestly, I just made this to show off that it could be done.  XD
Link to comment
Share on other sites

@♪♫♪:

> Yes. This formula just sets up the "Anim" variable. All the rest is generated later based off this number. Everything that normally works in Eclipse still works, except with 3 frames for movement now.
>
> The same thing could be done for NPCs, too. Instead of "Player(index).xoffset)" and such, you'd just use the corresponding MapNpc values.
>
> Now, I'm not exactly sure if this is more efficient, though. It's very math-heavy, and that might be a source of lag. Honestly, I just made this to show off that it could be done.  XD

Short code is always nice, but replacing a system of simple variable changing to a big-ass calculation could be pretty slow, especially as BltPlayer is called several times every loop.

It's nice, but I'll be releasing a simpler version later this week.
Link to comment
Share on other sites

  • 2 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...