PySFML

From Chaosdorf Wiki
Revision as of 20:15, 21 August 2012 by Bison (talk | contribs)
Jump to navigation Jump to search

PySFML

Simple and Fast Multimedia Libraray and Python.

HINWEIS: PySFML funktioniert NICHT mit Python 3 (Stand: August 2012)

Installation

Howto install on

Debian/Ubuntu

Eine Shell öffnen und mit root-rechten ausführen:

apt-get install python-sfml

oder

sudo apt-get install python-sfml

Benutzung

Der Standard Import lautet:

import PySFML

Notizen/Tasks für Pythonfoo

  • The Copyconstructor ???? siehe Displaying a Sprite
  • Sprite.SetScale(2.f, 0.5f)
  • Image.GetPixel(10,20)
  • Pixelfarbe feststellen ??? mGUI->getColorAtPixel(x,y).red; ???

Speicherplatz sparen/ Resourcenoptimierung

In a more complex engine, images would be automatically handled by a manager. This is a more generic and easy way of handling resources. The idea is to make the manager store the images, associated to their filename (or whatever unique identifier), so that if the same image is requested several times, the same instance will actually always be returned by the manager.

sf::Sprite Sprite;
// GetImage will always return the same image for the same filename
Sprite.SetImage(ImageManager.GetImage("data/missile.png"));


Links

Displaying a Sprite