0

the geometry dash code 2 with editor

đã đăng vào 20, Tháng 6, 2026, 11:31

line 6: editor put anything you want b: block [] : 30 pixels

s: spike /\ : 30 pixels

h: unreachable upspike: \/ ( useless, unrecommended) 30 pixels

unlimited length

m = mini block 15 pixels

u = pillar: /\ [] 30 pixels example editor input:

,(pixels, 'b or s or h or m or u'),

prepared code: change line 6:

import tkinter as tk, math
class MiniGD:
    def __init__(self, r):
        self.r = r
        self.w, self.h, self.sidebar_w, self.g, self.jf, self.base, self.gy, self.cy = 700, 400, 180, 1.5, -16, 8.5, 280, 120
        self.layout = [(400,'u'),(370, 'u'),(650,'s'),(900,'b'),(930,'b'),(960, 's'),(990, 's'),(1020, 's'),(1050, 's'),(1080, 's'),(1110, 's'),(1140,'s'),(1350,'b'),(1500,'s'),(2000,'s'),(2030,'s'),(2300,'b') ,(2330,'b'),(2510,'s'),(2540, 's'),(2700,'b'),(2730,'u'),(3000,'s'),(3030,'s'),(3300,'b'),(3330,'b'),(3360,'u'),(3550,'s'),(3800,'b'),(3950,'s'),(3980,'s'),(4200,'b'),(4230,'b'),(4350,'s'),(4600,'b'),(4630,'b'),(5000,'b'),(5030, 'u'),(5060, 's'),(5300, 'm'),(5315, 'm'),(5345, 'u'),(5500,'s'),(5700,'b'),(5730,'u'),(6000,'h'),(6200,'s'),(6500,'b'),(6530,'b'),(6700,'h'),(6730,'h'),(7000,'s'),(7300,'b'),(7330,'u'),(7720,'b'),(7850,'b'),(7880,'u'),(7910,'b'),(7940,'u'),(8200,'s'),(8500,'h'),(9000,'m'),(9300,'m'),(9600,'s'),(9900,'b'),(10200,'m'),(10500,'s'),(10530,'s'),(11000,'b'),(11030,'b'),(11060,'b'),(11300,'m'),(11600,'h'),(11900,'s'),(12500,'m'),(12700,'m'),(13000,'b'),(13030,'u'),(13400,'h'),(13700,'s'),(14000, 'b'),(14030, 'h'),(15000,'s'),(15030,'s'),(15400,'b'),(15600,'h'),(15900,'m'),(16200,'s'),(17000,'m'),(17200,'h'),(17500,'b'),(17530,'b'),(17800,'s'),(18200,'m'),(19000,'s'),(19030,'s'),(19060,'s'),(19500,'h'),(19800,'b'),(20200,'m'),(21000,'b'),(21030,'u'),(21500,'h'),(21530,'h'),(22000,'s'),(22500,'m'),(23500,'s'),(23800,'b'),(24100,'m'),(24400,'h'),(25000,'b'),(25500,'s'),(27000,'m'),(27300,'m'),(27600,'h'),(28000,'s'),(28500,'b'),(29000,'u'),(31000,'s'),(31030,'s'),(31500,'h'),(32000,'m'),(32500, 'b'),(33000,'s'),(35000,'m'),(35300,'m'),(36000,'h'),(36500, 'b'),(37000,'u'),(38500,'s'),(40000,'s'),(40030,'s'),(40500,'h'),(41000,'m'),(41500,'b'),(42000,'s'),(44000,'m'),(44300,'m'),(45000,'h'),(45500,'b'),(46000,'u'),(47000,'s'),(49000,'s'),(49030,'s'),(49060,'s'),(49500,'h'),(50000,'m'),(50500,'b'),(52000,'m'),(52300,'m'),(53000,'h'),(53500,'b'),(54000,'u'),(55000,'s'),(57000,'s'),(57030,'s'),(57500,'h'),(58000,'m'),(58500, 'b'),(59000,'s'),(61000,'m'),(61300,'m'),(62000,'h'),(62500,'b'),(63000,'u'),(64000,'s'),(66000,'s'),(66030,'s'),(66500,'h'),(67000,'m'),(67500,'b'),(68000,'s'),(70000,'m'),(70300,'m'),(71000,'h'),(71500,'b'),(72000,'u'),(72400, 'u'),(72600, 'u'),(72900, 'h'),(73200, 's'),(73500,'s'),(74000,'b'),(74030,'b'),(74060,'b'),(74090,'b'),(74120,'b'),(74250, 'u')]
        self.score_history = {}
        self.attempt = 1
        self.canvas = tk.Canvas(r, width=self.w + self.sidebar_w, height=self.h, bg="#001122", highlightthickness=0)
        self.canvas.pack()
        r.bind("<space>", lambda e: self.jmp_act())
        r.bind("<Up>", lambda e: self.jmp_act())
        self.reset()

    def jmp_act(self):
        if not self.jmp and self.act: self.vy, self.jmp = self.jf, True

    def tick(self):
        if not self.act: return
        self.vy += self.g
        self.vy = min(15, self.vy)
        y_prev = self.py
        self.py += self.vy
        self.sc += self.base + (self.sc / 18000)

        self.percentage = min(100.00, (self.sc / 74500) * 100)
        self.canvas.itemconfig(self.score_txt, text=f"PROGRESS: {self.percentage:.2f}%")

        if self.sc >= 74500:
            self.canvas.create_text(350, 200, text="CLEARED!", fill="#0fa", font=("Arial", 22, "bold"))
            return

        self.ang = (self.ang + 9.0) % 360 if self.jmp else round(self.ang / 90) * 90
        px = 120
        if self.py >= self.gy - 30: self.py, self.vy, self.jmp = self.gy - 30, 0, False

        cx, cy, rad = px + 15, self.py + 15, math.radians(self.ang)
        cos_a, sin_a, h = math.cos(rad), math.sin(rad), 15
        pts = []
        for lx, ly in [(-h,-h), (h,-h), (h,h), (-h,h)]:
            pts.append(float(cx + (lx * cos_a - ly * sin_a)))
            pts.append(float(cy + (lx * sin_a + ly * cos_a)))

        self.canvas.coords(self.p_id, *pts)

        for s in self.s: self.canvas.move(s, -(self.base + (self.sc / 18000)), 0)
        for b in self.b: self.canvas.move(b, -(self.base + (self.sc / 18000)), 0)

        px1, py1, px2, py2 = px, self.py, px + 30, self.py + 30
        on_plat = False
        for b in self.b:
            bbox = self.canvas.bbox(b)
            if bbox:
                bx1, by1, bx2, by2 = bbox
                if px2 > bx1 + 3 and px1 < bx2 - 3:
                    if py2 >= by1 and y_prev + 30 <= by1 + 12 and self.vy >= 0: 
                        self.py, self.vy, self.jmp, on_plat = by1 - 30, 0, False, True
                    elif py2 > by1 + 8 and px2 >= bx1 and px1 < bx1: 
                        return self.die()

        if not on_plat and self.py < self.gy - 30 and self.vy == 0: self.jmp = True

        # --- FIXED: UNPACK ARRAYS TO DESCRIPTIVE VARIABLES TO PREVENT LIST CONCAT CRASHES ---
        for s in self.s:
            c = self.canvas.coords(s)
            if c and len(c) >= 6:
                x_left = c[0]
                y_floor = c[1]
                x_tip = c[2]
                y_tip = c[3]
                x_right = c[4]

                if px2 > x_left + 4 and px1 < x_right - 4:
                    pm = (px1 + px2) / 2
                    ish = (y_floor == self.cy) # Check if hanging spike

                    rat = (pm - x_left) / (x_tip - x_left) if pm <= x_tip else (x_right - pm) / (x_right - x_tip)
                    sy = y_floor + (rat * (y_tip - y_floor)) if ish else y_floor - (rat * (y_floor - y_tip))

                    if (ish and py1 < sy - 4) or (not ish and py2 > sy + 4): 
                        return self.die()

        self.id = self.r.after(16, self.tick)

    def die(self):
        self.act = False
        if hasattr(self, 'id') and self.id: self.r.after_cancel(self.id)

        rounded_pct = round(self.percentage, 2)
        self.score_history[rounded_pct] = self.score_history.get(rounded_pct, 0) + 1

        self.canvas.create_text(350, 170, text="TRY AGAIN", fill="#ff4400", font=("Arial", 28, "bold"))
        self.canvas.create_text(350, 215, text=f"Reached: {rounded_pct:.2f}%", fill="#fff", font=("Arial", 14))
        self.r.after(850, self.reset_next_attempt)

    def reset_next_attempt(self):
        self.attempt += 1
        self.reset()

    def reset(self):
        if hasattr(self, 'id') and self.id: 
            self.r.after_cancel(self.id)
            self.id = None

        self.canvas.delete("all")
        self.b, self.s = [], []
        self.vy, self.ang, self.sc, self.jmp, self.act = 0, 0, 0, False, True

        self.score_txt = self.canvas.create_text(20, 30, text="PROGRESS: 0.00%", fill="#fff", font=("Arial", 12, "bold"), anchor="w")
        self.attempt_txt = self.canvas.create_text(self.w - 20, 30, text=f"ATTEMPT {self.attempt}", fill="#fff", font=("Arial", 12, "bold"), anchor="e")
        self.canvas.create_line(0, self.gy, self.w, self.gy, fill="#fff", width=3)

        self.canvas.create_rectangle(self.w, 0, self.w + self.sidebar_w, self.h, fill="#000b14", outline="#00ffff", width=2)
        self.canvas.create_text(self.w + 15, 30, text="TOP 10 RUNS", fill="#00ffff", font=("Arial", 11, "bold"), anchor="w")
        sorted_uniques = sorted(self.score_history.keys(), reverse=True)[:10]
        for i in range(10):
            val_str, color = "0.00%", "#8c9ea3"
            if i < len(sorted_uniques):
                pct = sorted_uniques[i]
                count = self.score_history[pct]
                val_str = f"{pct:.2f}%" + (f" (x{count})" if count > 1 else "")
                color = "#ffaa00" if i==0 else "#00ffaa" if i<3 else "#8c9ea3"
            self.canvas.create_text(self.w + 15, 65 + (i * 28), text=f"{i+1}. {val_str}", fill=color, font=("Courier New", 11, "bold"), anchor="w")

        self.py = self.gy - 30
        self.p_id = self.canvas.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill="#ff4400", outline="#fff", width=2)

        for x, t in self.layout:
            if t == 's': self.s.append(self.canvas.create_polygon(x, self.gy, x+15, self.gy-30, x+30, self.gy, fill="#fff"))
            elif t == 'h': self.s.append(self.canvas.create_polygon(x, self.cy, x+15, self.cy+30, x+30, self.cy, fill="#f44"))
            elif t == 'b': self.b.append(self.canvas.create_rectangle(x, self.gy-30, x+30, self.gy, fill="#024", outline="#0ff", width=2))
            elif t == 'm': self.b.append(self.canvas.create_rectangle(x, self.gy-45, x+15, self.gy-30, fill="#057", outline="#0ff", width=2))
            elif t == 'u':
                self.b.append(self.canvas.create_rectangle(x, self.gy-30, x+30, self.gy, fill="#024", outline="#0ff", width=2))
                self.s.append(self.canvas.create_polygon(x, self.gy-30, x+15, self.gy-60, x+30, self.gy-30, fill="#fff"))
        self.tick()

if __name__ == "__main__":
    win = tk.Tk()
    MiniGD(win)
    win.mainloop()

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.