Skip to main content
4 of 8
fixed up grammar, removed greetings
Quill
  • 12.1k
  • 5
  • 41
  • 94

Writing the "Camel Game" with Python

I'm currently on Ch 4 Lab 4 in Programming Arcade Games with Python and Pygame.

In this lab, I'm supposed to write the game "camel." After doing a little research on Google, I still can't find really what I'm looking for. The game seems to run ok, but I can't help but feel that something's not right. Any feedback would be greatly appreciated.

EDITED: I just realized the oasis variable isn't really in the game and I don't know how to implement it. The "natives are so and so far back" show at what mile the natives are and not necessarily how far away they are from the player how do I fix that? Also I think the variables are repeating the same numbers every time, do I include these in the loop?

import random

print("Welcome to Camel!")
print("""You have stolen a camel to make your way across the great Mobi desert.
The natives wnat their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
print()

#variables
milesTraveled = 0
thirst = 0
camelFatigue = 0
nativesTraveled = -20
canteen = 3
nativesBehind = random.randrange(7, 15)
fullSpeed = random.randrange(10, 21)
moderateSpeed = random.randrange(5, 13)
oasis = random.randrange(1, 21)
done = False

#start main loop
while not done:
    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    userInput = input("Your choice? ")
    if userInput.lower() == "q":
            done = True

#status
    elif userInput.lower() == "e":
        print("Miles traveled: ",milesTraveled)
        print("Drinks in canteen: ",canteen)
        print("Your camel has ",camelFatigue,"amount of fatigue.")
        print("The natives are ",nativesTraveled,"miles behind you.")

#stop for night
    elif userInput.lower() == "d":
        camelFatigue *= 0
        print("Your camel feels refreshed and happy his fatigue is now ",camelFatigue)
        nativesTraveled += nativesBehind
        
#move full speed
    elif userInput.lower() == "c":
        print("You traveled ",fullSpeed,"miles!")
        milesTraveled += fullSpeed
        thirst += 1
        camelFatigue += random.randrange(1, 4)
        nativesTraveled += nativesBehind

#move moderate speed
    elif userInput.lower() == "b":
        print("You traveled ",moderateSpeed,"miles!")
        milesTraveled += moderateSpeed
        thirst += 1
        camelFatigue += 1
        nativesTraveled += nativesBehind

#drink canteen
    elif userInput.lower() == "a":
        if canteen == 0:
            print("You're out of water.")
        else:
            canteen -= 1
            thirst *= 0
            print("You have ",canteen,"drinks left and you are no longer thirsty.")
    elif oasis:
        camelfatigue *= 0
        thirst *= 0
        canteen *= 0
        print("Lucky you, you have found an oasis. Your canteen is filled, your camel is rested, and you have no thirst.")
            
#not done check
    if milesTraveled >= 200 and not done:
        print("You made it across the desert, you win!")
        done = True
    if nativesTraveled >= milesTraveled and not done:
        print("The natives caught and beheaded you.")
        print("You're dead!")
        done = True
    if nativesTraveled <= -15 and not done:
        print("The natives are drawing near!")
    if thirst > 4 and thirst <= 6 and not done:
        print("You are thirsty")
    if thirst > 6:
        print("You died of thirst!")
        done = True
    if camelFatigue > 5 and camelFatigue <= 8 and not done:
        print("Your camel is getting tired.")
    if camelFatigue > 8:
        print("Your camel is dead.")
        done = True