Page 1 of 1
New to coding and need help on Pong game
Posted: Wed Mar 18, 2015 7:38 pm
by tuxranger
Hi. I am very new to any coding at all and was wanting to start to learn to code and specifically attempt to make a video game but I need a little help. I decided to try and make a working version of pong as a starting project. I wrote the code from the love physics tutorial to start to learn how to do things in love. I then implemented what I learned from that into my pong game, but I've become stuck. I have a couple things that I need help on. First I need help with making it so that my paddles do not move on the x axis at all. As far as I understand I could use edges and block my paddles in with that but, if there is a more efficient way would someone be willing to help me there? Secondly I need help with programming the movement on the ball. Specifically in starting the ball's movement when it is at a standstill and having it bounce off the paddles and edges. If someone would be willing to help me out here that would be awesome and thanks very much in advance. ^.^
Here's what I have coded so far.
http://pastebin.com/DyusjhQE
Re: New to coding and need help on Pong game
Posted: Wed Mar 18, 2015 7:57 pm
by s-ol
Using love.physics for a pong game is not only overkill, it's a very bad fit. You need at least three times the amount of code wrangling all the physics to act like you want compared to what the whole physics implementation would look like if you do it "by hand". There's a reason the notice atop of the love.physics wiki page reads:
love.physics is not lightweight, and not even remotely simple to use. It's a ten-ton hammer designed for heavy-lifting (er...hammer...lifting?)
If you are just trying to make a character jump around on blocks or the likes, then move along, nothing to see here.
making a ball bounce off two paddels is far below making a character jump around blocks in physics complexity.
Re: New to coding and need help on Pong game
Posted: Wed Mar 18, 2015 8:06 pm
by tuxranger
Oh. OK. That makes sense. How then would I go about starting to work on my project? Is there maybe a guide you would suggest that I follow?
Re: New to coding and need help on Pong game
Posted: Wed Mar 18, 2015 9:07 pm
by dizzykiwi3
I made a very basic version of pong for a class, give me a second to go find it a dissect it and label it
Re: New to coding and need help on Pong game
Posted: Wed Mar 18, 2015 9:14 pm
by dizzykiwi3
To see the code just change the extension from .love to .zip.
The game is split up into two different files and also has two sound files. I put the more intimidating looking stuff in a file called technicalstuff just so people who had never seen code before wouldn't get bogged down by it and could start modifying the game (changing colors, paddle size, ball speed), though honestly the technical stuff is really not that technical.
Lines 29 to 38 in the main file are a rubberbanding feature, basically saying if p1 is winning, give p2 this advantage, and viceversa, but everything else is standard pong.
The comments pretty much explain everything, but if you have any questions (even if they may sound simple) feel free to ask.
Re: New to coding and need help on Pong game
Posted: Thu Mar 19, 2015 1:55 am
by tuxranger
OK. Great! Thanks a ton!
Re: New to coding and need help on Pong game
Posted: Thu Mar 19, 2015 7:46 am
by s-ol
Re: New to coding and need help on Pong game
Posted: Thu Mar 19, 2015 12:21 pm
by tuxranger
Yea I had found that as well. Thank you for sharing though. ^.^