Skip to content
Sign upLog in
← Back to Community

Love2d Pong

Profile icon
HongjiDai

I'm a beginner in lua and love2d. I tried my best to make the game Pong. If you find any bugs please inform me. I'll probably try to fix it.

Voters
Profile icon
TotheMax54
Profile icon
HongjiDai
Comments
hotnewtop
Profile icon
Drip-shortsshor

--Controls
--W and S for P1
--Up and Down arrow for P2

local p = require ("paddle")
local p2 = require ("paddle2")
local b = require ("ball")

--Loading...
function love.load()
love.window.setTitle("Pong Game!")
love.window.setMode(800, 300)
end

--THE GAME PART
function love.draw()
love.graphics.setColor(255,255,255)
love.graphics.rectangle("fill", p.x, p.y, p.width, p.height)
love.graphics.rectangle("fill", p2.x, p2.y, p2.width, p2.height)
love.graphics.rectangle("fill", b.x, b.y, b.dimension, b.dimension)
end

--THE CODE PART
function love.update(dt)
p.movement(dt)
p.touch()
p2.movement(dt)
p2.touch()
b.movement(dt)
b.lbounce(b.x, b.y, p.x, p.y, p.width, p.height, p.offsety)
b.rbounce(b.x, b.y, b.dimension, p2.x, p2.y, p2.height, p2.offsety, p2.width)
b.celling(b.y)
b.floor(b.y)
b.reset(b.x, b.dimension, b.offsetxy)
print(b.x)
end

Profile icon
CodeLongAndPros

This is really cool!

Profile icon
HongjiDai

@CodeLongAndPros
Thank you!

Profile icon
CodeLongAndPros

@HongjiDai
You're welcome.