IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Programmation multimédia/Jeux Python Discussion :

Intégration de pgu dans pygame


Sujet :

Programmation multimédia/Jeux Python

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    287
    Détails du profil
    Informations personnelles :
    Localisation : Luxembourg

    Informations forums :
    Inscription : Septembre 2004
    Messages : 287
    Points : 137
    Points
    137
    Par défaut Intégration de pgu dans pygame
    Bonjour à tous,

    Je voudrais intégrer le module PGU (http://code.google.com/p/pgu/) dans mon jeu pygame, pour simplifier mon problème, j'utilise l'exemple suivant : http://www.programarcadegames.com/py...oard_smooth.py

    Celui-ci fonctionne parfaitement, le sprite bouge doucement et à la même vitesse tant que j'appuie sur les touches de déplacement. Mais lorsque j'intégre le module pgu, le sprite ne se déplace plus de manière constante.
    Mon exemple se trouve ici : http://steamcyberpunk.net/python/

    Auriez-vous une idée d'où pourrait provenir ce problème ?

    Merci.

  2. #2
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 046
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 046
    Points : 1 376
    Points
    1 376
    Par défaut
    Peux tu mettre un lien vers un .zip fonctionnel du code ?

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    287
    Détails du profil
    Informations personnelles :
    Localisation : Luxembourg

    Informations forums :
    Inscription : Septembre 2004
    Messages : 287
    Points : 137
    Points
    137
    Par défaut
    Voici le zip : http://steamcyberpunk.net/python/pgu.zip
    Contenant le fichier /examples/move_sprite_keyboard_smooth.py fonctionnel
    et le fichier /examples/sprite_smooth.py (avec pgu) "non fonctionnel"

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    287
    Détails du profil
    Informations personnelles :
    Localisation : Luxembourg

    Informations forums :
    Inscription : Septembre 2004
    Messages : 287
    Points : 137
    Points
    137
    Par défaut
    Mon problème a été résolu grâce au développeur du jeu "pyORPG" : http://www.powrtoch.org/pyorpg/

    Voici sa réponse (en anglais) :

    A little trial and error shows that this behaviour is caused by app.init(c) on line 102-103.
    When looking through the source of PGU, you'll find the app.init() function in file pgu/gui/app.py. In the app.init() function you'll see that this pygame function is being called:
    line 104: pygame.key.set_repeat(500,30)

    This tells pygame to repeat event keys 30 times with a delay of 500 ms.

    So that leaves you with two options for fixing your problem:

    (Worst option) You can comment out line 104 in pgu/gui/app.py so that the pygame.key.set_repeat() function isn't called on app.init(), or
    (Best option) set a limit for the player velocity.

    The best gamedesign-wise option is to limit the velocity of the player. This is easily done by adding the following lines to the top of your player.update() function:

    if self.change_x > 3: self.change_x = 3
    elif self.change_x < -3: self.change_x = -3

    if self.change_y > 3: self.change_y = 3
    elif self.change_y < -3: self.change_y = -3

    These few lines limit the velocity of your player.

    If you comment out line 104 in pgu/gui/app.py, you'll risk breaking PGU.
    PGU won't be able to have key repeats in text boxes etc., requiring users to re-press the "d" buttons if they were to enter "ddddddddddddddd" in a textbox.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [JSP/Tomcat] Intégration de PHP dans Java
    Par milhouz_deglingos dans le forum Tomcat et TomEE
    Réponses: 3
    Dernier message: 17/08/2005, 12h02
  2. [XSL/JavaScript]problème d'intégration code JS dans le XSL
    Par Devil666 dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 27/04/2005, 16h36
  3. [8.0] Intégration de PostGreSQL dans une appli windows
    Par Didier69 dans le forum PostgreSQL
    Réponses: 5
    Dernier message: 27/01/2005, 16h26
  4. Intégration éditeur html dans page asp
    Par Crazyblinkgirl dans le forum ASP
    Réponses: 2
    Dernier message: 06/05/2004, 09h04
  5. [NETBEANS] Intégration de Jboss dans NetBeans
    Par Kleb dans le forum NetBeans
    Réponses: 1
    Dernier message: 09/06/2003, 18h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo