Answers for "python game example"

1

simple game with python

# 1 - Import library
import pygame
from pygame.locals import *

# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))

# 3 - Load images
player = pygame.image.load("resources/images/dude.png")

# 4 - keep looping through
while 1:
    # 5 - clear the screen before drawing it again
    screen.fill(0)
    # 6 - draw the screen elements
    screen.blit(player, (100,100))
    # 7 - update the screen
    pygame.display.flip()
    # 8 - loop through the events
    for event in pygame.event.get():
        # check if the event is the X button 
        if event.type==pygame.QUIT:
            # if it is quit the game
            pygame.quit() 
            exit(0)
Posted by: Guest on January-13-2021
2

how to make a game on python

#Easy game in python

import random
import time

Passwordlist = ['abc123', '1234', '123456', 'QWERT', 'ASFDJKL;', '0102', '0', '100', '1000', '10000', '123', '2048', '1024', 'JSON', '1234567890']

ans = input('Enter an account name: ')
time.sleep(1)

print('Finding the password for it...')
time.sleep(1)
print(random.choice(Passwordlist)+ ' is the password')
Posted by: Guest on October-06-2020
0

how to make a game in python

#modules required - time and random
#Game 1
#Password game
import time
import random

Password = ['1', '2', 'a', 'G', '5', '89']

answer = input('Guess the password')
print(random.choice(Password)+' is the password')
Posted by: Guest on October-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language