Konuyu yanlışlıkla yayınladım silinebilir. Gptden chrome dinozor gibi oyun istedim top oyunu yazdı bu dedi konuda çalışır ama çalışmadı ama konuyu yayınladığım için kaldı kod aşağıda denemek isteyen kopyalasın herhangi bir html test sitesinde açsın ilginç geliyor bana hala alışamadım bu kadar hızlı gelişmesine
Alıntı
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Basit Top Oyunu</title>
<style>
canvas {
background-color: #f4f4f4;
display: block;
margin: auto;
cursor: pointer;
}
</style>
</head>
<body>
<canvas id="gameCanvas" width="480" height="320"></canvas>
<script>
let canvas = document.getElementById('gameCanvas');
let ctx = canvas.getContext('2d');
let x = canvas.width / 2;
let y = canvas.height - 30;
let dx = 2;
let dy = -2;
let ballRadius = 30;
let moving = false;
canvas.addEventListener('click', function() {
moving = !moving;
});
function drawBall() {
ctx.beginPath();
ctx.arc(x, y, ballRadius, 0, Math.PI * 2);
ctx.fillStyle = "#0095DD";
ctx.fill();
ctx.closePath();
ctx.font = "20px Arial";
ctx.fillStyle = "white";
ctx.fillText("R10", x - 25, y + 7);
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawBall();
if (moving) {
if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) {
dx = -dx;
}
if (y + dy > canvas.height - ballRadius || y + dy < ballRadius) {
dy = -dy;
}
x += dx;
y += dy;
}
}
setInterval(draw, 10);
</script>
</body>
</html>