Commits

Philipp Tiefenbacher committed 84b9b67 Draft

oldschool particle colission check is slow but works

  • Participants
  • Parent commits 6f5ee61

Comments (0)

Files changed (2)

File src/game/CellSpace.js

 			//reactor.mixDish(drawRectShader, enemyDish, {rectPos: [shipX+1, shipY+1], rectSize: [3, 3], state: 0});
 			
 
-			if (keyboard.isPressed(65+	1))
+			if (keyboard.isPressed(65+1))
 			{
+				pointCoordinates[1] += 0.03;
+				gl.bindBuffer(gl.ARRAY_BUFFER, pointsBuffer);
+				gl.bufferData(gl.ARRAY_BUFFER, pointCoordinates.byteLength, gl.STATIC_DRAW);
+				gl.bufferSubData(gl.ARRAY_BUFFER, 0, pointCoordinates);
+
 				reactor.applyShader(drawPointsShader, shipDish.getCurrentFramebuffer(), false, function(gl, shader) {
 
 					gl.bindBuffer(gl.ARRAY_BUFFER, pointsBuffer);
 
 					gl.drawArrays(gl.POINTS,0, pointCoordinates.length/2);
 				});
-				//shipDish.flip();
+
+				var pixelValues = new Uint8Array(1*1*4);
+				// no need to bindFramebuffer it's stil here
+				gl.bindFramebuffer(gl.FRAMEBUFFER, enemyDish.getCurrentFramebuffer());
+				gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, enemyDish.getCurrentTexture(), 0);
+				gl.readPixels(gameW*0.5*(pointCoordinates[0]+1), gameH*0.5*(pointCoordinates[1]+1), 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixelValues);
+				if (pixelValues[3] != 0) {
+					pointCoordinates[1] = -0.8;
+				}
 			}
 			
 

File src/game/gl/Reactor.js

 			gl.bindFramebuffer(gl.FRAMEBUFFER, null);
 
 		// other arguments
-		
 		if (bindCallback) bindCallback(gl, shader);
 
 		if (!renderCallbac) {