1# 1 - Import library
2import pygame
3from pygame.locals import *
4
5# 2 - Initialize the game
6pygame.init()
7width, height = 640, 480
8screen=pygame.display.set_mode((width, height))
9
10# 3 - Load images
11player = pygame.image.load("resources/images/dude.png")
12
13# 4 - keep looping through
14while 1:
15 # 5 - clear the screen before drawing it again
16 screen.fill(0)
17 # 6 - draw the screen elements
18 screen.blit(player, (100,100))
19 # 7 - update the screen
20 pygame.display.flip()
21 # 8 - loop through the events
22 for event in pygame.event.get():
23 # check if the event is the X button
24 if event.type==pygame.QUIT:
25 # if it is quit the game
26 pygame.quit()
27 exit(0)
28
1#Easy game in python
2
3import random
4import time
5
6Passwordlist = ['abc123', '1234', '123456', 'QWERT', 'ASFDJKL;', '0102', '0', '100', '1000', '10000', '123', '2048', '1024', 'JSON', '1234567890']
7
8ans = input('Enter an account name: ')
9time.sleep(1)
10
11print('Finding the password for it...')
12time.sleep(1)
13print(random.choice(Passwordlist)+ ' is the password')
14
1# Snake Game
2
3import turtle
4import random
5import time
6
7score = 0
8
9# screen
10screen = turtle.Screen()
11screen.bgcolor("black")
12screen.title("Snake Game By Atharva")
13screen.tracer(0)
14
15# Snake
16snake = turtle.Turtle()
17snake.shape("square")
18snake.color("green")
19snake.penup()
20snake_pos = "None"
21
22# apple
23apple = turtle.Turtle()
24apple.shape("circle")
25apple.color("red")
26apple.penup()
27apple.goto(0, 100)
28
29# classes
30
31
32class SnakeMovements:
33 y = 0
34 x = 0
35 snpos = snake_pos
36
37 snpos = None
38 def main(self):
39 if self.snpos == "up":
40 self.y = snake.ycor()
41 snake.sety(self.y + 15)
42
43 if self.snpos == "down":
44 self.y = snake.ycor()
45 snake.sety(self.y - 15)
46
47 if self.snpos == "right":
48 self.x = snake.xcor()
49 snake.setx(self.x + 15)
50
51 if self.snpos == "left":
52 self.x = snake.xcor()
53 snake.setx(self.x - 15)
54
55 def SnakeUp(self):
56 self.snpos = "up"
57
58 def SnakeDown(self):
59 self.snpos = "down"
60
61 def SnakeRight(self):
62 self.snpos = "right"
63
64 def SnakeLeft(self):
65 self.snpos = "left"
66
67instanceVar = SnakeMovements()
68
69# Keyboard Binding
70
71screen.listen()
72screen.onkeypress(instanceVar.SnakeUp, "Up")
73screen.onkeypress(instanceVar.SnakeDown, "Down")
74screen.onkeypress(instanceVar.SnakeRight, "Right")
75screen.onkeypress(instanceVar.SnakeLeft, "Left")
76
77# Mainloop of the game
78
79while True:
80 if snake.distance(apple) < 20:
81 score += 1
82 print(score)
83 applex = random.randint(-290, 290)
84 appley = random.randint(-290, 290)
85 apple.goto(applex, appley)
86
87 time.sleep(0.1)
88
89 instanceVar.main()
90 screen.update()
91
1# Snake Game
2
3import turtle
4import random
5import time
6
7score = 0
8
9# screen
10screen = turtle.Screen()
11screen.bgcolor("black")
12screen.title("Snake Game By Atharva")
13screen.tracer(0)
14
15# Snake
16snake = turtle.Turtle()
17snake.shape("square")
18snake.color("green")
19snake.penup()
20snake_pos = "None"
21
22# apple
23apple = turtle.Turtle()
24apple.shape("circle")
25apple.color("red")
26apple.penup()
27apple.goto(0, 100)
28
29# classes
30
31
32class SnakeMovements:
33 y = 0
34 x = 0
35 snpos = snake_pos
36
37 snpos = None
38 def main(self):
39 if self.snpos == "up":
40 self.y = snake.ycor()
41 snake.sety(self.y + 15)
42
43 if self.snpos == "down":
44 self.y = snake.ycor()
45 snake.sety(self.y - 15)
46
47 if self.snpos == "right":
48 self.x = snake.xcor()
49 snake.setx(self.x + 15)
50
51 if self.snpos == "left":
52 self.x = snake.xcor()
53 snake.setx(self.x - 15)
54
55 def SnakeUp(self):
56 self.snpos = "up"
57
58 def SnakeDown(self):
59 self.snpos = "down"
60
61 def SnakeRight(self):
62 self.snpos = "right"
63
64 def SnakeLeft(self):
65 self.snpos = "left"
66
67instanceVar = SnakeMovements()
68
69# Keyboard Binding
70
71screen.listen()
72screen.onkeypress(instanceVar.SnakeUp, "Up")
73screen.onkeypress(instanceVar.SnakeDown, "Down")
74screen.onkeypress(instanceVar.SnakeRight, "Right")
75screen.onkeypress(instanceVar.SnakeLeft, "Left")
76
77# Mainloop of the game
78
79while True:
80 if snake.distance(apple) < 20:
81 score += 1
82 print(score)
83 applex = random.randint(-290, 290)
84 appley = random.randint(-290, 290)
85 apple.goto(applex, appley)
86
87 time.sleep(0.1)
88
89 instanceVar.main()
90 screen.update()
91 ++
1#modules required - time and random
2#Game 1
3#Password game
4import time
5import random
6
7Password = ['1', '2', 'a', 'G', '5', '89']
8
9answer = input('Guess the password')
10print(random.choice(Password)+' is the password')
11