Could anyone help me write an hourglass program for the N95?
I want to start with a simple app that asks for the countdown in seconds and then have the hourglass work with the accelerometer.
Since the N95 sits up on both sides it would be great...
Could anyone help me write an hourglass program for the N95?
I want to start with a simple app that asks for the countdown in seconds and then have the hourglass work with the accelerometer.
Since the N95 sits up on both sides it would be great...
Hi NHaGa
First of all a warm welcome to you on the python discussion boards.
id dont know much about the hour glass but you can look at this for accelerometer.
Hope it helps
Gargi Das- http://gargidas.blogsot.com
Forum Nokia Python Wiki
Learn Python at http://mobapps.org/PyS60
That's a really clever idea for an app! For the graphics you can probably use two images, one empty and one full, then just blit different sections depending on the time. Or you can use vector graphics to make something cool and stylish, maybe with ellipses for depth so it doesn't look so flat.
You could even model sand particles, but I don't think N**2 problems are great for battery life.![]()
I was actually just giving the idea, because I am a complete newbie at programming and I thing this is a bit out of my league... Anyone interested?
I would love to if I had time. But you should give it a shot. Maybe write it on desktop first then port in to PyS60 later? It would be a good learning project. If you have the drive to do it you'll become an expert in no time.
Canvas update is fast, calculations you need to do before you're ready for that could be slow. I found that out with Rol-a-Bol, even run out of memory couple times. The complete screen is calculate every time, should do some optimizations with precalculated images etc.
Btw question: any ideas how to calculate FPS? I have a callback to canvas update and the system clock gives 1/64 second resolution, so I should be able to calculate fps slower than that? Right? At least something
Would it work, if I calculate for example averages of every 10 screen update calls and turn that around to fps?
Cheers,
--jouni
Well,
http://jouni.miettunen.googlepages.com/countdown
Here's a skeleton i.e. countdown timer. Just change the graphics
Cheers,
--jouni
Anyone know where I can get some info on coding and modeling the particles?
You need an array to hold each sand particle's x, y positions and vx, vy velocities. Then, on each cycle, you update the values based on surrounding grains of sand and the edges of the container, and add some to vy for gravity. You can multiply each velocity component by .999 each time to simulate a viscous atmosphere. Then just x += vx and y += vy to update each grain's position, and draw them on the screen. If a grain hits the container walls, you can modify the vx, vy based on the slope to make it bounce, like billiard balls that hit the edge of the table, plus dampen to some degree (perhaps by multiplying each component with .75 or so).
For particle collisions, to have check each's position against the positions of every other particle (n**2 problem), and make them sort of bounce if they are too close, and dampen, like billiard balls colliding with other billiard balls.
Hmm, I bet you could learn how to do most of this from an open source billiards game!
The current value for gravity could be based on the device's current tilt level. I did see a program that might help you with this:
http://www.youtube.com/watch?v=zqZeANFBmis
Or...
make three "video clips"; one for emptying upper part, another for a filling up the lower part, and a third that simulates the space in between (falling sand). Or maybe one "video" is enough, even.
And then vary the "video" frame rate/speed so that it approximates the time you want to take with the hourglass.
That'd approximate things well enough without taxing the poor phone processor and battery too much, I think.
Hi, in fact there is a HourGlass implementation for N95 on http://efforts.embedded.ufcg.edu.br/symbiancpp/?p=9.
It has been implemented with C++. With this you can see where you can reach.
best regards,
Olympio