Submissions by qubodup tagged demo

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


minimal.love759 bytes
19 downloads