How do you Install Pygame on Pydriod 3? | Sololearn: Learn to code for FREE!

0

How do you Install Pygame on Pydriod 3?

Pygame Game

6/4/2020 12:24:54 PM

Divine Onyema

19 Answers

New Answer

+5

Thank you guys!

+4

Just go to Command prompt and type "pip" then type "pip install pygame" and then it will start installing after a few seconds it will be installed 😊

+2

Divine Onyema import pygame_sdl2 pygame_sdl2.import_as_pygame() import sys import pygame from pygame.locals import * pygame.init() # Resolution is ignored on Android surface = pygame.display.set_mode((640, 480)) ball = pygame.image.load("pydroball.png") ballrect = ball.get_rect() clock = pygame.time.Clock() width = surface.get_width() height = surface.get_height() speed = [4, 4] while True: for ev in pygame.event.get(): if ev.type == QUIT: pygame.quit() clock.tick(60) surface.fill((0, 0, 0)) ballrect = ballrect.move(speed) if ballrect.left < 0 or ballrect.right > width: speed[0] = -speed[0] if ballrect.top < 0 or ballrect.bottom > height: speed[1] = -speed[1] surface.blit(ball, ballrect) pygame.display.flip()

+1

Open app Tap the menu in top left corner Tap the "pip" option Search for pygame and install

+1

Then pls how do you import it?

+1

Is it with this line of code ? : import pygame_sdl2 pygame_sdl2.import as pygame ? Pls help me..

+1

This should be one of your first lines: import pygame

+1

Divine Onyema import pygame_sdl2 pygame_sdl2.import_as_pygame() import sys import pygame from pygame.locals import *

+1

Pls did it work for either of you? Pls give me an instance to check if it worked coz i created a width and height then added a caption i expected it was going to show at the top of my screen but it didn't pls what can i do to check if it worked?

+1

Divine Onyema Yeah it works

+1

Pls give me an instance to check if it works.. Thank you.

+1

# opens a blank window import pygame pygame.init() surface_sz = 480 main_surface = pygame.display.set_mode((surface_sz, surface_sz)) while True: ev = pygame.event.poll() if ev.type == pygame.QUIT: break

+1

Divine Onyema Welcome 🤗

+1

Pls guys python still displayed an error saying i should rather use 'pygame sdl2 rather than pygame' for instance: pygame_sdl2.display.set_mode((5, 5)) I'm confused what can i do?

+1

The warning came from the Graphical program output..

+1

And when i run that code as a script in pydriod 3 it just show me Grasshopper app from play store with this i'm i assured that the pygame installion was successful?

+1

On Pydroid pygame should be preinstalled, just import it to your program as pygame_sdl2 and you should be able to use it.

+1

Go on www.python.org