Create Brain Overdrive Game in Android
This is yet another game like the 123Game. This game generates a single character which may be a Vowel, a Consonant, an Odd Number or may be an Even Number. The theme is you will get 3 seconds for each questions, you have to select the right option for it. If selected the right one then you will get 3 marks and the game gets over if u opt a wrong one !
Screenshots[Demo]
The Code:
For Generating Characters:
The OnClick Function
Alternatively you can download the whole ADT Project by clicking here.
Found Bugs, Comment them here !
Screenshots[Demo]
The Code:
For Generating Characters:
void calc()
{
es="02468";os="13579";vs="AEIOU";ks="BCDFGHJKLMNPQRSTVWXYZ";k="";
Random rand=new Random();
k=k+es.charAt(rand.nextInt((4 - 0) + 1));
k=k+os.charAt(rand.nextInt((4 - 0) + 1));
k=k+vs.charAt(rand.nextInt((4 - 0) + 1));
k=k+ks.charAt(rand.nextInt((20 - 0) + 1));
String input=k;
List<Character> characters = new ArrayList<Character>();
for(char c:input.toCharArray()){
characters.add(c);
}
StringBuilder output = new StringBuilder(input.length());
while(characters.size()!=0){
int randPicker = (int)(Math.random()*characters.size());
output.append(characters.remove(randPicker));
}
igc=new CountDownTimer(4000,1000) {
@Override
public void onTick(long arg0) {
t1.setText(((arg0/1000))+"Secs ");
t2.setText("Score: "+score);
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
dt1.setText("You Cannot ");
dt2.setText("Complete ?");
dt3.setText("You Scored: "+score);
ob.show();
upd();
}
}.start();
chk=output.toString().charAt(0)+"";
t3.setText(chk);
}
The OnClick Function
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.Button01)
{
if(ks.contains(chk))
{
igc.cancel();
score+=3;
calc();
}
else
{
igc.cancel();
dt1.setText("You Think "+chk);
dt2.setText("as Consonant ?");
dt3.setText("You Scored: "+score);
ob.show();
upd();
}
}
else if(v.getId()==R.id.button5)
{
if(os.contains(chk))
{
igc.cancel();
score+=3;
calc();
}
else
{
igc.cancel();
dt1.setText("You Think "+chk);
dt2.setText("as ODD ?");
dt3.setText("You Scored: "+score);
ob.show();
upd();
}
}
else if(v.getId()==R.id.Button02)
{
if(es.contains(chk))
{
igc.cancel();
score+=3;
calc();
}
else
{
igc.cancel();
dt1.setText("You Think "+chk);
dt2.setText("as EVEN ?");
dt3.setText("You Scored: "+score);
ob.show();
upd();
}
}
else if(v.getId()==R.id.button6)
{
if(vs.contains(chk))
{
igc.cancel();
score+=3;
calc();
}
else
{
igc.cancel();
dt1.setText("You Think "+chk);
dt2.setText("as VOWEL ?");
dt3.setText("You Scored: "+score);
ob.show();
upd();
}
}
else if(v.getId()==R.id.button1)
{
//Drawable d=getResources().getDrawable(R.drawable.play);
igc.cancel();
bp.setVisibility(View.GONE);
is = new Button(v.getContext());
is.setBackgroundResource(R.drawable.play);
is.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
calc();
is.setVisibility(View.GONE);
bp.setVisibility(View.VISIBLE);
}
});
ll.addView(is);
}
else if(v.getId()==R.id.button2)
{
Intent i= new Intent(this,GameActivity.class);
startActivity(i);
finish();
}
else if(v.getId()==R.id.imageView2)
{
finish();
}
else if(v.getId()==R.id.imageView3)
{
Intent i= new Intent(this,GameActivity.class);
startActivity(i);
finish();
}
}
Alternatively you can download the whole ADT Project by clicking here.
Found Bugs, Comment them here !

Comments
Post a Comment