Note that there are some explanatory texts on larger screens.

plurals
  1. POProcessing cpu Limitation
    primarykey
    data
    text
    <p>I'm making a 2D game with Processing, when I add a light, fps drops to 20~ from 30, if I add one more, it'll drop even more. But processing only uses %15 of cpu no matter what, how can I increase that, so I can see 30 fps?</p> <pre><code>void castLight(int mapNum){ color c = color(0, 0, 0); if(mapNum == 1){ for(int x = 0; x &lt; width; x++){ for(int y = 0; y &lt; height; y++){ if(improvedLights){ putShadow = improvedLights();//not working } else { putShadow = true; } for(int i = 0; i &lt; torchHolder1.size(); i++){ if(dist(x, y, torchHolderX1.get(i), torchHolderY1.get(i)) &lt;= maxDist){ if(improvedLights){ putShadow = improvedLights(); } else { putShadow = false; } } } if(putShadow){ int loc = x+y*width; float r,g,b; r = red (pixels[loc]); g = green (pixels[loc]); b = blue (pixels[loc]); r -= 100; g -= 100; b -= 100; r = constrain(r, 0, 255); g = constrain(g, 0, 255); b = constrain(b, 0, 255); if(torchAnimCounter % 31 &lt; 16){ c = color(r, g, b); } else { c = color(r+10, g+10, b+10); } pixels[y*width + x] = c; } } } for(int i = 0; i &lt; torchHolderX1.size(); i++){ for(int x = torchHolderX1.get(i) - maxDist; x &lt; torchHolderX1.get(i) + maxDist; x++){ if(x - maxDist &lt; torchHolderX1.get(i) &amp;&amp; x + maxDist &gt; torchHolderX1.get(i)){ torchCrossX = true; } else { torchCrossX = false; } for(int y = torchHolderY1.get(i) - maxDist; y &lt; torchHolderY1.get(i) + maxDist; y++){ if(y - maxDist &lt; torchHolderY1.get(i) &amp;&amp; y + maxDist &gt; torchHolderY1.get(i)){ torchCrossY = true; } else { torchCrossY = false; } float d = dist(x, y, torchHolderX1.get(i), torchHolderY1.get(i)); if(torchCrossX &amp;&amp; torchCrossY){ if(dist(x, y, torchHolderX1.get(i), torchHolderY1.get(i)) &lt;= maxDist){ if(x &gt; 0 &amp;&amp; x &lt; width &amp;&amp; y &gt; 0 &amp;&amp; y &lt; height){ int loc = x+y*width; float r,g,b; r = red (pixels[loc]); g = green (pixels[loc]); b = blue (pixels[loc]); float adjustBrightness = maxDist-d-100; r += adjustBrightness; g += adjustBrightness; b += adjustBrightness; r = constrain(r, 0, 255); g = constrain(g, 0, 255); b = constrain(b, 0, 255); if(torchAnimCounter % 31 &lt; 16){ c = color(r, g, b); } else { c = color(r+10, g+10, b+10); } pixels[y*width + x] = c; } } } } } } }//and same things goes for the second map </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload