#๐Ÿ”’ pygame.error: video system not initialized

61 messages ยท Page 1 of 1 (latest)

spare trenchBOT
#

@frank mason

Python help channel opened

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.

frank mason
#

I've been trying to make this game for my assignment but no matter how many times I re write the code or try a different method, I will always come back to this same problem

One this I also noticed is that the import sys is greyed out which I can't figure out how to fix

Full Error:

Traceback (most recent call last):
File "Trajectory", line 92, in <module>
for event in pygame.event.get():
^^^^^^^^^^^^^^^^^^
pygame.error: video system not initialized

versed musk
#

show the code

frank mason
#

Did it not send?

versed musk
#

nope

frank mason
#

tf

versed musk
#

I can only see the error u wrote

frank mason
#

that work?

#

Could i just dm it to you, or is there another way I have to provide it on the server.

versed musk
#

use this to show code

frank mason
#

like that?

versed musk
#

yeah

frank mason
#

Awesome, duly noted thanks

#

Yeah, this is the import sys in my code

versed musk
#

why are you using sys?

#

in the code

frank mason
#

Do i not need it?

#

I was led to beleive it was required for the drag and drog functions to work. That and to fix this error

versed musk
#

no, if it was needed it wouldnt be greyed out (grey colour are for module u import but never use in your code)

frank mason
#

yeah

#

Well, i guess i'll get rid of it now then. How do i fix that error?

versed musk
#

what is the display size of the device u are using?

frank mason
#

1920 by 1080

#

16 : 9

versed musk
#

backspace the last line

#

its working

frank mason
#

No error

#

but black screen

versed musk
#

so u cant see the images u are using?

frank mason
#

the title screen background and the start button

#

I can click where the start button would be and the phase changes as it would

versed musk
#

are all the images actually present in the path u provided?

frank mason
#

yes, they are

#

If i reverted my code, they would work

#

But it seems when I get to the drag and drop part of writing my code, it does this

versed musk
#

can u try this and tell

frank mason
#

IndentationError: expected an indented block after 'for' statement on line 118

versed musk
#

oh yeah indent the if after the for loop using space or tab

frank mason
#

so like this?

#

Traceback (most recent call last):
File "Trajectory", line 139, in <module>
team_health_text = font.render(f"Health: {pet.health}", True, (255, 255, 255))
^^^^
NameError: name 'font' is not defined. Did you mean: 'float'?

versed musk
#

did u initialized the font u were going to use?

frank mason
#

wdym

#

I wasn't gonna set a font

#

I think chatgpt did that bit

versed musk
#

ah well since u are using font.render to display text u need to initialize it before

#

Initialize the font

font = pygame.font.Font(None, 36)

#

this is just an example

#

u can set it according the game u want to create

#

and add it before the while loop

frank mason
#

Sorry i was gone for a bit

#

aight i've used ur example

#

but now the reroll button is broken.

#

I think it's this

Name 'mouse_pos' can be undefined

spare trenchBOT
#
Python help channel closed

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.