clear-code-projects / ultimatepygameintro Goto Github PK
View Code? Open in Web Editor NEWThe project for the ultimate introduction to pygame. Link: https://youtu.be/AY9MnQ4x3zk
The project for the ultimate introduction to pygame. Link: https://youtu.be/AY9MnQ4x3zk
make the screen on the game any size instead of a fixed size.
screen = pygame.display.set_mode((800,400),pygame.RESIZABLE)
Provide requirements.txt
I just completed the section of the video where you add the feature that adds snails by constantly adding them to an empty list but it spawns so many snails at once and they all over lap was trying to figure out if this is just something that can happen and will get fixed or if I messed up somewhere and need it fixed
Consider writing Python code meeting the PEP 8 standards:
https://www.python.org/dev/peps/pep-0008/
Sky.png and ground.png are the names used in the graphics folder. The difference in capitalization convention may throw off new programmers.
(Fantastic video by the way- this is the gold standard I'll be measuring other coding tutorials against from now on)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/home/emsi/PycharmProjects/UltimatePygameIntro/runner_class only.py", line 106, in <module>
player.add(Player())
File "/home/emsi/PycharmProjects/UltimatePygameIntro/runner_class only.py", line 8, in __init__
player_walk_1 = pygame.image.load('graphics/player/player_walk_1.png').convert_alpha()
FileNotFoundError: No file 'graphics/player/player_walk_1.png' found in working director```
Clearly there is no player
directory. It is Player
.
I don't know if my code is wrong but when I run it, it said that. Here's my code:
`import pygame
from sys import exit
pygame.init()
screen = pygame.display.set_mode((800, 400))
pygame.display.set_caption('Runner')
clock = pygame.time.Clock()
test_font = pygame.font.Font('Pixeltype.ttf', 50)
sky_surface = pygame.image.load('Sky.png').convert()
ground_surface = pygame.image.load('ground.png').convert()
test_surface = test_font.render('My game', False, 'Black')
snail_surface = pygame.image.load('snail1.png').convert_alpha()
snail_x_pos = 600
player_surf = pygame.image.load('player_walk_1.png').convert_alpha()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
screen.blit(sky_surface, (0, 0))
screen.blit(ground_surface, (0, 300))
screen.blit(test_surface, (300, 50))
snail_x_pos -= 4
if snail_x_pos < -100: snail_x_pos = 800
screen.blit(snail_surface, (snail_x_pos, 250))
screen.blit(player_surf(60,200))
pygame.display.update()
clock.tick(60)`
I'm currently using PyCharm Community Edition 2023.1.3.
At approx 1:21:00 in the tutorial a pink rect is drawn behind the score and a second one is drawn as an outlined rectangle to make it larger. This worked because the border was drawn half inside and half outside the rect. This no longer works.
From the pygame site:
"Changed in pygame 2.1.1: Drawing rects with width now draws the width correctly inside the rect's area, rather than using an internal call to draw.lines(), which had half the width spill outside the rect area."
A possible alternative could be something like:
pygame.draw.rect(screen,'Pink',score_rect.inflate(20,20))
This seems to draw an inflated box without permanently affecting the size of score_rect. I used a second pygame.draw() to confirm this by drawing score_rect in red without the inflate(). (Sorry, n00b here so I'm discovering as I write).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.