Sayfayı Yazdır | Pencereyi Kapat

Resim Karıştırma

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Clomosy ile değişken kullanımı
Forum Tanımlaması: TRObject dili ile değişken tanımlaması ve ekranda gösterme
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=1198
Tarih: 16 Aralık 2025 Saat 16:03
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: Resim Karıştırma
Mesajı Yazan: Gökçe ulusoy
Konu: Resim Karıştırma
Mesaj Tarihi: 22 Eylül 2025 Saat 11:09
Resimleri dize üzerine alıp oradan indexlerine göre karıştırmak istemistim fakat resimlerin konumları değişmedi ve sadece index değerleri değişti. Bu Durumda resimleri karıştırmak ve konumlarını rastgele ayarlamak istediğimde nasıl bir yol izlemeliyim. 
var
  myform:TclForm;
  Startbtn:TClProButton;
  welcomelabel:TCLLabel;
  PPanelMid, PPanel1Top, PPanel2Bottom:TclProPanel;
  Image1, Image2, Image3,Image4, Image5,Image6,Image7,Image8 ,backImg:TCLImage;
  Images: array[0..7] of TCLImage;
  //switch1:TCLSwitch;
  matched: array[0..7] of Boolean;
  i, j, k: Integer;

void StartGame;
  var 
    temp:String;
    {
      for (i=0 to 7)
      {
        myform.SetImage(Images, ' https://resmim.net/cdn/2025/09/18/jdNWJc.png" rel="nofollow - https://resmim.net/cdn/2025/09/18/jdNWJc.png ')
    }

  {
  
    myform=TclForm.Create(Self);
    
    myform.SetFormColor('#085e26','#4dcc1e',clGHorizontal);
    myform.clSetCaption('MyFirstGame')
    myform.clSetWindowState(fwsMaximized)
    
    
    Startbtn=myform.AddNewProButton(myform, 'Startbtn', 'Başla');
    
    Startbtn.Align=alMostBottom;
    Startbtn.width=50;
    Startbtn.height=100;
    Startbtn.clProSettings.RoundHeight=2;
    Startbtn.clProSettings.RoundWidth=2;
    Startbtn.clProSettings.BorderColor = clAlphaColor.ClHexToColor ('#604201')
    Startbtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#e9e2e2');
    Startbtn.SetClProSettings(Startbtn.clProSettings) 
    
    welcomelabel = myform.AddNewLabel(myform,'welcomelabel','Resim eşleştirme Oyununa Hoşgeldiniz');
    welcomelabel.Styledsettings=ssFamily;
    welcomelabel.Textsettings.Font.Size=35;
    welcomelabel.Textsettings.FontColor=clAlphaColor.clHexToColor('#ffffff');
    welcomelabel.Align=alTop;
    welcomelabel.Margins.Left=400;
    welcomelabel.width=50;
    welcomelabel.height=100;
    
    PPanelMid=myform.AddNewProPanel(myform,'PPanelMid');
    PPanelMid.Align = alCenter;
    PPanelMid.Width = 1200;
    PPanelMid.Height = 400;
    PPanelMid.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#d2c6c6');
    PPanelMid.clProSettings.IsFill = True; 
    PPanelMid.clProSettings.IsRound = True;
    PPanelMid.Margins.Top = -30;
    PPanelMid.Margins.Bottom = 50;
    PPanelMid.Margins.Left = -5;
    PPanelMid.Margins.Right = -5;
    PPanelMid.SetclProSettings(PPanelMid.clProSettings);
    
    PPanel1Top=myform.AddNewProPanel(PPanelMid,'PPanel1Top');
    PPanel1Top.Align = alTop;
    PPanel1Top.Width = 1200;
    PPanel1Top.Height = 200;
    PPanel1Top.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#d2c6c6');
    PPanel1Top.clProSettings.BorderColor = clAlphaColor.clHexToColor('#000000');
    PPanel1Top.clProSettings.BorderWidth = 2;
    PPanel1Top.clProSettings.IsFill = True; 
    PPanel1Top.clProSettings.IsRound = True;
    PPanel1Top.SetclProSettings(PPanel1Top.clProSettings);
    
    PPanel2Bottom=myform.AddNewProPanel(PPanelMid,'PPanel2Bottom');
    PPanel2Bottom.Align = alBottom;
    PPanel2Bottom.Width = 1200;
    PPanel2Bottom.Height = 200;
    PPanel2Bottom.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#d2c6c6');
    PPanel2Bottom.clProSettings.BorderColor = clAlphaColor.clHexToColor('#849e00');
    PPanel2Bottom.clProSettings.BorderWidth = 2;
    PPanel2Bottom.clProSettings.IsFill = True; 
    PPanel2Bottom.clProSettings.IsRound = True;
    PPanel2Bottom.SetclProSettings(PPanel2Bottom.clProSettings);
   
    Image1 = myform.AddNewImage(PPanel1Top,'Image1');
    Image1.Height = 150;
    Image1.width=150;
    myform.SetImage(Image1,' https://resmim.net/cdn/2025/09/17/jH0iCb.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0iCb.png ');
    Image1.Align=alLeft;
    Image1.Margins.Left = 150; 
   
    
    Image2 = myform.AddNewImage(PPanel1Top,'Image2');
    Image2.Height = 150;
    Image2.width=150;
    myform.SetImage(Image2,' https://resmim.net/cdn/2025/09/17/jH0iCb.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0iCb.png ');
    Image2.Align=alLeft;
    Image2.Margins.Left = 100;
    
    Image3 = myform.AddNewImage(PPanel1Top,'Image3');
    Image3.Height = 150;
    Image3.width=150;
    myform.SetImage(Image3,' https://resmim.net/cdn/2025/09/17/jH0Ob2.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0Ob2.png ');
    Image3.Align=alLeft;
    Image3.Margins.Left = 100; 
  
    Image4 = myform.AddNewImage(PPanel1Top,'Image4');
    Image4.Height = 150;
    Image4.width=150;
    myform.SetImage(Image4,' https://resmim.net/cdn/2025/09/17/jH0Ob2.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0Ob2.png ');
    Image4.Align=alLeft;
    Image4.Margins.Left = 100;
  
  

    Image5 = myform.AddNewImage(PPanel2Bottom,'Image5');
    Image5.Height = 150;
    Image5.width=150;
    myform.SetImage(Image5,' https://resmim.net/cdn/2025/09/17/jH0pMh.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0pMh.png ');
    Image5.Align=alLeft;
    Image5.Margins.Left = 150;
    
    Image6 = myform.AddNewImage(PPanel2Bottom,'Image6');
    Image6.Height = 150;
    Image6.width=150;
    myform.SetImage(Image6,' https://resmim.net/cdn/2025/09/17/jH0pMh.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0pMh.png ');
    Image6.Align=alLeft;
    Image6.Margins.Left = 100;
    
    Image7 = myform.AddNewImage(PPanel2Bottom,'Image7');
    Image7.Height = 150;
    Image7.width=150;
    myform.SetImage(Image7,' https://resmim.net/cdn/2025/09/17/jH0FgK.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0FgK.png ');
    Image7.Align=alLeft;
    Image7.Margins.Left = 100;
    
    Image8 = myform.AddNewImage(PPanel2Bottom,'Image8');
    Image8.Height = 150;
    Image8.width=150;
    myform.SetImage(Image8,' https://resmim.net/cdn/2025/09/17/jH0FgK.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0FgK.png ');
    Image8.Align=alLeft;
    Image8.Margins.Left = 100;
    
    Images[0] = Image1;
    Images[1] = Image2;
    Images[2] = Image3;
    Images[3] = Image4;
    Images[4] = Image5;
    Images[5] = Image6;
    Images[6] = Image7;
    Images[7] = Image8;
    
    myform.AddNewEvent(Startbtn,tbeOnClick,'StartGame');
 
   
    myform.Run;
    
  }
 



Cevaplar:
Mesajı Yazan: Emr.Erkmn
Mesaj Tarihi: 23 Eylül 2025 Saat 13:29
Merhaba Gökçe, 
Kodlarlar da yer alan hataları düzelttim 
Bir tane süslü parantez hatası vardı döngü kullandığın yerde. Bir kapanış daha koymak gerekliydi.
Ayrıca farklı yerler de hizlama yapmak istiyorsan align özelliğini AlNone olarak ayarlaman gerekiyor.
Kodu aşağıya bırakıyorum inceleyebilirsin;

var
  myform:TclForm;
  Startbtn:TClProButton;
  welcomelabel:TCLLabel;
  PPanelMid, PPanel1Top, PPanel2Bottom:TclProPanel;
  Image1, Image2, Image3,Image4, Image5,Image6,Image7,Image8 ,backImg:TCLImage;
  Images: array[0..7] of TCLImage;
  matched: array[0..7] of Boolean;
  i, j, k: Integer;
  posX: array[0..7] of Integer; // X pozisyonları
  posY: array[0..7] of Integer; // Y pozisyonları

void StartGame 
  var 
    temp: String;
    randomIndex: Integer;
    tempImage: TCLImage;
    tempX, tempY: Integer;
{
  {
    posX[0] = 150; posY[0] = 25;  
    posX[1] = 350; posY[1] = 25;  
    posX[2] = 550; posY[2] = 25;  
    posX[3] = 750; posY[3] = 25;  
    posX[4] = 150; posY[4] = 25;  
    posX[5] = 350; posY[5] = 25; 
    posX[6] = 550; posY[6] = 25;  
    posX[7] = 750; posY[7] = 25;  
    
    // Resimleri karıştır
    for i = 0 to 7 {
      randomIndex = Random(8);
      
      // Resimleri değiştir
      tempImage = Images;
      Images = Images[randomIndex];
      Images[randomIndex] = tempImage;
      
      // Pozisyonları değiştir
      tempX = posX;
      tempY = posY;
      posX = posX[randomIndex];
      posY = posY[randomIndex];
      posX[randomIndex] = tempX;
      posY[randomIndex] = tempY;
    }
    
    for i = 0 to 7 {
      Images.Align = alNone; 
      Images.Position.X = posX;
      Images.Position.Y = posY;
    }
    
    ShowMessage('Resimler karıştırıldı!');
  }
}

{
  myform=TclForm.Create(Self);
  
  myform.SetFormColor('#085e26','#4dcc1e',clGHorizontal);
  myform.clSetCaption('MyFirstGame');
  myform.clSetWindowState(fwsMaximized);
  
  Startbtn=myform.AddNewProButton(myform, 'Startbtn', 'Başla');
  Startbtn.Align=alMostBottom;
  Startbtn.width=50;
  Startbtn.height=100;
  Startbtn.clProSettings.RoundHeight=2;
  Startbtn.clProSettings.RoundWidth=2;
  Startbtn.clProSettings.BorderColor = clAlphaColor.ClHexToColor('#604201');
  Startbtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#e9e2e2');
  Startbtn.SetClProSettings(Startbtn.clProSettings);
  
  welcomelabel = myform.AddNewLabel(myform,'welcomelabel','Resim eşleştirme Oyununa Hoşgeldiniz');
  welcomelabel.Styledsettings=ssFamily;
  welcomelabel.Textsettings.Font.Size=35;
  welcomelabel.Textsettings.FontColor=clAlphaColor.clHexToColor('#ffffff');
  welcomelabel.Align=alTop;
  welcomelabel.Margins.Left=400;
  welcomelabel.width=50;
  welcomelabel.height=100;
  
  PPanelMid=myform.AddNewProPanel(myform,'PPanelMid');
  PPanelMid.Align = alCenter;
  PPanelMid.Width = 1200;
  PPanelMid.Height = 400;
  PPanelMid.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#d2c6c6');
  PPanelMid.clProSettings.IsFill = True; 
  PPanelMid.clProSettings.IsRound = True;
  PPanelMid.Margins.Top = -30;
  PPanelMid.Margins.Bottom = 50;
  PPanelMid.Margins.Left = -5;
  PPanelMid.Margins.Right = -5;
  PPanelMid.SetclProSettings(PPanelMid.clProSettings);
  
  PPanel1Top=myform.AddNewProPanel(PPanelMid,'PPanel1Top');
  PPanel1Top.Align = alTop;
  PPanel1Top.Width = 1200;
  PPanel1Top.Height = 200;
  PPanel1Top.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#d2c6c6');
  PPanel1Top.clProSettings.BorderColor = clAlphaColor.clHexToColor('#000000');
  PPanel1Top.clProSettings.BorderWidth = 2;
  PPanel1Top.clProSettings.IsFill = True; 
  PPanel1Top.clProSettings.IsRound = True;
  PPanel1Top.SetclProSettings(PPanel1Top.clProSettings);
  
  PPanel2Bottom=myform.AddNewProPanel(PPanelMid,'PPanel2Bottom');
  PPanel2Bottom.Align = alBottom;
  PPanel2Bottom.Width = 1200;
  PPanel2Bottom.Height = 200;
  PPanel2Bottom.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#d2c6c6');
  PPanel2Bottom.clProSettings.BorderColor = clAlphaColor.clHexToColor('#849e00');
  PPanel2Bottom.clProSettings.BorderWidth = 2;
  PPanel2Bottom.clProSettings.IsFill = True; 
  PPanel2Bottom.clProSettings.IsRound = True;
  PPanel2Bottom.SetclProSettings(PPanel2Bottom.clProSettings);

  Image1 = myform.AddNewImage(PPanel1Top,'Image1');
  Image1.Height = 150;
  Image1.width=150;
  myform.SetImage(Image1,' https://resmim.net/cdn/2025/09/17/jH0iCb.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0iCb.png ');
  Image1.Align=alNone;
  Image1.Position.X = 150;
  Image1.Position.Y = 25;

  Image2 = myform.AddNewImage(PPanel1Top,'Image2');
  Image2.Height = 150;
  Image2.width=150;
  myform.SetImage(Image2,' https://resmim.net/cdn/2025/09/17/jH0iCb.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0iCb.png ');
  Image2.Align=alNone;
  Image2.Position.X = 350;
  Image2.Position.Y = 25;

  Image3 = myform.AddNewImage(PPanel1Top,'Image3');
  Image3.Height = 150;
  Image3.width=150;
  myform.SetImage(Image3,' https://resmim.net/cdn/2025/09/17/jH0Ob2.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0Ob2.png ');
  Image3.Align=alNone;
  Image3.Position.X = 550;
  Image3.Position.Y = 25;

  Image4 = myform.AddNewImage(PPanel1Top,'Image4');
  Image4.Height = 150;
  Image4.width=150;
  myform.SetImage(Image4,' https://resmim.net/cdn/2025/09/17/jH0Ob2.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0Ob2.png ');
  Image4.Align=alNone;
  Image4.Position.X = 750;
  Image4.Position.Y = 25;

  Image5 = myform.AddNewImage(PPanel2Bottom,'Image5');
  Image5.Height = 150;
  Image5.width=150;
  myform.SetImage(Image5,' https://resmim.net/cdn/2025/09/17/jH0pMh.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0pMh.png ');
  Image5.Align=alNone;
  Image5.Position.X = 150;
  Image5.Position.Y = 25;

  Image6 = myform.AddNewImage(PPanel2Bottom,'Image6');
  Image6.Height = 150;
  Image6.width=150;
  myform.SetImage(Image6,' https://resmim.net/cdn/2025/09/17/jH0pMh.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0pMh.png ');
  Image6.Align=alNone;
  Image6.Position.X = 350;
  Image6.Position.Y = 25;

  Image7 = myform.AddNewImage(PPanel2Bottom,'Image7');
  Image7.Height = 150;
  Image7.width=150;
  myform.SetImage(Image7,' https://resmim.net/cdn/2025/09/17/jH0FgK.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0FgK.png ');
  Image7.Align=alNone;
  Image7.Position.X = 550;
  Image7.Position.Y = 25;

  Image8 = myform.AddNewImage(PPanel2Bottom,'Image8');
  Image8.Height = 150;
  Image8.width=150;
  myform.SetImage(Image8,' https://resmim.net/cdn/2025/09/17/jH0FgK.png" rel="nofollow - https://resmim.net/cdn/2025/09/17/jH0FgK.png ');
  Image8.Align=alNone;
  Image8.Position.X = 750;
  Image8.Position.Y = 25;

  Images[0] = Image1;
  Images[1] = Image2;
  Images[2] = Image3;
  Images[3] = Image4;
  Images[4] = Image5;
  Images[5] = Image6;
  Images[6] = Image7;
  Images[7] = Image8;
  
  myform.AddNewEvent(Startbtn,tbeOnClick,'StartGame');

  myform.Run;
}



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net