Jump to content

Array Stuck

- - - - -

  • Please log in to reply
5 replies to this topic

#1
alex1

alex1

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
Hi Guys! I have a superduper problem(ok its not a problem - its a stuck) - Im using turbopascal 1.5

I have to make an labirinth game using an array. I have stucked.Is it possible to change the "gotoxy(28,13);write('*');" with a command telling to place a '*' on (map[10,15] - for example)
I also can't place my array in the center of the dos monitor(24x80 lines) - its moving only the first line of the array at the center... :mad:

Please help me!!!Please!!!


uses wincrt;

var

   Map:array[1..22,1..60] of char;

   I,J: integer;


begin

for i:=1 to 22 do

    begin

         for J:=1 to 60 do

             begin

                  map[I,J]:='*';

             end;

    end;

for I:=1 to 22 do

    begin

         for J:=1 to 60 do

             begin

                  if (I=1)  or (J=1) or (J=60) or (I=22) then 

                  write(map[I,J])

                  else

                  write(' ');

             end;

         writeln;

    end;

gotoxy(35,9);write('*'); gotoxy(34,9);write('*'); gotoxy(33,9);write('*'); gotoxy(32,9);write('*');

gotoxy(31,9);write('*'); gotoxy(30,9);write('*'); gotoxy(25,9);write('*'); gotoxy(26,9);write('*');

gotoxy(27,9);write('*'); gotoxy(28,9);write('*'); gotoxy(29,9);write('*'); gotoxy(30,9);write('*');


gotoxy(35,11);write('*'); gotoxy(35,12);write('*'); gotoxy(35,13);write('*');


gotoxy(34,13);write('*'); gotoxy(33,13);write('*'); gotoxy(32,13);write('*');  gotoxy(31,13);write('*');

gotoxy(30,13);write('*'); gotoxy(29,13);write('*'); gotoxy(28,13);write('*');  gotoxy(27,13);write('*');

gotoxy(26,13);write('*'); gotoxy(25,13);write('*');


gotoxy(25,11);write('*'); gotoxy(25,12);write('*'); gotoxy(25,10);write('*');



gotoxy(30,11);

write('#');


gotoxy(10,22);

write('O');

gotoxy(11,22);

write('O');


gotoxy(9,21);write('*'); gotoxy(9,20);write('*'); gotoxy(9,19); write('*'); gotoxy(9,18);write('*');

gotoxy(9,17);write('*'); gotoxy(9,16);write('*');


gotoxy(12,21);write('*'); gotoxy(12,20);write('*'); gotoxy(12,19);write('*'); gotoxy(12,18);write('*');


gotoxy(13,18);write('*'); gotoxy(14,18);write('*'); gotoxy(15,18);write('*'); gotoxy(16,18);write('*');

gotoxy(17,18);write('*'); gotoxy(18,18);write('*');


gotoxy(18,19);write('*'); gotoxy(18,20);write('*'); gotoxy(18,21);write('*');



END.


#2
sam_l

sam_l

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
Why not do this. Fill your initial array with the default character, then update the specific spots in the array, say Map[30, 11], and set it equal to whichever character you need. It would go something like this.

1: Fill array with initial values
2: Draw array
3: Player Input
4: Update Array
5: Clear Screen
6: Draw Array
7: GoTo 3

#3
alex1

alex1

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
Hey! :) Thanks for the answer!

Quote

say Map[30, 11], and set it equal to whichever character you need.

Exacly this is my problem... I don't know how to do this.... Im always getting an error.
Don't I need to say " map[30,11]:='*' " ? - its not working...

How can I tell to it to go to map[30,11] and write ' * ' - except the gotoxy command.

#4
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
Then just wrap the GotoXY(x, y) and Write('*') commands inside a procedure (which you can name it Map). Next time you want to print * in a specific location you could simply call Map(x, y). For example this line of your code:
gotoxy(35,9);write('*'); gotoxy(34,9);write('*'); gotoxy(33,9);write('*'); gotoxy(32,9);write('*');

Can be replaced by:

  Map(35,9);

  Map(34,9);

  Map(33,9);

  Map(32,9);



#5
alex1

alex1

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
yay. Thank you. Today Im thinking much clealer and i figured out what to do :):):)

Thanks for the answer!!!! :cool:

I really apriciate your help!!!!

#6
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
Great to know that I can help!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users