Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float posX = 9, posY = 12.5;
- float dirX = -1, dirY = 0;
- float planeX = 0, planeY = 0.9;
- float time = 0, oldTime = 0;
- float cameraX, rayPosX, rayPosY, rayDirX, rayDirY, sideDistX, sideDistY, deltaDistX, deltaDistY, perpWallDist, frameTime, moveSpeed, rotSpeed, oldDirX, oldPlaneX;
- int x, y, mapX, mapY, stepX, stepY, hit, side, lineHeight, drawStart, drawEnd;
- cameraX = 2 * x / (float)(screenWidth) -1;
- rayPosX = posX;
- rayPosY = posY;
- rayDirX = dirX + planeX * cameraX;
- rayDirY = dirY + planeY * cameraX;
- mapX = (int)(rayPosX);
- mapY = (int)(rayPosY);
- deltaDistX = SquareRootFloat(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX));
- deltaDistY = SquareRootFloat(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY));
- hit = 0;
- if (rayDirX < 0)
- {
- stepX = -1;
- sideDistX = (rayPosX - mapX) * deltaDistX;
- }
- else
- {
- stepX = 1;
- sideDistX = (mapX + 1.0 - rayPosX) * deltaDistX;
- }
- if (rayDirY < 0)
- {
- stepY = -1;
- sideDistY = (rayPosY - mapY) * deltaDistY;
- }
- else
- {
- stepY = 1;
- sideDistY = (mapY + 1.0 - rayPosY) * deltaDistY;
- }
- while (hit == 0)
- {
- if (sideDistX < sideDistY)
- {
- sideDistX += deltaDistX;
- mapX += stepX;
- side = 0;
- }
- else
- {
- sideDistY += deltaDistY;
- mapY += stepY;
- side = 1;
- }
- if (worldMap[mapX][mapY] > 0) hit = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement