The Daily Click ::. Forums ::. Klik Coding Help ::. Soften out my platformmovement?
 

Post Reply  Post Oekaki 
 

Posted By Message

Lelle



Registered
  14/08/2003
Points
  82
1st July, 2009 at 20:46:06 -

I'm currently using a custom platform movement which works by adding or subtracting 1 to an alterable value while holding a direction key. (capped to 3 or -3)

alt value A >0
Set x of (player) to x(player)+1
alt value A >2
Set x of (player) to x(player)+1


alt value A <0
Set x of (player) to x(player)-1
alt value A <2
Set x of (player) to x(player)-1

(the second one doubles the "speed" if it's "3" or "-3")

If i try to make it move up to 3pixels per step it get's a bit twitchy...

Any idea how to make it softer with higher speed?

(hope noone mentioned this before)

 
n/a

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
1st July, 2009 at 21:21:18 -

You mean to soften the visuals/scrolling?
If so I say:
Higher frame rate obviously
Parallaxing background will help too.

Edited by Spitznagl

 
...

Lelle



Registered
  14/08/2003
Points
  82
1st July, 2009 at 21:34:31 -

I just mean the characters movement itself, even when it's not scrolling.
I move it pixel by pixel and it gets twitchy when I go above 3px per move...
I guess my movement isn't that professional since I haven't tried these things much...

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
2nd July, 2009 at 03:01:04 -

Sounds to me as if your character accelerates slowly. Try making the acceleration faster where it doesn't take much time to get up to top speed.

If your character is human (not trying to say be realistic, this is just an example), think about how long it takes for YOU to get up to top speed. Not long at all, correct?

Also, does your character stop completely before changing directions? You need an event to counter the fact that you're using a single alterable value for movement.

When your value = 0 it obviously wont move in either direction so make sure that if the person is inputting a command (left or right) to adjust the value when ever it equals 0 to the direction the player is inputting.

Sorry if this is incorrect, but it is pretty hard to comprehend your initial post. I think something like this would be much better if you posted an actual example, or code snippet.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
2nd July, 2009 at 06:19:12 -


repeat while right is pressed
alt val A < 3
Set x of (player) to x(player)+1
add 1 to alt val A

repeat while right is pressed
alt val A >= 3
Set x of (player) to x(player)+2

Would be my guess ... I don't really know what you're asking, lol .. toss the source up so we can see what you mean and help if this doesn't work.


 
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 ?

Lelle



Registered
  14/08/2003
Points
  82
2nd July, 2009 at 08:32:05 -

Thanks for the replies.
But I think I'll just work it out myself... Your method might work.
the only problem I had was that the player didn't move those 3 pixels smothly, it kinda "jumped" but i guess i can work it out some way...
Thanks again.

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
2nd July, 2009 at 15:40:09 -

Why don't you try posting some actual code? This should only take a minute to solve .

I think i've had a similar problem due to a corrupted file . . .but that was in TGF 1 I believe.

I might go install mmf and make you an example later, but I'm getting ready to go to my shop. Also I would recommend moving your character in increments of 1 pixel (ex alt value = 3 set x to x +1 3 times rather than just set x to x+3) unless you are using fastloop. This will solve any horizontal collision problems you >might< have later. You usually only need them when using faster speeds (5x etc.), but it IS a preventative of problems.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
2nd July, 2009 at 23:28:29 -

Also, you may want to include something like

Alt Value A > 3
---Set Alt Value A to 3

and

Alt Value A < -3
---Set Alt Value A to -3

This will cap your alterable value at 3 or -3, respectively.

 
n/a

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
3rd July, 2009 at 01:34:09 -

@s-m-r: why two new events when you can simply add conditions to the events wich modify that value?

Edited by Spitznagl

 
...

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
3rd July, 2009 at 02:16:00 -

Lelle's problem, despite multiple responses (all well-meaning but, no offense, unrelated) is in the fact that Lelle has decided that speed will work by moving the object pixel by pixel, where the Alterable Value is determining how many pixels the character moves per loop. This is a basic way to do this (as I used this manner of movement for New Super Mario Land's old engine and multiple older engines) and suffers when the character must "jump" more than two pixels at a time in any direction.

One way to solve this would be to have the character move left or right with a bouncing ball movement (thus allow for easier control of speed) or the default platform movement restricted with 0 gravity and No Jump. In this way Lelle can use Clickteam's manner of speed and make life much easier by having the speed always set to the Alterable Value and having that value increase as left or right is pressed. (For more controllable purposes I have always had it decrease with left and increase with right, and when the alterable value is negative the speed is set to Alterable Value*-1 and the direction is set accordingly.)

However, if you insist on using your original manner of moving by pixel, you can use cosines of a specific angle or radian. Muz has written a good article on the use of trigonometry for speed: http://www.create-games.com/article.asp?id=1984

 
Sandwich Time!Whoo!

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

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
3rd July, 2009 at 03:45:38 -


Originally Posted by Spitznagl
@s-m-r: why two new events when you can simply add conditions to the events wich modify that value?



I honestly don't know off the top of my head how to do what you're describing. Can you give an example?

(This would definitely help me learn more as well!)

 
n/a

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
3rd July, 2009 at 04:00:50 -

@s-m-r: That's not what the topic is about, so I'll be quick.

You already have an event such as this one:
+Repeat while "right arrow key" is pressed
-add 0.1 to Value A

Now just add this condition to that event:
+Value A < to 3


 
...

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
3rd July, 2009 at 12:19:37 -

But putting in the lines I suggested would prevent the Alt Value from becoming too high. In other words, even though the top speed is 3, the Alt Value that serves as a "speedometer" still increases in value. There may be lag time between when the player stops pressing the direction key, the lowering of the Alt Value, and when the object actually stops updating its position.

Ah, I don't know. It was just a suggestion. If that lags the code too much, then of course it can be erased.

 
n/a

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
3rd July, 2009 at 14:42:28 -

When an app lags, it skips entire frames, it doesn't break the event flow. And your argument is invalid since if it would skip events, it could skip your event wich reset the value to 3.

By checking if the value is lower than 3, it could get over 3, but just once, and since the result is rounded to the closest integer from zero, that wouldn't be a problem unless the event would add 2 or more to the value.

So, the results are pretty much the same, exept for the fact that you've got two events more than me.

 
...

The Chris Street

Administrator
Unspeakably Lazy Admin

Registered
  14/05/2002
Points
  48487

Game of the Week WinnerClickzine StaffAcoders MemberKlikCast StarVIP MemberPicture Me This Round 35 Winner!Second GOTW AwardYou've Been Circy'd!Picture Me This Round 38 Winner!GOTM December Third Place!!
I am an April FoolKliktober Special Award Tag
3rd July, 2009 at 14:46:44 -

Do this:

Always: Set X Position of X "Player" to X + (Alterable Value B / 4) - Don't forget these brackets, they're very important!

This gives the player some acceleration and decceleration. Which is what I presume you mean by "smoothing it out?"

Then the events:

Repeat while RIGHT is pressed
and Alterable Value B is LOWER than 16 (the maximum number is increased because the dividing of the Value means its a slower process to reach this number):

Add 1 to Value B (increase to increase the acceleration)

And vice versa for heading LEFT

Edited by an Administrator

 
n/a
   

Post Reply



 



Advertisement

Worth A Click