Coding query

This program runs OK on a Pi b+ under Wheezie but on transfering it to a Pi2 running Jessie it gives the error 'No video mode has been set'. It calls a gif file in the same directory called spritesheet.gif. I have not so far found any help in my reading; can anyone advise. The ##### is to indicate the faulty line.

Malcolm

#!/usr/bin/env python #animation.py

import pygame,sys from pygame.locals import*

pygame.init()

pygame.display.set_caption( 'Malcs Game2')

RED=(255,0,0) clock=pygame.time.Clock()

counter=0 sprites=[]

sheet=pygame.image.load('spritesheet.gif').convert_alpha()######## width=sheet.get_width() for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit()

for i in range(int(width/128)): sprites.append(sheet.subsurface(i*128,0,128,128))

ZONE.fill(RED) ZONE.blit(sprites[counter],(10,10))

counter=(counter+1)%8

clock.tick(16)

Reply to
T M Smith
Loading thread data ...

Did you type this is in yourself or did you copy it from your old Wheezie installation?

Reply to
mm0fmf

Copied from the old Wheezie

Malcolm

--
T M Smith 
Using an ARMX6 and RISC OS 5.21 in the North Riding of Yorkshire
Reply to
T M Smith

when a python program errors out it is always a good idea to copy and paste the full trace back this is usually very good at pinning down exactly where the error occurred

--
BS:	You remind me of a man. 
B:	What man? 
BS:	The man with the power. 
B:	What power? 
BS:	The power of voodoo. 
B:	Voodoo? 
BS:	You do. 
B:	Do what? 
BS:	Remind me of a man. 
B:	What man? 
BS:	The man with the power... 
		-- Cary Grant, "The Bachelor and the Bobby-Soxer"
Reply to
alister

Well I have got to admit being wrong in what I said above. I set up the PiB+ only to find the program does NOT run. The error given is 'pygame not found'. Does the above,re errors, mean keep a record of the displayed error?

Malcolm

--
T M Smith 
Using an ARMX6 and RISC OS 5.21 in the North Riding of Yorkshire
Reply to
T M Smith

I've a feeling it says a lot more than "pygame not found".

Maybe more like this:

Traceback (most recent call last): File "gametest.py", line 4, in import pygame,sys ImportError: No module named 'pygame'

So to help ensure python debugging help is accurate you should copy everything from the "Traceback..."

Your code is missing a mode setting statement. If you execute the following query:

formatting link

you will see help on how to solve this.

Reply to
mm0fmf
[snip]

Thanks for that info, a lot to get my teeth into! Looks like tomorrow night is testing time. Amazing how much info is around if you know how to find it.

Malcolm

--
T M Smith 
Using an ARMX6 and RISC OS 5.21 in the North Riding of Yorkshire
Reply to
T M Smith

pygame not found can be overcome with:

sudo apt-get install python-pygame

As for the video mode not set error:

formatting link

I believe that you need to call:

screen = pygame.display.set_mode((800, 600)) # change to the real resolution this call will actually return the surface that you want to blit on.

Sounds about right, but I have little experience with python and less with pygame.

--
Consulting Minister for Consultants, DNRC 
I can please only one person per day. Today is not your day. Tomorrow 
isn't looking good, either. 
I am BOFH. Resistance is futile. Your network will be assimilated.
Reply to
I R A Darth Aggie

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.