Zanzlanz

Raycast

Jul 28th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. for(int worldX = 0; worldX<screenWidth/scale; worldX+=1) {
  2.     for(int worldY = 0; worldY<screenHeight/scale; worldY+=1) {
  3.         xS = Math.sin((((float) (worldX-screenWidth/scale/2)/(screenWidth/scale))*75+xRot)/180*Math.PI)*3 *  Math.cos((((float) (worldY-screenHeight/scale/2)/(screenHeight/scale))*45+yRot)/180*Math.PI)*3;
  4.         yS = Math.sin((((float) (worldY-screenHeight/scale/2)/(screenHeight/scale))*45+yRot)/180*Math.PI)*3 *  Math.cos((((float) (worldX-screenWidth/scale/2)/(screenWidth/scale))*75+xRot)/180*Math.PI)*3;
  5.         zS = Math.cos((((float) (worldX-screenWidth/scale/2)/(screenWidth/scale))*75+xRot)/180*Math.PI)*3;
  6.         for(float ray=0; ray<=renderDistance; ray+=depthPercision+ray/100) {
  7.             x = (Math.abs((camX+xS*ray)) % worldWidth);
  8.             y = camY+yS*ray;
  9.             z = (Math.abs((camZ+zS*ray)) % worldLength);
  10.             if(world[(int) x][(int) y][(int) z] != null) {
  11.                 //I just hit a block...
  12.             }
  13.         }
  14.     }
  15. }
Add Comment
Please, Sign In to add comment