| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- # Sternenfänger
- # Links/Rechts bewegen, Sterne sammeln, Meteoriten vermeiden.
- # Nach Game Over mit START/X neu starten.
- initWindow(720, 480)
- function box(x, y, w, h, c)
- for ax = 0 to w - 1
- for ay = 0 to h - 1
- setPixel(x + ax, y + ay, c)
- end
- end
- end
- function star(x, y, c)
- setPixel(x + 2, y, c)
- setPixel(x + 2, y + 1, c)
- setPixel(x, y + 2, c)
- setPixel(x + 1, y + 2, c)
- setPixel(x + 2, y + 2, c)
- setPixel(x + 3, y + 2, c)
- setPixel(x + 4, y + 2, c)
- setPixel(x + 2, y + 3, c)
- setPixel(x + 2, y + 4, c)
- end
- function rock(x, y, c)
- box(x + 1, y, 4, 1, c)
- box(x, y + 1, 6, 4, c)
- box(x + 1, y + 5, 4, 1, c)
- end
- function ship(x, y, c)
- box(x + 7, y, 4, 2, c)
- box(x + 4, y + 2, 10, 2, c)
- box(x, y + 4, 18, 3, c)
- setPixel(x + 2, y + 7, c)
- setPixel(x + 15, y + 7, c)
- end
- bg = color(0, 0, 4)
- white = color(31, 31, 31)
- yellow = color(31, 31, 0)
- red = color(31, 5, 0)
- cyan = color(0, 31, 31)
- green = color(0, 31, 8)
- playerX = 111
- playerY = 148
- starX = random(4, 235)
- starY = 0
- rockX = random(4, 235)
- rockY = 0
- score = 0
- lives = 3
- speed = 1
- nextLevel = 5
- gameOver = 0
- while !shouldClose()
- nextFrame()
- clearWindow(bg)
- if gameOver == 0
- if isButtonDown(BT_LEFT)
- playerX = playerX - 2
- end
- if isButtonDown(BT_RIGHT)
- playerX = playerX + 2
- end
- if playerX < 0
- playerX = 0
- end
- if playerX > 222
- playerX = 222
- end
- starY = starY + speed
- rockY = rockY + speed + 1
- hitStar = 0
- if starY >= playerY - 5
- if starY <= playerY + 8
- if starX >= playerX
- if starX <= playerX + 18
- hitStar = 1
- end
- end
- end
- end
- if hitStar == 1
- score = score + 1
- starX = random(4, 235)
- starY = 0
- end
- if starY > 159
- starX = random(4, 235)
- starY = 0
- end
- hitRock = 0
- if rockY >= playerY - 6
- if rockY <= playerY + 8
- if rockX + 6 >= playerX
- if rockX <= playerX + 18
- hitRock = 1
- end
- end
- end
- end
- if hitRock == 1
- lives = lives - 1
- rockX = random(4, 235)
- rockY = 0
- end
- if rockY > 159
- rockX = random(4, 235)
- rockY = 0
- end
- if score >= nextLevel
- speed = speed + 1
- nextLevel = nextLevel + 5
- end
- if lives <= 0
- gameOver = 1
- end
- render(0, 0, white, "Score: ", score)
- render(96, 0, white, "Lives: ", lives)
- render(176, 0, white, "Speed: ", speed)
- star(starX, starY, yellow)
- rock(rockX, rockY, red)
- ship(playerX, playerY, cyan)
- end
- if gameOver != 0
- render(64, 48, red, "GAME OVER")
- render(48, 68, white, "Score: ", score)
- render(24, 96, green, "Press START / X")
- if getButtonDownTime(BT_START) == 1
- playerX = 111
- starX = random(4, 235)
- starY = 0
- rockX = random(4, 235)
- rockY = 0
- score = 0
- lives = 3
- speed = 1
- nextLevel = 5
- gameOver = 0
- end
- end
- end
- printLine("stop")
|