Moving objects with incremental slowdown..

News,announcements,programming,fixes,game patches & discussions.

Moderator: troed

Post Reply
User avatar
exxos
Site Admin
Site Admin
Posts: 23488
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

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.
https://www.exxosforum.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxosforum.co.uk/atari/store2/ - All my hardware mods for sale - Please help support by making a purchase.
viewtopic.php?f=17&t=1585 Have you done the Mandatory Fixes ?
Just because a lot of people agree on something, doesn't make it a fact. ~exxos ~
People should find solutions to problems, not find problems with solutions.
User avatar
PhilC
Moderator
Moderator
Posts: 6011
Joined: Fri Mar 23, 2018 8:22 pm

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: 474
Joined: Mon Aug 28, 2017 11:22 pm
Location: Kosice, Slovakia
Contact:

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.
Post Reply

Return to “SOFTWARE PROGRAMMING & DISCUSSION”