I got this problem since a few days.
I'm doing a game for my final exams and I have to present it infront of a comittee. My teacher said that I should try to build in at least one while, for and do while loop. But this is actually a huge problem for me . I had the whole game together only with if statements.
Now I'm actually forcing in some while and for loops but I don't think they make sense there.
Could somebody please check if they make sense there because if they ask me why I put it there I just can't say because you wanted me to :D
here for example in my opinion if would be much better
its the same as when I write
it just doesn't feel right for me as I would only use while if it would make sense to loop it.
I think this one is the only part were it would make a little bit of sense but actually if it happend once the game stops so no sense
It drives me crazy that I build them in but don't see the sense in them
could somebody please help me to get maybe an idea for a do while or for.
In my game there is a unicorn which falls down if you don't press the up button. You have to collect little images so the score gets up and there are some Castles and Clouds you have to avoid.
Any idea just for where it could be actually usefull to build one in?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | zaehler++; while (zaehler == k){ Actor Burg = new Burg(); //Schloss erstellen GreenfootImage image= Burg.getImage(); //Bildbereich addObject(Burg, getWidth(), Greenfoot.getRandomNumber( 116 )+ 200 ); // Abstand zwischen den Schlössern zaehler= 0 ; k= Greenfoot.getRandomNumber( 100 )+ 20 ; } |
1 2 3 | while (Greenfoot.isKeyDown( "up" )== true ){ dy = fliegen; } |
1 2 3 | while ( getY() > getWorld().getHeight()) { GameOveranzeigen(); } |
1 2 3 4 5 6 7 8 | public void GameOveranzeigen() { Game_Over Game_Over = new Game_Over(); getWorld().addObject(Game_Over, getWorld().getWidth()/ 2 , getWorld().getHeight()/ 2 ); Greenfoot.stop(); } |