1
Python / Python binding buggy?
« on: September 17, 2010, 03:27:23 pm »
Nope, it also crashes when I change the state. :-/
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
def Run( self, Window ):
string = sf.String( "MenuState", sf.Font.GetDefaultFont(), 30 )
while True:
Event = sf.Event()
while Window.GetEvent(Event):
if Event.Type == sf.Event.Closed:
return GameState
Window.Clear()
Window.Draw( string )
Window.Display()
return None
Works for me. Also, you are using media since you are using a font. Can you post the error that you get when running python yourapp.py from the command line?
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
It probably doesn't find the media in both cases. Can you post the error please?
Window.Draw( sf.String( "MenuState" , sf.Font.GetDefaultFont(), 30 ) )
from PySFML import sf
class BaseState( object ):
def Run( self, Window ):
return None
class MenuState( BaseState ):
def __init__( self ):
super( MenuState, self ).__init__()
def Run( self, Window ):
while True:
Event = sf.Event()
while Window.GetEvent(Event):
if Event.Type == sf.Event.Closed:
return GameState
Window.Clear()
Window.Draw( sf.String( "MenuState" , sf.Font.GetDefaultFont(), 30 ) )
Window.Display()
return None
class GameState( BaseState ):
def __init__( self ):
super( GameState, self ).__init__()
def Run( self, Window ):
while True:
Event = sf.Event()
while Window.GetEvent(Event):
if Event.Type == sf.Event.Closed:
return None
Window.Clear()
Window.Draw( sf.String( "GameState" , sf.Font.GetDefaultFont(), 30 ) )
Window.Display()
return None
class Game:
def Run( self ):
Window = sf.RenderWindow( sf.VideoMode( 800, 600, 32 ), "PySFMLTest", sf.Style.Close )
Window.SetFramerateLimit( 60 )
Next_State = MenuState
while Next_State is not None:
State = Next_State()
Next_State = State.Run( Window )
Main = Game()
Main.Run()
You must use the DLLs provided in the SFML SDK, not another release (espacially from Creative Labs website -- this implementation is buggy, deprecated and not used anymore by SFML).
Hm... Another idea: Try to download a current OpenAL32 runtime
Wolfram, did you check the output of std::cerr (normally the console)? Isn't there any error message?
You can also try to debug your application in order to find the point where it freezes.
This is a funny and interesting thing I'd love to do, after I've worked hard on a lot of boring stuff for SFML 2.0