13. Элементы виртуальной реальное

#include <bios.h>
#include <dos.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define VIEW WIDTH ( M PI/3) // viewing angle ( 60 degrees )
#define SCREEN WIDTH // size of rendering window
#define SCREEN HEIGHT // basic colors
#define FLOOR COLOR
#define CEILING COLOR
#define WALL COLOR // angles
#define ANGLE 90 M PI 2 // 90 degrees
#define ANGLE 180 M PI //180 degrees
#define ANGLE_270 (MJPÏ4.5) // 270 degrees
// bios key defintions
#define ESC 0x011b
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
// labyrinth
char * worldMap 0 = {
II *************************************** *************H
I
II* * *ll
I
II* ********* ************************** *H
I
II* * *ll
»
II* ********* * ************************ *H
t
II* * *M
t
II* ********* ************************** *"
»
II* * *"
t
11****************************************************11
};
float swing;
float locX;
float locY;
float angle;
long totalFrames = 01;
char far * screenPtr = (char far *) MK_FP ( OxAOOO, 0 ); float rayAngle [SCREENJ/VIDTH];
// angles for rays from main // viewing direction
////////////////////////// Functions ////////////////////////////////////
void drawSpan ( float dist, char wallColor, int x ) {
char far * vptr = screenPtr + x;
int h = dist >= 0.5 ? (int)(SCREEN_HEIGHT*0.5 / dist ) : SCREENJHEIGHT;
int j1 = ( SCREENJHEIGHT - h )/2; int j2 = j1 + h;

Компьютерная графика. Полигональные модели

for (int j = 0; j < j1; j++ vptr += 320 )
* vptr = CEILING_COLOR;
if (j2 > SCREENJHEIGHT ) j2 = SCREENJHEIGHT;
for (; j < j2; j++, vptr += 320 )
* vptr = wallColor;
for (; j < SCREENJHEIGHT; j+* vptr += 320 )

⇐ Предыдущая| |Следующая ⇒