delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/05/17:29:53

From: nicblais AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Please help...matrix problem with Allegro
Date: Tue, 05 Oct 1999 19:54:26 GMT
Organization: Deja.com - Before you buy.
Lines: 42
Message-ID: <7tdl1b$f2e$1@nnrp1.deja.com>
NNTP-Posting-Host: 205.151.225.202
X-Article-Creation-Date: Tue Oct 05 19:42:16 1999 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
X-Http-Proxy: 1.0 x42.deja.com:80 (Squid/1.1.22) for client 216.210.53.42, 205.151.225.202
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Here's my problem.  I made an array called matrix
composed of 2 dimension, res_x (resolution of x)
and res_y.  I want to plot a pixel on the screen
but not if it already exists so if, let's say
that matrix[78][204] = 1, it means that at 78,204
there's a pixel.  If it were 0, there wouldn't be.

Here's my code part that does just that:  It
freezes my computer.

#define RGB makecol15

ushort run_program()
{
ushort pix_x;
ushort pix_y;
ushort color_red;
unsigned int matrix[res_x][res_y];

for (unsigned int i = 0; i < (res_x * res_y); i++)
     {
     if (keypressed())
        break;
     pix_x = (random() % res_x) + 1;
     pix_y = (random() % res_y) + 1;
     if (matrix[pix_x][pix_y] == 1)
        continue;
     else
          matrix[pix_x][pix_y] = 1;
     color_red = (random() % 255) + 1;
     putpixel(screen, pix_x, pix_y, RGB
(color_red, 0, 0));
     }
return 1;
}


Please help.  Sincerly, Nicolas Blais.


Sent via Deja.com http://www.deja.com/
Before you buy.

- Raw text -


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