🎮ArcadeLab

Get the brainrots

by BoldPanda65
92 lines3.7 KB
▶ Play
import pygame
import random

# --- Settings ---
WIDTH, HEIGHT = 800, 600
WHITE, BLACK = (255, 255, 255), (15, 15, 15)
GOLD_COLOR = (255, 215, 0)
BRAINROT_COLOR = (139, 69, 19)

# Controls: P1(WASD+Space), P2(Arrows+R-Ctrl), P3(IJKL+P), P4(TFGH+Q)
CONTROLS = [
    {'up': pygame.K_w, 'down': pygame.K_s, 'left': pygame.K_a, 'right': pygame.K_d, 'atk': pygame.K_SPACE},
    {'up': pygame.K_UP, 'down': pygame.K_DOWN, 'left': pygame.K_LEFT, 'right': pygame.K_RIGHT, 'atk': pygame.K_RCTRL},
    {'up': pygame.K_i, 'down': pygame.K_k, 'left': pygame.K_j, 'right': pygame.K_l, 'atk': pygame.K_p},
    {'up': pygame.K_t, 'down': pygame.K_g, 'left': pygame.K_f, 'right': pygame.K_h, 'atk': pygame.K_q}
]

class Player:
    def __init__(self, i):
        self.i = i
        self.rect = pygame.Rect(100 + (i*150), 300, 40, 40)
        self.color = [(0,255,0), (0,0,255), (255,0,0), (255,255,0)][i]
        self.gold = 0
        self.range = 60

    def move(self, keys):
        c = CONTROLS[self.i]
        if keys[c['left']]: self.rect.x -= 5
        if keys[c['right']]: self.rect.x += 5
        if keys[c['up']]: self.rect.y -= 5
        if keys[c['down']]: self.rect.y += 5

def main():
    pygame.init()
    screen = pygame.display.set_mode((WIDTH, HEIGHT))
    clock = pygame.time.Clock()
    font = pygame.font.SysFont('Arial', 24)

    # Player Selection
    num_players, selecting = 1, True
    while selecting:
        screen.fill(BLACK)
        msg = font.render(f"Press 1-4 for Players. Current: {num_players}. Press ENTER to start.", True, WHITE)
        screen.blit(msg, (100, 250))
        for e in pygame.event.get():
            if e.type == pygame.KEYDOWN:
                if e.key in [pygame.K_1, pygame.K_2, pygame.K_3, pygame.K_4]: num_players = int(e.unicode)
                if e.key == pygame.K_RETURN: selecting = False
        pygame.display.flip()

    players = [Player(i) for i in range(num_players)]
    enemies = [pygame.Rect(random.randint(50,750), random.randint(50,550), 30, 30) for _ in range(6)]
    shop_open = False

    while True:
        screen.fill(BLACK)
        keys = pygame.key.get_pressed()
        for e in pygame.event.get():
            if e.type == pygame.QUIT: return
            if e.type == pygame.KEYDOWN:
                if e.key == pygame.K_TAB: shop_open = not shop_open
                if not shop_open:
                    for p in players:
                        if e.key == CONTROLS[p.i]['atk']:
                            hitbox = p.rect.inflate(p.range, p.range)
                            for en in enemies[:]:
                                if hitbox.colliderect(en):
                                    enemies.remove(en)
                                    p.gold += 20
                                    enemies.append(pygame.Rect(random.randint(50,750), random.randint(50,550), 30, 30))
                else: # Shop Buying
                    p = players[0] # P1 buys for now
                    if e.key == pygame.K_s and p.gold >= 50: p.gold -= 50; p.range += 30
                    if e.key == pygame.K_k and p.gold >= 100: p.gold -= 100; p.color = BRAINROT_COLOR

        if shop_open:
            s_msg = font.render("SHOP: [S] Sword Range (50g) | [K] Brainrot Skin (100g) | [TAB] Exit", True, GOLD_COLOR)
            screen.blit(s_msg, (100, 100))
        else:
            for p in players:
                p.move(keys)
                pygame.draw.rect(screen, p.color, p.rect)
                g_msg = font.render(f"P{p.i+1}: {p.gold}g", True, p.color)
                screen.blit(g_msg, (10, 10 + (p.i*30)))
            for en in enemies:
                pygame.draw.rect(screen, BRAINROT_COLOR, en)

        pygame.display.flip()
        clock.tick(60)

if __name__ == "__main__":
    main()

Game Source: Get the brainrots

Creator: BoldPanda65

Libraries: none

Complexity: moderate (92 lines, 3.7 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: get-the-brainrots-boldpanda65" to link back to the original. Then publish at arcadelab.ai/publish.