#Identifier
113 messages · Page 1 of 1 (latest)
?
what is the code supposed to do?
Basically a ping pong game
ok...the code isn't really making sense. Were you testing it while writing it?
It's on a live web
so whenever i make changes
it refreshed and updates the web
What's in the ball file?
Change the variable's name to something else
The ball file?
The one that's giving the error?
Me..
Make a ping pong game
you wrote 18 lines of code without testing it to see if it works or not?
wdym testing it..?
it arent finish
run the code
it wont do anything
I get that, but why are you making a request to that url?
so, you are following a tutorial?
can you send a link to it?
so, you didn't write it, but copied it...
im following a tutorial
for hort
link to what?
to the tutorial
Pong is the perfect beginner friendly game dev project. It has relatively simple logic which means you can focus on the basics of game dev without getting bogged down by complex logic.
📚 Materials/References:
GitHub Code: https://github.com/WebDevSimplified/js-pong
JavaScript Modules Video: https://youtu.be/cRHQNNcYf6s
JavaScript Modules Arti...
you don't have the same code that's in the tutorial
still not
umm...no
Look, coding is less about copying code, but more about understanding it. You are not going to learn anything if you blindly copy the code
:/
im just going through a tutorial
learning the basics of it
normally at the end i add comments on which part is which
and what it does
That's not the right way of learning it. Learn the basics first, and then you can watch someone build a project. You will understand it better and see how things fall in place.
this is what im mainly stuck on,
To the url?
I never made any request
ok, what did you do to get that error?
I can't help you if you don't know what you are doing 
I just ned help
*need
this error
Can you send all the files you have?
Screenshot?
No, copy paste
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<script src="script.js" type="module"></script>
<title>Document</title>
</head>
<body>
<div class="score">
<div id="player-score">0</div>
<div id="computer-score">0</div>
</div>
<div class="ball" id="ball"></div>
<div class="paddle left" id="player-paddle"></div>
<div class="paddle right" id="computer-paddle"></div>
</body>
</html>```
*, *::after, *::before {
box-sizing: border-box;
}
:root{
--hue: 200;
--saturation: 50%;
--foreground-color: hsl(var(--hue), var(--saturation), 75%);
--background-color: hsl(var(--hue), var(--saturation), 20%);
}
body{
margin: 0;
background-color: var(--background-color);
}
.paddle {
--position: 50;
position: absolute;
background-color: var(--foreground-color);
top: calc(var(--position) * 1vh);
transform: translate(-50%);
width: 1vh;
height: 10vh;
}
.paddle.left {
left:1vw
}
.paddle.right {
right:1vw
}
.ball {
--x: 50;
--y: 50;
position: absolute;
background-color: var(--foreground-color);
left: calc(var(--x) * 1vw);
top: calc(var(--y) * 1vh);
border-radius: 50%;
transform: translate(-50%, -50%);
width: 2.5vh;
height: 2.5vh;
}
.score{
display: flex;
justify-content: center;
font-weight: bold;
font-size: 7vh;
color: var(--foreground-color);
}
.score > * {
flex-grow: 1;
flex-basis: 0;
padding: 0 2vh;
margin: 1vh 0;
opacity: .5;
border-right: .5vh solid var(--foreground-color);
}
.score > :first-child {
text-align: right;
}```
export default class ball {
constructor(ballElem) {
this.ballElem = ballElem
}
}```
import Ball from "./Ball";
const ball = new Ball(document.getElementById("ball"))
let lastTime
function update(time) {
if (lastTime !=null) {
const delta = time - lastTime
//Update Code
}
console.log(delta)
lastTime = time
window.requestAnimationFrame(update)
}
window.requestAnimationFrame(update)```
ok...try closing your browser and launch a new live server
import Ball from "./Ball"; should be import Ball from "./Ball.js";
Now
another error
"Delta is not defined."
How would I define anything?
What do i need to do
learn the basics the right way
That's one of the very first things one learns when they learn programming
Tell me how to define delta...
I will watch a tutoral later
*tutorial
ok good luck
I want to learn how to define delta..
You can learn that by following the tutorial