#π pygamee open screen not working
107 messages Β· Page 1 of 1 (latest)
@iron vortex
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
it said pygame.init() is wrong idk why
if Python is outputting an error message when you try to run your program it would be useful if you also posted that so we can help to diagnose your problem
alright
ah you are getting an error
how i fix
also i think the pygame init call has to come last, but i'm not really sure
when you write Python code, you have to have consistent whitespace so Python knows what scope the code belongs to
I think there's a command which explains this
!indentation
ah, well
Okay so indentation refers to the whitespace (which basically just means spaces/tabs/or any other character which represents a 'space') that you put before each line. In your code you have a space before pygame.init() so the Python interpreter sees pygame.init() (note the leading space). In some languages indentation is not important but in Python you have to be careful how you indent because the interpreter uses it to determine how statements are grouped together. I can illustrate what 'grouped together' means by this example ```py
my_variable = 'hello'
another_variable = input('type a word: ') # prompt the user to input a word
if my_variable == another_variable:
# only the code we have 'indented' will be ran if the above statement is true
print('you said hello!'
else:
print('you said something else')
...
To fix your problem, you will have to remove the leading spaces on lines 3 and 5 (your linter has highlighted them in red for you)
sorry yes you're totally right
i remember pygame
ama share screen
oh ok
u rather do unity or smthn
alright, I won't be able to talk to you cause it is pretty late where I am
naw id code
4?
im talking to cat
if you could send a screenshot that would probably be fine too
i remember i memorised the default beginning for starting a basic window
no it hapen in the blink of a eye
I think you have to get voice verified to be able to stream
as soon as i open it it closes
while loop it i think
since you're running it in VSCode, there should be an error message printed in the 'Terminal' tab on the bottom of your screen like in your previous message #1312922112104730684 message
oh ill try
it said screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT = 600))
when you're debugging, you have to look at the error message that the programming language is reporting to you, not just the offended line
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Basic Window")
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
try
it said
import pygame
ModuleNotFoundError: No module named 'pygame
dude this just wont work
idk why
well u didnt install it then
wdy mean
where do i put that in
A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run:
π«‘
w
well ill tell u pygame does get very confusing pnce u get deep into the stuff
like those big games
mm where can i learn pygame code
yt?
if you're unfamiliar with some of the basics of how Python works then it may be worth reading some of the sections of the 'Automate the Boring Stuff' book (which you can read online for free) before attempting to continue with pygame. Specifically relating to your issue is this section on Control Flow and indentation (the book says 'Blocks')
it will be easier for you to write code with pygame if you understand the basics first
!res
There are some other resources here as well
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
this is where i learnt everything lol
oh ill try
definitely! It's also something that Python is used a lot for
ummmmmmm yea no idk what this is
like im pretty sure it brushes on data analysis but it goes into thingw like models and stuff i think I donβt know much but ill try learn at some point
theres so much
i watch tutorials
I usually recommend Clear Code on youtube, there are a few others too, Tech with Tim, Programming with Nick, DaFluffyPotato, but recommend being decent at python too, pygame is not really a python beginner thing
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.