Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,321 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,717 people online right now. Registration is fast and FREE... Join Now!




Python: video system not initialized?

 
Reply to this topicStart new topic

Python: video system not initialized?

Solid
31 Aug, 2008 - 02:03 PM
Post #1

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 23

Okay so I have created a small screen, added music, and added background and it all worked out perfectly.

But I have never gotten this before???

Traceback (most recent call last):
File "C:\Documents and Settings\Owner\Desktop\Py\Python\GameName\Grassland\grassland.py", line 57, in <module>
event = pygame.event.wait ()
error: video system not initialized

I don't get it... I have used pygame.event.wait() in earlier stuff?

Can anyone tell me why it won't work. I have even tried to use the pygame.display.init() and it still won't work?
User is offlineProfile CardPM
+Quote Post

Nova Dragoon
RE: Python: Video System Not Initialized?
31 Aug, 2008 - 04:40 PM
Post #2

The Innocent Shall Suffer, Big Time
Group Icon

Joined: 16 Aug, 2001
Posts: 6,129



Thanked: 7 times
Dream Kudos: 515
Expert In: Python, Linux

My Contributions
Code you post the rest of your relevant code.
User is online!Profile CardPM
+Quote Post

Solid
RE: Python: Video System Not Initialized?
31 Aug, 2008 - 04:59 PM
Post #3

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 23

QUOTE(Nova Dragoon @ 31 Aug, 2008 - 05:40 PM) *

Code you post the rest of your relevant code.



CODE

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


class TSOH:
    def __init__(self, width=643,height=460):
        
        #Initialize Pygame
        pygame.init()
        pygame.display.init()

        self.width = width
        self.height = height

        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption('2D game')
        
        
    def MainLoop(self):

        self.LoadSprites();
        
        pygame.key.set_repeat(500, 30)

        self.background = pygame.Surface(self.screen.get_size())
        self.background = self.background.convert()
        self.background.fill((0, 0, 0))

        self.screen.blit(self.background, (0, 0))
        self.hero_sprites.draw(self.screen)
        pygame.display.flip()
        

class Hero(pygame.sprite.Sprite):

    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_image('hero.bmp',-1)
        self,y_dist = 10
        self,x_dist = 10

    def move(self, key):
        xMove = 0;
        yMove = 0;

        if (key == K_D):
            xMove = self.x_dist
        elif (key == K_A):
            xMove == -self.x_dist
        elif (key == K_W):
            yMove == self.y_dist
        elif (key == K_S):
            yMove == -self.y_dist
        self.rect.move_ip(xMove,yMove)

running = True
while running:
    event = pygame.event.wait ()
    if event.type == pygame.QUIT:
        running = False
pygame.quit()


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 07:24AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month