ÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÀ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌÀ¬ÀÀÀ¬ÀÀÀ¬ÀÀÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÌ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌ̬ÀÀÀ¬ÀÀÀ¬ÀÀ¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî >ê9ÿÿðÿÿÿðÿÿðÿwÿÿÿðÿÿÿ÷ÿwððÿÿÿpwÿpÿðÿwð÷ð÷ðÿÿÿÿðððÿðÿwð÷ÿðÿðððpðÿwÿÿÿpÿðÿwp÷ÿðpÿðÿpÿÿpÿðpÿ÷ÿÿÿÿ÷pÿðÿpÿpwwwwpwpwwwwpwpww""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"""""" """"3333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333333330333333333033333333303333DDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDDDDDD@DDDDUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUUUUUUPUUUUfffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`fffffffff`ffffwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwwwwwwpwwwwˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆ€ˆˆˆˆ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ™™™™™�™™™™ ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª ªªªªª ªªªª »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» »»»»»°»»»» ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÌÌÌÌÌÀÌÌÌÌ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ ÝÝÝÝÝÐÝÝÝÝ îîî333333333333333333333333333333333333333333333333d-- title: Breakout -- author: TechTeens Krostitz -- desc: Projektergebnis SJ 23/24 -- script: lua -- origin: digitsensitive function init() --definiert, was am Anfang des Spiels passieren soll --wird einmal zum Start abgerufen, danach nicht mehr --unsere Spielfigur: player = { x = (240/2)-12, y = 120, width = 24, height = 4, color = 3, speed = { x = 0, max = 4 } } --unser Ball ball = { x = player.x+(player.width/2)-1.5, y = player.y-5, width = 3, height = 3, color = 14, deactive = true, speed = { x = 0, y = 0, max = 1.5 } } --unsere Spielsteine bricks = {} brickCountWidth = 19 brickCountHeight = 12 --Spielsteine erzeugen for i=0, brickCountHeight, 1 do for j=0, brickCountWidth, 1 do local brick = { x = 10+j*11, y = 10+i*5, width = 10, height = 4, color = i+1 } table.insert(bricks, brick) end end --Variablen bgColor = 0 lives = 3 score = 0 end init() function TIC() -- Spielschleife, wird nach Spielbeginn immer wiedrholt cls(bgColor) input() if lives > 0 then update() collisions() draw() --if lives > 0 and score==228 then -- nextLevel() --end elseif lives==0 then gameOver() end end function input() --Steuerung der Spielfigur local sx = player.speed.x local smax = player.speed.max -- Bewegung nach links if btn(2) then if sx>-smax then sx=sx-2 else sx=-smax end end -- Bewegung nach rechts if btn(3) then if sx 0 then psx=psx-1 else psx=psx+1 end end player.x=px player.speed.x=psx player.speed.max=smax --Ballposition aktualisieren ball.x = ball.x + ball.speed.x ball.y = ball.y + ball.speed.y --max. Ballgeschwindigkeit pruefen if ball.speed.x > ball.speed.max then ball.speed.x = ball.speed.max end end function collisions() --Spielfigur <-> Wand playerWallCollision() --Ball <-> Wand ballWallCollision() --Ball <-> Boden ballGroundCollision() --Spielfigur <-> Ball playerBallCollision() --Ball <-> Spielsteine ballBrickCollision() end function playerWallCollision() if player.x < 0 then player.x = 0 elseif player.x+player.width > 240 then player.x = 240 - player.width end end function ballWallCollision() -- Oben if ball.y < 0 then ball.speed.y = -ball.speed.y -- Links elseif ball.x < 0 then ball.speed.x = -ball.speed.x -- Rechts elseif ball.x > 240 - ball.width then ball.speed.x = -ball.speed.x end end function ballGroundCollision() if ball.y > 136 - ball.width then -- Neustart Ball ball.deactive = true -- ein Leben verlieren if lives > 0 then lives = lives - 1 elseif lives == 0 then -- Game Over gameOver() end end end function playerBallCollision() if collide(player,ball) then ball.speed.y = -ball.speed.y ball.speed.x = ball.speed.x + 0.3*player.speed.x end end function collide(a,b) --Step 1: Parameter von a und b bekommen local ax = a.x local ay = a.y local aw = a.width local ah = a.height local bx = b.x local by = b.y local bw = b.width local bh = b.height --Kollision pruefen if ax < bx+bw and ax+aw > bx and ay < by+bh and ah+ay > by then --Kollision return true end --keine Kollision return false end function ballBrickCollision() for i,brick in pairs(bricks) do -- Parameter bekommen: local x = bricks[i].x local y = bricks[i].y local w = bricks[i].width local h = bricks[i].height -- Kollision pruefen: if collide(ball,bricks[i]) then -- Kollision links oder rechts if y < ball.y and ball.y < y+h and ball.x < x or x+w < ball.x then ball.speed.x = -ball.speed.x end -- kollision oben oder unten if ball.y < y or ball.y > y and x < ball.x and ball.x < x+w then ball.speed.y = -ball.speed.y end table.remove(bricks, i) score = score + 1 end end end function draw() --wir sehen was passiert bei Tastendruck drawGameObjects() drawGUI() end function drawGameObjects() -- Spielobjekte zeichnen lassen -- Spielfigur zeichnen: rect(player.x, player.y, player.width, player.height, player.color) -- Ball zeichnen: rect(ball.x, ball.y, ball.width, ball.height, ball.color) -- Spielsteine zeichnen: for i,brick in pairs(bricks) do rect(bricks[i].x, bricks[i].y, bricks[i].width, bricks[i].height, bricks[i].color) end end function drawGUI() -- Benutzeroberflaeche zeichnen lassen print("Score",5,1,7) print(score,40,1,7) print("Score",5,0,15) print(score,40,0,15) print("Lives",190,1,7) print(lives,225,1,7) print("Lives",190,0,15) print(lives,225,0,15) end function gameOver() print("Game Over",(240/2)-6*4.5,136/2) print("Score",5,1,7) print(score,40,1,7) print("Score",5,0,15) print(score,40,0,15) spr(0,240/2-4,136/2+10) if btn(5) then init() end end --function nextLevel() --score=228 --init() --end