collision in android not detected -


i developing android game in bird should able dodge objects approaching using accelerometer sensor.

this code should detect collision, isn't. can tell problem is?

do{             random(); //for generating random no.k//moving objects using animations.             translateanimation animation_plane = new translateanimation(0.0f, 0.0f,                     0.0f, 800.0f);             animation_plane.setduration(4500);             animation_plane.setrepeatcount(i);             translateanimation animation_superman = new translateanimation(0.0f, 0.0f,                     0.0f, 800.0f);             animation_superman.setduration(3000);             animation_superman.setrepeatcount(i);             translateanimation animation_space = new translateanimation(0.0f, 0.0f,                     0.0f, 800.0f);             animation_space.setduration(2500);             animation_space.setrepeatcount(i); if (answer % 2 == 0)  //answer random int being generated                 plane.startanimation(animation_plane);             if (answer % 3 == 0)                 superman.startanimation(animation_superman);             if (answer % 4 == 0 || answer % 5 == 0)                 spaceship.startanimation(animation_space);     bird_x = bird.getx();//for getting position of objects , bird.               bird_y = bird.gety();     plane_x = plane.getx();     plane_y = plane.gety();     superman_x = superman.getx();     superman_y = superman.gety();     spaceship_x = spaceship.getx();     spaceship_y = spaceship.gety();          if(spaceship.gettranslationy()>660)             {                 score+=1;                 newscore="score = "+score+"";                 text.settext(newscore);             }             if(superman.gettranslationy()>660)             {                 score+=1;                 newscore="score = "+score+"";                 text.settext(newscore);             }             if(plane.gettranslationy()>660)             {                 score+=1;                 newscore="score = "+score+"";                 text.settext(newscore);             }         }while(bird.gettranslationx()!=plane.gettranslationx()||bird.gettranslationx()!=spaceship.gettranslationx()||bird.gettranslationx()!=superman.gettranslationx());` 

should while condition use && instead of ||?

i'm struggling follow logic in game, i'm assuming point once plane/spaceship/superman goes bottom of screen, meaning you've dodged it? if of objects aligns bird x position, loop ends, , game ends?

you may need check bird y position same object y position too.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -