How to code a simple python game(using vscode)

preview_player
Показать описание
MUST SAVE WITH .PY
Рекомендации по теме
Комментарии
Автор

I am planning on a voice reveal next month.

codingmaster
Автор

Here's a simpler version of the same code:

print("GHOST GAME!")
print("Three doors ahead of you, and a ghost behind one of them")
print("Which door do you want to open?")
door = input("1, 2, or 3? : ")
score = 0

if door == "1":
print("You escaped!")
score += 10

elif door == "2":
print("Ghost!!! Run!!!")
score = 0

elif door == "3":
print("You escaped!")
score += 10

print("Your score: "+ str(score))

ishanmurali
Автор

#Ghost Game
from random import randint
print('Ghost Game')
feeling_brave=True
score=0
while feeling_brave:
ghost_door = randint(1, 3)
print('Three doors ahead')
print('A ghost behind one.')
print('Which door do you open?')
door = input('1, 2, or 3?')
door_num = int(door)
if door_num == ghost_door:
print('GHOST!')
feeling_brave = False
else:
print('No ghost!')
print('Y0u enter the next room.')
score = score + 1
print('Run Away!')
print('Game over! You scored', score)

MilindScr
Автор

Y'all this version of the code fixes a flaw
# GHOST GAME

from random import randint
print('Ghost Game')
feeling_brave = True
score = 0
while feeling_brave:
ghost_door = randint(1, 3)
print('Three doors ahead...')
print('A ghost behind one.')
print('Which door do you open?')
door = input('1, 2, or 3: ')
door_num = int(door)
if door_num == ghost_door:
print('GHOST')
feeling_brave = False
elif door_num < 1 or door_num > 3:
print('Invalid choice, please choose again :)')
else:
print('No ghost!')
print('You enter the next room.')
score = score + 1
print('Run away!')
print('Game Over! You scored', score)

noeditzzone
Автор

Where is your voice? Why dont you say anything?

discovernewhere
Автор

Palistine lives matter. Save Palestine.

codingmaster
Автор

What kind of game is this?.. Nice video greet from Indonesia

ramasutjipto
Автор

To make it work when you save the file you must put .py after the name you choose. Lets say I call mine game I will save it as game.py

codingmaster
Автор

import random

score = 0

while True:

print("\nGHOST GAME!")

safe_door = str(random.randint(1, 3))

door = input("Choose a door (1, 2, or 3): ")

if door not in ["1", "2", "3"]:

print("Invalid choice.")

continue

if door == safe_door:

print("You escaped!")

score += 10

else:

print("Ghost!!! Run!!!")

score = 0

print("Your score: " + str(score))

break

print("Your score: " + str(score))

if input("Continue? (yes/no):

").strip().lower() != "yes":

print("Final score: " + str(score))

darkroblox
Автор

What language are you using and you really didn't show every single step for us to create a folder as for beginners who don't know nothing about python or what this language is but it's a nice it up😉😉

drainniend
Автор

is it supposed to run on cmd or chrome?

bloomz
Автор

(not working for me)
# Ghost Game
from random import randint
print('Ghost Game')
feelling_brave = True
score - 0
while feeling_brave:
ghost_door = randint(1, 3)
print('three doors ahead...')
print('A ghost is behind one.')
print('which door do you open?')
door = input('1, 2 or 3?')
door_num = int (door)
id door_num == ghost_door:
print('GHOST!')
feeling_brave - False
else:
print('no ghost!')
score - score + 1
print('run away!')
print('Game over! you scored', score)
(pls let me know if I made any mistakes)

kevinmoses
Автор

Can You please tell me where do i have to run the code

virajmehta
Автор

it says, there are problems in the codes. i code it on mac

Lynch
Автор

i pressed save as but the file is the code only not the game

roastingmachine
Автор

bro it is in plain text mode how did you code

இயற்கை-வல
Автор

Bro it's saving in notepad I can't run it

StarLight_