#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    232
    Rep Power
    1

    Best IDE for Pygame?


    Hello,

    So I'm currently using Pyscripter 3.3 with Python 3.3, but the thing is, whenever I try to import Pygame and actually draw something on screen like a fullscreened window, it will open a window upon execution though if I click on it, the top title bar says Pygame (not responding)

    Is this an IDE problem or my computer having problems?

    This one's a dinosaur in comparison to modern standards.

    Its got a single core AMD 3800+, Radeon X1650XT, 3 gigs of ram, and 7 gigs of hdd space left on the windows drive.

    Any ideas on an alternate IDE to use Pygame with to test out what's wrong with what I'm doing?

    Here's some example code that causes this issue, which could open up a screen normally without stalling from Pygame:

    Code:
    # Creating a window with a specific size ex:
    size = (700, 500)
    screen = pygame.display.set_mode(size)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    232
    Rep Power
    1
    Wow, as soon I was done writing the above post, I looked at the next paragraph down and the "Programming Arcade Games with Pygame" book told me that it should stall since I have to code in user input and prevent it from hanging.

    Sorry about that, either way, does anyone have a preference for the IDE they use?

    I currently use PyScripter but am willing to switch to a better IDE regardless if anyone has suggestions.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    Yes, until you have an event loop, your game will stall.

    Here is a basic template for a pygame program:
    python Code:
    import os
    import sys
    import pygame as pg
     
     
    class Control(object):
        def __init__(self,screen_size):
            pg.init()
            os.environ["SDL_VIDEO_CENTERED"] = "TRUE"
            self.screen = pg.display.set_mode(screen_size)
            self.screen_rect = self.screen.get_rect()
            self.clock = pg.time.Clock()
            self.fps = 60.0
            self.done = False
     
        def event_loop(self):
            for event in pg.event.get():
                if event.type == pg.QUIT:
                    self.done = True
     
        def update(self):
            pass
     
        def draw(self):
            pass
     
        def main_loop(self):
            while not self.done:
                self.event_loop()
                self.update()
                self.draw()
                pg.display.update()
                self.clock.tick(self.fps)
     
     
    if __name__ == "__main__":
        app = Control((500,500))
        app.main_loop()
        pg.quit()
        sys.exit()

    As for IDEs PyScripter should do fine (I find it occasionally unstable though). Check out a few others if you want but don't worry too much about it.
    -Mek
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    232
    Rep Power
    1
    Thanks a bunch!

    Yeah, I'm getting the hang of drawing stuff on the canvas, but following the overall suggested layouts pretty easy so far.

    Ah your example's in object orientated style programming. I have always struggled with that. How did you learn it because for some reason all the self.() sections always confused me, but this time around, I really want to get the hang of it.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    I learned it by doing things wrong; and doing them wrong for a long time. Eventually wrong turned into right (or at least less wrong).

    Here is my repo of object oriented pygame examples if you are interested:
    https://github.com/Mekire/meks-pygame-samples

    -Mek
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    232
    Rep Power
    1
    Hey Thanks a bunch for the links, much appreciated, bookmarked and will check out later.

IMN logo majestic logo threadwatch logo seochat tools logo