Adjusted PySFML to work with the current SFML2 branch.

Note that it's just compatible. A lot of the new functionality is still in the pipeline.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1308 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
tankbo 2009-12-07 11:53:38 +00:00
parent fb7470cbc3
commit 839c80556d
29 changed files with 544 additions and 354 deletions

View file

@ -3,40 +3,40 @@
# You can notice that here we use PySFML.sf instead of just PySFML
# Therefore it won't be needed to put sf. in front of SFML classes
from PySFML.sf import *
from PySFML import sf
def Main():
Buffer = SoundBuffer()
Buffer = sf.SoundBuffer()
if not Buffer.LoadFromFile("data/fart.wav"): # Loads the sound
return
Fart = Sound(Buffer, False)
Fart = sf.Sound(Buffer, False)
WindowWidth, WindowHeight = 640, 480
App = RenderWindow(VideoMode(WindowWidth,WindowHeight,32), "Sound with PySFML", Style.Close, WindowSettings(24,8,0))
App = sf.RenderWindow(sf.VideoMode(WindowWidth,WindowHeight,32), "Sound with PySFML", sf.Style.Close, sf.ContextSettings(24,8,0))
App.SetFramerateLimit(30)
EventHandler = Event()
EventHandler = sf.Event()
InputHandler = App.GetInput()
Text = String("Turn the sound on.\nClick anywhere on the screen.\nMove the mouse. Click again.\nTry clicking in the corners.")
Text = sf.Text("Turn the sound on.\nClick anywhere on the screen.\nMove the mouse. Click again.\nTry clicking in the corners.")
Text.SetX(30.)
Text.SetY(20.)
Text.SetColor(Color(150, 100, 10, 255))
Text.SetColor(sf.Color(150, 100, 10, 255))
while App.IsOpened(): # Main loop
while App.GetEvent(EventHandler): # Event Handler
if EventHandler.Type == Event.Closed:
if EventHandler.Type == sf.Event.Closed:
App.Close()
if EventHandler.Type == Event.KeyPressed and EventHandler.Key.Code == Key.Escape:
if EventHandler.Type == sf.Event.KeyPressed and EventHandler.Key.Code == sf.Key.Escape:
App.Close()
if EventHandler.Type == Event.MouseButtonPressed and EventHandler.MouseButton.Button == Mouse.Left:
if EventHandler.Type == sf.Event.MouseButtonPressed and EventHandler.MouseButton.Button == sf.Mouse.Left:
Fart.SetPitch(1.5 - 1.*InputHandler.GetMouseY()/WindowHeight)
Fart.SetPosition( 1.*(InputHandler.GetMouseX() - WindowWidth/2)/(WindowWidth/20), 2., -2.)
Fart.Play()
App.Draw(Text)
App.Display()
App.Clear(Color.Black)
App.Clear(sf.Color.Black)
Main()