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

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 16:19:12 -

I think by smoothing it out, Lelle means that when the object moves three pixels at a time, it looks skippy. Like below:

Where the object is moved 1, 2, or 3 pixels at a time when right or left is pressed.

 
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
3rd July, 2009 at 18:50:44 -

so completely relevant posts are unrelated, jon?

Make sense.

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
3rd July, 2009 at 19:06:47 -

also, various people were pointing out that the problem can have multiple causes. Your vitalized example wasn't really necessary.

 
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
3rd July, 2009 at 19:26:57 -

Relevant was the word I was looking for when I posted that. Not unrelated, thank you. Again, I didn't mean to offend anyone but it just seemed to me that when this was said:

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


and this:
Originally Posted by Lelle
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...


led me to believe that none of the previous responses addressed the problem (and if they do, I don't see how as none of them as far as I can see address the fact that moving an object 3 pixels in one loop causes a noticeable jump in position), as well as leading me to believe that the "jump" or "twitch" was caused by the fact that the object is moved three pixels at a time, as opposed to accelerating too slowly, or not having acceleration or decceleration. The Vitalize app was supposed to demonstrate that jump in position, but if it wasn't necessary then I'm sorry.

If I've offended anyone here or misunderstand what anyone is saying, them I'm sorry. I also don't mean to be speaking harshly or anything, in fact I'm taking a very calm tone to this, but somehow or another my syntax apparently makes me sound angry or frustrated on the internet at all times.

 
Sandwich Time!Whoo!

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

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 19:46:23 -

Nothing happens in your Vitalize app for me anyway, I can change the counter value but nothing happens when I press left/right.

 
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 19:47:16 -

What Lelle says isn't so clear, but I'm still inclined to believe that his/her problem must have nothing to do with the way he/she move the character. It must be related to the visual.

Three pixel isn't much, but if it's for your walrus project, wich seem to have a pretty small resolution (320x240 at most), and with small sprites, it's a problem. See... if I have 64x80 pixels sprite and I move it by 3 pxls, then when the screen refreshes, the new sprite's display overlaps the the old one by 95%. That makes a smooth movement. But your blue walrus is only 15x24 pxls so 80%. If your frame is resized bigger, then it should look blocky too, and that won't help. It should still look fine though technicaly.

Also, the trail visual illusion produced by moving too fast should be reduced if the background color is close too the moved object, or at least if it isn't too pale. So if you're testing on a white background, that might be the cause.

Once you implement scrolling, the character should be centered, so it's the background wich'll look "twitchy". It shouldn't matter anymore since the player should focus on the character.

 
...

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
3rd July, 2009 at 22:38:01 -

I didn't take offense to it, but the fact was that we were trying to eliminate some of the possibilities of his problem.The posts were, in fact, relevant. He didn't explain his problem very well (which isn't 100% his fault anyway).

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
4th July, 2009 at 03:18:29 -

We are all trying to help and all on topic, so all these posts are relevant.
Chris Street's solution is the one that works to solve Lelles' problem btw, unless it is an animation or hotspot/action point issue.
After reading all the posts, I'm willing to bet that it's acceleration/deceleration which Lelle was wanting to know how to do.


 
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 ?
   

Post Reply



 



Advertisement

Worth A Click