delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/10/16:19:16

Message-ID: <001e01ba0780$b828cd40$a0f9c6c3@johans-dator>
From: "Johan Henriksson" <johan DOT he AT telia DOT com>
To: <djgpp AT delorie DOT com>
Subject: Re: Allegro program won't work
Date: Mon, 10 Apr 1995 22:19:50 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

from Johan Henriksson, Sweden    HTTP://come.to/jhewok  |
Primary mail: johan DOT he AT telia DOT com                  #UIN 12035895
Second: jhe75 AT hotmail DOT com    Third: johan_he AT yahoo DOT com
Leadprogrammer and FX-specialist at Real software
http://come.to/real_software
*************************************************************************
-----Original Message-----
From: Anders Pedersen <anders_p AT forum DOT dk>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Saturday, April 10, 1999 9:18 PM
Subject: Allegro program won't work



Do you perform any clipping? If not, DBZ usually occurs if you don't clip
against hither clippingplane.





>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