Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //in method for casting single ray
- //where
- perpendicularDistToWall = distToWallByRay*Math.Cos((Player.me().worldViewAngle-rayAngle).rad);
- double stripHeight = (64.0d / perpendicularDistToWall) * Player.me().worldDistToProjectionPlane;
- //
- int stripPosY = (ProjectionPlane.me().sizeInWorld.Y/2 - (int)(stripHeight / 2));
- stripPosY += (int)stripHeight-1;
- int startPixel = stripPosY;
- while (startPixel != ProjectionPlane.me().sizeInWorld.Y){
- float curdist = ProjectionPlane.me().sizeInWorld.Y / (2.0f * startPixel - ProjectionPlane.me().sizeInWorld.Y);
- float weight = curdist / (float)(perpendicularDistToWall);
- float floorX = weight * minimalIntersection.X + (1.0f - weight) * Player.me().worldPosition.X;
- float floorY = weight * minimalIntersection.Y + (1.0f - weight) * Player.me().worldPosition.Y;
- int textureX = (int)(floorX * 32) % 32;
- int textureY = (int)(floorY * 32) % 32;
- textureX = Math.Abs(textureX);
- textureY = Math.Abs(textureY);
- b = new SolidBrush(ProjectionPlane.imageFloor1.GetPixel(textureX, textureY));
- //draw current floor pixel directly in buffer
- //stripX from 0 to projection_plane width
- g.FillRectangle(b, stripX, startPixel, 1, 1);
- startPixel++;
Add Comment
Please, Sign In to add comment