Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


K1NNY

Member Since 06 Sep 2011
Offline Last Active Mar 02 2013 10:23 AM

Posts I've Made

In Topic: Trouble with importing my own modules

02 March 2013 - 10:26 AM

As ultramailman mentioned, you initialized "WHITE" but never used it anywhere. The value is correct for a true white color, it just comes down to setting the color of the screen. 

 

 

 

screen.fill(WHITE); 
 

 

 

and after that you are going to want to make sure that you use pygame's flip method to properly display the screen. 

 

 

 

pygame.display.flip();
 

 

I'm not sure why it isn't in the code sections above but i called for "DISPLAY" to be filled "WHITE" and it is not working. I combined CreateDisplay.py and Game.py, and added pygame.diplsay.flip() to the Game() definition and it works fine now. I assumed having pygame.display.update() in Main.py would be enough.


In Topic: Trouble with importing my own modules

28 February 2013 - 10:22 PM

Why are you importing CreateDisplay into Main.py? You are not using it. Anyway, I suspect the problem is you are trying to use python modules like C++ headers. You import pygame three times, once in each file. Each file will have a separate, distinct pygame object (or whatever it is). What you should do is create your stuff in the main script, and pass it to the other scripts. But for simplicity I suggest you stick to a single file for now.

 

I've made many programs using one file and am doing my new project this way to learn how to properly do it. So I should only import pygame in Main.py?


In Topic: import issues in Python

08 November 2012 - 04:11 PM

Thanks for the help. I planned on moving all the keyboard input events into check_input() i was just testing it first. And i'm still not sure whats causing the display (or the while loops) to update.

In Topic: import issues in Python

08 November 2012 - 01:44 PM


the suggestion you gave earlier worked after i changed around some stuff. now im having problems with the most basic things in my program like switching while loops which doesnt work at all now.

Post the part that is problematic with error lines


i wish i could but it doesn't show an error. it gets the input, it just doesn't switch while loops. the code for detecting the input is in my check_input definition here:

[source lang="python"]######check input definition####################################def check_input(): for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_a: global a print "detection" a.draw(DISPLAY) if event.key == pygame.K_F1: terminal = False inst_prgrms_scrn = True if event.key == pygame.K_F5: terminal = False slaves_scrn = True if event.key == pygame.K_SLASH: terminal = False help_page_1 = True[/source]

none of these work including when i try to draw "a" to the screen, but it does detect some input because it will print "detection".

In Topic: import issues in Python

08 November 2012 - 12:36 PM

Ok, I tried. Created both files and run root.py but now i am missing textrect because i get error at the line import textrect
Since Letter.py is not so big file I would suggest you first try moving everything in one file till it works and then separate class letter in its own file after that. Well that was what I did in myPong and it worked.


the suggestion you gave earlier worked after i changed around some stuff. now im having problems with the most basic things in my program like switching while loops which doesnt work at all now.

PARTNERS