Help: Quick way to test if value lies within a list of lists of ranges?
Scenario: = Using PyGame in particular, I am trying to write an application that will run a scripted timeline of events, eg at 5.5 seconds, play xxx.mp3 and put the image of a ball on screen, at 7.8 seconds move the ball up and down. At this point, I hear you say 'Oh, like Flash'. Yes, well... Like Flash, but I don't want to take this app in the same direction as Macromedia took Flash, nor do I (ever) want the two to be compatible. One particular need is for the timeline to be quickly traversable. If I want to go to time=239.4 seconds, I'd like it to go there pretty much painlessly and hopefully with one call. (Same with play, reverse and pause really) I also want it to play for a long duration, with lots of different items (images, audio, etc.) Let me be a little more specific: sprite(a) -> (onscreen during) 2 - 10 secs, 20 - 50 secs sprite(b) -> (onscreen during) 15 - 30 secs sprite(c) -> (onscreen during) 42 - 50 secs I need a quick way to rattle off a list of sprites that should be on screen at a given time. Needless to say the number of sprites will be variable, and might even change unpredictably in game. E.G. onscreen(time = 8.8 secs): return [sprite(a)] onscreen(time = 44.134 secs): return [sprite(a), sprite(c)] onscreen(time = 28 secs): return [sprite(a), sprite(b)] (NB Anything from 10 -> 200 sprites would be normal intended usage, each set -up with a list of start,stop times.) Any suggestions on a clever way to do this? I don't like the idea of looping through 100+ sprites and test them each an arbitary number of times every update. Is this just something unavoidable which should be written in C for speed and included with SWIG or something similar? Ben (Anti-Zealotry ward) :0: * ^Subject:.*Re: Microsoft Hatred FAQ | gzip >> junk-archive.gz IMO, We all have our personal experience or beliefs as to how MS operates. Petitioning MEP's/Senators will accomplish more than arguing on a Python mailing list. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why the nonsense number appears?
On Mon, October 31, 2005 9:39, Sybren Stuvel said: > Johnny Lee enlightened us with: >> Why are there so many nonsense tails? thanks for your help. > > Because if the same reason you can't write 1/3 in decimal: > > http://docs.python.org/tut/node16.html > > Sybren > -- > The problem with the world is stupidity. Not saying there should be a > capital punishment for stupidity, but why don't we just take the > safety labels off of everything and let the problem solve itself? > Frank Zappa > -- > http://mail.python.org/mailman/listinfo/python-list > I think that the previous poster was asking something different. I think he was asking something like this: If >>> t1 = 0.500 >>> t2 = 0.461 >>> print t1-t2 0.039 Then why: >>> t1 += 12345678910 >>> t2 += 12345678910 >>> # Note, both t1 and t2 have been incremented by the same amount. >>> print t1-t2 0.0389995574951 It appears Yu-Xi Lim beat me to the punch. Using decimal as opposed to float sorts out this error as floats are not built to handle the size of number used here. Ben -- http://mail.python.org/mailman/listinfo/python-list
Re: Why the nonsense number appears?
On Mon, October 31, 2005 10:23, Sybren Stuvel said: > Ben O'Steen enlightened us with: >> Using decimal as opposed to float sorts out this error as floats are >> not built to handle the size of number used here. > > They can handle the size just fine. What they can't handle is 1/1000th > precision when using numbers in the order of 1e10. > I used the word 'size' here incorrectly, I intended to mean 'length' rather than numerical value. Sorry for the confusion :) > Sybren > -- > The problem with the world is stupidity. Not saying there should be a > capital punishment for stupidity, but why don't we just take the > safety labels off of everything and let the problem solve itself? > Frank Zappa > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list