Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Slowing down pixel movement not working

Author
Message
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 12th Dec 2010 17:53
I'm trying to make a 2d fireworks utility. It's currently in a verry primitive state, using dots and boxes. But I need to position dots in a way to make an explosion circular. I've acheived this by setting a velocity for each dot using sin and cos. THe explotion works but is way to fast. But when I just scale down the Xvel and Yvel, the circle becomes more of a square since you can position pixels at integer positions. So I tried using a timer and increase the position by the velocities only in certain time increments but that makes everything very chopy. Anyone know a solution?

My computer surpasses all the technologies of the day. What computer do I have?

BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 12th Dec 2010 17:59 Edited at: 12th Dec 2010 18:00
well the easiest thing to do is set the sync rate 60
or, use timer based movement for your dots and boxes.

It's nice that you have too much speed, that is easy to fix,
as you add more complexity, more particles,etc. you will strain for enough speed.

Also, we would love to see some source code, we love fireworks here!
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th Dec 2010 18:15
Use floats instead of integers, and use timer-based movement.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 12th Dec 2010 18:46
Well that's the thing, my sync rate is at 60. And I can't use floats because you can't position pixels at float positions, only integer positions.

My computer surpasses all the technologies of the day. What computer do I have?

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Dec 2010 21:11
You can use floats, then when you use them to position your dots, DBPro will automatically convert to integers.

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 12th Dec 2010 21:49 Edited at: 12th Dec 2010 21:50
I just found a solution, divide the velocities by 1.5 in increments of time so this was the code I got.

It works really good actually.


My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2026-07-21 04:20:35
Your offset time is: 2026-07-21 04:20:35