In this challenge, I attempt (emphasis on the word “attempt”) to program the classic video game Pong in Processing (Java). This also marks the return of the timer to help me keep track of time! Now I remember why I got rid of the timer in the first place, oops.
💻Challenge:
Links discussed in this video:
🔗Pong Game:
🔗Paddle angles drawing:
🔗Polar Coordinates Video:
🚂Website:
💡Github:
💖Membership:
🛒Store:
📚Books:
🖋️Twitter:
Video editing by Mathieu Blanchette.
🎥Coding Challenges:
🎥Intro to Programming:
🔗 p5.js:
🔗 Processing:
📄 Code of Conduct:
🌐Help us caption and translate:
🚩Suggest Topics:
👾Share your contribution:
Nguồn: https://partnersinsublime.com/
Xem thêm bài viết khác: https://partnersinsublime.com/game/
Xem thêm Bài Viết:
- Disney's Tarzan (PS1) 100% Walkthrough – Part 6 – Level 5: Coming of Age (Hard)
- Game Boy Accessories – Angry Video Game Nerd (AVGN)
- LEGIT APPS THAT PAY YOU MONEY | HOW TO EARN MONEY ONLINE
- EXTREME DIRTY GAMERTAG TROLLING 2! (Call Of Duty Ghosts)
- Bad Boys: Miami Takedown – Longplay (Nintendo GameCube)
did angles between 135 and -135 map through 180, not 0?
In which program are you doing this
51:58 I don't think he fixed the bug where the ball gets stuck behind the paddle. I tried it out and the ball got stuck at a steeper angle. He only tried one angle, and didn't test it again.
2:42 keybord fin
watching this at 2020 quarantine, anyone else?
What I love about these videos is that Daniel is not afraid to make a mistake on the video. He actually laughs about it, learns from it, then figures out the workaround on his feet. Brilliant dude. His videos really encourage me to not be afraid to explore and make a mistake, and when I do (which is a lot right now…:), I'm learning to calm down, not give up, and find the answer (most of the time on Google, lol) His videos are so refreshing, and so much fun, and I've learned so much from him.
?🤴
I'm writing the code for pong along with Daniel, and pause each segment. I try to write the code myself and check if both our minds are alike. Until 22:30 everything was fine. Ah, I'm loving it. The spaghetti is real.
Screaming for minutes that you don't use the paddle parameter which specifies whether it's a left or right paddle in the collision function. Anyway nice video as always
#dingdingdingdingding
Tks, I customized the code and put AI
http://rodrigo-kulb.com.br/pong/
https://github.com/rodrigoKulb/pongAI
void checkPaddle( Paddle p, int dir)
{
// should multiply with the both sides of the relations therefore it works for both right movin (1) and left moving( -1) Pucks
if ( dir*xspeed > 0 && dir*(x+dir*r) > dir*(p.x – dir*p.w/2) )
{
if (y < p.y+p.h/2 && y > p.y-p.h/2)
{
x = x – dir*r;
xspeed *= -1;
}
}
}
16:58
What a great guy, thank you for this fantastic tutorial/guidance on how to program pong. Thank you once again!
i tried making a speedY & speedX for the ball then made a copy of mouseY that will update to be mouseY every two seconds
then if the ball touched the paddle and the copy of mouseY was higher than the copy then the ball would go down speedY would be a positive
number (y=y+speedY) if lower than the copy the ball would go up speedY would be negative
if the ball touched the edges speedY would =speedY * -1 if touching any paddle speedX= speedX * -1 .
i like the way Dan did it though as it seems to be smoother i also learned about the the released key function
👊👊 the more you know
if you would like to see the version of pong i made then you can copy paste this on processing .
still has some bugs though
kind of like the bugs in the video that i forgot to patch up.
//======================================================================================
float x; float speedx=-4 ;
float y; float speedy=0 ;
float yo; float py ;
float chance ; float timer ;
float sc ; float sc2 ;
float diff = 470 ;
float d1; float d2=255; float d3; float di ;
void setup (){
surface.setResizable(true);
size (900,600);
frameRate(100);
x=width/2 ;
y=height/2;
}
void opon (){
background(0) ;
noFill();
stroke (14,219,4,200);
line (width/2,0,width/2,height);
//================================================================ball
rect (x,y,20,20);
x=x+speedx ;
y=y+speedy ;
if (y<0||y>height-20){speedy=speedy*-1;} //bouce off t b
if (x>width){x=width/2 ;y=height/2;speedy=0;sc2++;}
if (x<0){x=width/2 ;y=height/2;speedy=0;sc++;}// reset
if (x<0){sc=sc+1;} // score
if (x>width){sc2=sc2+1;} // score
//=======================================================================================================================================================================
if (x<60 && mouseY>py&&y<mouseY+30 && y>mouseY-20 &&x>40){speedy=4; speedx=speedx*-1;} // down bounce
if (x<60 && mouseY<py&&y<mouseY+30 && y>mouseY-20 &&x>40){speedy=-4; speedx=speedx*-1;} // up bounce
if (x<60 && mouseY-py==0 && y > mouseY-30 && y < mouseY+45 ){speedx=speedx*-1;} // bounce straight
//=======================================================================================================================================================================
if (x>width-60 &&y<yo+60 && y>yo &&x>40){speedx=speedx*-1;} // bounce op //
//=======================================================================================================================================================================player
timer++;
if( timer >2 ){timer=0 ; py= mouseY;}
rect (40,mouseY-20,20,60);
//========================================================================================================================================================================opponent
rect (width-60,yo,20,60);
chance = random (500);
if (chance > diff){yo=y-25;}else{yo=yo+random(-5,10); };
fill (0,200,0);
// text((x-60)/10,100,100);
text(sc ,width-50,height-50); text(sc2,50,height-50);
//================================================================
}
void draw (){
textSize (15);
opon();
noFill();
rect (90,30,25,30); rect (90+50,30,25,30); rect (90+100,30,25,30); rect (90+150,30,30,30);
fill(d1,255,d1);
text (1,100,50); if( mousePressed&& mouseX>90 && mouseX<90+25 && mouseY<120){ diff=480 ;d1=255;d2=0;d3=0;di=0;}
fill(d2,255,d2);
text (2,150,50); if(mousePressed&& mouseX>140 && mouseX<140+25 && mouseY<120){diff=470 ;d1=0;d2=255;d3=0;di=0;}
fill(d3,255,d3);
text (3,200,50); if(mousePressed&& mouseX>190 && mouseX<190+25 && mouseY<120){diff=425 ;d1=0;d2=0;d3=255;di=0;}
fill(di,255,di);
text (100,240,50); if(mousePressed&& mouseX>240 && mouseX<265 && mouseY<120){diff=0 ;d1=0;d2=0;d3=0;di=255;}
}
Thanks for HUG
yo he did all of this without any errors but whenever i do something i get an error every 3rd time
Is there a way to use processing with a different editor like vscode?
you could have used inheritance here…the left and the right paddle could be the child classes and a paddle class be the parent class..in this way you could have done it easier….
I don't know a anything about processing but I have programmed the Arduino so I wanted to ask if instead of making the separate keyRealeased function couldn't you just put a while loop instead of an if statement so that when the key is pressed the paddle will keep on moving up or down. I'm talking about 18:07
Wow you the best coding guy I ever seen
How do you open javascript files like p5?
It looks like he has been up all night coding
use the bouncing ball function for the puck in pong challenge…..☺😎
Excellent video. I have a question I can use processing to do a simulation of electromagnetism, like a simulation or something?
hey nerds someone send me the coding for this i need it asap cocky for school
I'm brand new to coding… this was great fun and I can see your thought process going through this… I'm from a maths background and I wanted to see the fun side of coding… this was it!
i’m trying to follow this, got to around 24:10, and for some reason it is now goving me “unexpected token” errors for everything that starts with left., right., and puck.
do you have any ideas as to why that is?
HI everyone! I also did pong on my youtube channel! I did it in Java with Eclipse, however. Go check it out to help me out! Just click on me lol or click the link: https://www.youtube.com/channel/UCw69Prn13ccg-37YMLz5dJw.
Thank you. 🙂
Hey! I'm currently making pong myself, however I have ran into an issue and was wondering if you could help. So basically, whenever I press more than one key at once (lets just say one player presses w to go up and the other player presses j to go down), it only allows one to move at a time.
not 61 minutes
"Short 12 minutes.." :))
At 43:10, laughed really hard because I thought the ding was from the "ding.mp3" that you were doing at first! That timing couldn't have been better! Thought you were testing to make sure that sound works!
#dingdingdingdingding
I'm a noob in this, why not use keyIsDown instead of keyPressed?
Great video. There a few other youtube versions of 'pong' mostly in the browser with js. Your version is great because you are so passionate. Keep it up!
Just as x and y can be zero resulting in a ball that doesn't move, so an angle of 90 or 270 will result in a puck that just bounces up and down and doesn't approach the bats. Should use vectors too 👍
Hi, I'm a total beginner in Processing and I really need help. Could someone please explain me what "ychange" actually means? I've got a headache trying to do this game, the man is too fast😅😂It literally took me a few days because it was too much and now I'm trying to understand what this whole code means so if you're willing to, then please, help me to answer that question😅😊
(Btw this video is truly helpful and funny at the same time (Now I'm curious to know the man's IQ lol)! Thank you for sharing it with the rest of the world! 🙂 )
forgot to add R and minus R when checking for out of bounds when checking for y out of bounds