Moving objects with incremental slowdown..

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

Moderator: troed

Post Reply
User avatar
exxos
Site Admin
Site Admin
Posts: 12239
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
YouTube: https://www.youtube.com/user/exxosuk
Contact:

Moving objects with incremental slowdown..

Post by exxos » Thu Apr 16, 2020 12:44 pm

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.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxoshost.co.uk/atari/store2/ - All my hardware mods for sale - Please help support by making a purchase.

User avatar
PhilC
Moderator
Moderator
Posts: 3641
Joined: Fri Mar 23, 2018 8:22 pm

Re: Moving objects with incremental slowdown..

Post by PhilC » Thu Apr 16, 2020 12:49 pm

Table of numbers is how I used to do my sine scrollers etc.
If it ain't broke, test it to Destruction.

mikro
Posts: 221
Joined: Mon Aug 28, 2017 11:22 pm

Re: Moving objects with incremental slowdown..

Post by mikro » Fri Apr 17, 2020 7:40 am

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”