This site requires JavaScript, please enable it in your browser!
Greenfoot back
Grennfootnoob
Grennfootnoob wrote ...

2016/2/5

counter

Grennfootnoob Grennfootnoob

2016/2/5

#
Hi, I'd want to know how to know if a variable is odd or even so it can count +1
danpost danpost

2016/2/5

#
You just want to know if the value does have or does not have a remainder after dividing by two (or, rather, if the remainder is zero or one). Review the table of arithmetic operators on this page of the java tutorials.
Grennfootnoob Grennfootnoob

2016/2/6

#
I want to program a break and the program should count the number of the keys so I can use the same key for stopping and starting greenfoot
if(Greenfoot.isKeyDown("space"))
                {
                    click = click+1;
                    
                    if( click/2 == number || number1 || number2 )
                    {
                        Greenfoot.delay(1000000000);
                    }
                    else
                    {
                        Greenfoot.start();
                    }
                    
                }
  int number = 1;
       int number1 = 3;
       int number2 = 5;
danpost danpost

2016/2/6

#
Grennfootnoob wrote...
I want to program a break and the program should count the number of the keys so I can use the same key for stopping and starting greenfoot
That is impossible. Your program cannot detect any keystrokes when it is in a stopped state.
You need to login to post a reply.