Help Please

First Question: how do i get a random number from an array. i have made an array from 1..45, and declared what each one is, it has 1..9 are 1, 1..17 are 2 and so on. and i want to get a random one of these from the array.
Second Question: How do i make an if that does someting like this:
IF check = check1 then
begin
(then i make things multiply).
end;
(i would be doing this for checker = check and check1, check = checker

and checker = check1.
Third Question: how would i make a hold function(i am making a fruit machine)that has a 5050 chance to get to hold, and you can hold upto 2 columns(out of 3).
to help in answering i have posted my entire program below.
Thanks in advance, ~megamidge11
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
program fruitmachine;

uses crt;

var bet,semibank,spin,bank,winings,yahoo,endscreen,endscreenwin,mulitplier,holdyn,checker,check,check1,written,blob,hold5050,rand:integer;
var fruit : array[1..9] of string;
var rare : array[1..45] of integer;

begin
repeat
//random table
rare[1]:=1;
rare[2]:=1;
rare[3]:=1;
rare[4]:=1;
rare[5]:=1;
rare[6]:=1;
rare[7]:=1;
rare[8]:=1;
rare[9]:=1;
rare[10]:=2;
rare[11]:=2;
rare[12]:=2;
rare[13]:=2;
rare[14]:=2;
rare[15]:=2;
rare[16]:=2;
rare[17]:=2;
rare[18]:=3;
rare[19]:=3;
rare[20]:=3;
rare[21]:=3;
rare[22]:=3;
rare[23]:=3;
rare[24]:=3;
rare[25]:=4;
rare[26]:=4;
rare[27]:=4;
rare[28]:=4;
rare[29]:=4;
rare[30]:=4;
rare[31]:=5;
rare[32]:=5;
rare[33]:=5;
rare[34]:=5;
rare[35]:=5;
rare[36]:=6;
rare[37]:=6;
rare[38]:=6;
rare[39]:=6;
rare[40]:=7;
rare[41]:=7;
rare[42]:=7;
rare[43]:=8;
rare[44]:=8;
rare[45]:=9;
cursoroff;
//Initialising fruits
fruit[1]:=' cherry ';
fruit[2]:=' banana ';
fruit[3]:=' lemon ';
fruit[4]:=' orange ';
fruit[5]:=' bar ';
fruit[6]:=' melon ';
fruit[7]:=' coconut ';
fruit[8]:=' bell ';
fruit[9]:=' butter ';

//writing of reels:
gotoxy(25,10);
write(char(201));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(203));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(203));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(187));

gotoxy(25,11);
write(char(186));
gotoxy(36,11);
write(char(186));
gotoxy(47,11);
write(char(186));
gotoxy(58,11);
write(char(186));

gotoxy(25,12);
write(char(186));
gotoxy(36,12);
write(char(186));
gotoxy(47,12);
write(char(186));
gotoxy(58,12);
write(char(186));

gotoxy(25,13);
write(char(186));
gotoxy(36,13);
write(char(186));
gotoxy(47,13);
write(char(186));
gotoxy(58,13);
write(char(186));

gotoxy(25,14);
write(char(186));
gotoxy(36,14);
write(char(186));
gotoxy(47,14);
write(char(186));
gotoxy(58,14);
write(char(186));

gotoxy(25,15);
write(char(186));
gotoxy(36,15);
write(char(186));
gotoxy(47,15);
write(char(186));
gotoxy(58,15);
write(char(186));

gotoxy(25,16);
write(char(186));
gotoxy(36,16);
write(char(186));
gotoxy(47,16);
write(char(186));
gotoxy(58,16);
write(char(186));

gotoxy(25,17);
write(char(186));
gotoxy(36,17);
write(char(186));
gotoxy(47,17);
write(char(186));
gotoxy(58,17);
write(char(186));

gotoxy(25,18);
write(char(186));
gotoxy(36,18);
write(char(186));
gotoxy(47,18);
write(char(186));
gotoxy(58,18);
write(char(186));

gotoxy(25,19);
write(char(186));
gotoxy(36,19);
write(char(186));
gotoxy(47,19);
write(char(186));
gotoxy(58,19);
write(char(186));

gotoxy(25,20);
write(char(200));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(202));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(202));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(188));
//end of writing blank reels
//instructions:
gotoxy(60,10);
write('INSTRUCTIONS:');
gotoxy(60,11);
write('-type 4 to quit');
gotoxy(60,12);
write('-type 01 to to bank');
gotoxy(60,13);
write('your money');
gotoxy(60,14);
write('to hold...');
gotoxy(60,15);
write('YOU MUST BET OVER 5!');

repeat
gotoxy(30,4);
write('place a bet');
cursoron;
gotoxy(30,5);
write(' ');
gotoxy(30,5);
read(bet);

cursoroff;
//to BANK:
if bet = 01 then
begin
winings:=semibank;
end;
until (bet > 5) or (bet = 4);
//resetting the spin:
spin:=0;

//if bet is 4 it skips to end scene(0 is the quit function)
//at first i tried to do it with an IF statement, but it disabled
//the ability to play the game. i then, whilst writing these notes, the
//repeat-until did the job just fine.
//'spinning' animation:
if bet > 5 then
begin
repeat

//randomizer
//left reel
randomize;
rand:=random(8);
rand:=rand+1;
gotoxy(26,15);
if rand = 1 then
begin
checker:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
checker:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
checker:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
checker:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
checker:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
checker:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
checker:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
checker:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
checker:=9;
write(fruit[9]);
end;
//center reel
rand:=random(8);
rand:=rand+1;
gotoxy(37,15);
if rand = 1 then
begin
check:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check:=9;
write(fruit[9]);
end;
//right reel
rand:=random(8);
rand:=rand+1;
gotoxy(48,15);
if rand = 1 then
begin
check1:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check1:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check1:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check1:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check1:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check1:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check1:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check1:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check1:=9;
write(fruit[9]);
end;
delay(100);
spin:=spin+1;
until spin = 25;

end;

//randomizer for HOLDING
randomize;
hold5050:=random(1)+1;

//randomizer
//left reel
randomize;
rand:=random(8);
rand:=rand+1;
gotoxy(26,15);
if rand = 1 then
begin
checker:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
checker:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
checker:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
checker:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
checker:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
checker:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
checker:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
checker:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
checker:=9;
write(fruit[9]);
end;
//center reel
rand:=random(8);
rand:=rand+1;
gotoxy(37,15);
if rand = 1 then
begin
check:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check:=9;
write(fruit[9]);
end;
//right reel
rand:=random(8);
rand:=rand+1;
gotoxy(48,15);
if rand = 1 then
begin
check1:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check1:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check1:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check1:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check1:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check1:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check1:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check1:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check1:=9;
write(fruit[9]);
end;

gotoxy(26,15);
//For 3 the same
if checker = check and check1 then
begin
if checker = 1 then
begin
mulitplier:=3;
end;
if checker = 2 then
begin
mulitplier:=4;
end;
if checker = 3 then
begin
mulitplier:=5;
end;
if checker = 4 then
begin
mulitplier:=6;
end;
if checker = 5 then
begin
mulitplier:=7;
end;
if checker = 6 then
begin
mulitplier:=8;
end;
if checker = 7 then
begin
mulitplier:=9;
end;
if checker = 8 then
begin
mulitplier:=10;
end;
if checker = 9 then
begin
mulitplier:=20;
end;
bet:=bet*mulitplier;

end;
//For rell 1 and 2 the same
if checker = check then
begin
if checker = 1 then
begin
mulitplier:=2;
end;
if checker = 2 then
begin
mulitplier:=3;
end;
if checker = 3 then
begin
mulitplier:=4;
end;
if checker = 4 then
begin
mulitplier:=5;
end;
if checker = 5 then
begin
mulitplier:=6;
end;
if checker = 6 then
begin
mulitplier:=7;
end;
if checker = 7 then
begin
mulitplier:=8;
end;
if checker = 8 then
begin
mulitplier:=9;
end;
if checker = 9 then
begin
mulitplier:=10;
end;
bet:=bet*mulitplier;

end;
//For reel 1 and 3 the same
if checker = check1 then
begin
if checker = 1 then
begin
mulitplier:=2;
end;
if checker = 2 then
begin
mulitplier:=3;
end;
if checker = 3 then
begin
mulitplier:=4;
end;
if checker = 4 then
begin
mulitplier:=5;
end;
if checker = 5 then
begin
mulitplier:=6;
end;
if checker = 6 then
begin
mulitplier:=7;
end;
if checker = 7 then
begin
mulitplier:=8;
end;
if checker = 8 then
begin
mulitplier:=9;
end;
if checker = 9 then
begin
mulitplier:=10;
end;
bet:=bet*mulitplier;

end;
//For reel 2 and 3 the same
if check = check1 then
begin
if check = 1 then
begin
mulitplier:=2;
end;
if check = 2 then
begin
mulitplier:=3;
end;
if check = 3 then
begin
mulitplier:=4;
end;
if check = 4 then
begin
mulitplier:=5;
end;
if check = 5 then
begin
mulitplier:=6;
end;
if check = 6 then
begin
mulitplier:=7;
end;
if check = 7 then
begin
mulitplier:=8;
end;
if check = 8 then
begin
mulitplier:=9;
end;
if check = 9 then
begin
mulitplier:=10;
end;
if mulitplier > 1 then
begin
bet:=bet*mulitplier;

end;


end;



semibank:=semibank+bet;
gotoxy(2,10);
cursoron;
write('you have ',bet,' pounds!');
gotoxy(2,11);
write('you have ',winings,' secured');

mulitplier:=1;








until bet = 4;
gotoxy(2,15);

clrscr;
repeat

repeat
gotoxy(35,14);
write('YOU WON ',winings,' POUNDS');
gotoxy(35,14);
delay(100);
write(' ');
delay(100);
endscreenwin:=endscreenwin+1;
until endscreenwin = 20;

gotoxy(35,12);
write('G');
delay(100);
write('A');
delay(100);
write('M');
delay(100);
write('E');
delay(100);
write(' ');
delay(100);
write('O');
delay(100);
write('V');
delay(100);
write('E');
delay(100);
write('R');
delay(1000);
gotoxy(35,12);

write(' ');
delay(01);
if winings > 15000 then
begin

repeat

gotoxy(2,2);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,4);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,6);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,8);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,10);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,14);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,16);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,18);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,20);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,22);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
delay(100);
gotoxy(2,2);
write(' ');
gotoxy(2,4);
write(' ');
gotoxy(2,6);
write(' ');
gotoxy(2,8);
write(' ');
gotoxy(2,10);
write(' ');
gotoxy(2,14);
write(' ');
gotoxy(2,16);
write(' ');
gotoxy(2,18);
write(' ');
gotoxy(2,20);
write(' ');
gotoxy(2,22);
write(' ');
yahoo:=yahoo+1;
delay(100);
until yahoo = 100;
end;
endscreen:=endscreen+1;
until endscreen = 9001;
gotoxy(23,5);
write('press enter to quit');
read(bet);

end.


Comments

  • Nowadays, a handbag has the same value as a jewel; they're fashionable and accessible in quite a few colours and designs. These well-known site supplies probably the most favorable cost of replica handbags and authentic designer handbags. This [link=http://www.longchampbagsoutletaustralian.com/]Longchamp Bag[/link] is offered in two sizes, the smaller one particular with an extra shoulder strap. Regarding its function, it features chronograph function: measures time times within a few minutes, seconds and 1/ten seconds and waterproof to louis vuitton purses 100 meters. Besides, there's a diamond ring to clip an adjunct or key holder.

    Your perfectly assembled outfit needs the ultimate accessory. Here we go, I guess black could mean mysterious. Facing a shortage of standard materials. You can as effectively get some inspirations from celebrities who usually wear fashionable and decent. If it features a shabby glimpse then your image will not likely be enhanced by carrying it all around. But with my mum, she keeps her everyday school/work bag in the so called pantry in addition to her going-out [link=http://www.longchampbagsoutletaustralian.com/longchamp-cosmetic-bags-c-2.html]Longchamp Cosmetic Bags[/link]. There has never been a secret that accessories are what makes you wonderful and determine regardless of whether or not you have got a good fashion sense.

    michael kors bags te a few the ladies is a very little diligent of looking for this approach kind of boots or shoes due to their worth. It seems like I am asigning moods for the colour of Birkin bag that she is carrying on any given day. I a 38 yr old sewing addict and came across an ad at xmas for one particular of one's sock monkey kits from Save the Youngsters in a mag I was given. They are best for almost everything from groceries to garden instruments and beach towels. I am fighting for my personal significant event. They would add a page here and there, just as a hobby.

    [link=http://www.longchampbagsoutletaustralian.com/]http://www.longchampbagsoutletaustralian.com/[/link]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion