Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jun 2003

    Simple game do NOT imply simple solution...

    I'm trying to make a game where there are a number of balls bouncing (for now only with 45 degree angle) on a rectangular area and where you can controll a cursor moving horizontally or vertically in the same rectangular area.

    The problem seems to be very simple, but there are a lot of things to care attention in order to have the best result.

    There are 2 main targets that I would like to reach:
    1-smooth movement of balls
    2-very quick response to keypress event

    Unfortunately two targets are in conflic each other, because if you want a smooth movement you have to repaint practically every loop inside a while statement, but in this way you don't leave spaces for response key.

    If you put a sleep (also a sleep(5) !!) the balls movements becomes very slow, but unfortunately you don't get any improvements for the "response key problem".

    There is to note that every step I don't clean all the screen but only the previous point where there was the balls, and then I repaint only the balls in the next position.
    I have tried also to use fillRect insted balls image with the same results...

    Also using keyRepeated, the time from one cursor movement and the other (especially after the first button press) is too slow for my taget.

    I have to try to use more than one thread?

    Every advice, also the smallest, will be very appreciated!!!
    Many thanks in advance!

  2. #2
    Registered User
    Join Date
    Mar 2005


    Since you have a while lopp which is computationally deciding how to draw the balls why don't you have this while loop also process keys that have been placed in a queue from the keypressed. Basically the key press could simple set a value to a variable that is checked in the while loop to process a key movement or you can have a queue. Just a thought. I think a single variable would be fine since you will no optimize any faster with a queue unless of course you want to compute the series of keys in a queue to the final movement.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Hi! I'm a newbie too and i have the same problem.

    I'm developing a pong-like game and i can't get the player's pad move smoothly on the Nokia 3510i

    I set a variable true when keyPressed() is called and i reset it with keyReleased(). In the main loop, if the variable is set true, i move the player's pad up or down.

    With the "DefaultColorPhone" emulator provided with WTK, everything works fine, but when i switch to Nokia's 3510i (emulator or real phone) the pad moves very very slow, making the game unplayable.

    If anybody wants to give it a look, the code is published at digilander.libero.it/armenioweb/code/index.htm

    Thank you everyone!

  4. #4
    Registered User
    Join Date
    Mar 2003

    Fixed it!

    Thanks anyway, but i managed to solve my self the problem.
    The problem was that my code wasn't optimized and, since the 3510i is really slow, the collision detection procedure slowed it all, although the game was really simple and i'd never thought i had this kind of trouble.

    Hmm... i hope my english is correct... bye!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts