Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ 1 2 [3] >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: some math help please?< Next Oldest | Next Newest >
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 23 2008,21:10 QUOTE

Well at least the one based on my last "patch" doesn't seem to have the "line-grav" anymore...
Code Sample
-- based on last code "patch"
 if distance <= 25 then -- warp it offscreen
   ball[i]:color(b)
-- delete old 2 lines, add
   if math.random(0,1) == 0 then
      bx = math.random(0,1)*max_x
      by = math.random(1,max_y)
   else
      bx = math.random(1,max_x)
      by = math.random(0,1)*max_y
   end
 end
This one make them warp offscreen, but looks 'square-ish' unless you add an additional offset to it (due to choosing a coordinate on the edges of the window box).  Not sure how many random()'s you'd want to use.

My previous post's warp just copied the random code that was used at the start where it chooses a coordinate anywhere in the window.
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Jan. 23 2008,21:58 QUOTE

Quote
This one make them warp offscreen, but looks 'square-ish' unless you add an additional offset to it (due to choosing a coordinate on the edges of the window box).  Not sure how many random()'s you'd want to use.
That's exactty the issue I was trying to solve from my most recent test (I'm up to version "3e" now)

btw, color(b) is a typo. The b variable was a leftover from a previous script. The color should be c


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Jan. 23 2008,22:41 QUOTE

mikshaw, Thanks for posting/sharing. It is really cool!
Back to top
Profile PM WEB 
spark-o-matic Offline





Group: Members
Posts: 68
Joined: Jan. 2008
Posted: Jan. 30 2008,06:49 QUOTE

I have played with things like this on and off dating back to 1992.
One thing i like to do is use sin() to move the object more slowly as it reaches its objective or move it in a non-strait line.  logrithems behave similarly but a different pattern.
i also like to reposition the object to a random location at a random time with the odds of it being repositioned increasing as it gets closer to the objective.  this can be done with a simple
Code Sample
(Distance From Objective) < (Random Number)

And this random number would not need to be generated again until the object reaches it.  This can reduce the number of objects close together where their all headed to.
You can also weight the occurences of where it is repositioned(maybe you want more to end up at the edge of the screen).

Sorry this is pretty general, but i dont recognise enough of the sytnax to give good code.  maybe it might give you some ideas.

sparks


--------------
The smartest person is not the person who knows the most.  
The smartest person is the one who knows which book to look in.
Community knowledge can be the sum of it's knowledge or the sum of it's ignorance
The Definition of a 'Brain Fart':
When something comes out of my brain that Stinks!
Back to top
Profile PM WEB 
13 replies since Jan. 23 2008,00:42 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ 1 2 [3] >/
reply to topic new topic new poll
Quick Reply: some math help please?

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code