d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Python / Pygame (help) > Animated Background?
Add Reply New Topic New Poll
Member
Posts: 35,078
Joined: Jun 18 2008
Gold: 0.00
May 29 2014 12:06am
I'm in the early stages of learning how to code (python 2.76 is my first language) and one thing that's bugging me is not being able to make animated backgrounds.

Anyone wish to help me out by giving me an example of how to do this? ^_^

If you want you can just add it to this basic python/pygame script.

Code
bif = "bg.jpg"
mif = "rectile.gif"

import pygame, sys, pygame.mixer
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((480,320),0,32)
sound = pygame.mixer.Sound("music.wav")

sound.play(loops=999)

background = pygame.image.load(bif).convert()
mouse_c = pygame.image.load(mif).convert_alpha()

while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()

screen.blit(background, (0,0))

x,y = pygame.mouse.get_pos()
x -= mouse_c.get_width()/2
y -= mouse_c.get_height()/2

screen.blit(mouse_c,(x,y))



pygame.display.update()


This post was edited by Metalkon on May 29 2014 12:22am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 29 2014 06:06am
http://www.pygame.org/docs/ref/image.html
Quote
GIF (non animated)

you can't use animated gifs. split it up into multiple images, then rotate between them with a delay.

http://www.gamedev.net/topic/459408-pygame-animated-gif/

why are you even trying a game when you don't know how to code? you'll constantly run into road blocks.

This post was edited by carteblanche on May 29 2014 06:12am
Member
Posts: 28
Joined: May 24 2014
Gold: 26.84
May 30 2014 12:40am
Where have you started learning Python? I'm interested to try it too but dunno where would be best place to start.
Member
Posts: 35,078
Joined: Jun 18 2008
Gold: 0.00
May 30 2014 01:38am
Quote (Python_Supernova @ May 30 2014 03:40am)
Where have you started learning Python? I'm interested to try it too but dunno where would be best place to start.


codeacademy (website)
thenewboston (youtube channel)
Member
Posts: 73
Joined: May 31 2014
Gold: 0.00
May 31 2014 02:55pm
Try with some books for beginners like Learning Python (5th Edition) from O'Reilly Media, Python Essential Reference (4th Edition) from Addison-Wesley Professional
or Think Python from O'Reilly Media.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll