Hi, I have a question about the game I am making in pygame. In the middle of the game screen there is the "notepad" where doodles can move around and such. Around that is the "desk" the notepad is on. I have a link to a screenshot here. But underneath the "notepad" is a black box which I don't see how I coded in. Here is the basic code...

import pygame
from pygame.locals import *

pygame.init()

#create screen
screen = pygame.display.set_mode((1280, 720), pygame.FULLSCREEN)
pygame.display.set_caption('screen')

#set colors
white = (255, 255, 255)

#load images
backg = pygame.image.load('backg.png')
image1 = pygame.image.load('supptruck.png')

#set transparency codes
backg.set_colorkey(white)

walk = 0
done = False
close = False
x = 171
y = 0
keystate = pygame.key.get_pressed()

#main loop
while not close:

    #game loop
    while not done:
        #goto pause menu with escape key
        for event in pygame.event.get():
            if (event.type == KEYDOWN):
                print event
                if (event.key == K_ESCAPE):
                    pausemenu = True
                    done = True

            #detect movement left or right
            if (event.type == KEYDOWN):
                print event

                if (event.key == K_RIGHT):
                    walk = 1

                if (event.key == K_LEFT):
                    walk = 2

            if (event.type == KEYUP):
                print event
                if (event.key == K_RIGHT):
                    walk = 0

                if (event.key == K_LEFT):
                    walk = 0

        #change backdrop position
        if walk == 1:
            x -= 1

        if walk == 2:
            x += 1

        #paste images
        screen.blit(image1, (x, y))
        screen.blit(backg, (0,0))
        #update screen
        pygame.display.flip()

I am wondering if any of you guys can spot anything in it that may make that box.
Thanks!!!

Not sure, but this could do the trick.

#you should clear the screen surface before adding new stuff
#so add this codeline before the image pasting.
screen.fill((0, 0, 0))

I am posting this from iPad so sorry for the weird formatting.

Edited 3 Years Ago by pyTony: Use Markdown syntax/menus, fixed code formatting (at least 4 space indent)

Thanks so much for replying, but the black part is still there...

the backg.png is 1408x788 and th supptruck.png is 928x680.

This article has been dead for over six months. Start a new discussion instead.