delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/05/14:45:48

Message-ID: <35C8A4A5.18817E15@mail.bip.net>
From: Conan <Dr DOT Conan AT mail DOT bip DOT net>
Reply-To: Dr DOT Conan AT Technologist DOT com
Organization: Apocalypse Inc.
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Array level building?
References: <01bdc097$e0e5e780$LocalHost AT default>
Lines: 101
Date: Wed, 05 Aug 1998 18:32:41 GMT
NNTP-Posting-Host: 130.244.205.107
NNTP-Posting-Date: Wed, 05 Aug 1998 20:32:41 MET DST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Xee'Gh wrote:

> Hi!
> ---
> I started to do a level with array like the cutted code shows but
> but..
> The number 0 is nothing and 1 is (or should be) red pixel,  So i need
> to
> define
> number as red.. Its 2D matrix array but i dont know how can i fill it
> with
> the putpixel routine.I have a book but it is written so hard that i
> cant
> understand it.
> So if somebody would help me, please.
>
> This is huge favour to me if somebody would fix my code that way that
> it
> works.
> or least tell me how fix if nothing else.
> I use putpixel now because its easier than using bitmaps to number
> one.
>
> by the way what happens if i take the 'int' out before peli[10][10] ?
>
> I got 2 error messages which i cant fix.
>
> 1.int-array 'peli[0]' initiliazed from non-wide string.
> 2.parse error before 200.
>
> It looks simple on book but (there arent no examples) when i started
> to do
> it , its hard.
> Here is the code....
>
> #include <allegro.h>
>
> DATAFILE *data;
> BITMAP *bmp, *page1, *page2, *page3;
>
> int  peli[10][10] ={ "0000100001"
>                      "1001010100"
>                      "1010001010"
>                      "0010001100"
>                      "0001010000"
>                      "0010001000"
>                      "1010001000"
>                      "1010000100"
>                      "0100000010"
>                      "0001000100"
>                      "0010101010" };
> int MakeLevel()
> {
> int x, y;
>
> for (y=0; y<10; y++)
> {
> for (x=0; x<10; x++)
> {
>  if (peli[3][4])
>   {
>   putpixel(screen, x, y, 93);
>   }
>  }
> }
> }
>
> void main()
> {
> allegro_init();
> set_gfx_mode(GFX_AUTODETECT, 320 200, 0, 0);
> MakeLevel(); /*parse error*/
> kbhit();
> allegro_exit();
> }
>
> --
> He really needs help.


Here's your problem!!!
int  peli[10][10] ={ "0000100001"
                     "1001010100"
                     "1010001010"
                     "0010001100"
                     "0001010000"
                     "0010001000"
                     "1010001000"
                     "1010000100"
                     "0100000010"
                     "0001000100"
                     "0010101010" };

it should look like this:
char array[4][4] ={{0,1,0,0},
                        {1,0,1,0},
                        {0,1,0,0},
                        {0,1,0,0}, };
/Conan


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019