SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("var_header_name", "game-render.js")
31 STORE("var_header_description", "")
32 STORE("var_header_icon", "")
33 STORE("dURL", "")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "/")
36 STORE("fileCheckC", "0b6fe15e0c1401a7833c62747595131ad015c510c5c4cc6c30812ac10a780a27")
37 STORE("fileCheckS", "2de2689dc598daedd545cc0e0a827a6d981f2a8a3e87f4a44b9cc8cf7c79102f")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
// ============================================================
// CIPHER SNAKE DELUXE - Render layer + FX
// ============================================================
// ---- AUTO-SIZE BOARD ----
(function autoSizeBoard(){
var holder = document.querySelector('.canvas-holder');
var panels = document.querySelectorAll('.game-layout > aside.panel');
var FRAME_CHROME = 26;
var MIN_SIZE = 300;
var lastSize = 0;
var ro = null;
var pending = false;
function compute(){
if (window.innerWidth <= 980){
var w = Math.min(window.innerWidth - 40, 520);
writeSize(w); return;
}
var maxH = 0;
for (var i = 0; i < panels.length; i++){
maxH = Math.max(maxH, panels[i].getBoundingClientRect().height);
}
var viewportCap = Math.max(MIN_SIZE, window.innerHeight - 120);
var raw = Math.floor(maxH - FRAME_CHROME);
var size = Math.max(MIN_SIZE, Math.min(raw, viewportCap));
writeSize(size);
}
function writeSize(size){
if (Math.abs(size - lastSize) < 2) return;
lastSize = size;
if (ro) ro.disconnect();
holder.style.setProperty('--board-size', size + 'px');
requestAnimationFrame(function(){
if (ro){
for (var i = 0; i < panels.length; i++) ro.observe(panels[i]);
}
});
}
function schedule(){
if (pending) return;
pending = true;
requestAnimationFrame(function(){ pending = false; compute(); });
}
if ('ResizeObserver' in window){
window.addEventListener('error', function(e){
if (e && e.message && /ResizeObserver loop/i.test(e.message)){
e.stopImmediatePropagation();
}
}, true);
ro = new ResizeObserver(schedule);
for (var i = 0; i < panels.length; i++) ro.observe(panels[i]);
}
window.addEventListener('resize', schedule);
if (document.fonts && document.fonts.ready) document.fonts.ready.then(compute);
compute();
setTimeout(compute, 150);
})();
// ---- MATRIX RAIN ----
(function matrixRain(){
var c = document.getElementById('matrix-rain');
var ctx = c.getContext('2d');
var W, H, cols, drops;
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789DERO01$#@*+=";
var fontSize = 16;
var timer = null;
function resize(){
W = c.width = window.innerWidth;
H = c.height = window.innerHeight;
cols = Math.floor(W / fontSize);
drops = new Array(cols).fill(0).map(function(){ return Math.random() * -H; });
}
resize();
window.addEventListener('resize', resize);
function draw(){
ctx.fillStyle = 'rgba(2, 6, 10, 0.08)';
ctx.fillRect(0, 0, W, H);
ctx.font = fontSize + "px 'Share Tech Mono', monospace";
for (var i = 0; i < cols; i++){
var ch = chars[Math.floor(Math.random() * chars.length)];
var x = i * fontSize;
var y = drops[i] * fontSize;
ctx.fillStyle = Math.random() > 0.975 ? '#ccffdd' : '#00ff66';
ctx.fillText(ch, x, y);
if (y > H && Math.random() > 0.975) drops[i] = 0;
drops[i]++;
}
}
function start(){ if (!timer){ c.style.display = ''; timer = setInterval(draw, 55); } }
function stop(){
if (timer){ clearInterval(timer); timer = null; }
// Clear and hide to free GPU composite layer while game runs
ctx.clearRect(0, 0, W, H);
c.style.display = 'none';
}
window.__rain = { start: start, stop: stop };
start();
})();
// ---- BOARD RENDERER ----
(function(){
var G = window.__game;
if (!G){ console.error('__game state missing'); return; }
var canvas = G.canvas;
var ctx = canvas.getContext('2d');
var GRID = G.GRID, CELL = G.CELL, MARGIN = G.SPAWN_MARGIN;
var pulse = 0;
function draw(){
pulse += 0.08;
var snake = G.getSnake();
var dir = G.getDir();
var orb = G.getOrb();
var hazards = G.getHazards();
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = 'rgba(0, 255, 102, 0.06)';
ctx.lineWidth = 1;
for (var i = 1; i < GRID; i++){
ctx.beginPath();
ctx.moveTo(i*CELL, 0); ctx.lineTo(i*CELL, canvas.height); ctx.stroke();
ctx.beginPath();
ctx.moveTo(0, i*CELL); ctx.lineTo(canvas.width, i*CELL); ctx.stroke();
}
var grad = ctx.createRadialGradient(
canvas.width/2, canvas.height/2, canvas.width*0.25,
canvas.width/2, canvas.height/2, canvas.width*0.75
);
grad.addColorStop(0, 'rgba(0,255,102,0.0)');
grad.addColorStop(1, 'rgba(0,255,102,0.08)');
ctx.fillStyle = grad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
var m = MARGIN * CELL;
ctx.strokeStyle = 'rgba(0, 240, 255, 0.14)';
ctx.setLineDash([4, 6]);
ctx.lineWidth = 1;
ctx.strokeRect(m, m, canvas.width - 2*m, canvas.height - 2*m);
ctx.setLineDash([]);
if (hazards && hazards.length){
var flash = G.flashHazard > 0 ? 1 : 0;
if (G.flashHazard > 0) G.flashHazard--;
for (var k = 0; k < hazards.length; k++){
var h = hazards[k];
var hx = h.x * CELL, hy = h.y * CELL;
ctx.shadowColor = '#ff003c';
ctx.shadowBlur = 18 + Math.sin(pulse*2) * 4;
ctx.fillStyle = flash ? '#ffffff' : '#ff003c';
ctx.fillRect(hx+2, hy+2, CELL-4, CELL-4);
ctx.shadowBlur = 0;
ctx.strokeStyle = '#ffcccc';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(hx+5, hy+5); ctx.lineTo(hx+CELL-5, hy+CELL-5);
ctx.moveTo(hx+CELL-5, hy+5); ctx.lineTo(hx+5, hy+CELL-5);
ctx.stroke();
}
}
if (G.tierFlash > 0){
var a = Math.min(1, G.tierFlash / 45);
ctx.fillStyle = 'rgba(255, 0, 229, ' + (a * 0.15) + ')';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'rgba(255, 0, 229, ' + a + ')';
ctx.font = "bold 22px 'Orbitron', monospace";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.shadowColor = '#ff00e5';
ctx.shadowBlur = 20;
ctx.fillText('!! HAZARD TIER UP !!', canvas.width/2, 40);
ctx.shadowBlur = 0;
G.tierFlash--;
}
if (orb){
var ox = orb.x * CELL + CELL/2;
var oy = orb.y * CELL + CELL/2;
var r = CELL/2 - 2;
var pulseR = r + Math.sin(pulse*3) * 1.4;
ctx.shadowColor = '#ff00e5';
ctx.shadowBlur = 22;
var og = ctx.createRadialGradient(ox, oy, 0, ox, oy, pulseR);
og.addColorStop(0, '#ffb0f5');
og.addColorStop(0.5, '#ff00e5');
og.addColorStop(1, '#8a0080');
ctx.fillStyle = og;
ctx.beginPath();
ctx.arc(ox, oy, pulseR, 0, Math.PI*2);
ctx.fill();
ctx.shadowBlur = 0;
ctx.fillStyle = '#ffffff';
ctx.font = 'bold ' + Math.floor(CELL*0.75) + "px 'Orbitron', monospace";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.shadowColor = '#ffffff';
ctx.shadowBlur = 6;
ctx.fillText('D', ox, oy + 1);
ctx.shadowBlur = 0;
}
if (snake){
for (var s = snake.length - 1; s >= 0; s--){
var seg = snake[s];
var sx = seg.x * CELL, sy = seg.y * CELL;
var isHead = s === 0;
var alpha = isHead ? 1 : Math.max(0.35, 1 - s * 0.04);
ctx.shadowColor = '#00ff66';
ctx.shadowBlur = isHead ? 16 : 6;
ctx.fillStyle = isHead ? '#b6ffcf' : 'rgba(0, 255, 102, ' + alpha + ')';
ctx.fillRect(sx+1, sy+1, CELL-2, CELL-2);
ctx.shadowBlur = 0;
if (isHead){
ctx.fillStyle = '#000';
var e1, e2;
if (dir.x === 1){ e1 = [sx+CELL-5, sy+5]; e2 = [sx+CELL-5, sy+CELL-5]; }
else if (dir.x === -1){ e1 = [sx+3, sy+5]; e2 = [sx+3, sy+CELL-5]; }
else if (dir.y === -1){ e1 = [sx+5, sy+3]; e2 = [sx+CELL-5, sy+3]; }
else { e1 = [sx+5, sy+CELL-5]; e2 = [sx+CELL-5, sy+CELL-5]; }
ctx.beginPath(); ctx.arc(e1[0], e1[1], 1.8, 0, Math.PI*2); ctx.fill();
ctx.beginPath(); ctx.arc(e2[0], e2[1], 1.8, 0, Math.PI*2); ctx.fill();
}
}
}
}
window.__draw = draw;
draw();
})();
*/ |
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("var_header_name", "game-render.js")
31 STORE("var_header_description", "")
32 STORE("var_header_icon", "")
33 STORE("dURL", "")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "/")
36 STORE("fileCheckC", "0b6fe15e0c1401a7833c62747595131ad015c510c5c4cc6c30812ac10a780a27")
37 STORE("fileCheckS", "2de2689dc598daedd545cc0e0a827a6d981f2a8a3e87f4a44b9cc8cf7c79102f")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
// ============================================================
// CIPHER SNAKE DELUXE - Render layer + FX
// ============================================================
// ---- AUTO-SIZE BOARD ----
(function autoSizeBoard(){
var holder = document.querySelector('.canvas-holder');
var panels = document.querySelectorAll('.game-layout > aside.panel');
var FRAME_CHROME = 26;
var MIN_SIZE = 300;
var lastSize = 0;
var ro = null;
var pending = false;
function compute(){
if (window.innerWidth <= 980){
var w = Math.min(window.innerWidth - 40, 520);
writeSize(w); return;
}
var maxH = 0;
for (var i = 0; i < panels.length; i++){
maxH = Math.max(maxH, panels[i].getBoundingClientRect().height);
}
var viewportCap = Math.max(MIN_SIZE, window.innerHeight - 120);
var raw = Math.floor(maxH - FRAME_CHROME);
var size = Math.max(MIN_SIZE, Math.min(raw, viewportCap));
writeSize(size);
}
function writeSize(size){
if (Math.abs(size - lastSize) < 2) return;
lastSize = size;
if (ro) ro.disconnect();
holder.style.setProperty('--board-size', size + 'px');
requestAnimationFrame(function(){
if (ro){
for (var i = 0; i < panels.length; i++) ro.observe(panels[i]);
}
});
}
function schedule(){
if (pending) return;
pending = true;
requestAnimationFrame(function(){ pending = false; compute(); });
}
if ('ResizeObserver' in window){
window.addEventListener('error', function(e){
if (e && e.message && /ResizeObserver loop/i.test(e.message)){
e.stopImmediatePropagation();
}
}, true);
ro = new ResizeObserver(schedule);
for (var i = 0; i < panels.length; i++) ro.observe(panels[i]);
}
window.addEventListener('resize', schedule);
if (document.fonts && document.fonts.ready) document.fonts.ready.then(compute);
compute();
setTimeout(compute, 150);
})();
// ---- MATRIX RAIN ----
(function matrixRain(){
var c = document.getElementById('matrix-rain');
var ctx = c.getContext('2d');
var W, H, cols, drops;
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789DERO01$#@*+=";
var fontSize = 16;
var timer = null;
function resize(){
W = c.width = window.innerWidth;
H = c.height = window.innerHeight;
cols = Math.floor(W / fontSize);
drops = new Array(cols).fill(0).map(function(){ return Math.random() * -H; });
}
resize();
window.addEventListener('resize', resize);
function draw(){
ctx.fillStyle = 'rgba(2, 6, 10, 0.08)';
ctx.fillRect(0, 0, W, H);
ctx.font = fontSize + "px 'Share Tech Mono', monospace";
for (var i = 0; i < cols; i++){
var ch = chars[Math.floor(Math.random() * chars.length)];
var x = i * fontSize;
var y = drops[i] * fontSize;
ctx.fillStyle = Math.random() > 0.975 ? '#ccffdd' : '#00ff66';
ctx.fillText(ch, x, y);
if (y > H && Math.random() > 0.975) drops[i] = 0;
drops[i]++;
}
}
function start(){ if (!timer){ c.style.display = ''; timer = setInterval(draw, 55); } }
function stop(){
if (timer){ clearInterval(timer); timer = null; }
// Clear and hide to free GPU composite layer while game runs
ctx.clearRect(0, 0, W, H);
c.style.display = 'none';
}
window.__rain = { start: start, stop: stop };
start();
})();
// ---- BOARD RENDERER ----
(function(){
var G = window.__game;
if (!G){ console.error('__game state missing'); return; }
var canvas = G.canvas;
var ctx = canvas.getContext('2d');
var GRID = G.GRID, CELL = G.CELL, MARGIN = G.SPAWN_MARGIN;
var pulse = 0;
function draw(){
pulse += 0.08;
var snake = G.getSnake();
var dir = G.getDir();
var orb = G.getOrb();
var hazards = G.getHazards();
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = 'rgba(0, 255, 102, 0.06)';
ctx.lineWidth = 1;
for (var i = 1; i < GRID; i++){
ctx.beginPath();
ctx.moveTo(i*CELL, 0); ctx.lineTo(i*CELL, canvas.height); ctx.stroke();
ctx.beginPath();
ctx.moveTo(0, i*CELL); ctx.lineTo(canvas.width, i*CELL); ctx.stroke();
}
var grad = ctx.createRadialGradient(
canvas.width/2, canvas.height/2, canvas.width*0.25,
canvas.width/2, canvas.height/2, canvas.width*0.75
);
grad.addColorStop(0, 'rgba(0,255,102,0.0)');
grad.addColorStop(1, 'rgba(0,255,102,0.08)');
ctx.fillStyle = grad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
var m = MARGIN * CELL;
ctx.strokeStyle = 'rgba(0, 240, 255, 0.14)';
ctx.setLineDash([4, 6]);
ctx.lineWidth = 1;
ctx.strokeRect(m, m, canvas.width - 2*m, canvas.height - 2*m);
ctx.setLineDash([]);
if (hazards && hazards.length){
var flash = G.flashHazard > 0 ? 1 : 0;
if (G.flashHazard > 0) G.flashHazard--;
for (var k = 0; k < hazards.length; k++){
var h = hazards[k];
var hx = h.x * CELL, hy = h.y * CELL;
ctx.shadowColor = '#ff003c';
ctx.shadowBlur = 18 + Math.sin(pulse*2) * 4;
ctx.fillStyle = flash ? '#ffffff' : '#ff003c';
ctx.fillRect(hx+2, hy+2, CELL-4, CELL-4);
ctx.shadowBlur = 0;
ctx.strokeStyle = '#ffcccc';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(hx+5, hy+5); ctx.lineTo(hx+CELL-5, hy+CELL-5);
ctx.moveTo(hx+CELL-5, hy+5); ctx.lineTo(hx+5, hy+CELL-5);
ctx.stroke();
}
}
if (G.tierFlash > 0){
var a = Math.min(1, G.tierFlash / 45);
ctx.fillStyle = 'rgba(255, 0, 229, ' + (a * 0.15) + ')';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'rgba(255, 0, 229, ' + a + ')';
ctx.font = "bold 22px 'Orbitron', monospace";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.shadowColor = '#ff00e5';
ctx.shadowBlur = 20;
ctx.fillText('!! HAZARD TIER UP !!', canvas.width/2, 40);
ctx.shadowBlur = 0;
G.tierFlash--;
}
if (orb){
var ox = orb.x * CELL + CELL/2;
var oy = orb.y * CELL + CELL/2;
var r = CELL/2 - 2;
var pulseR = r + Math.sin(pulse*3) * 1.4;
ctx.shadowColor = '#ff00e5';
ctx.shadowBlur = 22;
var og = ctx.createRadialGradient(ox, oy, 0, ox, oy, pulseR);
og.addColorStop(0, '#ffb0f5');
og.addColorStop(0.5, '#ff00e5');
og.addColorStop(1, '#8a0080');
ctx.fillStyle = og;
ctx.beginPath();
ctx.arc(ox, oy, pulseR, 0, Math.PI*2);
ctx.fill();
ctx.shadowBlur = 0;
ctx.fillStyle = '#ffffff';
ctx.font = 'bold ' + Math.floor(CELL*0.75) + "px 'Orbitron', monospace";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.shadowColor = '#ffffff';
ctx.shadowBlur = 6;
ctx.fillText('D', ox, oy + 1);
ctx.shadowBlur = 0;
}
if (snake){
for (var s = snake.length - 1; s >= 0; s--){
var seg = snake[s];
var sx = seg.x * CELL, sy = seg.y * CELL;
var isHead = s === 0;
var alpha = isHead ? 1 : Math.max(0.35, 1 - s * 0.04);
ctx.shadowColor = '#00ff66';
ctx.shadowBlur = isHead ? 16 : 6;
ctx.fillStyle = isHead ? '#b6ffcf' : 'rgba(0, 255, 102, ' + alpha + ')';
ctx.fillRect(sx+1, sy+1, CELL-2, CELL-2);
ctx.shadowBlur = 0;
if (isHead){
ctx.fillStyle = '#000';
var e1, e2;
if (dir.x === 1){ e1 = [sx+CELL-5, sy+5]; e2 = [sx+CELL-5, sy+CELL-5]; }
else if (dir.x === -1){ e1 = [sx+3, sy+5]; e2 = [sx+3, sy+CELL-5]; }
else if (dir.y === -1){ e1 = [sx+5, sy+3]; e2 = [sx+CELL-5, sy+3]; }
else { e1 = [sx+5, sy+CELL-5]; e2 = [sx+CELL-5, sy+CELL-5]; }
ctx.beginPath(); ctx.arc(e1[0], e1[1], 1.8, 0, Math.PI*2); ctx.fill();
ctx.beginPath(); ctx.arc(e2[0], e2[1], 1.8, 0, Math.PI*2); ctx.fill();
}
}
}
}
window.__draw = draw;
draw();
})();
*/'] |