www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/21/20:57:06

From: "Arthur" <arfa AT clara DOT net>
To: <djgpp AT delorie DOT com>
Subject: RE: Oh!!help me allegro..
Date: Wed, 21 Oct 1998 23:23:18 +0100
Message-ID: <000401bdfd41$671b8400$5a4e08c3@arthur>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
In-Reply-To: <362E511C.47287F22@netian.com>
Reply-To: djgpp AT delorie DOT com

> void CreateEnemy()
> {
>  word i=0;
>  for (i=0; i<max_num; i++)
>  {
>   if (enemy[i].isEnemy == False)
>   {
>    enemy[i].x = srandom(270);
>    //Is this correct?
>    //I want to select between 1 and 270.
>    //I write  random(270) to Borland turbo c.
>    //Allegro find "error message"..

Try "random() % 270 + 1" instead. srandom() seeds the random generator with
a seed value. random() returns a sodding great number, so you use the
modulus function (%) to reduce the number to between 0 and 269. You then
have to add 1 to get it between 1 and 270.

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819

- Raw text -


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