Sayfayı Yazdır | Pencereyi Kapat

Kelime oyunu

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Genel İşlemler
Forum Tanımlaması: TRObject dili ile programlama yaparken karşılaşılan genel işlemler
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=567
Tarih: 07 Ocak 2025 Saat 23:11
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: Kelime oyunu
Mesajı Yazan: ibrahimethem
Konu: Kelime oyunu
Mesaj Tarihi: 25 Ağustos 2023 Saat 10:13
var 
MyForm:TclForm;
LblDisplay,ztStartLbl:TclLabel;
myGameEngine:TclGameEngine;
MyWord,WordMean:String;
MyPanel:TclPanel;
MyWordMean:TclMemo;
wordEdt:TclEdit;
ztHintBtnLayout:TclLayout;
ztHintBtn :TclImage;
LblDisplayLayout,ztLayout,ztStartBtnLayout,ztStartLblLayout:TclLayout;
ztStartBtn:TclImage;
AnswStr:String;
wrongCount:integer;
Lblword:TcLProLabel;
control:Boolean;
chance:Integer;
myArray:TclArrayString;
iIndex:Integer;
rnd:Integer;
 
  procedure GetNewWord;
 var 
q :integer;
 begin
q:= clMath.GenerateRandom(0,40);
case  q of
0:WordMean:='Discrimination ';
1:WordMean:='Invent ';
2:WordMean:='Suddenly ';
3:WordMean:='Waste ';
4:WordMean:='Salary ';
5:WordMean:='Awake ';
6:WordMean:='Frustrated ';
7:WordMean:='Growth ';
8:WordMean:='Depend ';
9:WordMean:='Solve ';
10:WordMean:='Advice ';
11:WordMean:='Reputation ';
12:WordMean:='Punctual ';
13:WordMean:='Impatient ';
14:WordMean:='Instand ';
15:WordMean:='Advice ';
16:WordMean:='Permission ';
17:WordMean:='Hometown ';
18:WordMean:='Prescription ';
19:WordMean:='Even ';
20:WordMean:='Smartly ';
21:WordMean:='Advice ';
22:WordMean:='Impression ';
23:WordMean:='Complain ';
24:WordMean:='Persuade ';
25:WordMean:='Solution ';
26:WordMean:='Pain ';
27:WordMean:='Seatbelt ';
28:WordMean:='Sibling ';
29:WordMean:='Tissue ';
30:WordMean:='Extrovert ';
31:WordMean:='Several ';
32:WordMean:='Drug ';
33:WordMean:='Overtime ';
34:WordMean:='Desting ';
35:WordMean:='Indeed ';
36:WordMean:='Starred ';
37:WordMean:='Scream ';
38:WordMean:='Delivery ';
39:WordMean:='Occasion ';
40:WordMean:='clever';
 
 end;
 case q of
0:MyWord:='Ayrımcılık';
1:MyWord:='İcat';
2:MyWord:='Birdenbire'; 
3:MyWord:='İsraf';
4:MyWord:='Maaş';
5:MyWord:='Uyanık';
6:MyWord:='Hakkı yenmiş';
8:MyWord:='Büyütmek';
9:MyWord:='Bağımlı';
10:MyWord:='Çözmek';
11:MyWord:='Şöhret';
12:MyWord:='Dakik';
13:MyWord:='Sabırsız';
14:MyWord:='Anlık';
15:MyWord:='Tavsiye';
16:MyWord:='İzin';
17:MyWord:='Memleket';
18:MyWord:='Reçete';
19:MyWord:='Bile';
20:MyWord:='Şık';
21:MyWord:='Tavsiye';
22:MyWord:='İzlenim';
23:MyWord:='Yakınmak';
24:MyWord:='İkna etmek';
25:MyWord:='Çözüm';
26:MyWord:='Ağrı';
27:MyWord:='Emniyet kemeri';
28:MyWord:='Kardeş';
29:MyWord:='Peçete';
30:MyWord:='Sosyal';
31:MyWord:='Birçok';
32:MyWord:='İlaç';
33:MyWord:='Mesai';
34:MyWord:='Kader';
35:MyWord:='Aslında';
36:MyWord:='Başrol';
37:MyWord:='Çığlık';
38:MyWord:='Teslimat';
39:MyWord:='Fırsat';
40:MyWord:='Zeki';
 end;
 
 end;
  Procedure CheckGameOnClick;
 begin
AnswStr:=wordEdt.Text;
AnswStr:=AnsiLowerCase(AnswStr);
 If AnswStr=MyWord Then
 begin
ShowMessage('True Answer!  ✓ Congratulations');
chance:=0;
control:=false;
ztStartBtn.Tag:=0;
MyForm.setImage(ztStartBtn,'https://cdn3.iconfinder.com/data/icons/game-101/256/Game_start_1.png');
ztStartLbl.Text:=' ';
wordEdt.Text:='';
LblDisplay.Visible:=False;
MyWordMean.Text:='Start again to see more questions.';
 end;
 else
 begin
 if wrongCount=3 then
 begin
ShowMessage('Answer: '+MyWord+' ✘ Try again.');
chance:=0;
control:=false;
MyForm.setImage(ztStartBtn,'https://cdn3.iconfinder.com/data/icons/game-101/256/Game_start_1.png');
ztStartLbl.Text:=' ';
ztStartBtn.Tag:=0;
wrongCount:=1;
GetNewWord;

wordEdt.Text := '';
MyWordMean.Text := 'You Can, Try Again';
LblDisplay.Visible := False;
 end;
 else
 begin
wrongCount:=wrongCount +1;
ShowMessage('False Answer 🙁 Try Again.  --Right of Reply Used='+IntToStr(wrongCount-1)+'/3'+'--');
wordEdt.Text:='';
 end;
 end;
 end;

  Procedure BtnStartGameClick;
 begin
 case ztStartBtn.Tag of
0:
 begin
MyForm.setImage(ztStartBtn,'https://cdn4.iconfinder.com/data/icons/quiz-flaticon-1/64/true_or_false-quiz-decision-contest-risk-thinking-exam_-512.png');
ztStartLbl.Text := ' ';
ztStartBtn.Tag := 1;
wrongCount := 1;
GetNewWord;
MyWordMean.Text := WordMean;
wordEdt.Text :='';
LblDisplay.Visible := False;
 end;
1:
 begin
CheckGameOnClick;
 end;
 end;
 End;

  Procedure SetupLayout;
 begin
LblDisplayLayout:= MyForm.AddNewLayout(MyForm,'LblDisplayLayout');
LblDisplayLayout.Align := alBottom;
LblDisplayLayout.Height := 35;

LblDisplay:= MyForm.AddNewLabel(LblDisplayLayout,'LblDisplay',' ');
LblDisplay.Align := alRight;
LblDisplay.Visible := True;
LblDisplay.Margins.Bottom:=0;

MyPanel:= MyForm.AddNewPanel(MyForm,'MyPanel','');
MyPanel.Align := alCenter;
MyPanel.Height := 25;
MyPanel.Margins.Top:=100;
MyPanel.Margins.Left:=125;
MyPanel.Width := 140;

wordEdt := MyForm.AddNewEdit(MyPanel,'wordEdt','Enter Answer');
wordEdt.Width := 140;
wordEdt.Align := alLeft;
wordEdt.MaxLength := 14;
 end;

  Procedure SetupStartBtn;
 begin
ztLayout := MyForm.AddNewLayout(MyForm,'ztLayout');
ztLayout.Align:=alBottom;
ztLayout.Height := 200;
ztLayout.Width := 100;
ztLayout.Margins.Bottom := 30;

ztStartBtnLayout := MyForm.AddNewLayout(ztLayout,'ztStartBtnLayout');
ztStartBtnLayout.Align:=alCenter;
ztStartBtnLayout.Height := 100;
ztStartBtnLayout.Width := 100;

ztStartBtn:= MyForm.AddNewImage(ztStartBtnLayout,'ztStartBtn');
ztStartBtn.Align := alTop;
ztStartBtn.Height := 100; 
ztStartBtn.Width := 100;
ztStartBtn.Tag := 0;

MyForm.setImage(ztStartBtn,'https://cdn3.iconfinder.com/data/icons/game-101/256/Game_start_1.png');

MyForm.AddNewEvent(ztStartBtn,tbeOnClick,'BtnStartGameClick');

ztStartLblLayout := MyForm.AddNewLayout(ztLayout,'ztStartLblLayout');
ztStartLblLayout.Align:=alCenter;
ztStartLblLayout.Height := 100;
ztStartLblLayout.Width := 150;
ztStartLblLayout.Margins.Top := 40;
ztStartLblLayout.Margins.Left := 55;

ztStartLbl:= MyForm.AddNewLabel(ztStartLblLayout,'ztStartLbl',' ');
ztStartLbl.StyledSettings := ssFamily;
ztStartLbl.TextSettings.Font.Size:=16;
ztStartLbl.Align := alBottom;
 end;

  Procedure ztHintBtnOnClick;
 var
hintValue : String;
firstLetter,secondLetter : String;
firstIndex,secondIndex : Integer;
i : Integer;

 begin
 if MyWordMean.Text <> '' then
 begin
 if control = false then
 begin
control := true;
 if chance < 2 then
 begin
chance := chance +1;
 for i := 1 to Length(MyWord) do
 begin
firstIndex := clMath.GenerateRandom(1,Length(MyWord));
secondIndex := clMath.GenerateRandom(1,Length(MyWord));
 if secondIndex <> firstIndex then
break;
 end;

firstLetter := Copy(MyWord,firstIndex,1); 
secondLetter := Copy(MyWord,secondIndex,1); 
LblDisplay.Visible := True;
LblDisplay.Text := '';

 for i:= 1 to Length(MyWord) do
 begin
 if i = firstIndex then
LblDisplay.Text := LblDisplay.Text + firstLetter
 else if i = secondIndex then 
LblDisplay.Text := LblDisplay.Text + secondLetter

 else
LblDisplay.Text := LblDisplay.Text + ' - ';
 end;
 end;
 end;
 else
ShowMessage('I can not give any more letters 😞');
 end;

 else
ShowMessage('You Have To Start The Game First! 🤙');
 end;

  procedure SetupHintBtn;
 begin
ztHintBtnLayout := MyForm.AddNewLayout(MyForm,'ztHintBtnLayout');
ztHintBtnLayout.Align:=alcenter;
ztHintBtnLayout.Align:=alRight;
ztHintBtnLayout.Margins.Right:=30;
ztHintBtnLayout.Height := 50;
ztHintBtnLayout.Width := 100;
   
ztHintBtn:= MyForm.AddNewImage(ztHintBtnLayout,'ztHintBtn');
ztHintBtn.Align := alRight;
ztHintBtn.Height := 55;
ztHintBtn.Width := 55;
ztHintBtn.Margins.Bottom:=-80;

MyForm.setImage(ztHintBtn,'https://cdn2.iconfinder.com/data/icons/toolbar-signs-3/512/search_information-64.png');
MyForm.AddNewEvent(ztHintBtn,tbeOnClick,'ztHintBtnOnClick');
 end;

  Procedure SetupWordMean;
 var
ztProPanel : TclProPanel;
 begin

ztProPanel:=MyForm.AddNewProPanel(MyForm,'ztProPanel');
clComponent.SetupComponent(ztProPanel,'{"Align" : "Top","Width" :95,"MarginBottom" : 0,
"MarginLeft" : 20,"MarginRight" : 20, "Height":110,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#ffa54f","BorderWidth":3}');

MyWordMean:= MyForm.AddNewMemo(ztProPanel,'MyWordMean','Click the "GAME START" button to start the competition.');
MyWordMean.Align := alClient;
MyWordMean.Margins.Left:=10;
MyWordMean.Margins.Right:=10;
MyWordMean.Margins.Bottom:=10;
MyWordMean.Margins.Top:=10;
MyWordMean.ReadOnly := True;
MyWordMean.TextSettings.WordWrap := True;
   
 end;

 begin
MyForm := TclForm.Create(Self);
chance := 0;
Lblword := MyForm.AddNewProLabel(MyForm,'Lblword','TRANSLATE GAME');
clComponent.SetupComponent(Lblword,'{"Align" : "TOP","MarginBottom":35,"Width" :210, "Height":26,
"TextColor":"#008080","TextSize":20,"TextVerticalAlign":"top","TextHorizontalAlign":"center","TextBold":"yes"}');

  MyForm.SetFormBGImage('https://e0.pxfuel.com/wallpapers/31/873/desktop-wallpaper-ortaya-lahmacun-on-arka-plan-space-phone-planets-dark-black-aztec.jpg');
  control := false;
  SetupLayout;
  SetupWordMean;
  SetupStartBtn;
  SetupHintBtn;
  MyForm.Run;
 End;

Yaptığım translate oyunu projesinde soruların cevabını doğru vermeme rağmen uygulama cevaba yanlış diyor sebebi ne olabilir ?



Cevaplar:
Mesajı Yazan: Alforce
Mesaj Tarihi: 25 Ağustos 2023 Saat 14:08
Büyük küçük uyumluluğu ile alakalı bir sorun var gibi duruyor.

Bu yama işini görür, 127. satır:
AnswStr:=wordEdt.Text;
  If AnsiLowerCase(AnswStr) = AnsiLowerCase(MyWord) Then


Mesajı Yazan: KIDEMLI
Mesaj Tarihi: 05 Eylül 2023 Saat 22:40
sorun çözüldü mü?



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