REMINDER - Stay logged in for at least 2 hours a week to get whitelisted.
Also it helps build a picture where our "good traffic" is coming from for detection scripts.
:o)

Moving objects with incremental slowdown..

News,announcements,programming,fixes,game patches & discussions.
User avatar
exxos
Site Admin
Site Admin
Posts: 28605
Joined: 16 Aug 2017 23:19
Location: UK

Moving objects with incremental slowdown..

Post by exxos »

Moving a object to the right for example I can simply do X=X+1 kinda thing. But there are effects where the object moves really fast for maybe 80% like X=X+10, but then incrementally slows down to a stop.

There is also another effect which has a kind of "rubber bounce" at the end, where it overshoots the stop position slows down and moved back to the left a few pixels. I guess the demo coders may know of this effect and how possibly to do it?

I am sure I did this in STOS like 25 years ago.. and it was using SIN/COS in the mix to get the full effect.. But I don't remember anything about it now :( I guess as a last resort I could just manually type in a table of numbers to do the effect.
User avatar
PhilC
Moderator
Moderator
Posts: 7495
Joined: 23 Mar 2018 20:22

Re: Moving objects with incremental slowdown..

Post by PhilC »

Table of numbers is how I used to do my sine scrollers etc.
If it ain't broke, test it to Destruction.
mikro
Posts: 825
Joined: 28 Aug 2017 23:22
Location: Kosice, Slovakia

Re: Moving objects with incremental slowdown..

Post by mikro »

Yup, just use a 1D array of some nice function (can be sin, cos, log, whatever you prefer/looks nice but sin is probably the easiest way).

So the first effect is easy, start at sin(90) = 1 and decrement the angle (index) to 0 (or increment to 180, same thing) which will produce smaller numbers (increases to X in your case). Of course, it's much easier to precalculate the whole thing, i.e. have the final "X" in your table for each increment.

For the bounce effect, that's easy, just don't end up with sin(0) directly on the border but, with, say, sin(5) so the last indices (4, 3, 2, 1, 0) would fall behind the border. Then wrap your sine curve and start counting backwards the same amount (5 indices in my example), putting it back to the border.

Return to “SOFTWARE PROGRAMMING & DISCUSSION”

Who is online

Users browsing this forum: ClaudeBot and 1 guest