Comutare navigație
pbInfo.ro
Probleme
Probleme - clasa a IX-a
Probleme - clasa a X-a
Probleme - clasa a XI-a
Probleme din concursuri
Căutare problemă
Exerciții
Programează cu Blockly
Desenează cu Processing
Exersează SQL
Soluţii
Resurse
Resurse pentru clasa a IX-a
Resurse pentru clasa a X-a
Resurse pentru clasa a XI-a
Subiecte bacalaureat
Ajutor
Autentificare
Înregistrare
×
Autentificare
Utilizator sau email
Parola
Acest site foloseşte cookies. Navigând în continuare, vă exprimaţi acordul asupra folosirii cookie-urilor.
Îti place pbInfo? Atunci acceptă-l cu totul! Dezactivează modulul de blocare a reclamelor!
×
Lista scripturi
Script Nou
Ajutor
"χψω" - Processing
ID
Autor
Duplicat din
Ultima modificare
#1639
Ciurcau Leonardo (Goth)
-
Duminica, 13 mai 2018, 19:20
var player = { x: 0, y: 0 }; var level = 1, health = 200; function setup(){ createCanvas(400, 400); player.x = width / 2 - 12; player.y = height / 2 - 12; } function draw(){ background(200); playerMovement(); Player(); square(); Flashlight(); if(level == 1)level1(); } function playerMovement(){ if(keyIsPressed){ if((key == 'w' || key == 'W') && player.y - 18 > 0)player.y -= 3; if((key == 's' || key == 'S') && player.y -10 +28 < height)player.y += 3; if((key == 'd' || key == 'D')&& player.x - 10 +28 < width)player.x += 3; if((key == 'a' || key == 'A') && player.x-18 > 0)player.x -= 3, health--; if(health < 0)health = 0; } } function Player(){ fill(150); strokeWeight(3); stroke(51); rectMode(CENTER); rect(player.x, player.y, 25, 25); rectMode(CORNER); } function square(){ noStroke(); fill(5); rect(width / 2, height / 2, 40, 40); } function Flashlight(){ fill(0, 0); stroke(0); strokeWeight(500); ellipse(player.x, player.y, 600, 600); } function healthBar(){ noStroke(); fill(110); rect(110, 2, health, 10); noFill(); strokeWeight(3); stroke(30); rect(110, 2, 200, 10); } function level1(){ healthBar(); }
Duplicare
Executare
Cod
×
Cod HTML
<iframe sandbox="allow-scripts" src="/p5js/index.php?id=1639" style="width:408px; height:408px;border:solid 1px gray; overflow: scroll;"></iframe>
×
Duplicare script
Denumirea noului script
Du-te sus!