Jump to content

help with pygame coding [Python3 & Pygame]

12andCounting

so i have pygame installed becase when i do import pygame in the shell it doesn't give me a error saying it cant find pygame as you see here (http://prntscr.com/8n5g41)

 

but when i made my code i wanted to see if the window would show up this happened  as you see here (http://prntscr.com/8n5gau)

 

and this is my code 

 

 import pygame pygame.init()gameDisplay = pygame.display.set_mode((800,600))pygame.display.set_caption('drivin meh truck-by me')clock = pygame.time.clock() crashed = False while not crashed:     for event in pygame.event.get():        if event.type == pygame.QUIT:            crashed = True         print (event)     pygame.display.update()    clock.tick(60) pygame.quit()quit()
Link to comment
Share on other sites

Link to post
Share on other sites

I think this is an error linking your pygame library location, the compiler doesnt know where to get the files from

 

not sure how to fix it, but search google for "pygame init compile error" and you will probably find tons of posts on stackoverflow on how to fix it

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
Share on other sites

Link to post
Share on other sites

I think this is an error linking your pygame library location, the compiler doesnt know where to get the files from

 

not sure how to fix it, but search google for "pygame init compile error" and you will probably find tons of posts on stackoverflow on how to fix it

okay i did that and it said i probably have a folder name pygame that's masking the pygame file and i do have a folder name pygame but it has all the .h files in it so idk why it doesn't work. humm

Link to comment
Share on other sites

Link to post
Share on other sites

okay i did that and it said i probably have a folder name pygame that's masking the pygame file and i do have a folder name pygame but it has all the .h files in it so idk why it doesn't work. humm

It needs to find the built Python version of pygame not the source, which should have been installed into your lib folder in Pythons root directory. Try moving that pygame folder you have somewhere else.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

okay so i had a rar on my desktop with a pygame folder it was using i moved that to my pyton34 folded and now i get a error saying my clock = pygame.time.clock() has no attribute 

Link to comment
Share on other sites

Link to post
Share on other sites

the box shows up but it doesn't do what its supposed to because its stopping at the clock code 

Link to comment
Share on other sites

Link to post
Share on other sites

is it just saying i don't have/it cant find the file that has to clock attribute?

No, it's saying there is no "clock", go back to whatever tutorial you're using and reread the code and make sure you copied it correctly.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

No, it's saying there is no "clock", go back to whatever tutorial you're using and reread the code and make sure you copied it correctly.

wow it was a capital C in time.clock the little details 

Link to comment
Share on other sites

Link to post
Share on other sites

i have a new problem now this shows up http://prntscr.com/8n6ghh

 

this is were the code is 

 

 def things(thingx, thingy, thingw, thingh, color):    pygame.draw.rect(gameDisplay, color,[thingx, thingy, thingw, thingh]) 
Link to comment
Share on other sites

Link to post
Share on other sites

Try using round brackets, instead of square ones around [thingx... y... w... h]

Eeh, by gum.
 

ThrustJetViperPowerMustang: FX-6100 @4.4GHz (Stock Cooler) / 4x4GB Hyperam @ 1333MHz / OCZ Octane 250GB SSD / Asus HD6670 2GDDR3 / Asus M5A78LM-USB3

Link to comment
Share on other sites

Link to post
Share on other sites

Try using round brackets, instead of square ones around [thingx... y... w... h]

i still get the Rect argument is invalid and i changed it to ( then i tired { and then [ and same error every time. and i even went to pgames site looked up the code for drawing a rectangle and coped it and pasted it and it was the exact same so it still gave me the error  

Link to comment
Share on other sites

Link to post
Share on other sites

now i have a new problem i had this yesterday and fixed it on my own but now i dont remember how i did and cant see how i can,

 

its a syntax error in the work that highlighted red in this pic http://prntscr.com/8ne8mm

 

and this is the code

 def game_intro():    intro = True     while game_intro:        for event in pygame.event.get():            if event.type == pygame.QUIT:                pygame.quit()                quit()                        gameDisplay.fill(white)        LargeText = pygame.font.Font('freesansbold.ttf',40)        TextSurf, TextRect = text_objects("Drivin Meh Truck by GeeZillion",LargeText)        TextRect.center = ((display_width/2),(display_height/4))        gameDisplay.blit(TextSurf, TextRect)         pygame.draw.rect(gameDisplay, green,(150,450,100,50)                                  pygame.display.update()                      clock.tick(15)
Link to comment
Share on other sites

Link to post
Share on other sites

What error is it giving you? 
Without looking, try 'pygame.display.flip()' instead

Eeh, by gum.
 

ThrustJetViperPowerMustang: FX-6100 @4.4GHz (Stock Cooler) / 4x4GB Hyperam @ 1333MHz / OCZ Octane 250GB SSD / Asus HD6670 2GDDR3 / Asus M5A78LM-USB3

Link to comment
Share on other sites

Link to post
Share on other sites

What error is it giving you? 

Without looking, try 'pygame.display.flip()' instead

its just giving me a syntax error and only saying the syntax error is on the word python, not in .update part

Link to comment
Share on other sites

Link to post
Share on other sites

What error is it giving you? 

Without looking, try 'pygame.display.flip()' instead

get the same error with .flip

Link to comment
Share on other sites

Link to post
Share on other sites

get the same error with .flip

Syntax errors are usually on the line before the one giving the error. Stare at the line above the error long enough and you'll see what's wrong.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

Syntax errors are usually on the line before the one giving the error. Stare at the line above the error long enough and you'll see what's wrong.

i see now i missed a parenthese. i didn't know the error was usually the line about it so i didn't even look at it 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×