Jump to content
  • Advertisement
Sign in to follow this  
RidiculousName

Graphical Libraries for Python 3

This topic is 670 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Edited by RidiculousName

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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.

Edited by devn'sam91

Share this post


Link to post
Share on other sites

@ 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.

Share this post


Link to post
Share on other sites

 

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

Edited by mrpeed

Share this post


Link to post
Share on other sites

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. 

Edited by RenzoCoppola

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!