0

This code works in my pycharm but not in IDLE, they both are running 3.7. When I run it in IDLE I get a "<rect(0, 0, 750, 750)>" spam in the console. If I drag the window around it will grab the background color I have set.

import pygame
import random

blue = (135, 206, 250)
black = ( 0, 0, 0)
white = ( 255, 255, 255)

gravity = 1 # speed
FPS = 60 #FPS
width = 750
height = 750
snowSize = 8
snowNum = 50

varHeight = height
snowColour = white
bgColour = blue


# Intialize the pygame
pygame.init()

# create the screen
screen = pygame.display.set_mode((750, 750))


#Font
myfont = pygame.font.SysFont('Comic Sans MS', 25)


#Title and Icon
pygame.display.set_caption("Christmas Card")

#player
playerImg = pygame.image.load('C:/Users/Owner/Desktop/tammy program/untitled-2.png')
playerX = 300
playerY = 350

#player2
playerImg2 = pygame.image.load('C:/Users/Owner/Desktop/tammy program/tree.png')
player2X = 5
player2Y = 5

snowFlake = []
for q in range(snowNum):
    x = random.randrange(0,width)
    y = random.randrange(0,varHeight)
    snowFlake.append([x,y])
clock = pygame.time.Clock



def player():
    screen.blit(playerImg, (playerX, playerY))

def player2():
    screen.blit(playerImg2, (player2X, player2Y))

def greeting():
    screen.blit(textsurface, (300, 0))

# Game Loop
running = True
while running:
    # Screen Color
    screen.fill((125, 205, 255))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    textsurface = myfont.render('Merry Christmas', False, (0, 0, 0))
    greeting()
    player()
    player2()

    for i in snowFlake:
        i[1] += gravity

    pygame.draw.circle(screen, snowColour, i, snowSize)

    if i[1] > varHeight:
        i[1] = random.randrange(-50, -5)
        i[0] = random.randrange(width)

    pygame.display.flip()

    pygame.display.update()
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    That's not an error. You're printing a rectangle object somewhere. – Carcigenicate Dec 24 '19 at 00:08
  • If you're printing it on every iteration of the game loop then I'd guess pycharm is ticking a counter up of how many times it printed the same thing and idle is writing out to the rect repeatedly like an errant schoolboy. – Jared Smith Dec 24 '19 at 00:53
  • @JaredSmith Your comment is cute but the analogy is wrong. The IDLE Shell is like a slavishly obedient student that displays exactly what is requested, just like Python run in a system terminal. This is an IDLE design goal. – Terry Jan Reedy Dec 24 '19 at 17:12
  • Kyle, run you program in the system terminal or console with "python " (or 'python3', depending on system). I expect you should see the same repeated "", since that is coming from python, not IDLE. – Terry Jan Reedy Dec 24 '19 at 17:15
  • @TerryJanReedy I made the comment as a joke because having a schoolchild write out the same thing over and over again, say 100x, on a blackboard was a common punishment when I was a child. And I haven't ever really used IDLE: python wasn't my first language and I already had usage expectations built around a CLI. I didn't mean to imply it's behavior was somehow unreasonable. – Jared Smith Dec 26 '19 at 15:11

0 Answers0