0
JS Game Dev
Hi i ament actually finished the game my gravity does not work i dont know where to place the blocks of code
26 Answers
+ 2
my count meter doesnt show up either
+ 1
window.onload = function() {
let btn = document.getElementById("jump");
let count = 0;
btn.onclick = function() {
count += 1;
y-=25;
document.onkeydown = function() {
count += 1;
y -= 25;
}
document.ontouchstart = function() {
count += 1;
y -= 25;
}
function draw() {
context.clearRect(0, 0, 600, 400);
context.beginPath();
context.arc(x, y, 50, 0, 2 * Math.PI);
context.fillStyle="red";
context.fill();
context.font = "25px Arial";
context.fillStyle = "white"
content.fillText("Count: " + count, 20, 30);
window.requestAnimationFrame(draw);
}
draw();
}
}
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var x = 300;
var y = 350;
context.arc(x, y, 50, 0, 2 * Math.PI);
context.fillStyle="red";
context.fill();
+ 1
Fixed, just that it falls on first click then proceeds up off the screen
+ 1
This what your looking for?
+ 1
Ooopppsss did a great debug and correcrion of my code, taught me something. Good help ๐
0
None just this its a challenge, but it rewards before completion. #bugbounty
0
Thanks
0
window.onload = function() {
let btn = document.getElementById("jump");
let count = 0;
btn.onclick = function() {
count += 1;
y-=25;
document.onkeydown = function() {
count += 1;
y -= 25;
}
document.ontouchstart = function() {
count += 1;
y -= 25;
}
function draw() {
context.clearRect(0, 0, 600, 400);
context.beginPath();
context.arc(x, y, 50, 0, 2 * Math.PI);
context.fillStyle="red";
context.fill();
context.font = "25px Arial";
context.fillStyle = "white"
content.fillText("Count: " + count, 20, 30);
window.requestAnimationFrame(draw);
}
draw();
}
}
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var x = 300;
var y = 350;
context.arc(x, y, 50, 0, 2 * Math.PI);
context.fillStyle="red";
context.fill();
0
Dont know where to put the gravity function
0
I have published this code yesterday ill try find link
0
Ok ill reset and learn again
0
Request me to follow you
0
Id like some help, let me know where im wrong