This commit is contained in:
Robert committed 2025-03-11 18:10:15 +00:00
1 parent 873fd6dd33
commit 3bd4f58fd1
6 files changed
+108 -15

No files matched your search

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Game</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="game-container">
<div id="player" class="player"></div>
</div>
<script src="./script.js"></script>
</body>
</html>
@@ -0,0 +1,43 @@
document.addEventListener('DOMContentLoaded', () => {
const player = document.getElementById('player');
const gameContainer = document.querySelector('.game-container');
const containerWidth = gameContainer.clientWidth;
const containerHeight = gameContainer.clientHeight;
const playerSize = 50; // Width and height of the player
let playerX = 0;
let playerY = 0;
function movePlayer(x, y) {
playerX += x;
playerY += y;
// Ensure the player does not move out of the container
playerX = Math.max(0, Math.min(containerWidth - playerSize, playerX));
playerY = Math.max(0, Math.min(containerHeight - playerSize, playerY));
player.style.left = `${playerX}px`;
player.style.top = `${playerY}px`;
}
document.addEventListener('keydown', (event) => {
const step = 10; // Number of pixels to move
switch (event.key) {
case 'ArrowUp':
movePlayer(0, -step);
break;
case 'ArrowDown':
movePlayer(0, step);
break;
case 'ArrowLeft':
movePlayer(-step);
break;
case 'ArrowRight':
movePlayer(step);
break;
default:
break;
}
});
});
@@ -0,0 +1,26 @@
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.game-container {
width: 500px;
height: 500px;
background-color: #fff;
border: 2px solid #000;
position: relative;
}
.player {
width: 50px;
height: 50px;
background-color: #ff0000;
position: absolute;
top: 0;
left: 0;
}
+16 -11
View File
@@ -1,11 +1,16 @@
<html lang="en">
<link rel="stylesheet" href="/WebGames-master/WebGames-master/main.css">
<body>
<p class="one">
<head class="two">
<a herf="/BubbleGame/index.html"><img src="/WebGames-master/WebGames-master/assets/the_bubble_game.png" alt="The Bubble Game" width="150" height="150"></a>
<a herf="/BubbleGame/index.html"><img src="/WebGames-master/WebGames-master/assets/the_bubble_game.png" alt="The Bubble Game" width="150" height="150"></a>
</head>
</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/WebGames-master/WebGames-master/main.css">
</head>
<body>
<div class="one">
<div class="two"></div>
<a href="/WebGames-master/WebGames-master/tic-tac-toe/index.html"><img src="./assets/tic-tac-toe.png" alt="tic-tac-toe" width="150" height="150"></a>
<a href="/WebGames-master/WebGames-master/BubbleGame/index.html"><img src="/WebGames-master/WebGames-master/assets/the_bubble_game.png" alt="The Bubble Game" width="150" height="150"></a>
<a herf="/WebGames-master/WebGames-master/Robertgame/index.html">Game</a>
</div>
</body>
</html>
+8 -4
View File
@@ -9,12 +9,13 @@
}
html {
background-image: url("/image-robert-added/bgc4n1.gif");
background-image: url("/image-robert-added/215837.gif");
background-attachment: scroll;
background-size: cover;
z-index: 2;
}
p.one {
div.one {
-moz-box-shadow: 0 0 10px #777777;
-webkit-box-shadow: 0 0 10px #777777;
box-shadow: inset 0 0 10px #777777;
@@ -23,8 +24,11 @@ p.one {
-moz-border-radius: 10px;
border-radius: 10px;
padding: 20px;
text-align: left;
position: absolute;
z-index: 1;
}
head.two {
text-align: left;
a:hover {
background-color: aquamarine;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB