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
New to coding and need help on Pong game
Re: New to coding and need help on Pong game
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:
making a ball bounce off two paddels is far below making a character jump around blocks in physics complexity.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.
Re: New to coding and need help on Pong game
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?
- dizzykiwi3
- Citizen
- Posts: 58
- Joined: Tue Jan 14, 2014 2:03 am
Re: New to coding and need help on Pong game
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
- dizzykiwi3
- Citizen
- Posts: 58
- Joined: Tue Jan 14, 2014 2:03 am
Re: New to coding and need help on Pong game
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.
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.
- Attachments
-
- Pong.love
- (34.32 KiB) Downloaded 79 times
Re: New to coding and need help on Pong game
OK. Great! Thanks a ton!
Re: New to coding and need help on Pong game
Yea I had found that as well. Thank you for sharing though. ^.^
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests