The Daily Click ::. Forums ::. Klik Coding Help ::. Making a smooth custom movement behaviour for sprite
 

Post Reply  Post Oekaki 
 

Posted By Message

eski



Registered
  20/09/2009
Points
  39
9th July, 2010 at 00:50:42 -

I want my player and all moving sprites to have smooth movements in my game.
When i use the platform movement that is in MMF, well its just laggy.
I have seen many games made with MMF that have very smooth movements, just not the source.

I was wondering what was the first thing that i need to consider when making a custom movement on a sprite.
What is the best way to achieve this goal, basicly to have the sprite move around smootly without the sprite images to be blurry or all jiggery like on the platform movement type.
Is this somehow related to the Frame rate on the application ?

Its hard to describe this problem but i get these results for example when moving a simple sprite in Flash or with the default movements behaviour in Construct.


 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
9th July, 2010 at 01:14:29 -

I think I know what you're talking about and it could indeed be related to Frame Rate. Have you tried enabling VSync?

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

eski



Registered
  20/09/2009
Points
  39
9th July, 2010 at 02:21:24 -

Yaubb, Vsync on/off does'nt matter. And not the machine independent speed thing also.
I have a super computer so that is not the problem.

Its like the basic movements draw the sprites somehow weird when moving.
When they move in a straight line they go like 20px per second but it looks like they go and jump a little further like 20px + 2-3px. Its like the timeline on the movement is somehow laggy.

God damn, its hard to explain this.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
9th July, 2010 at 02:39:14 -

Could you build an exe for me? And have you had any experience making custom engines before?

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
9th July, 2010 at 08:01:22 -

Have you tried disabling some fast loops? I know those can add up and really bring a game to it's knee's.

 
http://www.facebook.com/truediamondgame

eski



Registered
  20/09/2009
Points
  39
9th July, 2010 at 22:19:32 -

Allright, first off, i dont know how to make a custom movement thing.
I'm just asking what i should mind when starting to make them.

In this zip file i have two .exe that i maked.
One is from MMF and has a build in movement.
The other one is from Construct, build in movement but much smoother.

The one in MMF well you can see that the sprite is all shaky when its moved.
Is this something i can fix with "frame rate" or with custom movements and something more ?

http://dl.dropbox.com/u/4436588/balls.zip

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
10th July, 2010 at 07:40:18 -

Built in movement sucks, learn custom.. it's really not that hard. I mean if you're going to take as big of a short cut as to use a large program like MMF to make your game for you, the least you could do is take some control over how it's actually done.

 
http://www.facebook.com/truediamondgame

eski



Registered
  20/09/2009
Points
  39
10th July, 2010 at 10:42:41 -

I know i need to use custom movements in MMF to get a smooth move.
If you would read my first post you would see that I am asking about custom movements.

Do i have to change the default settings og the mmf application (frame rate, machine independent speed ....) ?
Do i use fastloops making a custom moves ?
What are the do's and dont's ?
How would i go by geting the ball-construct.exe movement in MMF ?

In the .exe files i used the build in movements to demostrate a point.


 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
10th July, 2010 at 15:39:47 -

If there is anything I learned from DavidN's tutorial, it is that you can use fastloops to make it nice.

http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastloop_plattutorial.zip

You'd use a fastloop that detects backdrops and other collisions and then forces your character out so that they aren't stuck in the ground, walls, or ceiling.

Besides that, you'd also use FrameRate to make sure that the object doesn't move more than a certain amount of pixels per loop. For example, if a speed of 200 means that your object should move 200 pixels per second, then you would have the object move 200/FrameRate pixels at a time. If the framerate were 50, that would be 4 pixels per loop.

You shouldn't have to change any of the default settings of the application, but if you change the FrameRate after having done what I just said, things will look smoother and still move the same amount. Of course, if you increase the frame rate, you'll make performance drop on weaker computers.

I just got done making this the other day; it uses fastloops for collision detection and checks FrameRate for movement (although you wouldn't be able to tell.) You can use the arrow keys to move, Shift to jump, and R to restart it.



Edited by an Administrator

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
10th July, 2010 at 19:47:11 -


Originally Posted by Jon Lambert
If there is anything I learned from DavidN's tutorial, it is that you'll need fastloops to make it nice.

http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastloop_plattutorial.zip




You do not need fastloops to make a smooth, bugless, custom engine. Just about anything you can do with fastloops can be done without fastloops.

Edited by GamesterXIII

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
10th July, 2010 at 22:42:24 -


Originally Posted by GamesterXIII

Originally Posted by Jon Lambert
If there is anything I learned from DavidN's tutorial, it is that you'll need fastloops to make it nice.

http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastloop_plattutorial.zip




You do not need fastloops to make a smooth, bugless, custom engine. Just about anything you can do with fastloops can be done without fastloops.

Fixed it. I usually don't make claims like that. Anyways, if you could whip up a quick example to teach us all, I'm sure I'd learn something.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1968

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
10th July, 2010 at 22:46:44 -


Originally Posted by Jon Lambert
If there is anything I learned from DavidN's tutorial, it is that you'll need fastloops to make it nice.

http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastloop_plattutorial.zip



That's really not a good example to follow. It uses fastloops where they're not needed, making it inefficient and hard to use with duplicates (eg. enemy objects), it uses a detector object (again, not duplicate-friendly), and it's not smooth because it doesn't even store the coordinates as floats.

Fastloops are useful for pushing objects out of obstacles, but they're not needed for the movement itself.

The standard refresh rate of most monitors is 60 hertz, so there's no point setting your game's framerate any higher than 60fps. To be able to achieve that framerate even on old computers, you may need to code your engine quite efficiently (ie. DO NOT use a lot of fastloops) and use hardware acceleration.

One of the most important things to remember when trying to make a smooth custom movement of any kind, is to store everything in alterable values.
The built-in X/Y position properties only hold integers (whole numbers). That means that if you have an object with a speed of 1.8 pixels per frame, it will actually move exactly 2 pixels because it gets rounded up. Similarly, if the speed is 0.4 ppf the object won't move at all.
You get around this by using alterable values to store the object position, and then set the actual X and Y coordinates to those alterable values after.

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
10th July, 2010 at 22:57:51 -


Originally Posted by Sketchy
That's really not a good example to follow. It uses fastloops where they're not needed, making it inefficient and hard to use with duplicates (eg. enemy objects), it uses a detector object (again, not duplicate-friendly), and it's not smooth because it doesn't even store the coordinates as floats.

Fastloops are useful for pushing objects out of obstacles, but they're not needed for the movement itself.

Oh yeah, I forgot to mention that, about using values for position storage. I used fastloops for collision detection as well as angle detection and sticking to the ground in that engine. I just used that example because it teaches the use of fastloops for collision detection.

So yeah, you would use alterable values or other such things to store values that represent the X and Y positions, and then you would have the X and Y positions set to those values. I also made my engine reliant upon a number of alterable values that determine how you move. In that engine, I used values for acceleration, deceleration, maximum x and y velocities, gravity, jump strength, jump endurance, lateral recoil (that is, how far your character is pushed if you jump off of sloped ground), as well as storing X and Y velocities in separate values, so that I can manipulate virtually all traits of the engine at runtime, making things like temporary speed or jump boosts easier to implement.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

eski



Registered
  20/09/2009
Points
  39
11th July, 2010 at 02:10:53 -

Ah, so the build in movements in MMF use integers ?
Would explain why they are so weird


 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1968

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
11th July, 2010 at 15:27:11 -

Actually, I don't think the custom movements do use integers to store the object positions - only variables such as speed (1 speed unit = 8 pixels per frame; meaning speed is variable in increments of 0.125 ppf).

It's just a very common mistake that people often make when trying to create custom movements.

 
n/a

eski



Registered
  20/09/2009
Points
  39
11th July, 2010 at 22:54:16 -

OK, now i know little more about this.
Do you know of any articles or tutorials how to make a good custom movements ?
Something that doesn't use fastloops and is smooth as a fox
If not then could you explain how you do it, just the basic stuff for a simple platform.

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14564

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
12th July, 2010 at 00:08:36 -


Originally Posted by GamesterXIII

Originally Posted by Jon Lambert
If there is anything I learned from DavidN's tutorial, it is that you'll need fastloops to make it nice.

http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastloop_plattutorial.zip




You do not need fastloops to make a smooth, bugless, custom engine. Just about anything you can do with fastloops can be done without fastloops.



I made my own custom physics engine without using fastloops. I didn't want to have to work out how to use extra fastloop events to sort through the multiple instances to get it all to work properly. But on the other hand i now have about a hundred extra events lol.
The same goes for my enemies movements actually.

 
.

eski



Registered
  20/09/2009
Points
  39
12th July, 2010 at 23:02:33 -

I dont have a clue how i would make a custom movement without fastloops.
Just, while pressing some key down then this happens.. ?

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
14th July, 2010 at 01:48:32 -

Here's a couple ways that I know:

1) * Put everything into groups in the event editor and use the built-in group loops. *
------ It's good to be able to turn off a loop easily when you need to.
A nice thing to do sometimes is create an activation group, where you put all the events that trigger the other groups.
If there's alot of code, using several of these activation groups makes for better organisation.

2) * Use counters or alterable values to simulate a loop. *
------ This method can be quite effective. I usually prefer counters but when the code gets complex, alterable values are nice.
A mixture of the two is ideal.

3) * Hotkey a button press during game runtime to Use an outside Script or Programming Language. *
------ If you want more versatility and power in your loops this could be the way to go.
I'm really just guessing on this one as I haven't actually tried it yet. Use of .ini's or arrays may be needed for some of this <shrugs>

Edit: well, I have used 3, but only to run a magnification script during gameplay, never used it for loops as of yet


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Ricky

loves Left For Dead 2

Registered
  28/12/2006
Points
  4175

Has Donated, Thank You!Game of the Week WinnerVIP MemberWii OwnerHero of TimeGOTM Winner! - November 2009I am an April Fool
14th July, 2010 at 02:55:19 -

I'm sure there are plenty of articles you could search for that would help you. You can also do a search in the downloads for open source. That will give you a basic idea of different ways to approach movements, and then you can create your own.

http://search.create-games.com/?q=movement&sar=on

http://search.create-games.com/?q=open+source&sdo=on

 
-
   

Post Reply



 



Advertisement

Worth A Click