New to coding and need help on Pong game

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
tuxranger
Prole
Posts: 4
Joined: Wed Mar 18, 2015 4:07 pm

New to coding and need help on Pong game

Post 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
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: New to coding and need help on Pong game

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
tuxranger
Prole
Posts: 4
Joined: Wed Mar 18, 2015 4:07 pm

Re: New to coding and need help on Pong game

Post 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?
User avatar
dizzykiwi3
Citizen
Posts: 58
Joined: Tue Jan 14, 2014 2:03 am

Re: New to coding and need help on Pong game

Post 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
User avatar
dizzykiwi3
Citizen
Posts: 58
Joined: Tue Jan 14, 2014 2:03 am

Re: New to coding and need help on Pong game

Post 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.
Attachments
Pong.love
(34.32 KiB) Downloaded 74 times
tuxranger
Prole
Posts: 4
Joined: Wed Mar 18, 2015 4:07 pm

Re: New to coding and need help on Pong game

Post by tuxranger »

OK. Great! Thanks a ton!
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: New to coding and need help on Pong game

Post by s-ol »


s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
tuxranger
Prole
Posts: 4
Joined: Wed Mar 18, 2015 4:07 pm

Re: New to coding and need help on Pong game

Post by tuxranger »

Yea I had found that as well. Thank you for sharing though. ^.^
Post Reply

Who is online

Users browsing this forum: No registered users and 214 guests