First Game

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

ter in another number from 0 - 255.

"))
if color_create_3 > 255:
color_create_3 = 255
player_color = (color_create_1, color_create_2, color_create_3)
print("The color that you created is (" + str(color_create_1) + "," +
str(color_create_2) + "," + str(color_create_3) + ")")
if color_create == "n":
print("You have chosen to not create your own color.")
print("Your character color options are:")
print("Blue: b " + str(BLUE))
print("Purple: p " + str(PURPLE))
print("Maroon: m " + str(MAROON))
player_choice = input("Enter in the lowercase letter of the color that you
chose. (b/p/m) ")
pygame.time.wait(100)
if player_choice == "b":
print("Your player color is Blue")
player_color = BLUE
if player_choice == "p":
print("Your player color is Purple")
player_color = PURPLE
if player_choice == "m":
print("Your player color is Maroon")
player_color = MAROON
'''
input("Press enter to continue.")
print("\n" * 10)
w_key_down = False
s_key_down = False
a_key_down = False
d_key_down = False
corner1 = False
corner2 = False
corner3 = False
corner4 = False
corner5 = False
corner6 = False
corner7 = False
corner8 = False
'''
window = pygame.display.set_mode([50,50])
window.fill(WHITE)
pygame.draw.circle(window, player_color, (25,25), 10)
pygame.display.flip()
print("This is what your character looks like.")
player_name = input("What is your character's name?")
print()
input("Press enter to begin the game.")
pygame.time.wait(100)
playing = True
w = pygame.display.set_mode([100,100])
w.fill(GRAY)
y_move = 10
x_move = 10
win = False
pygame.draw.circle(w, player_color, (x_move,y_move), 5)
while playing:
w.fill(GRAY)
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
y_move -= 5
if event.key == pygame.K_s:
y_move += 5
if event.key == pygame.K_a:
x_move -= 5
if event.key == pygame.K_d:
x_move += 5
'''
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
w_key_down = True
while w_key_down:
pygame.display.flip()
y_move -= 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
w_key_down = False
if event.key == pygame.K_s:
s_key_down = True
while s_key_down:
pygame.display.flip()
y_move += 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
s_key_down = False
if event.key == pygame.K_a:
a_key_down = True
while a_key_down:
pygame.display.flip()
x_move -= 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
a_key_down = False
if event.key == pygame.K_d:
d_key_down = True
while d_key_down:
pygame.display.flip()
x_move += 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
d_key_down = False
'''
pygame.draw.circle(w, player_color, (x_move,y_move), 5)
#pygame.draw.polygon(w, RED, [(50,50), (75,50), (75, 25), (50,25)], 5)
#pygame.draw.polygon(w, RED, [(100,100), (125,100), (125, 75), (100,75)], 5)
pygame.draw.circle(w, GREEN, (75,75),5)

if x_move == 75 and y_move == 75:


win = True
break
'''
if x_move == 50 and y_move == 50:
corner1 = True
if x_move == 75 and y_move == 50:
corner2 = True
if x_move == 75 and y_move == 25:
corner3 = True
if x_move == 50 and y_move == 25:
corner4 = True
if x_move == 100 and y_move == 100:
corner5 = True
if x_move == 125 and y_move == 100:
corner6 = True
if x_move == 125 and y_move == 75:
corner7 = True
if x_move == 100 and y_move == 75:
corner8 = True
if corner1 and corner2 and corner3 and corner4 and corner5 and corner6 and
corner7 and corner8:
win = True
'''
pygame.display.flip()
if win == True:
print()
print()
print("------------------------------")
print("------------------------------")
print("------------------------------")
print("--------- You Win " + player_name + " ---------")
print("------------------------------")
print("------------------------------")
print("------------------------------")

'''
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
w_key_down = True
while w_key_down:
y_move -= 1
if event.type == pygame.KEYUP:
w_key_down = False
if event.key == pygame.K_s:
s_key_down = True
while s_key_down:
y_move += 1
if event.type == pygame.KEYUP:
s_key_down = False
if event.key == pygame.K_a:
a_key_down = True
while a_key_down:
x_move -= 1
if event.type == pygame.KEYUP:
a_key_down = False
if event.key == pygame.K_d:
d_key_down = True
while d_key_down:
x_move += 1
if event.type == pygame.KEYUP:
d_key_down = False

'''

"""
LESSON: 3.3 - Animation
EXERCISE: Code Your Own

TITLE: Small Movement Game


DESCRIPTION: Use WASD
"""

import pygame
import random
pygame.init()

BLUE = (36, 43, 171)


RED = (235, 64, 52)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (38, 173, 40)
PURPLE = (161, 39, 232)
MAROON = (110, 16, 16)
GRAY = (91, 89, 92)

print("Welcome to a small Puzzle Game")


print("Use the WASD to maneuver your character.")
print()
print("The goal of the game is to get to the center of the Green Circle.")
print()
print()

color_create = input("Before we begin, would you like to create your own color for
your character? (y/n) ")
if color_create == "y":
print("You have chosen to create your own color.")
color_create_1 = int(input("Enter in a number from 0 - 255. "))
if color_create_1 > 255:
color_create_1 = 255
color_create_2 = int(input("Enter in another number from 0 - 255. "))
if color_create_2 > 255:
color_create_2 = 255
color_create_3 = int(input("Enter in another number from 0 - 255. "))
if color_create_3 > 255:
color_create_3 = 255
player_color = (color_create_1, color_create_2, color_create_3)
print("The color that you created is (" + str(color_create_1) + "," +
str(color_create_2) + "," + str(color_create_3) + ")")
if color_create == "n":
print("You have chosen to not create your own color.")
print("Your character color options are:")
print("Blue: b " + str(BLUE))
print("Purple: p " + str(PURPLE))
print("Maroon: m " + str(MAROON))
player_choice = input("Enter in the lowercase letter of the color that you
chose. (b/p/m) ")
pygame.time.wait(100)
if player_choice == "b":
print("Your player color is Blue")
player_color = BLUE
if player_choice == "p":
print("Your player color is Purple")
player_color = PURPLE
if player_choice == "m":
print("Your player color is Maroon")
player_color = MAROON
'''
input("Press enter to continue.")
print("\n" * 10)
w_key_down = False
s_key_down = False
a_key_down = False
d_key_down = False
corner1 = False
corner2 = False
corner3 = False
corner4 = False
corner5 = False
corner6 = False
corner7 = False
corner8 = False
'''
window = pygame.display.set_mode([50,50])
window.fill(WHITE)
pygame.draw.circle(window, player_color, (25,25), 10)
pygame.display.flip()
print("This is what your character looks like.")
player_name = input("What is your character's name?")
print()
input("Press enter to begin the game.")
pygame.time.wait(100)
playing = True
w = pygame.display.set_mode([100,100])
w.fill(GRAY)
y_move = 10
x_move = 10
win = False
pygame.draw.circle(w, player_color, (x_move,y_move), 5)
while playing:
w.fill(GRAY)
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
y_move -= 5
if event.key == pygame.K_s:
y_move += 5
if event.key == pygame.K_a:
x_move -= 5
if event.key == pygame.K_d:
x_move += 5
'''
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
w_key_down = True
while w_key_down:
pygame.display.flip()
y_move -= 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
w_key_down = False
if event.key == pygame.K_s:
s_key_down = True
while s_key_down:
pygame.display.flip()
y_move += 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
s_key_down = False
if event.key == pygame.K_a:
a_key_down = True
while a_key_down:
pygame.display.flip()
x_move -= 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
a_key_down = False
if event.key == pygame.K_d:
d_key_down = True
while d_key_down:
pygame.display.flip()
x_move += 1
for event in pygame.event.get():
if event.type == pygame.KEYUP:
d_key_down = False
'''
pygame.draw.circle(w, player_color, (x_move,y_move), 5)
#pygame.draw.polygon(w, RED, [(50,50), (75,50), (75, 25), (50,25)], 5)
#pygame.draw.polygon(w, RED, [(100,100), (125,100), (125, 75), (100,75)], 5)
pygame.draw.circle(w, GREEN, (75,75),5)

if x_move == 75 and y_move == 75:


win = True
break

'''
if x_move == 50 and y_move == 50:
corner1 = True
if x_move == 75 and y_move == 50:
corner2 = True
if x_move == 75 and y_move == 25:
corner3 = True
if x_move == 50 and y_move == 25:
corner4 = True
if x_move == 100 and y_move == 100:
corner5 = True
if x_move == 125 and y_move == 100:
corner6 = True
if x_move == 125 and y_move == 75:
corner7 = True
if x_move == 100 and y_move == 75:
corner8 = True
if corner1 and corner2 and corner3 and corner4 and corner5 and corner6 and
corner7 and corner8:
win = True
'''
pygame.display.flip()
if win == True:
print()
print()
print("------------------------------")
print("------------------------------")
print("------------------------------")
print("--------- You Win " + player_name + " ---------")
print("------------------------------")
print("------------------------------")
print("------------------------------")

'''
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
w_key_down = True
while w_key_down:
y_move -= 1
if event.type == pygame.KEYUP:
w_key_down = False
if event.key == pygame.K_s:
s_key_down = True
while s_key_down:
y_move += 1
if event.type == pygame.KEYUP:
s_key_down = False
if event.key == pygame.K_a:
a_key_down = True
while a_key_down:
x_move -= 1
if event.type == pygame.KEYUP:
a_key_down = False
if event.key == pygame.K_d:
d_key_down = True
while d_key_down:
x_move += 1
if event.type == pygame.KEYUP:
d_key_down = False
'''

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy