Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let gemX, gemY, hp = 800, points = 0, size = 50;
- gemX = Math.random()*750
- gemY = 600
- function update() {
- if (hp <= 0){
- return;
- }
- if (size <= 0){
- return;
- }
- gemY = gemY - 5
- if (gemY <= -50){
- gemY = 600;
- gemX = Math.random()*750;
- hp = hp - 100;
- }
- if (mouseX >= gemX && mouseX <= gemX + size && mouseY >= gemY && mouseY <= gemY + size){
- gemY = 600;
- gemX = Math.random()*750;
- points = points + 1;
- size = size - 1;
- }
- }
- function draw() {
- context.fillStyle = "lightgray";
- context.font = "200px Arial";
- context.fillText(points, 200, 400);
- context.fillStyle = "red";
- context.fillRect(0, 20, hp, 30);
- drawImage(gem[0], gemX, gemY, size, size);
- };
- function keyup(key) {
- };
- function mouseup() {
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement