Guest User

Untitled

a guest
Jun 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. //in method for casting single ray
  2. //where
  3. perpendicularDistToWall = distToWallByRay*Math.Cos((Player.me().worldViewAngle-rayAngle).rad);
  4.  
  5. double stripHeight = (64.0d / perpendicularDistToWall) * Player.me().worldDistToProjectionPlane;
  6. //
  7.  
  8. int stripPosY = (ProjectionPlane.me().sizeInWorld.Y/2 - (int)(stripHeight / 2));
  9. stripPosY += (int)stripHeight-1;
  10. int startPixel = stripPosY;
  11.  
  12. while (startPixel != ProjectionPlane.me().sizeInWorld.Y){
  13. float curdist = ProjectionPlane.me().sizeInWorld.Y / (2.0f * startPixel - ProjectionPlane.me().sizeInWorld.Y);
  14.  
  15. float weight = curdist / (float)(perpendicularDistToWall);
  16.  
  17. float floorX = weight * minimalIntersection.X + (1.0f - weight) * Player.me().worldPosition.X;
  18. float floorY = weight * minimalIntersection.Y + (1.0f - weight) * Player.me().worldPosition.Y;
  19.  
  20. int textureX = (int)(floorX * 32) % 32;
  21. int textureY = (int)(floorY * 32) % 32;
  22.  
  23. textureX = Math.Abs(textureX);
  24. textureY = Math.Abs(textureY);
  25.  
  26. b = new SolidBrush(ProjectionPlane.imageFloor1.GetPixel(textureX, textureY));
  27. //draw current floor pixel directly in buffer
  28. //stripX from 0 to projection_plane width
  29. g.FillRectangle(b, stripX, startPixel, 1, 1);
  30.  
  31. startPixel++;
Add Comment
Please, Sign In to add comment