help to convert this code

iwant to convert this code to while and Do-while-> iam using the Bu

Page 1 of 1

5 Replies - 1020 Views - Last Post: 19 May 2009 - 12:40 AM Rate Topic: -----

#1 student omar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-May 09

help to convert this code

Posted 03 May 2009 - 04:38 AM

 if (!game_over)
  {
  if (no_shoots==5)
  {
	Rec1->Visible=true;
	Rec2->Visible=true;
	Rec3->Visible=true;
	Rec4->Visible=true;
	Rec5->Visible=true;
	Label4->Visible=false;
	Edit4->Visible=false;
	if (curr_player==1) Edit1->Text=Edit6->Text;
	if (curr_player==2) Edit1->Text=Edit7->Text;
	if (curr_player==3) Edit1->Text=Edit8->Text;
	if (curr_player==4) Edit1->Text=Edit9->Text;
	Edit2->Text=0;
	score=0;
	Edit3->Text=5;
	no_shoots=5;
	Cir->Left=380;
	StartTime=clock(); // new player
  }
  if (my_key==32) shoot=true;
  if (my_key==37) if (Cir->Left>0)Cir->Left-=10;
  if (my_key==39) if (Cir->Left<740) Cir->Left+=10;
  if (shoot && Cir->Top>40) Cir->Top-=5;
  if (Cir->Top==40)
  {
	Edit3->Text=--no_shoots;
	if (Cir->Left>40 && Cir->Left<140 && Rec1->Visible)
	{
	  Edit2->Text=++score;
	  Rec1->Visible=false;
	}
	if (Cir->Left>180 && Cir->Left<280 && Rec2->Visible)
	{
	  Edit2->Text=++score;
	  Rec2->Visible=false;
	}
	if (Cir->Left>320 && Cir->Left<420 && Rec3->Visible)
	{
	  Edit2->Text=++score;
	  Rec3->Visible=false;
	}
	if (Cir->Left>460 && Cir->Left<560 && Rec4->Visible)
	{
	  Edit2->Text=++score;
	  Rec4->Visible=false;
	}
	if (Cir->Left>600 && Cir->Left<700 && Rec5->Visible)
	{
	  Edit2->Text=++score;
	  Rec5->Visible=false;
	}
	if (no_shoots==0)
	{
	  EndTime=clock();
	  score_arr[curr_player-1]=score;
	  time_arr[curr_player-1]=difftime(EndTime,StartTime);
	  player_arr[curr_player-1]=Edit1->Text;
	  if (curr_player==no_players) game_over=true; else curr_player++;
	  Label4->Visible=true;
	  Edit4->Visible=true;
	  Edit4->Text=difftime(EndTime,StartTime);
	  no_shoots=5;
	}
	Cir->Top=340;
	shoot=false;
  }
  my_key=38;
  }
  else // GAME OVER
  {
	for(int i=0; i<no_players-1; i++)
	{
	   for (int j=i+1; j<no_players; j++)
	   {
		 if (score_arr[j]>score_arr[i])
		 {
		   int k=score_arr[i];
		   score_arr[i]=score_arr[j];
		   score_arr[j]=k;
		   k=time_arr[i];
		   time_arr[i]=time_arr[j];
		   time_arr[j]=k;
		   AnsiString m=player_arr[i];
		   player_arr[i]=player_arr[j];
		   player_arr[j]=m;
		 }
		 if ((score_arr[j]==score_arr[i]) && (time_arr[j]<time_arr[i]))
		 {
		   int k=score_arr[i];
		   score_arr[i]=score_arr[j];
		   score_arr[j]=k;
		   k=time_arr[i];
		   time_arr[i]=time_arr[j];
		   time_arr[j]=k;
		   AnsiString m=player_arr[i];
		   player_arr[i]=player_arr[j];
		   player_arr[j]=m;
		 }
	   } // for j
	}  // for i
	Label10->Visible=true;
	Label11->Visible=true;
	if (no_players>1) Label12->Visible=true;
	if (no_players>2) Label13->Visible=true;
	if (no_players>3) Label14->Visible=true;
	Label15->Visible=true;
	Label16->Visible=true;
	Edit10->Visible=true;
	if (no_players>1) Edit11->Visible=true;
	if (no_players>2) Edit12->Visible=true;
	if (no_players>3) Edit13->Visible=true;
	Edit14->Visible=true;
	if (no_players>1) Edit15->Visible=true;
	if (no_players>2) Edit16->Visible=true;
	if (no_players>3) Edit17->Visible=true;
	Edit18->Visible=true;
	if (no_players>1) Edit19->Visible=true;
	if (no_players>2) Edit20->Visible=true;
	if (no_players>3) Edit21->Visible=true;
	for (int i=0; i<no_players; i++)
	{
	  if (i==0)
	  {
		Edit10->Text=player_arr[i];
		Edit14->Text=score_arr[i];
		Edit18->Text=time_arr[i];
	  }
	  if (i==1)
	  {
		Edit11->Text=player_arr[i];
		Edit15->Text=score_arr[i];
		Edit19->Text=time_arr[i];
	  }
	  if (i==2)
	  {
		Edit12->Text=player_arr[i];
		Edit16->Text=score_arr[i];
		Edit20->Text=time_arr[i];
	  }
	  if (i==3)
	  {
		Edit13->Text=player_arr[i];
		Edit17->Text=score_arr[i];
		Edit21->Text=time_arr[i];
	  }
	} // for => results
  }  // else
}

Attached File(s)


This post has been edited by student omar: 03 May 2009 - 05:37 AM


Is This A Good Question/Topic? 0
  • +

Replies To: help to convert this code

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: help to convert this code

Posted 03 May 2009 - 04:58 AM

Welcome to DIC!

Please write your question in the body of your post not in the heading.

Your questions has been truncated so we don't know what you were trying to ask.

We are going to need a lot more specific information to help you than the fact that you want to use while() and do-while() loops in your code.
Was This Post Helpful? 0
  • +
  • -

#3 student omar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-May 09

Re: help to convert this code

Posted 03 May 2009 - 05:27 AM

i am attach file to be more clear
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: help to convert this code

Posted 03 May 2009 - 05:42 AM

Attachments are usually a bad idea and they have turned out to be a bad idea here.

Your attached 'code.txt' file is empty!

Just post your code like this :code:
Then we can all see it.

----

Your question is below (wrapped in code tags to avoid taking up to much space) so others can see it without having at muck around with attachments.
People really don't want to download and open attachments.
Just posting stuff out here in the open is the best idea.

----

But the main issue is that we aren't as interested in your homework as you are.

I'm not going to read all through the question to try and work out what you are asking about.
Someone else might, but I wouldn't bet on it.

Just ask a specific question so people can give you a specific answer.

A series of specific questions is going to work better for you than hoping someone will care enough to do a lot of reading and guessing for you.

----
Small Game : You are asked to develop a small game involving many players. The idea of the game is the following: at the top of running window you need to draw 5 targets. The targets consist of colored rectangle of the same size and color. They must be distributed symmetrically over the width of the running window. 

At the bottom of the running window you have a small ball. The horizontal movement of the ball should be controlled by the user. Pressing the left arrow should move the ball horizontally to the left. Pressing the right arrow should move the ball horizontally to the right. Pressing the space bar will lunch the ball vertically to the top of the window. If the ball touches one of the targets, the following events will happen:

The corresponding reached target disappears.
The score of the corresponding user increments by one.
The permitted number of shots for the current player decrements by one. 
The ball returns back to its last position at the last launching shot.

If the ball did not reach the target, the following events will happen:
The permitted number of shots for the current player decrements by one.
The ball returns back to its last position at the last launching shot.

The user has the right for 5 shots. The best scenario will happen if the user moves correctly the small ball and shoots the targets in 5 shots.

The movement speed of the ball should be rational. The user can see it clearly and he does not have to wait long in order to see if it destroys the target or not.  It should not be very fast, neither very slow. 

The session of the player ends after the last shot (5th one). Then, a new player starts shooting the targets. The program does not allow more than four players for the game.
When the program starts, it should ask the user about the number of players. Then, the user enters the names of the corresponding players. Each player has the right for one session. The first session will be for the first entered name, the second session is for the second entered name and so on.
At the end of the game, the program presents the results and the players classifications with respect to their scores.  If two players have the same scores they should not be ranked equally. You should look to the time needed by each of them to finish his session. For that reason, you need to add the time factor for each user session. The session time starts when you select the corresponding user and it ends when the user finishes his last shot.
You have to submit to your tutor the project with the source code and the executable files. You are asked to develop C++ program with the following features:

Create a new project and save it as SGame.bpr
Drop five rectangular shapes, equal dimensions, green color, placed at the top of the running window and distributed in equal distances from the left and the right borders of the window.
Drop a circular shape, red color, placed at the central bottom of the running window.
The program asks the user to provide the names and the nick names of five players.
The user can select the player to start the game.
When the player is selected, the program should indicate somewhere in the running window who is the current player and what is his score.
The player is in control of the ball. Pressing the right arrow should move the ball horizontally to the right. Pressing the left arrow should move the ball horizontally to the left.
Pressing the space bar should launch the ball vertically toward the top of the window. You choose the movement speed of the ball such that the player can see it properly.
If the ball touches one of the rectangle:
The corresponding reached target disappears.
The score of the corresponding user increments by one.
The permitted number of shots for the current player decrements by one. 
The ball returns back to its last position at the last lunching shot.
If the ball did not reach the target, the following events will happen:
The permitted number of shots for the current player decrements by one.
The ball returns back to its last position at the last launching shot.
The program should present at all times the top score reached so far and the name of the corresponding player. When a higher score is reached, the score and its player should replace the current top score data.
If two players have the same score, the winner is the one who shots the targets in a smaller time than the other. 
The user should be able at any time to check the scores of the top 10 players sorted with respect to the score value in a descending order. For this goal, you need to save the names and the scores in an external file. The file could have a maximum of 10 records. These records correspond to the top 10 scores with the corresponding players’ names. If a new score is reached which is greater than the lowest saved score, this last should be deleted and the new one should be saved along with the corresponding player name.


This post has been edited by janotte: 03 May 2009 - 05:44 AM

Was This Post Helpful? 0
  • +
  • -

#5 student omar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-May 09

Re: help to convert this code

Posted 05 May 2009 - 06:31 AM

 //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <iostream.h>
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int my_key;
bool shoot=false;
int score=0;
int no_shoots=5;
int no_players;
int curr_player=1;
bool game_over=false;
int score_arr[4];
int time_arr[4];
AnsiString player_arr[4];
clock_t StartTime, EndTime;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
		: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
	  TShiftState Shift)
{
  my_key=Key;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  if (!game_over)
  {
  if (no_shoots==5)
  {
	Rec1->Visible=true;
	Rec2->Visible=true;
	Rec3->Visible=true;
	Rec4->Visible=true;
	Rec5->Visible=true;
	Label4->Visible=false;
	Edit4->Visible=false;
	if (curr_player==1) Edit1->Text=Edit6->Text;
	if (curr_player==2) Edit1->Text=Edit7->Text;
	if (curr_player==3) Edit1->Text=Edit8->Text;
	if (curr_player==4) Edit1->Text=Edit9->Text;
	Edit2->Text=0;
	score=0;
	Edit3->Text=5;
	no_shoots=5;
	Cir->Left=380;
	StartTime=clock(); // new player
  }
  if (my_key==32) shoot=true;
  if (my_key==37) if (Cir->Left>0)Cir->Left-=10;
  if (my_key==39) if (Cir->Left<740) Cir->Left+=10;
  if (shoot && Cir->Top>40) Cir->Top-=5;
  if (Cir->Top==40)
  {
	Edit3->Text=--no_shoots;
	if (Cir->Left>40 && Cir->Left<140 && Rec1->Visible)
	{
	  Edit2->Text=++score;
	  Rec1->Visible=false;
	}
	if (Cir->Left>180 && Cir->Left<280 && Rec2->Visible)
	{
	  Edit2->Text=++score;
	  Rec2->Visible=false;
	}
	if (Cir->Left>320 && Cir->Left<420 && Rec3->Visible)
	{
	  Edit2->Text=++score;
	  Rec3->Visible=false;
	}
	if (Cir->Left>460 && Cir->Left<560 && Rec4->Visible)
	{
	  Edit2->Text=++score;
	  Rec4->Visible=false;
	}
	if (Cir->Left>600 && Cir->Left<700 && Rec5->Visible)
	{
	  Edit2->Text=++score;
	  Rec5->Visible=false;
	}
	if (no_shoots==0)
	{
	  EndTime=clock();
	  score_arr[curr_player-1]=score;
	  time_arr[curr_player-1]=difftime(EndTime,StartTime);
	  player_arr[curr_player-1]=Edit1->Text;
	  if (curr_player==no_players) game_over=true; else curr_player++;
	  Label4->Visible=true;
	  Edit4->Visible=true;
	  Edit4->Text=difftime(EndTime,StartTime);
	  no_shoots=5;
	}
	Cir->Top=340;
	shoot=false;
  }
  my_key=38;
  }
  else // GAME OVER
  {
	for(int i=0; i<no_players-1; i++)
	{
	   for (int j=i+1; j<no_players; j++)
	   {
		 if (score_arr[j]>score_arr[i])
		 {
		   int k=score_arr[i];
		   score_arr[i]=score_arr[j];
		   score_arr[j]=k;
		   k=time_arr[i];
		   time_arr[i]=time_arr[j];
		   time_arr[j]=k;
		   AnsiString m=player_arr[i];
		   player_arr[i]=player_arr[j];
		   player_arr[j]=m;
		 }
		 if ((score_arr[j]==score_arr[i]) && (time_arr[j]<time_arr[i]))
		 {
		   int k=score_arr[i];
		   score_arr[i]=score_arr[j];
		   score_arr[j]=k;
		   k=time_arr[i];
		   time_arr[i]=time_arr[j];
		   time_arr[j]=k;
		   AnsiString m=player_arr[i];
		   player_arr[i]=player_arr[j];
		   player_arr[j]=m;
		 }
	   } // for j
	}  // for i
	Label10->Visible=true;
	Label11->Visible=true;
	if (no_players>1) Label12->Visible=true;
	if (no_players>2) Label13->Visible=true;
	if (no_players>3) Label14->Visible=true;
	Label15->Visible=true;
	Label16->Visible=true;
	Edit10->Visible=true;
	if (no_players>1) Edit11->Visible=true;
	if (no_players>2) Edit12->Visible=true;
	if (no_players>3) Edit13->Visible=true;
	Edit14->Visible=true;
	if (no_players>1) Edit15->Visible=true;
	if (no_players>2) Edit16->Visible=true;
	if (no_players>3) Edit17->Visible=true;
	Edit18->Visible=true;
	if (no_players>1) Edit19->Visible=true;
	if (no_players>2) Edit20->Visible=true;
	if (no_players>3) Edit21->Visible=true;
	for (int i=0; i<no_players; i++)
	{
	  if (i==0)
	  {
		Edit10->Text=player_arr[i];
		Edit14->Text=score_arr[i];
		Edit18->Text=time_arr[i];
	  }
	  if (i==1)
	  {
		Edit11->Text=player_arr[i];
		Edit15->Text=score_arr[i];
		Edit19->Text=time_arr[i];
	  }
	  if (i==2)
	  {
		Edit12->Text=player_arr[i];
		Edit16->Text=score_arr[i];
		Edit20->Text=time_arr[i];
	  }
	  if (i==3)
	  {
		Edit13->Text=player_arr[i];
		Edit17->Text=score_arr[i];
		Edit21->Text=time_arr[i];
	  }
	} // for => results
  }  // else
}
//---------------------------------------------------------------------------


void __fastcall TForm1::cmdEnterNamesClick(TObject *Sender)
{
  no_players=Edit5->Text.ToInt();
  if (no_players==1)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	//Label7->Visible=false;
	//Edit7->Visible=false;
	//Label8->Visible=false;
	//Edit8->Visible=false;
	//Label9->Visible=false;
	//Edit9->Visible=false;
  }
  if (no_players==2)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	Label7->Visible=true;
	Edit7->Visible=true;
	//Label8->Visible=false;
	//Edit8->Visible=false;
	//Label9->Visible=false;
	//Edit9->Visible=false;
  }
  if (no_players==3)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	Label7->Visible=true;
	Edit7->Visible=true;
	Label8->Visible=true;
	Edit8->Visible=true;
	//Label9->Visible=false;
	//Edit9->Visible=false;
  }
  if (no_players==4)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	Label7->Visible=true;
	Edit7->Visible=true;
	Label8->Visible=true;
	Edit8->Visible=true;
	Label9->Visible=true;
	Edit9->Visible=true;
  }
  if (no_players>4 || no_players <1)
  {
	//Label6->Visible=false;
	//Edit6->Visible=false;
	//Label7->Visible=false;
	//Edit7->Visible=false;
	//Label8->Visible=false;
	//Edit8->Visible=false;
	//Label9->Visible=false;
	//Edit9->Visible=false;
	Edit5->Text="";
	Edit5->SetFocus();
  }
  if (no_players>=1 && no_players<=4) cmdStart->Visible=true;
  //
}
//---------------------------------------------------------------------------



void __fastcall TForm1::cmdStartClick(TObject *Sender)
{
  Edit5->Enabled=false;
  cmdEnterNames->Enabled=false;
  Edit6->Enabled=false;
  Edit7->Enabled=false;
  Edit8->Enabled=false;
  Edit9->Enabled=false;
  cmdStart->Enabled=false;
}
//---------------------------------------------------------------------------







Was This Post Helpful? 0
  • +
  • -

#6 samsong  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-May 09

Re: help to convert this code

Posted 19 May 2009 - 12:40 AM

could u show each of (Edit1, Edit2,..., Edit21 ) is for what & also for (Label1,...,Label16) please.




View Poststudent omar, on 5 May, 2009 - 05:31 AM, said:

 //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <iostream.h>
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int my_key;
bool shoot=false;
int score=0;
int no_shoots=5;
int no_players;
int curr_player=1;
bool game_over=false;
int score_arr[4];
int time_arr[4];
AnsiString player_arr[4];
clock_t StartTime, EndTime;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
		: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
	  TShiftState Shift)
{
  my_key=Key;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  if (!game_over)
  {
  if (no_shoots==5)
  {
	Rec1->Visible=true;
	Rec2->Visible=true;
	Rec3->Visible=true;
	Rec4->Visible=true;
	Rec5->Visible=true;
	Label4->Visible=false;
	Edit4->Visible=false;
	if (curr_player==1) Edit1->Text=Edit6->Text;
	if (curr_player==2) Edit1->Text=Edit7->Text;
	if (curr_player==3) Edit1->Text=Edit8->Text;
	if (curr_player==4) Edit1->Text=Edit9->Text;
	Edit2->Text=0;
	score=0;
	Edit3->Text=5;
	no_shoots=5;
	Cir->Left=380;
	StartTime=clock(); // new player
  }
  if (my_key==32) shoot=true;
  if (my_key==37) if (Cir->Left>0)Cir->Left-=10;
  if (my_key==39) if (Cir->Left<740) Cir->Left+=10;
  if (shoot && Cir->Top>40) Cir->Top-=5;
  if (Cir->Top==40)
  {
	Edit3->Text=--no_shoots;
	if (Cir->Left>40 && Cir->Left<140 && Rec1->Visible)
	{
	  Edit2->Text=++score;
	  Rec1->Visible=false;
	}
	if (Cir->Left>180 && Cir->Left<280 && Rec2->Visible)
	{
	  Edit2->Text=++score;
	  Rec2->Visible=false;
	}
	if (Cir->Left>320 && Cir->Left<420 && Rec3->Visible)
	{
	  Edit2->Text=++score;
	  Rec3->Visible=false;
	}
	if (Cir->Left>460 && Cir->Left<560 && Rec4->Visible)
	{
	  Edit2->Text=++score;
	  Rec4->Visible=false;
	}
	if (Cir->Left>600 && Cir->Left<700 && Rec5->Visible)
	{
	  Edit2->Text=++score;
	  Rec5->Visible=false;
	}
	if (no_shoots==0)
	{
	  EndTime=clock();
	  score_arr[curr_player-1]=score;
	  time_arr[curr_player-1]=difftime(EndTime,StartTime);
	  player_arr[curr_player-1]=Edit1->Text;
	  if (curr_player==no_players) game_over=true; else curr_player++;
	  Label4->Visible=true;
	  Edit4->Visible=true;
	  Edit4->Text=difftime(EndTime,StartTime);
	  no_shoots=5;
	}
	Cir->Top=340;
	shoot=false;
  }
  my_key=38;
  }
  else // GAME OVER
  {
	for(int i=0; i<no_players-1; i++)
	{
	   for (int j=i+1; j<no_players; j++)
	   {
		 if (score_arr[j]>score_arr[i])
		 {
		   int k=score_arr[i];
		   score_arr[i]=score_arr[j];
		   score_arr[j]=k;
		   k=time_arr[i];
		   time_arr[i]=time_arr[j];
		   time_arr[j]=k;
		   AnsiString m=player_arr[i];
		   player_arr[i]=player_arr[j];
		   player_arr[j]=m;
		 }
		 if ((score_arr[j]==score_arr[i]) && (time_arr[j]<time_arr[i]))
		 {
		   int k=score_arr[i];
		   score_arr[i]=score_arr[j];
		   score_arr[j]=k;
		   k=time_arr[i];
		   time_arr[i]=time_arr[j];
		   time_arr[j]=k;
		   AnsiString m=player_arr[i];
		   player_arr[i]=player_arr[j];
		   player_arr[j]=m;
		 }
	   } // for j
	}  // for i
	Label10->Visible=true;
	Label11->Visible=true;
	if (no_players>1) Label12->Visible=true;
	if (no_players>2) Label13->Visible=true;
	if (no_players>3) Label14->Visible=true;
	Label15->Visible=true;
	Label16->Visible=true;
	Edit10->Visible=true;
	if (no_players>1) Edit11->Visible=true;
	if (no_players>2) Edit12->Visible=true;
	if (no_players>3) Edit13->Visible=true;
	Edit14->Visible=true;
	if (no_players>1) Edit15->Visible=true;
	if (no_players>2) Edit16->Visible=true;
	if (no_players>3) Edit17->Visible=true;
	Edit18->Visible=true;
	if (no_players>1) Edit19->Visible=true;
	if (no_players>2) Edit20->Visible=true;
	if (no_players>3) Edit21->Visible=true;
	for (int i=0; i<no_players; i++)
	{
	  if (i==0)
	  {
		Edit10->Text=player_arr[i];
		Edit14->Text=score_arr[i];
		Edit18->Text=time_arr[i];
	  }
	  if (i==1)
	  {
		Edit11->Text=player_arr[i];
		Edit15->Text=score_arr[i];
		Edit19->Text=time_arr[i];
	  }
	  if (i==2)
	  {
		Edit12->Text=player_arr[i];
		Edit16->Text=score_arr[i];
		Edit20->Text=time_arr[i];
	  }
	  if (i==3)
	  {
		Edit13->Text=player_arr[i];
		Edit17->Text=score_arr[i];
		Edit21->Text=time_arr[i];
	  }
	} // for => results
  }  // else
}
//---------------------------------------------------------------------------


void __fastcall TForm1::cmdEnterNamesClick(TObject *Sender)
{
  no_players=Edit5->Text.ToInt();
  if (no_players==1)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	//Label7->Visible=false;
	//Edit7->Visible=false;
	//Label8->Visible=false;
	//Edit8->Visible=false;
	//Label9->Visible=false;
	//Edit9->Visible=false;
  }
  if (no_players==2)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	Label7->Visible=true;
	Edit7->Visible=true;
	//Label8->Visible=false;
	//Edit8->Visible=false;
	//Label9->Visible=false;
	//Edit9->Visible=false;
  }
  if (no_players==3)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	Label7->Visible=true;
	Edit7->Visible=true;
	Label8->Visible=true;
	Edit8->Visible=true;
	//Label9->Visible=false;
	//Edit9->Visible=false;
  }
  if (no_players==4)
  {
	Label6->Visible=true;
	Edit6->Visible=true;
	Label7->Visible=true;
	Edit7->Visible=true;
	Label8->Visible=true;
	Edit8->Visible=true;
	Label9->Visible=true;
	Edit9->Visible=true;
  }
  if (no_players>4 || no_players <1)
  {
	//Label6->Visible=false;
	//Edit6->Visible=false;
	//Label7->Visible=false;
	//Edit7->Visible=false;
	//Label8->Visible=false;
	//Edit8->Visible=false;
	//Label9->Visible=false;
	//Edit9->Visible=false;
	Edit5->Text="";
	Edit5->SetFocus();
  }
  if (no_players>=1 && no_players<=4) cmdStart->Visible=true;
  //
}
//---------------------------------------------------------------------------



void __fastcall TForm1::cmdStartClick(TObject *Sender)
{
  Edit5->Enabled=false;
  cmdEnterNames->Enabled=false;
  Edit6->Enabled=false;
  Edit7->Enabled=false;
  Edit8->Enabled=false;
  Edit9->Enabled=false;
  cmdStart->Enabled=false;
}
//---------------------------------------------------------------------------







Was This Post Helpful? 0
  • +
  • -

Page 1 of 1