Streak Club is a place for hosting and participating in creative streaks.
The goal of this minigame was making the easiest possible game demo that has movement and collision detection for teaching purposes. Here's the source with German language commentary:
function love.load() -- hier werden zu Beginn einmalig Befehle ausgeführt
sx,sy = 700,300 -- stehen für Spieler X- und Y-Koordinate
cx,cy = 50,300 -- stehen für Computer X- und Y-Koordinaten
end
function love.draw() -- hier werden Bilder und Formen gezeichnet
love.graphics.circle("fill", sx, sy, 50) -- Großen Kreis (Spieler) zeichnen
love.graphics.circle("fill", cx, cy, 25) -- Kleinen Kreis (Computer) zeichnen
end
function love.update() -- hier werden Veränderungen berechnet
if love.mouse.isDown("l") then -- falls Mausknopf/Touchscreen gedrückt/berührt
if love.mouse.getY() > sy then -- wenn Maus/Finger höher als Spieler ist...
sy = sy + 10 -- Spielerbewegung nach unten
else -- ... in allen anderen Fällen
sy = sy - 10 -- Spielerbewegung nach oben
end
end
cx = cx + 5 -- Bewegung des Computers nach rechts
if cx > 800 then -- Beim Berühren des Rechten Randes
cx = 0 -- wird der Computer nach links versetzt
cy = math.random(1,600) -- wird die Höhe des Computers zufällig berechnet
end
-- Wenn Spieler und Computer einander nahe sind
if math.abs(sx - cx) < 50 and math.abs(sy - cy) < 50 then
cx = 0
cy = math.random(1,600)
end
end
I figure some of you could use this to learn some German! :D
Needs LÖVE to run
daily from
Post a comment
Great stuff. Shows how few lines are needed to have something interactive on the screen.
I have very good memories using LOVE2d. It's been so long since I've touched the library though and my programming skills haven't improved much. This is a perfect introduction to getting quickly up and running with LOVE2d.
Have you considered turning this into a tutorial for new-comers?