Mirage Source

Free ORPG making software.
It is currently Thu Mar 28, 2024 4:07 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1029 posts ]  Go to page 1, 2, 3, 4, 5 ... 42  Next
Author Message
PostPosted: Wed Jun 03, 2009 12:46 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
This replaces the current Processmovement subroutines to have an extra "catch-all" code to make sure people don't wonder off a tile completely, which is what causes the flight effect where sprites start running off-screen.

It's copy and paste, I can't be arsed with decent formatting, so here you go.

Processmovement:

Code:
    Select Case GetPlayerDir(Index)
        Case DIR_UP
            Player(Index).YOffset = Player(Index).YOffset - MovementSpeed
            If Player(Index).YOffset <= 0 Then Player(Index).YOffset = 0
        Case DIR_DOWN
            Player(Index).YOffset = Player(Index).YOffset + MovementSpeed
            If Player(Index).YOffset >= 0 Then Player(Index).YOffset = 0
        Case DIR_LEFT
            Player(Index).XOffset = Player(Index).XOffset - MovementSpeed
            If Player(Index).XOffset <= 0 Then Player(Index).XOffset = 0
        Case DIR_RIGHT
            Player(Index).XOffset = Player(Index).XOffset + MovementSpeed
            If Player(Index).XOffset >= 0 Then Player(Index).XOffset = 0
    End Select


Processnpcmovement:

Code:
        Select Case MapNpc(MapNpcNum).Dir
            Case DIR_UP
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - WALK_SPEED
                If MapNpc(MapNpcNum).YOffset <= 0 Then MapNpc(MapNpcNum).YOffset = 0
            Case DIR_DOWN
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + WALK_SPEED
                If MapNpc(MapNpcNum).YOffset >= 0 Then MapNpc(MapNpcNum).YOffset = 0
            Case DIR_LEFT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - WALK_SPEED
                If MapNpc(MapNpcNum).XOffset <= 0 Then MapNpc(MapNpcNum).XOffset = 0
            Case DIR_RIGHT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + WALK_SPEED
                If MapNpc(MapNpcNum).XOffset >= 0 Then MapNpc(MapNpcNum).XOffset = 0
        End Select


Enjoy.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Jun 03, 2009 5:59 pm 
Offline
Regular
User avatar

Joined: Thu May 28, 2009 9:39 pm
Posts: 71
Location: Florida
don't fully understand.

_________________
I support pregnant women! (and Matts)
Image
Image
Image


Top
 Profile  
 
PostPosted: Wed Jun 03, 2009 7:13 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
DarkPhoenix wrote:
don't fully understand.


Then ignore it.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Jun 03, 2009 9:02 pm 
Offline
Regular
User avatar

Joined: Thu May 28, 2009 9:39 pm
Posts: 71
Location: Florida
I mean I don't understand the flight effect and the sprites walking off the tile/screen? How would this code affect that?

_________________
I support pregnant women! (and Matts)
Image
Image
Image


Top
 Profile  
 
PostPosted: Wed Jun 03, 2009 9:09 pm 
DarkPhoenix wrote:
I mean I don't understand the flight effect and the sprites walking off the tile/screen? How would this code affect that?


Simple.

It makes it NOT happen.


Top
  
 
PostPosted: Wed Jun 03, 2009 11:40 pm 
Offline
Regular
User avatar

Joined: Thu May 28, 2009 9:39 pm
Posts: 71
Location: Florida
So it already happens without this code.... that's weird.

_________________
I support pregnant women! (and Matts)
Image
Image
Image


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 12:42 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
DarkPhoenix wrote:
So it already happens without this code.... that's weird.


No, it's not.

The reason the speeds can only be 1, 2, 4, 8, 16 or 32 is because the movement is pretty much just taking the speed value away from 32 until it reaches 0, or adding it to -32, depending on which direction you're going.

Of course, if the number isn't a factor of 32, it wont reach 0 exactly, which causes it to never stop walking. This code simply makes sure that a number can never go over the maximum or under the minimum values.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 12:53 am 
Offline
Regular
User avatar

Joined: Thu May 28, 2009 9:39 pm
Posts: 71
Location: Florida
wait... there is more than two speed values that are usable? O_o

_________________
I support pregnant women! (and Matts)
Image
Image
Image


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 1:27 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
DarkPhoenix wrote:
wait... there is more than two speed values that are usable? O_o


What?

In the default source, RUN_SPEED and WALK_SPEED are 8 and 4 respectively. Anything apart from those two numbers, generally will fuck up. This tutorial allows those values to be ANY number.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 2:30 am 
Offline
Regular
User avatar

Joined: Thu May 28, 2009 9:39 pm
Posts: 71
Location: Florida
so you can add more when you add this code, if I understand what you are saying.

_________________
I support pregnant women! (and Matts)
Image
Image
Image


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 3:51 am 
DarkPhoenix wrote:
so you can add more when you add this code, if I understand what you are saying.


This code would allow, say, higher speed for your character to make you move slightly faster than other players. Or for speed buffs and what not. So, if you have 4 walk speed by default and you have you get +1 from a buff or item, you'd have a walk speed of 5, allowing you to walk just a tad faster.

However, with the default code, if you had 5 walking speed, you'd just glide off the screen and never stop moving. That's the problem. That's what this code fixes.

Awesome tut, Robin. Very useful.


Top
  
 
PostPosted: Thu Jun 04, 2009 4:59 am 
Offline
Persistant Poster
User avatar

Joined: Fri Aug 15, 2008 3:11 pm
Posts: 633
on the old way it could be only 4 8 16 or 32
or else it will glide off
with this it can be any number

_________________
╔╗╔═╦═╦══╦═══╗
║║║║║║║╔╗║╔═╗║
║║║║║║║╚╝║║║║║
║╚╣║║║║╔╗║╚═╝║
╚═╩╩═╩╩╝╚╩═══╝


╔╦═╦╦════╦═══╗
║║║║╠═╗╔═╣╔══╝
║║║║║║║║╚═╗
║║║║║║║║╔═╝
╚═╩═╝╚╝╚╝ ?


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 5:04 am 
Offline
Regular
User avatar

Joined: Thu May 28, 2009 9:39 pm
Posts: 71
Location: Florida
sweet I'm so using this.

_________________
I support pregnant women! (and Matts)
Image
Image
Image


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 11:50 am 
Offline
Pro
User avatar

Joined: Mon May 29, 2006 3:26 pm
Posts: 493
Location: São Paulo, Brasil
Google Talk: blackagesbr@gmail.com
Very nice tut. I'll try to make it work with my server-side canmove sub xD
Client side deciding the speed is just way too much insecure =/

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
PostPosted: Sun Jun 14, 2009 6:27 pm 
Offline
Newbie

Joined: Sat Jun 13, 2009 10:49 pm
Posts: 1
Very good script there, and it looks as if you kept it very compact and with no trash script involved. Gotta give you some nice props for this one!


Top
 Profile  
 
PostPosted: Sun Jun 14, 2009 7:14 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Dragoons Master wrote:
Very nice tut. I'll try to make it work with my server-side canmove sub xD
Client side deciding the speed is just way too much insecure =/


Pfft, you and your security.

Also wouldn't adding it server side cause more lag? After all it's not like you want to add a heavier load to the server when the client can do it, right?

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
PostPosted: Sun Jun 14, 2009 10:13 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
No, Nean...no.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Sun Jun 14, 2009 11:40 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
The client-side CanMove stuff is all there to counter-act the packet delay. It's not nice pressing "up" and only moving a second or so later.

It's decent enough theory, but not programmed very well. Handling speed and movement server side is fine, but having it all handled client side for a player's own character only is perfect. As long as you do some checks to make sure it's not out of sync, which is a common problem in all Mirage-based engines/games.

It's an easy fix, just like this was. I might post a tutorial to fix it, eventually.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Mon Jun 15, 2009 4:21 am 
Offline
Regular
User avatar

Joined: Sun Jun 01, 2008 8:39 pm
Posts: 91
Can you fix that lag where other people's movements are a bit laggy? Or is just something I'm going to have to live with?


Top
 Profile  
 
PostPosted: Mon Jun 15, 2009 11:50 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
I haven't really seen anything to show whether that's a programming error. I've noticed lag where people host the servers themselves, but when I was hosting my own game on a VPS, there was no movement lag at all.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Mon Jun 15, 2009 1:58 pm 
Offline
Regular
User avatar

Joined: Sun Jun 01, 2008 8:39 pm
Posts: 91
Meh, it's probably just my internet then. :(


Top
 Profile  
 
PostPosted: Mon Jun 15, 2009 2:06 pm 
Offline
Knowledgeable

Joined: Sun Jul 29, 2007 12:23 am
Posts: 199
I see the same stuff. Its quite annoying sometimes.


Top
 Profile  
 
PostPosted: Mon Jun 15, 2009 4:50 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
It has to do with your ping. You could receive data every 200 milliseconds or 20 milliseconds or even 1000+ milliseconds (which means 1 second of delay).

When the player moves you will receive their location every however many ping. They can move faster than your ping (unless you're under 32 or something probably) and when you catch up with the server they will jump from where you currently see them to where they actually are...which is what we call lag.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Mon Jun 15, 2009 9:49 pm 
Offline
Knowledgeable

Joined: Sun Jul 29, 2007 12:23 am
Posts: 199
I wouldnt expect to really lag on a 2D DX7 game. Idk though. :?


Top
 Profile  
 
PostPosted: Tue Jun 16, 2009 6:54 am 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
Beres wrote:
I wouldnt expect to really lag on a 2D DX7 game. Idk though. :?


It really all depends. I get alot of clientside lag. I hate playing games that uses DX7 though. DX8 is already outdated..

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1029 posts ]  Go to page 1, 2, 3, 4, 5 ... 42  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group