1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

First (kinda) Big Python Game? (amd help witrh graphic interface)

Discussion in 'Programming/Internet' started by WimJim, Oct 8, 2018.

  1. WimJim

    WimJim Guest

    Hey so I was wondering if you can see any bugs in my code, and can you maybe give me a few tips about adding a graphical interface? Thanks! Also I'm new to Stack Overflow so forgive me if the indenting is messed up.

    from random import randint
    still_afloat = True
    enemy_afloat = True
    ammo = 10
    print('Where will you place your ship?')
    your_pos = input('1,2,3,4, or 5?')
    while enemy_afloat == True and still_afloat == True:
    subm_num = randint(1,5)
    print('enemy territory ahead')
    print('A submarine somewhere.')
    print('Where do you fire?')
    print('The submarine moves each time you miss')
    target = input('1,2,3,4, or 5?')
    target_num = int(target)
    from random import randint
    sub_shot = randint(1,5)
    print('The Submarine fired at', sub_shot )

    if sub_shot == your_pos:
    still_afloat = False

    print('The Submarine Missed You')

    if target_num == subm_num:
    enemy_afloat = False

    print('You Miss!')
    print('The Submarine moves')
    ammo = ammo - 1
    print('Ammo remaining =' , ammo )

    if ammo == 0:
    print('You run out of ammo')
    print('The Submarine Escapes')
    still_afloat = False
    print('The Sub got away!')
    print('Game Over!')

    if still_afloat == False:
    print('The Submarine Sunk you')
    print('Mission Failed, We Will Get em Next Time')

    if enemy_afloat == False:
    print('You Sunk The Submarine')
    print('You Win')

    Login To add answer/comment

Share This Page