NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

OYUN PROGRAMLAMA 3.HAFTA
metodun başına static eklersek diğer sınıflardan da çağırabiliriz.

0'dan 6'ya kadar

{
for(int i=0;i<6; i++)
{
Debug.Log(i);
if(i==6)
{ break; }

}
}
-----------------------------------------------------------------------------------------
window'dan console aç
game object ekle üzerinde add component script olarak ata
project-c# script aç
-----------------------------------------------------------------------------------------
Diziler

dizinin 0. elemanını yazan

int[] dizi = new int[100];
dizi[0] = 22;
dizi[1] = 25;
dizi[99] = 57;
Debug.Log(dizi[0]);
}
-------------------
dizinin elemanlarına değer atanmadığı için hepsini 0 yazar.
int[] dizi = new int[100];
for(int i=0;i<100;i++)
Debug.Log(dizi[i]);
--------------------------------------------------------------------------------
0'dan 100'e kadar yaz
void Start ()
{
int[] dizi = new int[100];
for(int i=0;i<100;i++)
{
dizi[i]=i;
Debug.Log(dizi[i]);
-------------------------------------
ilk eleman 0 ikinci eleman 20,üçüncü eleman 30 ,diğer elemanlar(100'e kadar) 0
void Start () {
int[] dizi = new int[100];
for(int i=0;i<100;i++)
dizi[2] = 20;
dizi[3] = 30;
Debug.Log(dizi[i]);
---------------------------------------------
alt alta sema cem alper yazar.
string[] isimler=new string[3];
isimler[0]="sema";
isimler[1]="cem";
isimler[2]="alper";
for (int i=0;i<isimler.Length;i++)
{
Debug.Log(isimler[i]);
}
------------------------------------------------------------------------------
isimleri yaşları unity'de size'den gir.girilen kişinin adını ve yaşını yazan prog
public int[] isimler;
public int[] yaslar;
void Start(){
for(int i=0;,<isimler.Length;i++)
Debug.Log("ismi="+isimler[i]+"kişisinin yaşı="+yaslar[i]);
-------------------------------------------------------------------------------
for ile ekrana yazı yazdırma
void Start(){
for (int i = 0; i < 10; i++)
{
Debug.Log("OYUN PROGRAMLAMA DERSİ ÇOK ZEVKLİ");
}
--------------------------------------------------------------------------------
while ile ekrana yazı yazdırma
int i = 0;
while(i<10)
{
Debug.Log("OYUN PROGRAMLAMA DERSİ ÇOK ZEVKLİ");
i++;
}
------------------------------------
for döngüsüyle oyunları ekrana yazdırma
void Start(){
string[] oyunlar = { "gta", "counter", "metin2", "raınbow", "supermarıo" };
for(int i=0;i<5;i++)
{ Debug.Log(oyunlar[i]);
} }
---------------------------------------------
while döngüsüyle oyunları ekrana yazdırma
string[] oyunlar = { "gta", "counter", "metin2", "raınbow", "supermarıo" };
int i = 0;
while (i<5)
{ Debug.Log(oyunlar[i]);
i++;
} }
----------------------------------------------------------------
for döngüsüyle oyunları ekrana tersten yazdırma
string[] oyunlar = { "gta", "counter", "metin2", "raınbow", "supermarıo" };
for(int i=4;i>=0;i--)
{ Debug.Log(oyunlar[i]);
---------------------------------------------
oyunların içinde limbo varsa bulundu yoksa bulunamadı yazan program
string[] oyunlar = { "gta", "counter", "metin2", "raınbow", "supermarıo" };
for(int i=0;i<5;i++)
{ if(oyunlar[i]=="limbo")
{Debug.Log("bulundu");}
else Debug.Log("bulunamadı");
-----------------------------
true false ile oyunların içinde limbo varsa bulundu yoksa bulunamadı yazan program
bool kontrol=true;
string[] oyunlar = { "gta", "counter", "metin2", "raınbow", "supermarıo" };
for(int i=0;i<5;i++)
{if(oyunlar[i]=="limbo")
{kontrol=true;
break;}
else
{kontrol=false;}
}
{if (kontrol)
{ Debug.Log("bulundu");}
else{Debug.Log("bulunamadı");}
}
--------------------------------------------------------------------------------
fonksiyonlar(metodlar)
ekrana sema32bilgili
void Start(){
toplama("sema", 32, "bilgili");
}
// Update is called once per frame
void Update()
{
}
void toplama(string x, int y, string z)
{ Debug.Log(x + y + z); }
}
-------------------------------------------------------------------------------
0'dan 14'e kadar metodla yazma
void Start()
{
sayici(15);
}
// Update is called once per frame
void Update () {
}
void sayici(int x)
{
for (int i = 0; i < x; i++)
Debug.Log(i);
--------------------------------------------------------------------------------
metodla sayıları toplayan
{
int sayi = toplama(25, 35);
Debug.Log(sayi);
}
// Update is called once per frame
void Update () {
}
int toplama(int x, int y)
{ return x + y; }
}
--------------------------------------------------------------------------------
string ile sayıların toplamı
void Start()
{
string metin = deneme(300, 500);
Debug.Log(metin);
}
// Update is called once per frame
void Update () {
}
string deneme(int x, int y)
{ return "bu sayıların toplamı="+(x + y); }
}
-------------------------------------------------------------------------------
-10
void Start()
{
matematik x = new matematik();
Debug.Log(x.cikarma(20, 30));
}
void Update ()
{
}
}
class matematik
{
public int cikarma(int a, int b)
{ return a - b; }
public int carpma(int a, int b)
{ return a * b; }
}
-----------------------------------------------------------------------------------------
class'ta static kullanarak matematiksel işlem yapma
void Start()
{
Debug.Log(matematik.cikarma(60, 30));
}
void Update () {
}
}
class matematik
{
public static int cikarma(int a, int b)
{ return a - b; }

public static int carpma(int a, int b)
{ return a * b; }
}
-----------------------------------------------------------------------------------------
obje oluşturma
void Start()
{
for(int i=0;i<=5;i++)
{GameObject obje=new GameObject();}
}
void Update()
--------------------------
kamera ayarlama ctrl+shift+f
---------------------------------------------------------------------------------------
Topu klavye ile hareket ettirme
Rigidbody fizik;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec);
}
}
---------------------------------------------------------------------------------------
hız'ı public int'le tanımlayarak topu hızlandırma(hız'ı add component in üstünde hız çarpımını yaz
Rigidbody fizik;
public int hiz;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec*hiz);
}
}

-------------------------------------------------------------------------------------
kameraya topu takip ettirmek
public class Kamerakontrol : MonoBehaviour {
Vector3 aradakimesafe;
public GameObject top;
// Use this for initialization
void Start () {
aradakimesafe = transform.position - top.transform.position;

}

// Update is called once per frame
void Update () {
transform.position = top.transform.position + aradakimesafe;
}
}

-------------------------------------------------

void Update () {
transform.Rotate(new Vector3(15,30,45)*Time.deltaTime);

-------------------------------------------------
is trigger =içinden geçirgenlik özelliği
--------------------------------------------------------------------------------
topun temas ettiği nesneyi yok etme
--------------------------------------------------------------------------------
OnTriggerEnter=temas etme
OnTrıggerStay=temas ettiği sürece
OnTriggerExıt=temas etmeden çıkma
--------------------------------------------------------------------------------
top objeye ilk değdiği anda console'da temas balşadı yaz(topkontrol)

void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec*hiz);
}
private void OnTriggerEnter(Collider other)<<<
{
Debug.Log("temas başladı");<<<

}
}

--------------------------------------------------------------------------------
topun değdiği objeleri tamamen yok etme(topkontrol)
void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec*hiz);
}
private void OnTriggerEnter(Collider other)<<<
{
Destroy(other.gameObject); <<<

}
}
--------------------------------------------------------------------------------
topun değdiği objeleri pasif hale getir görünmez yap(topkontrol)
void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec*hiz);
}
private void OnTriggerEnter(Collider other)
{
other.gameObject.SetActive(false);

}
}
--------------------------------------------------------------------------------
küpleri topla capsulün içinden geç-frefabın tagına engel isimli değişken ekle
public int hiz;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec*hiz);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag=="engel")
{
other.gameObject.SetActive(false);
}
}
}

--------------------------------------------------------------------------------
top objelere değdiğinde console'da puan verme
Rigidbody fizik;
public int hiz;
int sayac = 0;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate () {
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec*hiz);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag=="engel")
{
other.gameObject.SetActive(false);
sayac++;
Debug.Log("puanınız=" + sayac);
}
}
}
--------------------------------------------------------------------------------
game object>UI>text ekle(topkontrol)
public Text puan;
public Text oyunbitti;
Rigidbody fizik;
public int hiz;
int sayac = 0;
// Use this for initialization
void Start()
{
fizik = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate()
{
float yatay = Input.GetAxisRaw("Horizontal");
float dikey = Input.GetAxisRaw("Vertical");
Vector3 vec = new Vector3(yatay, 0, dikey);
fizik.AddForce(vec * hiz);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "engel")
{
other.gameObject.SetActive(false);
sayac++;
Debug.Log("puanınız=" + sayac);
puan.text = "puanınız=" + sayac;
}
if (sayac == 8)
{
(oyunbitti.text = "oyun bitti");
}
}
}
--------------------------------------------------------------------------------
2.oyun
--------------------------------------------------------------------------------
arka planın siyah yapmak için skbox'ı kapat main cameranın inspector clar flagsı solid color yap
background'u siyah yap
2-free aspect + tıkla 600 e 900 buyutlandır
--------------------------------------------------------------------------------





























     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.