Advertisement

Graphical Libraries for Python 3

Started by February 04, 2017 09:57 PM
7 comments, last by Dipesh 7 years, 10 months ago

I'm a college student who's been learning Python 3 for a little over two semesters now. I don't have any other programming experience. I'd like to try and make a game, but I'm not sure how to find out about the various graphical library options for python. I just want to create a simple text game to start with. I'd like to learn a library that will grow with me as I learn more. What options are there for me?

EDIT:

Okay, I learned pygame was available for python 3. I'm still trying to figure out how to install it though. I can't find a good tutorial for installing .whl files.

EDIT:

Nevermind, I managed to install pygame. Since I can't delete this thread, know any good tutorials?

Check out this free book:

https://inventwithpython.com/pygame/chapters/

It's great for beginners and is what I used when I first learned pygame.

Also, the pygame docs have links to a few tutorials.

http://www.pygame.org/docs/

Advertisement

Thanks, I wasn't sure about the tutorials they provided since many of the tutorials and the site itself seems pretty out of date.

I messed around with pygame a while ago and got basic 2D stuff working.

The basic things needed are:


"""
Imports
"""
import pygame as pg
"""
Class Game
"""
class Game():
    def __init__(self):
        self.gameLoop = True
        pg.init()
        self.screen = pg.display
        self.screen.__init__("directx")
        self.screen = pg.display.set_mode([1062, 600])

        self.mySpriteImage = pg.image.load("C:/sprite.png")
        self.mySpriteRect = self.mySpriteImage.get_rect()

    def processInput(self):
        """
        Mouse input
        """
        click = pg.mouse.get_pressed()[0]
        if click:
            p2 = [pg.mouse.get_pos()[0], pg.mouse.get_pos()[1]]
            
        """
        Keyboard input
        """
        keys = pg.key.get_pressed()
        if keys[pg.K_ESCAPE]:
            self.gameLoop = False

        if keys[pg.K_a]:
            
        elif keys[pg.K_d]:
            
        if keys[pg.K_s]:
            
        elif keys[pg.K_w]:

    """
        Main Function
        """

    def main(self):

        """
        Main Game Loop
        """
        while self.gameLoop:
            """
            Handle Input
            """
            pg.event.pump()
            self.processInput()

            """
            Update Game Objects
            """


            """
            Update Game Screen & Draw
            """
            self.screen.fill(Constants.Constants.color_black)
            self.screen.blit(self.mySpriteImage, [0, 0])

            pg.display.flip()

        """
        Game Exit
        """
        print("Game Exit\n")
        pg.quit()

Here, I just stripped down a simple project I had. Just a skeleton of basic game loop, user input, updating display/drawing images to display.

I usually program in C++, so sorry if this is ugly Python.

I'm a college student who's been learning Python 3 for a little over two semesters now. I don't have any other programming experience. I'd like to try and make a game, but I'm not sure how to find out about the various graphical library options for python. I just want to create a simple text game to start with. I'd like to learn a library that will grow with me as I learn more. What options are there for me?

EDIT:

Okay, I learned pygame was available for python 3. I'm still trying to figure out how to install it though. I can't find a good tutorial for installing .whl files.

EDIT:

Nevermind, I managed to install pygame. Since I can't delete this thread, know any good tutorials?

I am learning Python as well, and have been for the last few months. I found out that I was able to use Pycharm for the main source of my Python code. Pycharm has a similar environment to Visual Studio. Everything is organized and any errors or uncertainties in your code are color-coded. I know that Pygame is available to Python 3, but I, too, am uncertain as how to import Pygame into Python 3. I also have a very helpful Python programming book that I downloaded that is geared towards OOP and gives useful examples on creating classes, loops, etc. If you would like, I could send you the file and we can collaborate knowledge and learn more about the language together.

There is a kid on YouTube thenewboston and sendex, and they do some amazing, in depth tutorials about the backbones of game programming in Python using Pygame.

@ devn'sam91

I'm not really interested in collaborating, thanks anyway.

thenewboston and sendex do have some great videos, but I tend to learn better by reading

@ tomd1013

Thanks for the example, I'll take a look at it.

Advertisement

I'm a college student who's been learning Python 3 for a little over two semesters now. I don't have any other programming experience. I'd like to try and make a game, but I'm not sure how to find out about the various graphical library options for python. I just want to create a simple text game to start with. I'd like to learn a library that will grow with me as I learn more. What options are there for me?

EDIT:

Okay, I learned pygame was available for python 3. I'm still trying to figure out how to install it though. I can't find a good tutorial for installing .whl files.

EDIT:

Nevermind, I managed to install pygame. Since I can't delete this thread, know any good tutorials?

I am learning Python as well, and have been for the last few months. I found out that I was able to use Pycharm for the main source of my Python code. Pycharm has a similar environment to Visual Studio. Everything is organized and any errors or uncertainties in your code are color-coded. I know that Pygame is available to Python 3, but I, too, am uncertain as how to import Pygame into Python 3. I also have a very helpful Python programming book that I downloaded that is geared towards OOP and gives useful examples on creating classes, loops, etc. If you would like, I could send you the file and we can collaborate knowledge and learn more about the language together.

There is a kid on YouTube thenewboston and sendex, and they do some amazing, in depth tutorials about the backbones of game programming in Python using Pygame.

You can Install pygame from the command line via pip with the following command:

pip install pygame

than you can import it in your .py file:

import pygame

http://www.pygame.org/wiki/GettingStarted

Python is everywhere. I think there's an implementation in .NET, so most probably you could use the same libraries that .NET developers use. Its name is Ironpython, but you would need to look deeper if I'm correct, and... maybe it's not in an usable state.

I am trying to pull out python but its making me crazy . need lots of practice more and more . still Trying :)

This topic is closed to new replies.

Advertisement