Uploaded wavy sine draw function redefinition thing
I didn't expect this to be possible.
This commit is contained in:
parent
086fb55572
commit
41bf2d82de
|
|
@ -0,0 +1,31 @@
|
|||
runAfterLoad(function() {
|
||||
drawPixels = function(forceTick=false) {
|
||||
// newCurrentPixels = shuffled currentPixels
|
||||
var newCurrentPixels = currentPixels.slice();
|
||||
newCurrentPixels.sort(function() {return 0.5 - Math.random()});
|
||||
for (var i = 0; i < newCurrentPixels.length; i++) {
|
||||
pixel = newCurrentPixels[i];
|
||||
//if (pixelMap[pixel.x][pixel.y] == undefined || currentPixels.indexOf(pixel) == -1) {continue}
|
||||
if (pixel.del) {continue}
|
||||
if ((!paused) || forceTick) {pixelTick(pixel);};
|
||||
}
|
||||
// Draw the current pixels
|
||||
if (!hiding) {
|
||||
var canvas = document.getElementById("game");
|
||||
var ctx = canvas.getContext("2d");
|
||||
for (var i = 0; i < newCurrentPixels.length; i++) {
|
||||
pixel = newCurrentPixels[i];
|
||||
if (pixelMap[pixel.x][pixel.y] == undefined) {continue}
|
||||
ctx.fillStyle = pixel.color;
|
||||
ctx.fillRect(pixel.x*pixelSize+(18*Math.sin((pixel.y)/4.4)), pixel.y*pixelSize+(18*Math.sin((pixel.x)/4.4)), pixelSize, pixelSize);
|
||||
if (pixel.charge) { // Yellow glow on charge
|
||||
if (!elements[pixel.element].colorOn) {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.fillRect(pixel.x*pixelSize, pixel.y*pixelSize, pixelSize, pixelSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!paused) || forceTick) {pixelTicks++};
|
||||
}
|
||||
});
|
||||
Loading…
Reference in New Issue