raycast style lighting glitches.

ive been playing around with doing ray cast lighting on a 32bit scale but its not very efficient and nor is it very accurate.

public void tick(int x, int y) {// updates the light
		if (lighting) {
			for (int xx = core.xoffset / 32; xx < (core.xoffset
					+ Core.core.WIDTH + 32) / 32; xx++) {
				for (int yy = core.yoffset / 32; yy < (core.yoffset
						+ Core.core.HEIGHT + 32) / 32; yy++) {
					core.addtomap(xx * 32, yy * 32, nolight);
				}

			}
			for (double i = -3.15; i < 3.15; i += 0.02) {
				rays[0].tick(player.x, player.y + 1, i,20);
			}
			

		}
	}

Currently i run it off of an array because I was testing out using multiple rays. that is the main lighting handler.

public void ray() {

		boolean candraw = true;
		nx = Math.sin(dir);
		ny = Math.cos(dir);
		
		for (int i = 0; i < dist; i++) {// err CHECKS!
			x += nx;
			y += ny;
			sx = (int) x;
			sy = (int) y;
			
			if (sx < ((Core.core.WIDTH * 18) + 16) / 32
					&& sy < ((Core.core.HEIGHT * 18) + 16) / 32) {
				if (sx >= 0 && sy >= 0) {
					if (core.world.tilemap[ sx][ sy] != null) {
						if (candraw) {
							core.addtomap( sx * 32,  sy * 32,
									core.world.tilemap[ sx][ sy]
											.getgraphics());
						}
						if (core.world.tilemap[ sx][ sy].isopaque()) {
							candraw = false;
							continue;
						}
					}
					

				}
			}
		}
		

		
	}

	public void tick(int x, int y, double dir, int dist) {
		this.x = x / 32;
		this.y = y / 32;
		this.dir = dir;
		this.dist = dist;
		ray();
	}

this is the actual ray code it runs through a set direction based off of the dir value.
here is one of the issues i get with it.

Im mainly wandering if there is a way i could do this more efficiently.