[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] I have had a bg but...



> for example I have 2 surfaces loaded, then how to display them ?(bg
> pic is already there)  this is my code below :
> 
> bgpic=pygame.image.load("background.jpg") 
> 
> bg=pygame.display.set_mode(bgpic.get_size())
> 
> bg.blit(bgpic, (0, 0))
> 
> kitten=pygame.image.load("cat01.jpg")
> 
> doggie=pygame.image.load("dog01.jpg")
> 

Hmm, if you read the tutorials, I think you will understand after a while.
To solve your problem, you need to blit the images to the screen like
this:

bg.blit(kitten,(15,15)) #i dont know the size of your cat and dog
bg.blit(doggie,(30,30)) #so you have to adjust the numbers yourself

I can understand your problem, bg is an images, but you can paste as many
images into it as you want. Pygame is nore low level than flash, you don't
have a image object that you can move around. In pygame you have to do it
yourself by pasting images on the screen at the position you want. 
How do I get rid of them? is the next question. Simple! You just paste the
background image on the screen again to remove everything else.

A suggestion in your code is to change the name bg to screen, since bg is
a misleading name.

bgpic = pygame.image.load("background.jpg") 
screen = pygame.display.set_mode(bgpic.get_size())
screen.blit(bgpic, (0, 0))
kitten=pygame.image.load("cat01.jpg")
doggie=pygame.image.load("dog01.jpg")
screen.blit(kitten,(15,15))
screen.blit(doggie,(30,30))

Most people write their own sprite code to get a model more
close to "a image that you can move on". Examples of such code you can
find in most games, like Solarwolf or Twitch.

If you only have programmed in flash before, you will have quite much to
learn about real programming.

/Fredrik


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org