SC CODE: // Copyright 2024. Civilware. All rights reserved.
// TELA Decentralized Web Document (TELA-DOC-1)
Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "main.js")
31 STORE("descrHdr", "Main JS file")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "main.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "b8c821252eca577dec2f2e411c7b4f95a43ddbaf5385379d5aace0fd5020d00")
37 STORE("fileCheckS", "2527b09f8ee7b5f778a96c2781742851b4cf920daf7ff37f3d995f77893cd7cf")
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
/*// Full Tank - Open Source under the MIT License
// See LICENSE for details.
function gameStatus(){
// Count player bullets
let playerBullets = 0;
for (let p of game.projectiles) {
if (p.type === "player" | p.type === "turret") playerBullets++;
}
if (game.enemies.length === 0 && game.bases.length === 0) {
setState(STATE.WIN);
}
if (game.player.dead) setState(STATE.DEAD);
}
//Main loop
let last = performance.now();
let acc = 0;
const dt = 16;
function loop(now) {
let delta = now - last;
// Clamp delta to avoid death-spiral
if (delta > 200) delta = 200;
acc += delta;
last = now;
while (acc >= dt) {
gatherInput(dt);
if (game.state === STATE.PLAYING) {
applyPlayerIntent(dt);
update(dt);
collision();
gameStatus();
}
updateParticles(dt);
acc -= dt;
}
render();
requestAnimationFrame(loop);
}
game.state = STATE.MENU;
requestAnimationFrame(loop);*/ |
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// Copyright 2024. Civilware. All rights reserved.
// TELA Decentralized Web Document (TELA-DOC-1)
Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "main.js")
31 STORE("descrHdr", "Main JS file")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "main.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "b8c821252eca577dec2f2e411c7b4f95a43ddbaf5385379d5aace0fd5020d00")
37 STORE("fileCheckS", "2527b09f8ee7b5f778a96c2781742851b4cf920daf7ff37f3d995f77893cd7cf")
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
/*// Full Tank - Open Source under the MIT License
// See LICENSE for details.
function gameStatus(){
// Count player bullets
let playerBullets = 0;
for (let p of game.projectiles) {
if (p.type === "player" | p.type === "turret") playerBullets++;
}
if (game.enemies.length === 0 && game.bases.length === 0) {
setState(STATE.WIN);
}
if (game.player.dead) setState(STATE.DEAD);
}
//Main loop
let last = performance.now();
let acc = 0;
const dt = 16;
function loop(now) {
let delta = now - last;
// Clamp delta to avoid death-spiral
if (delta > 200) delta = 200;
acc += delta;
last = now;
while (acc >= dt) {
gatherInput(dt);
if (game.state === STATE.PLAYING) {
applyPlayerIntent(dt);
update(dt);
collision();
gameStatus();
}
updateParticles(dt);
acc -= dt;
}
render();
requestAnimationFrame(loop);
}
game.state = STATE.MENU;
requestAnimationFrame(loop);*/'] |