Created
October 8, 2017 16:34
-
-
Save uruskan/3a11a85f4512182550864d575b042b86 to your computer and use it in GitHub Desktop.
Cancer1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.uruskan.shock.myapplication; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.GridLayout; | |
import android.widget.GridView; | |
import android.widget.LinearLayout; | |
import android.widget.RelativeLayout; | |
import android.widget.TextView; | |
import android.widget.GridLayout.LayoutParams; | |
import org.w3c.dom.Text; | |
public class GameScreen extends AppCompatActivity { | |
int sonKart = 0; | |
int skor = 0; | |
int hata = 0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_game_screen); | |
Intent i = getIntent(); | |
final String s = i.getStringExtra("Mesaj"); | |
TextView tv = (TextView) findViewById(R.id.gstv); | |
tv.setText(s + " Skorunuz :" + skor); | |
GridLayout gl = (GridLayout)findViewById(R.id.glayout); | |
kart kartlar[] = new kart[16]; | |
for(int j =1;j<=16;j++) { | |
kartlar[j-1]=new kart(this, j); | |
kartlar[j-1].setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
final kart k = (kart)v; | |
k.cevir(); | |
if(sonKart>0){ | |
final kart k2 = (kart)findViewById(sonKart); | |
if(k2.onplanID==k.onplanID&&k2.getId()!=k.getId()){ | |
//Eslestiler | |
k2.cevrilebilir=false; | |
k.cevrilebilir=false; | |
k.setClickable(false); | |
k2.setClickable(false); | |
skor++; | |
TextView tv = (TextView) findViewById(R.id.gstv); | |
tv.setText(" Skorunuz:"+skor); | |
if(skor==8){ | |
Intent i =new Intent(GameScreen.this,FinalScreen.class); | |
i.putExtra("puan",hata); | |
i.putExtra("isim",s); | |
i.putExtra("skor",skor); | |
startActivity(i); | |
//oyun bitti | |
} | |
} | |
else{ | |
// eslesmediler geri cevir 2 karti | |
k.cevir(); | |
k2.cevir(); | |
hata++; | |
TextView tv = (TextView)findViewById(R.id.gstv); | |
tv.setText("Hata Sayisi:"+hata); | |
sonKart=0; | |
} | |
} | |
else{ | |
sonKart = k.getId(); | |
} | |
} | |
}); | |
} | |
//Karistir | |
for(int j=0;j<16;j++) { | |
int rg = (int)(Math.random()*16); | |
kart k = kartlar[rg]; | |
kartlar[rg]=kartlar[j]; | |
kartlar[j]=k; | |
} | |
for(int j =0;j<16;j++) { | |
gl.addView(kartlar[j]); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment