News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
someone with mad math skills, help please
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: someone with mad math skills, help please

I tried it assuming that 'a' was maximum speed, and came up with something different, but not very different than what I already had. Actually it was farther away from my goal.

Here is the curent loop I have, with this change:

Code:
function grav_loop()
local my_x,bx=Fl:event_x(),0
local my_y,by=Fl:event_y()-demo_bh,0
local c=math.random(1,255)
local b=math.random(1,balls)
ball[b]:color(c)
  for i=1,balls do
    local xdistance=math.abs(my_x-ball[i]:x())
    local ydistance=math.abs(my_y-ball[i]:y())
    local distance=math.sqrt(xdistance*xdistance+ydistance*ydistance)
    local speed=1+5/distance
    if distance > 0 then
      if my_x > ball[i]:x() then
        bx=ball[i]:x()+speed
      else
        bx=ball[i]:x()-speed
      end
      if my_y > ball[i]:y() then
        by=ball[i]:y()+speed
      else
        by=ball[i]:y()-speed
      end
      ball[i]:position(bx,by)
    end
  end
demo_widget:redraw()
grav_timer:doWait(.05)
end

ball is a table of randomly placed circles

EDIT: Actually I kinda like that one too. I'm going to keep it in the mix as stage 3. Thanks.

This post was last modified: 01-23-2008 12:27 PM by mikshaw.

01-23-2008 12:18 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
RE: someone with mad math skills, help please - mikshaw - 01-23-2008 12:18 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: