Portfolio

A selection of projects. Click any image to view it full size.

bomb_tag.pyPython
import pygameimport randomimport timepygame.init()screen_width = 1000screen_height = 1000try:    pygame.mixer.music.load("music.wav")    pygame.mixer.music.play(-1)except Exception:    passtry:    explosion = pygame.mixer.Sound("boom.wav")except Exception:    explosion = Nonetry:    passsound = pygame.mixer.Sound("pass.wav")except Exception:    passsound = Nonescreen = pygame.display.set_mode((screen_width, screen_height))pygame.display.set_caption("Bomb Tag")try:    backgroundimg = pygame.image.load("backgroundimg.png")except Exception:    backgroundimg = pygame.Surface((screen_width, screen_height))    backgroundimg.fill((50, 50, 50))menu = pygame.image.load("menu.png")startimage = pygame.image.load("play.png")quitimage = pygame.image.load("quit.png")try:    bombimage = pygame.image.load("bomb.png")except Exception:    bombimage = pygame.Surface((40, 40))    bombimage.fill((255, 165, 0))font = pygame.font.Font(None, 50)clock = pygame.time.Clock()def load_anim(prefix, count):    frames = []    for i in range(1, count + 1):        try:            img = pygame.image.load(f"{prefix}{i}.png")            frames.append(pygame.transform.scale(img, (50, 70)))        except Exception:            surf = pygame.Surface((50, 70))            surf.fill((0, 0, 255))            frames.append(surf)    return framesexplosion_frames = load_anim("Explosion", 12)down_images = load_anim("down", 6)up_images = load_anim("up", 6)right_images = load_anim("right", 6)upright_images = load_anim("upright", 6)downright_images = load_anim("downright", 6)player = pygame.Rect(300, 250, 50, 70)player2 = pygame.Rect(700, 250, 50, 70)player_image = down_images[0]player2_image = down_images[0]startbutton = pygame.Rect(350, 700, 300, 70)quitbutton = pygame.Rect(382, 820, 240, 70)playerspeed = 5player2speed = 5Startmenu = Truerunning = Truedef reset_game():    global time_val, timer    global playerlives, player2lives    global playerbomb, player2bomb    global bombclock, bombx, bomby    global is_exploding, exp_anim_index, exp_anim_counter    global anim_index, anim_counter    global player_image, player2_image    time_val = 10    timer = 60    playerlives = 3    player2lives = 3    playerbomb = False    player2bomb = True    bombclock = 0    bombx = 600    bomby = 200    player.x, player.y = 300, 250    player2.x, player2.y = 700, 250    is_exploding = False    exp_anim_index = 0    exp_anim_counter = 0    anim_index = 0    anim_counter = 0    player_image = down_images[0]    player2_image = down_images[0]reset_game()while running:    if Startmenu:        for event in pygame.event.get():            if event.type == pygame.QUIT:                running = False            if event.type == pygame.MOUSEBUTTONDOWN:                if event.button == 1:                    if quitbutton.collidepoint(event.pos):                        running = False                    if startbutton.collidepoint(event.pos):                        reset_game()                        Startmenu = False        screen.blit(menu, (0, 0))        pygame.draw.rect(screen, "Black", startbutton)        pygame.draw.rect(screen, "Black", quitbutton)        screen.blit(startimage, startbutton)        screen.blit(quitimage, quitbutton)        pygame.display.flip()        clock.tick(60)    else:        for event in pygame.event.get():            if event.type == pygame.QUIT:                running = False        keys = pygame.key.get_pressed()        dx = 0        dy = 0        if keys[pygame.K_w]:            dy -= 1        if keys[pygame.K_s]:            dy += 1        if keys[pygame.K_a]:            dx -= 1        if keys[pygame.K_d]:            dx += 1        p1_sprinting = keys[pygame.K_LSHIFT]        p1_crouched = keys[pygame.K_LCTRL]        if p1_sprinting:            playerspeed = 10        elif p1_crouched:            playerspeed = 1        else:            playerspeed = 5        if dx != 0 or dy != 0:            if dx > 0 and dy < 0:                anim_images = upright_images            elif dx < 0 and dy < 0:                anim_images = upright_images            elif dx > 0 and dy > 0:                anim_images = downright_images            elif dx < 0 and dy > 0:                anim_images = downright_images            elif dx > 0:                anim_images = right_images            elif dx < 0:                anim_images = right_images            elif dy < 0:                anim_images = up_images            else:                anim_images = down_images            player.x += dx * playerspeed            player.y += dy * playerspeed            anim_counter += 1            if anim_counter >= 5:                anim_index = (anim_index + 1) % len(anim_images)                player_image = anim_images[anim_index]                if dx < 0 and dy == 0:                    player_image = pygame.transform.flip(                        player_image, True, False                    )                elif dx < 0:                    player_image = pygame.transform.flip(                        player_image, True, False                    )                anim_counter = 0        dx2 = 0        dy2 = 0        if keys[pygame.K_UP]:            dy2 -= 1        if keys[pygame.K_DOWN]:            dy2 += 1        if keys[pygame.K_LEFT]:            dx2 -= 1        if keys[pygame.K_RIGHT]:            dx2 += 1        p2_sprinting = keys[pygame.K_RSHIFT]        p2_crouched = keys[pygame.K_RCTRL]        if p2_sprinting:            player2speed = 10        elif p2_crouched:            player2speed = 1        else:            player2speed = 5        if dx2 != 0 or dy2 != 0:            if dx2 > 0 and dy2 < 0:                anim_images = upright_images            elif dx2 < 0 and dy2 < 0:                anim_images = upright_images            elif dx2 > 0 and dy2 > 0:                anim_images = downright_images            elif dx2 < 0 and dy2 > 0:                anim_images = downright_images            elif dx2 > 0:                anim_images = right_images            elif dx2 < 0:                anim_images = right_images            elif dy2 < 0:                anim_images = up_images            else:                anim_images = down_images            player2.x += dx2 * player2speed            player2.y += dy2 * player2speed            anim_counter += 1            if anim_counter >= 5:                anim_index = (anim_index + 1) % len(anim_images)                player2_image = anim_images[anim_index]                if dx2 < 0:                    player2_image = pygame.transform.flip(                        player2_image, True, False                    )                anim_counter = 0        player.clamp_ip(screen.get_rect())        player2.clamp_ip(screen.get_rect())        timer -= 1        if timer <= 0:            time_val -= 1            timer = 60        if time_val <= 0:            if explosion:                explosion.play()            if playerbomb:                playerlives -= 1                explosion_x, explosion_y = player.x, player.y            else:                player2lives -= 1                explosion_x, explosion_y = player2.x, player2.y            is_exploding = True            exp_anim_index = 0            exp_anim_counter = 0            time_val = 10            if playerlives <= 0 or player2lives <= 0:                Startmenu = True        bombclock += 1        if player2.colliderect(player) and not playerbomb and bombclock >= 60:            if passsound:                passsound.play()            playerbomb = True            player2bomb = False            bombclock = 0        elif player2.colliderect(player) and playerbomb and bombclock >= 30:            if passsound:                passsound.play()            playerbomb = False            player2bomb = True            bombclock = 0        if playerbomb:            bombx = player.x            bomby = player.y        elif player2bomb:            bombx = player2.x            bomby = player2.y        screen.blit(backgroundimg, (0, 0))        screen.blit(player_image, player)        screen.blit(player2_image, player2)        if not is_exploding:            screen.blit(bombimage, (bombx, bomby))        if is_exploding:            if exp_anim_index < len(explosion_frames):                screen.blit(                    explosion_frames[exp_anim_index],                    (explosion_x, explosion_y)                )                exp_anim_counter += 1                if exp_anim_counter >= 5:                    exp_anim_index += 1                    exp_anim_counter = 0            else:                is_exploding = False        score_text = font.render(            "Time: " + str(time_val), True, "White"        )        playerhealth_text = font.render(            "P1 Lives: " + str(playerlives), True, "Red"        )        player2health_text = font.render(            "P2 Lives: " + str(player2lives), True, "Red"        )        screen.blit(score_text, (400, 60))        screen.blit(playerhealth_text, (10, 160))        screen.blit(player2health_text, (10, 200))        pygame.display.flip()        clock.tick(60)pygame.quit()

Bomb Tag

Two-player pass-the-bomb game

My role: I wrote the whole game in Python with Pygame: player movement and animation, the bomb timer and passing, lives and the explosion effects.

A two-player game built with Python and Pygame. One player is holding a bomb on a 10-second fuse, and you pass it on by touching the other player. When it goes off, the holder loses a life, and the first player to run out of lives loses. Player 1 uses W, A, S, D and player 2 uses the arrow keys, and both can sprint or crouch.

Tools
Python, Pygame
Players
2, same keyboard
space_shooter.pyPython
import pygameimport randompygame.init()WIDTH = 480HEIGHT = 600screen = pygame.display.set_mode((WIDTH, HEIGHT))pygame.display.set_caption("Space Shooter")clock = pygame.time.Clock()font = pygame.font.Font(None, 36)big_font = pygame.font.Font(None, 72)background = pygame.image.load("background.png")ship_image = pygame.image.load("ship.png")ship_left_image = pygame.image.load("shipleft.png")ship_right_image = pygame.image.load("shipright.png")bullet_image = pygame.image.load("bullet.png")asteroid_image = pygame.image.load("asteroid2.png")explosion_frames = []for number in range(13):    try:        explosion_frames.append(pygame.image.load(f"Explosion{number}.png"))    except Exception:        passship = pygame.Rect(WIDTH // 2 - 38, HEIGHT - 90, 76, 54)bullets = []asteroids = []explosions = []score = 0best = 0lives = 3cooldown = 0spawn_timer = 8invulnerable = 0state = "menu"def new_game():    global score, lives, cooldown, spawn_timer, invulnerable, state    score = 0    lives = 3    cooldown = 0    spawn_timer = 8    invulnerable = 0    ship.x = WIDTH // 2 - 38    bullets.clear()    asteroids.clear()    explosions.clear()    state = "play"def spawn_asteroid():    size = int(88 * random.uniform(0.8, 1.4))    x = random.randint(0, WIDTH - size)    speed_y = random.uniform(3, 6) + min(score / 200, 4)    speed_x = random.uniform(-1, 1)    if random.random() < 0.25:        frames = (ship.y + size) / speed_y        speed_x = (ship.centerx - (x + size / 2)) / frames        speed_x = max(-3, min(3, speed_x))    asteroids.append({        "x": x,        "y": -size,        "size": size,        "speed_x": speed_x,        "speed_y": speed_y,        "image": pygame.transform.scale(asteroid_image, (size, size)),    })def asteroid_rect(asteroid):    size = asteroid["size"]    return pygame.Rect(        int(asteroid["x"] + size * 0.15),        int(asteroid["y"] + size * 0.15),        int(size * 0.7),        int(size * 0.7),    )def add_explosion(x, y, size):    explosions.append({"x": x, "y": y, "size": int(size), "frame": 0, "timer": 0})def draw_centered(text, y, text_font, colour):    image = text_font.render(text, True, colour)    screen.blit(image, (WIDTH // 2 - image.get_width() // 2, y))running = Truewhile running:    for event in pygame.event.get():        if event.type == pygame.QUIT:            running = False        if state != "play":            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:                new_game()            if event.type == pygame.MOUSEBUTTONDOWN:                new_game()    keys = pygame.key.get_pressed()    if state == "play":        direction = 0        if keys[pygame.K_LEFT] or keys[pygame.K_a]:            direction -= 1        if keys[pygame.K_RIGHT] or keys[pygame.K_d]:            direction += 1        ship.x += direction * 6        ship.clamp_ip(screen.get_rect())        if cooldown > 0:            cooldown -= 1        if (keys[pygame.K_SPACE] or keys[pygame.K_UP] or keys[pygame.K_w]) and cooldown == 0:            bullets.append(pygame.Rect(ship.centerx - 9, ship.y - 40, 18, 67))            cooldown = 12        for bullet in bullets:            bullet.y -= 10        bullets = [bullet for bullet in bullets if bullet.bottom > 0]        spawn_timer -= 1        if spawn_timer <= 0:            spawn_asteroid()            spawn_timer = max(7, 20 - score // 80) + random.randint(0, 7)        for asteroid in asteroids:            asteroid["x"] += asteroid["speed_x"]            asteroid["y"] += asteroid["speed_y"]        asteroids = [a for a in asteroids if a["y"] < HEIGHT + a["size"]]        for asteroid in asteroids[:]:            hitbox = asteroid_rect(asteroid)            for bullet in bullets[:]:                if hitbox.colliderect(bullet):                    bullets.remove(bullet)                    asteroids.remove(asteroid)                    add_explosion(hitbox.centerx, hitbox.centery, asteroid["size"] * 1.1)                    score += 10                    break        if invulnerable > 0:            invulnerable -= 1        else:            ship_hitbox = ship.inflate(-26, -20)            for asteroid in asteroids[:]:                hitbox = asteroid_rect(asteroid)                if hitbox.colliderect(ship_hitbox):                    asteroids.remove(asteroid)                    add_explosion(hitbox.centerx, hitbox.centery, asteroid["size"] * 1.1)                    add_explosion(ship.centerx, ship.centery, 90)                    lives -= 1                    invulnerable = 90                    if lives <= 0:                        best = max(best, score)                        state = "over"                    break    for explosion in explosions:        explosion["timer"] += 1        if explosion["timer"] >= 3:            explosion["frame"] += 1            explosion["timer"] = 0    explosions = [e for e in explosions if e["frame"] < len(explosion_frames)]    screen.blit(background, (0, 0))    if state == "menu":        draw_centered("SPACE SHOOTER", 200, big_font, "White")        draw_centered("Arrow keys or A / D to move", 290, font, "White")        draw_centered("Space to fire", 325, font, "White")        draw_centered("Press Enter or click to start", 400, font, "Orange")        screen.blit(ship_image, (WIDTH // 2 - 38, 470))    else:        for asteroid in asteroids:            screen.blit(asteroid["image"], (asteroid["x"], asteroid["y"]))        for bullet in bullets:            screen.blit(bullet_image, bullet)        if state == "play" and (invulnerable == 0 or (invulnerable // 6) % 2 == 1):            current_image = ship_image            if keys[pygame.K_LEFT] or keys[pygame.K_a]:                current_image = ship_left_image            elif keys[pygame.K_RIGHT] or keys[pygame.K_d]:                current_image = ship_right_image            screen.blit(current_image, ship)        for explosion in explosions:            frame = pygame.transform.scale(                explosion_frames[explosion["frame"]],                (explosion["size"], explosion["size"])            )            screen.blit(                frame,                (explosion["x"] - explosion["size"] // 2, explosion["y"] - explosion["size"] // 2)            )        score_text = font.render("Score: " + str(score), True, "White")        lives_text = font.render("Lives: " + str(lives), True, "Red")        screen.blit(score_text, (12, 10))        screen.blit(lives_text, (WIDTH - lives_text.get_width() - 12, 10))        if state == "over":            draw_centered("GAME OVER", 230, big_font, "Red")            draw_centered("Score: " + str(score) + "   Best: " + str(best), 300, font, "White")            draw_centered("Press Enter or click to play again", 360, font, "Orange")    pygame.display.flip()    clock.tick(60)pygame.quit()

Space Shooter

Shoot the asteroids before they reach you

My role: I wrote the whole game in Python with Pygame.

A space shooter built with Python and Pygame. Fly your ship along the bottom of the screen, fire at the asteroids coming down and watch them explode. I modelled, textured and rendered all the sprites myself.

Tools
Python, Pygame
Screenshot of the Cinema Booking app
cinema_booking.pyPython
import tkinter as tkimport tkinter.font as tkFontfrom tkinter import messageboxwindow = tk.Tk()window.geometry("520x460")window.title("Cinema Booking")window.configure(bg="#121212")movie_type = tk.StringVar(value="None")title_font = tkFont.Font(family="Segoe UI", size=18, weight="bold")label_font = tkFont.Font(family="Segoe UI", size=10)bold_font = tkFont.Font(family="Segoe UI", size=10, weight="bold")label1 = tk.Label(window, text="🎬 Cinema Booking", font=title_font, fg="#ffb703", bg="#121212")label1.grid(row=0, column=0, columnspan=2, sticky="w", padx=20, pady=(15, 10))try:    photo = tk.PhotoImage(file='logo.png')    image_label = tk.Label(window, image=photo, bg="#121212")    image_label.grid(row=1, column=1, columnspan=2, padx=10, pady=5)except Exception:    passdetails_frame = tk.LabelFrame(window, text=" Customer Details ", font=bold_font, bg="#121212", fg="#e0e0e0", bd=1, relief="solid")details_frame.grid(row=1, column=0, padx=20, pady=5, sticky="nsew")movie_frame = tk.LabelFrame(window, text=" Select Movie ", font=bold_font, bg="#121212", fg="#e0e0e0", bd=1, relief="solid")movie_frame.grid(row=2, column=0, padx=20, pady=10, sticky="nsew")extras_frame = tk.LabelFrame(window, text=" Extras ", font=bold_font, bg="#121212", fg="#e0e0e0", bd=1, relief="solid")extras_frame.grid(row=2, column=1, padx=10, pady=10, sticky="nsew")price_frame = tk.LabelFrame(window, text="", bg="#121212", fg="#e0e0e0", bd=0)price_frame.grid(row=4, column=0, padx=20, pady=5, sticky="w")calc_frame = tk.LabelFrame(window, text="", bg="#121212", fg="#e0e0e0", bd=0)calc_frame.grid(row=4, column=1, padx=10, pady=5, sticky="e")error = tk.Label(window, text="", bg="#121212", fg="#ff6b6b")error.grid(row=5, column=0, columnspan=2)screeningTime = tk.StringVar()screeningTime.set("Choose a time")timeMenu = tk.OptionMenu(    window,    screeningTime,    "14:30",    "17:00",    "19:30",    "21:00")timeMenu.config(bg="#1e1e1e", fg="white", activebackground="#333333", activeforeground="white", highlightthickness=0, font=label_font)timeMenu["menu"].config(bg="#1e1e1e", fg="white", font=label_font)timeMenu.grid(row=3, column=0, padx=20, pady=5, sticky="w")snack = tk.IntVar()glasses = tk.IntVar()snackCheck = tk.Checkbutton(    extras_frame,    text="Snack Pack (+£4)",    variable=snack,    bg="#121212",    fg="#e0e0e0",    selectcolor="#1e1e1e",    activebackground="#121212",    activeforeground="#e0e0e0",    font=label_font)snackCheck.grid(row=0, column=0, sticky="w", padx=10, pady=5)glassesCheck = tk.Checkbutton(    extras_frame,    text="3D Glasses (+£2)",    variable=glasses,    bg="#121212",    fg="#e0e0e0",    selectcolor="#1e1e1e",    activebackground="#121212",    activeforeground="#e0e0e0",    font=label_font)glassesCheck.grid(row=1, column=0, sticky="w", padx=10, pady=5)spider_radio = tk.Radiobutton(    movie_frame,    text="Spider-Man",    variable=movie_type,    value="spiderman",    bg="#121212",    fg="#e0e0e0",    selectcolor="#1e1e1e",    activebackground="#121212",    activeforeground="#e0e0e0",    font=label_font)spider_radio.grid(row=0, column=0, sticky="w", padx=10, pady=2)marvel_radio = tk.Radiobutton(    movie_frame,    text="Marvel Universe",    variable=movie_type,    value="marvel",    bg="#121212",    fg="#e0e0e0",    selectcolor="#1e1e1e",    activebackground="#121212",    activeforeground="#e0e0e0",    font=label_font)marvel_radio.grid(row=1, column=0, sticky="w", padx=10, pady=2)dc_radio = tk.Radiobutton(    movie_frame,    text="DC Extended",    variable=movie_type,    value="dc",    bg="#121212",    fg="#e0e0e0",    selectcolor="#1e1e1e",    activebackground="#121212",    activeforeground="#e0e0e0",    font=label_font)dc_radio.grid(row=2, column=0, sticky="w", padx=10, pady=2)label2 = tk.Label(details_frame, text="Name:", bg="#121212", fg="#e0e0e0", font=label_font)label2.grid(row=0, column=0, sticky="w", padx=10, pady=5)nameEntry = tk.Entry(details_frame, bg="#1e1e1e", fg="white", insertbackground="white", relief="solid", bd=1)nameEntry.grid(row=0, column=1, pady=5, padx=5)adult_label = tk.Label(details_frame, text="Adult tickets (£10):", bg="#121212", fg="#e0e0e0", font=label_font)adult_label.grid(row=1, column=0, sticky="w", padx=10, pady=5)adultEntry = tk.Entry(details_frame, bg="#1e1e1e", fg="white", insertbackground="white", relief="solid", bd=1, width=10)adultEntry.grid(row=1, column=1, sticky="w", pady=5, padx=5)adultEntry.insert(0, "0")child_label = tk.Label(details_frame, text="Child tickets (£8):", bg="#121212", fg="#e0e0e0", font=label_font)child_label.grid(row=2, column=0, sticky="w", padx=10, pady=5)childEntry = tk.Entry(details_frame, bg="#1e1e1e", fg="white", insertbackground="white", relief="solid", bd=1, width=10)childEntry.grid(row=2, column=1, sticky="w", pady=5, padx=5)childEntry.insert(0, "0")label4 = tk.Label(price_frame, text="Total Price:", bg="#121212", fg="#e0e0e0", font=bold_font)label4.grid(row=0, column=0, sticky="w", padx=5)price = tk.Label(price_frame, text="£0.00", font=("Segoe UI", 14, "bold"), fg="#2ec4b6", bg="#121212")price.grid(row=0, column=1, sticky="w", padx=5)def clear():    nameEntry.delete(0, tk.END)    adultEntry.delete(0, tk.END)    adultEntry.insert(0, "0")    childEntry.delete(0, tk.END)    childEntry.insert(0, "0")    price.config(text="£0.00")    error.config(text="")    movie_type.set("None")    screeningTime.set("Choose a time")    snack.set(0)    glasses.set(0)def calculate():    nameinput = nameEntry.get().strip()    selected_movie = movie_type.get()        if selected_movie != "None":        if not nameinput:            messagebox.showerror("Error", "Please enter a name.")            return        try:            adults = int(adultEntry.get())            children = int(childEntry.get())                        if adults < 0 or children < 0:                messagebox.showerror("Error", "Ticket quantities cannot be negative.")                return                            total_tickets = adults + children            if total_tickets == 0:                messagebox.showerror("Error", "Please select at least one ticket.")                return                            if total_tickets > 10:                messagebox.showerror("Error", "Total tickets cannot exceed 10.")                return                            adult_cost = adults * 10.0            child_cost = children * 8.0            total = adult_cost + child_cost            if snack.get() == 1:                total = total + 4            if glasses.get() == 1:                total = total + 2            if total_tickets > 4:                total *= 0.9                            formatted_price = f"£{total:.2f}"            price.config(text=formatted_price)            error.config(text="")                        messagebox.showinfo(                "Receipt",                f"{nameinput} has bought {adults} adult and {children} child ticket(s) for {selected_movie} for a total price of {formatted_price}"            )        except ValueError:            messagebox.showerror("Error", "Make sure ticket quantities are valid whole numbers.")    else:        messagebox.showerror("Error", "Select a movie.")calc_button = tk.Button(calc_frame, text="Calculate", width=10, command=calculate, bg="#2ec4b6", fg="black", font=bold_font, relief="flat", cursor="hand2")calc_button.grid(row=0, column=0, padx=5, pady=5)clear_button = tk.Button(calc_frame, text="Clear", width=8, command=clear, bg="#e71d36", fg="white", font=bold_font, relief="flat", cursor="hand2")clear_button.grid(row=0, column=1, padx=5, pady=5)window.mainloop()

Cinema Booking App

10% off groups of 5+ tickets

My role: I designed and built the whole app in Python: the Tkinter interface, the pricing logic, input validation and the receipt pop-up.

A desktop cinema booking app built with Python and Tkinter. Pick a film and showtime, enter adult and child tickets, add extras like a snack pack or 3D glasses, and get a total price with a receipt. Input is validated, and bookings of five or more tickets get 10% off.

What I'd improve: The showtime isn't checked or shown on the receipt yet, and I'd separate the pricing logic from the interface so it's easier to test.

Tools
Python, Tkinter
Year
2026
Type
School project
Output of the text adventure game running in a terminal
text_adventure.pyPython
import randomoutside = Trueadjectiveslocation = ["large", "small", "shallow", "endless", "normal", "creepy"]locationsoutside = ["forest", "cliff", "beach", "field", "mountain"]locationsinside = ["castle", "skyscraper", "house", "restaurant", "shed"]movement = ["north","east","south","west","forward","backward","left","right", "back"]lookaroundinside = ["dirty walls and a collapsing ceiling followed with boarded up doorways", "rough walls with litter everywhere"]enter = ["inside", "enter"]exitwords = ["leave", "exit", "outside"]def startgame(currentlocation, currentlocationdescription, insiderandom, isoutside):    print("you start out lost at a", currentlocationdescription, currentlocation)    answer(currentlocation, currentlocationdescription, insiderandom, outside)def answer(currentlocation, currentlocationdescription, insiderandom, outside):    ans = input(">_")    if any(m in ans for m in movement) :        if outside == False:            print("you bump into a wall because you are inside a", insiderandom)            answer(currentlocation, currentlocationdescription, insiderandom, outside)        else:            print("you move to", ans, "from the", currentlocation )            insiderandom = random.choice(locationsinside)            currentlocation = random.choice(locationsoutside)            currentlocationdescription = random.choice(adjectiveslocation)            features = random.randint(0,1)            if features == 1:                           print("you walk until you find a", currentlocationdescription, currentlocation, "with a", insiderandom, "near by")                answer(currentlocation, currentlocationdescription, insiderandom, outside)            else:                print("you walk until you find a", currentlocationdescription, currentlocation )                answer(currentlocation, currentlocationdescription, insiderandom, outside)    elif any(e in ans for e in enter):        if outside == True:            print("you enter inside the", insiderandom)            currentlocation = random.choice(locationsoutside)            currentlocationdescription = random.choice(adjectiveslocation)            outside = False            features = random.randint(0,2)            answer(currentlocation, currentlocationdescription, insiderandom, outside)        else:            print("there is nowhere to enter...")            answer(currentlocation, currentlocationdescription, insiderandom, outside)    elif any(e in ans for e in exitwords):        if outside == False:            print("you leave the", insiderandom)            currentlocation = random.choice(locationsoutside)            currentlocationdescription = random.choice(adjectiveslocation)            outside = True            features = random.randint(0,2)            answer(currentlocation, currentlocationdescription, insiderandom, outside)        else:            print("there is nowhere to enter...")            answer(currentlocation, currentlocationdescription, insiderandom, outside)    else:        print(ans, "You can't do that!")        answer(currentlocation, currentlocationdescription, insiderandom, outside)startgame(random.choice(locationsoutside), random.choice(adjectiveslocation), random.choice(locationsinside), outside)

Text Adventure Game

New random location on every move

My role: I wrote the whole game in Python: the command input, the random location generator and the inside/outside system.

A text-based exploration game written in Python. You start lost in a random place and type commands to move around: directions like north or forward, plus enter and leave to go in and out of buildings. Every move generates a new location, sometimes with a building nearby, and once you're inside you can't wander off, you'll just bump into a wall.

What I'd improve: Replace the repeated function calls with a loop so long games can't hit Python's recursion limit, and add items to find.

Tools
Python
Year
2026
Type
School project

Want to work together?

Tell me about your next project and I'll get back to you.

Get in touch