delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/10/23:10:50

From: trippylsdtab AT yahoo DOT com (Trippy)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro program won't work
Date: Sat, 10 Apr 1999 18:38:17 GMT
Organization: Customer of Planet Online
Message-ID: <370f9a10.1781433@news.freeserve.co.uk>
References: <TQFP2.131$eo4 DOT 138 AT news DOT get2net DOT dk>
NNTP-Posting-Host: modem-3.boron.dialup.pol.co.uk
X-Trace: news4.svr.pol.co.uk 923769595 15722 62.136.2.3 (10 Apr 1999 18:39:55 GMT)
NNTP-Posting-Date: 10 Apr 1999 18:39:55 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
Lines: 118
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

Intrested in 3d games myself so I thought I would take a look at your
program.

I compiled and ran....No probs it never crashed me out ??? weird...
What errors if any do you get ?

Regards
Trip




On Sat, 10 Apr 1999 12:35:10 +0200, "Anders Pedersen"
<anders_p AT forum DOT dk> wrote:

>I'm trying to learn how to make 3d games. I've found an tutorial on the net
>and readed it. After that I wanted to do some research, and I've done this
>program that make an 3d rectangle (allmost there some lines in the rectangle
>missing) that you can move around with the keypads an zoom in and out with Z
>and X. The program work fine but when you try to zoom in so you can't se the
>rectangle more the program crashes.
>
>Anders
>
>Program:
>#include <allegro.h>
>
>float x[4]={2,2,-2,-2}; // Here are the X and Y values
>float y[4]={2,-2,2,-2}; // for the rectangle
>
>float z=10; // And here are the z value
>
>int screenx1,screeny1,screenx2,screeny2; // Some integers to store the
>calculated points before they're blitted to the screen
>
>int i; // Just an integer for the loop
>
>int done=FALSE;
>
>BITMAP *temp; // A doublebuffer
>
>int main(void)
>{
> allegro_init();
>
> set_gfx_mode(GFX_AUTODETECT,320,200,0,0);
>
> install_keyboard();
>
> temp=create_bitmap(320,200);
>
>
> do
> {
>  for (i=0; i!=4; i++) // we need to draw 4 lines
>  {
>
>   screenx1=160.0+256.0*( x[i] / z);           // This algorithm
>   screeny1=100.0+256.0*( y[i] / z);           // calculate where
>   screenx2=160.0+256.0*( x[i] / (z+5.0)); // I should draw
>   screeny2=100.0+256.0*( y[i] / (z+5.0)); // the line
>
>   line(temp, screenx1, screeny1, screenx2, screeny2, 6); // draw the line
>to the double buffer
>  }
>  blit(temp,screen,0,0,0,0,320,200);
>  clear(temp);
>
>  // getinput from keyboard
>  if (key[KEY_UP])
>  {
>   y[0]--;   // Move rectangle up
>   y[1]--;
>   y[2]--;
>   y[3]--;
>  }
>  if (key[KEY_DOWN])
>  {
>   y[0]++;   // Move rectangle down
>   y[1]++;
>   y[2]++;
>   y[3]++;
>  }
>  if (key[KEY_LEFT])
>  {
>   x[0]--;   // move rectangle left
>   x[1]--;
>   x[2]--;
>   x[3]--;
>  }
>  if (key[KEY_RIGHT])
>  {
>   x[0]++;    // move rectangle right
>   x[1]++;
>   x[2]++;
>   x[3]++;
>  }
>  if (key[KEY_X])
>  {
>   z++;                  // Zoom in
>  }
>  if (key[KEY_Z])
>  {
>   z--;                  // Zoom out
>  }
>  if (key[KEY_ESC])
>  {
>   done=TRUE;               // exit program
>  }
>  clear_keybuf();
> } while (done==FALSE);
> return 0;
>}
>
>

- Raw text -


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