فهرست منبع

Stabler Docker build

Kajetan Johannes Hammerle 3 روز پیش
والد
کامیت
3898af852f
2فایلهای تغییر یافته به همراه171 افزوده شده و 3 حذف شده
  1. 2 3
      Dockerfile
  2. 169 0
      examples/space.basic

+ 2 - 3
Dockerfile

@@ -1,7 +1,6 @@
 FROM debian:trixie-backports
 
-RUN apt update
-RUN apt install -y --no-install-recommends \
+RUN apt update && apt install -y --no-install-recommends \
         gcc \
         ninja-build \
         libc-dev \
@@ -9,4 +8,4 @@ RUN apt install -y --no-install-recommends \
         libxkbcommon-dev \
         xorg-dev \
         libglew-dev
-RUN apt install -y --no-install-recommends -t trixie-backports cmake
+RUN apt update && apt install -y --no-install-recommends -t trixie-backports cmake

+ 169 - 0
examples/space.basic

@@ -0,0 +1,169 @@
+# 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")