You Are Here:

Community: Developer Discussion Boards

#1 Old Simple game do NOT imply simple solution... - 2005-03-14, 10:41

Join Date: Jun 2003
Posts: 81
etamburini
Offline
Regular Contributor
Hi!
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!
Reply With Quote

#2 Old I am also having this slow key response problem - 2005-03-16, 22:12

Join Date: Mar 2005
Posts: 1
curtk555
Offline
Registered User
For some reason my apps are also responding slowly to key presses - even when practically no code is executed in the main loop. how is this solved? my apps work fine on other phones and i have seen several midp1 games that don't have this problem, so i am stumped.
Reply With Quote

#3 Old 2005-04-04, 09:04

Join Date: Nov 2004
Posts: 8
evianhat
Offline
Registered User
I believe that you would want seperate threads for the drawing and the key-checking.
Reply With Quote

#4 Old 2005-04-04, 16:29

Join Date: Jan 2004
Posts: 82
Leicester22
Offline
Regular Contributor
Maybe this will help you.
I made a arcade space shooter and I have quick responses to key events and smooth movement of shots/enemys/etc.
I implemented a Timer that starts each time the canvas is shown and stopps when canvas is hidden.
When the Timer is started you can define the interval in which the run() method of TimerTask is executed, and each time run() is executed it calls the canvas' paint() method. interval = 1000/(Frames per second) I have 15 Frames/second and it looks smoth.

Code:
 
Canvas.showNotify(){
    startFrameTimer();
}

Canvas.hideNotify{
    stoppFrameTimer();
}

stoppFrameTimer(){
    iTimer.cancel();
}

startFrameTimer(){
    iTimer = new Timer();
    iTimerTask = new TimerTask{
        public void run(){
            repaint();
        }
    };
    iTimer.schedule(iTimerTask, interval, interval);
}
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ