Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User NHaGa's Avatar
    Join Date
    Jul 2008
    Posts
    6
    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...

  2. #2
    Nokia Developer Champion gaba88's Avatar
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,692
    Quote Originally Posted by NHaGa View Post
    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

  3. #3
    Regular Contributor GonzalezM's Avatar
    Join Date
    Jun 2008
    Posts
    87
    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.

  4. #4
    Registered User NHaGa's Avatar
    Join Date
    Jul 2008
    Posts
    6
    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?

  5. #5
    Regular Contributor GonzalezM's Avatar
    Join Date
    Jun 2008
    Posts
    87
    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.

  6. #6
    Registered User NHaGa's Avatar
    Join Date
    Jul 2008
    Posts
    6
    Good idea. I'll try that

  7. #7
    Super Contributor jethro.fn's Avatar
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524
    Quote Originally Posted by GonzalezM View Post
    For the graphics you can probably use two images, one empty and one full, then just blit different sections depending on the time.
    Ha! If I had the time (no pun intended), I would definitely use particles, i.e. grains of sand. I wonder how many pixel-sized particles a PyS60 canvas could update with a reasonable frame-rate. Ten, maybe more?

  8. #8
    Super Contributor JOM's Avatar
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976
    Quote Originally Posted by jethro.fn View Post
    I wonder how many pixel-sized particles a PyS60 canvas could update with a reasonable frame-rate. Ten, maybe more?
    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

  9. #9
    Super Contributor JOM's Avatar
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976
    Quote Originally Posted by NHaGa View Post
    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?
    Well,

    http://jouni.miettunen.googlepages.com/countdown

    Here's a skeleton i.e. countdown timer. Just change the graphics

    Cheers,

    --jouni

  10. #10
    Regular Contributor GonzalezM's Avatar
    Join Date
    Jun 2008
    Posts
    87
    Quote Originally Posted by jethro.fn View Post
    Ha! If I had the time (no pun intended), I would definitely use particles, i.e. grains of sand. I wonder how many pixel-sized particles a PyS60 canvas could update with a reasonable frame-rate. Ten, maybe more?
    That's cool, but if you only use a small number of particles your hourglass's timing might be unpredictable.

  11. #11
    Registered User NHaGa's Avatar
    Join Date
    Jul 2008
    Posts
    6
    Anyone know where I can get some info on coding and modeling the particles?

  12. #12
    Regular Contributor GonzalezM's Avatar
    Join Date
    Jun 2008
    Posts
    87
    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

  13. #13
    Nokia Developer Moderator petrib's Avatar
    Join Date
    Mar 2003
    Posts
    9,414
    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.

  14. #14
    Nokia Developer Champion olympio's Avatar
    Join Date
    Nov 2005
    Posts
    42
    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

Similar Threads

  1. A Cracking Idea!!
    By Raggyroller in forum News, Announcements and Job Listings
    Replies: 3
    Last Post: 2006-10-26, 16:27
  2. Idea for all phones PIR
    By kimmi in forum News, Announcements and Job Listings
    Replies: 0
    Last Post: 2006-08-02, 22:20
  3. next steps after having an idea?
    By MKCHD in forum Mobile Java General
    Replies: 3
    Last Post: 2006-03-22, 01:23
  4. Development idea
    By jassharp in forum General Development Questions
    Replies: 0
    Last Post: 2004-10-04, 16:56
  5. New Product Idea
    By 050371 in forum Multimodecards
    Replies: 1
    Last Post: 2002-07-03, 04:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved