I just made this in a few minutes. More information coming. Last update: Sept 15, 2025
Please test your Visual Studio Code Program works by following these instructions:
Here is a set of code to run pygame which basically just opens a purple window.
# Example file showing a basic pygame "game loop"
import pygame
# pygame setup
pygame.display.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# fill the screen with a color to wipe away anything from last frame
screen.fill("purple")
# RENDER YOUR GAME HERE
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(60) # limits FPS to 60
pygame.quit()
Textbox Example Program.
# Example file showing a basic pygame "game loop"
import pygame
# pygame setup
pygame.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
# basic font for user typed
base_font = pygame.font.Font(None, 32)
user1_text = ''
user2_text = ''
# create rectangle
input1_rect = pygame.Rect(200, 200, 140, 32)
input2_rect = pygame.Rect(400, 200, 140, 32)
active1 = False
active2 = False
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
# Check for backspace
if event.key == pygame.K_BACKSPACE:
# get text input from 0 to -1 i.e. end.
if(active1):
user_text1 = user1_text[:-1]
if(active2):
user_text2 = user2_text[:-1]
# Unicode standard is used for string
# formation
else:
if(active1):
user1_text += event.unicode
if(active2):
user2_text += event.unicode
if event.type == pygame.MOUSEBUTTONDOWN:
if input1_rect.collidepoint(event.pos):
active1 = True
else:
active1 = False
if input2_rect.collidepoint(event.pos):
active2 = True
else:
active2 = False
#print(pygame.mouse.get_pos())
print("x=" + str(pygame.mouse.get_pos()[0]))
print("y=" + str(pygame.mouse.get_pos()[1]))
# fill the screen with a color to wipe away anything from last frame
screen.fill("purple")
# RENDER YOUR GAME HERE
if active1:
pygame.draw.rect(screen, (150,150,250), input1_rect)
else:
pygame.draw.rect(screen, (150, 150, 150), input1_rect)
pygame.draw.rect(screen, (150, 150, 150), input2_rect)
text1_surface = base_font.render(user1_text, True, (255, 255, 255))
text2_surface = base_font.render(user2_text, True, (255, 255, 255))
# render at position stated in arguments
screen.blit(text1_surface, (input1_rect.x + 5, input1_rect.y + 5))
screen.blit(text2_surface, (input2_rect.x + 5, input2_rect.y + 5))
# set width of textfield so that text cannot get
# outside of user's text input
input1_rect.w = max(100, text1_surface.get_width() + 10)
input2_rect.w = max(100, text2_surface.get_width() + 10)
pygame.display.flip()
clock.tick(60) # limits FPS to 60
pygame.quit()
Key resource for learning Python:
Python Tutorial (w3schools.com)
Need print command, quotes, brackets
1. Say "Hello, World!" With Python | HackerRank
Need casting, types, *,+,- and input command
2. Arithmetic Operators | HackerRank
Integer vs float division
3. Python: Division | HackerRank
Conditional Statement (Tricky, learn mod (%) first)
4. Python If-Else | HackerRank
Adding with a string, working within functions
5. What's Your Name? | HackerRank
Basic loops - for/while
6. Print Function | HackerRank
Create your own function (Tricky):
7. Write a function | HackerRank
Working with lists (takes time)
8. Lists | HackerRank
Use a list: (A little tricky)
9. Find the Runner-Up Score! | HackerRank
String manipulation (use upper() and lower() commands)
10. sWAP cASE | HackerRank
String (split)
11. String Split and Join | HackerRank
String Slicing (see example in problem definition)
12. Mutations | HackerRank
Substring - use 'in'
13. Find a string | HackerRank
String practice
14. Minion Game | HackerRank
Math practice - please sign up as needed for the competition
15. DSBN Codes Shape Math