2

I'm using replit as my IDE, and I installed everything correctly. for some reason, when I run the code, it says it's running but has no pygame window in the display tab.

my code:

import pygame
import pymunk
from pymunk import pygame_util
from classes import *
from constants import *
pygame.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
space = pymunk.Space()
space.gravity = 0, gravity
draw_options = pygame_util.DrawOptions(screen)
player1 = player(100, 100, ("blue_player.png", "blue_player_hold.png"))
space.add(player1.body, player1.shape)
while running:
 space.step(1 / 60)
 clock.tick(60)
 screen.fill("white")
 
 for event in pygame.event.get():
 ...
 space.debug_draw(draw_options)
 pygame.display.flip()
julaine
2,2061 gold badge20 silver badges38 bronze badges
asked Oct 8 at 13:24
8
  • 1
    as I remeber replit needs special version of Python to display` PyGame` in web browers because pygame wasn't created to work in web browser Commented Oct 8 at 13:31
  • 1
    I've used pygame in replit in the past, and it worked fine. it displays the window in a display tab of the IDE. just in case though, the python version being run is 3.11 Commented Oct 8 at 13:32
  • did you try the simples code without images? Commented Oct 8 at 13:33
  • There aren't any images yet. I'm just trying to set up the physics. Commented Oct 8 at 13:33
  • Also the display tab is called the preview tab, sorry. Commented Oct 8 at 13:34

1 Answer 1

1

I'm not sure but when I created new project with PyGame then it didn't show it in Display or Preview tab but it opened tab VNC to redirect PyGame window to browser.

VNC to display PyGame window

You can find it in + which opens new tab:

New Tab menu


Wikipedia: VNC (for Virtual Network Computing)

answered Oct 8 at 14:00
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.