developer.ibm.com

Bare-Bones Pygame Platformer Starter (opens in new tab)

Discussed on DEV

This Python pygame code is based on the JavaScript code and algorithms described in this article. import pygame W = 600 H = 300 S = 20 # pygame setup pygame.init() screen = pygame.display.set_mode((W, H)) clock = pygame.time.Clock() running = True # game setup player = pygame.Rect( (50, 50), (S, S) ) v = pygame.Vector2(0, 0) g = pygame.Vector2(0, 1) # platforms platforms = [ pygame.Rect((25, 100), (100, 50)), pygame.Rect((125, 125), (100, 50)) ] while running: # poll for events for event in p...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help