Author Topic: any working pyglet roguelikes?  (Read 16296 times)

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
any working pyglet roguelikes?
« on: April 01, 2014, 08:01:38 PM »
Anyone currently got a working roguelike built on the pyglet library (Python)?  I had one in development that worked fine on my old PC, but doesn't work on my new one.  I'd like to download someone else's game and run it -- to see if the problem is my code, or my computer.

Pyglet sprites simply aren't appearing in the window (or are appearing but they're all-black or all-transparent).  I have tested the code with simpler scripts and can't make it work with any sprite or any image (however, text labels work fine).  The game doesn't know it isn't working.  No error is thrown.  My code FYI: https://github.com/joeclark77net/roguestate

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: any working pyglet roguelikes?
« Reply #1 on: April 02, 2014, 04:09:44 AM »
I give it a quick try, but couldn't get it working. It gives me the following error:

Code: [Select]
Traceback (most recent call last):
  File "roguestate.py", line 15, in <module>
    import program.window
ImportError: No module named program.window

I didn't have time to look into it more, but could do that later in the evening. It's probably just something really simple that has something to do how I'm running it and how I set up the directory and paths.
« Last Edit: April 02, 2014, 04:13:28 AM by tuturto »
Everyone you will ever meet knows something you don't.
 - Bill Nye

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: any working pyglet roguelikes?
« Reply #2 on: April 02, 2014, 05:46:52 PM »
Hm.. spritetest.py works just fine for me. But I'm testing with Python 3.3.2.

I couldn't get pyglet version working that is in dependencies directory. It seems to me that it's 2.x version and running 2to3 in order to convert it to 3.x didn't work for me. But installing pyglet with pip worked like a charm.
Everyone you will ever meet knows something you don't.
 - Bill Nye

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
Re: any working pyglet roguelikes?
« Reply #3 on: April 02, 2014, 06:06:16 PM »
Should work now.  I had some bad import statements that weren't throwing exceptions for me, and I can't figure out why.  Maybe my IDE (PyCharm) was secretly tweaking my PYTHONPATH or something.  Now the references should work.  I also have no idea which copy of pyglet was being loaded, so now it's explicitly running the one in the game's "dependencies" folder, and it should print something to the shell that says so. 

By the way, if you want to see a simpler test that still fails, just run program/sprite_test.py instead of running the whole game.

To Tuturto's comment (which just came in as I hit 'post'), I can see that the conversion from 2 to 3 failed.  I replaced the pyglet library with one from my older game which I had painstakingly converted by hand.  The problem still occurs.  Maybe I should try the pip method instead...

I'm developing and testing on Windows, so I would be curious to see if this works for anybody on a Mac or Linux system.

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
Re: any working pyglet roguelikes?
« Reply #4 on: April 02, 2014, 06:06:45 PM »
I mean I just pushed the fix right now.  Tuturto, could you try redownloading and see if it works for you?  If it fails, then I know the problem is my version of pyglet.

By the way, a successful test would mean you see TWO robots in the window.
« Last Edit: April 02, 2014, 06:08:18 PM by joeclark77 »

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: any working pyglet roguelikes?
« Reply #5 on: April 02, 2014, 06:11:12 PM »
Sure thing, I'll grab the latest version and test it.

In the meantime, I modified roguestate.py to handle modifying path slightly differently and after that the game starts up fine. I get a yellow @ on screen.

I'm running Python 3.3.2 on Linux (Lubuntu 13.4).

With the latest version from GitHub, I'll get following error:

Code: [Select]
Traceback (most recent call last):
  File "roguestate.py", line 16, in <module>
    import program.window
  File "/home/tuukka/programming/python/projects/roguestate/program/window.py", line 2, in <module>
    import dependencies.pyglet as pyglet
ImportError: No module named 'dependencies'

It might be how you are modifying the pythonpath in roguestate.py. I made a pull request that has fix that worked for me.
« Last Edit: April 02, 2014, 06:30:40 PM by tuturto »
Everyone you will ever meet knows something you don't.
 - Bill Nye

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
Re: any working pyglet roguelikes?
« Reply #6 on: April 02, 2014, 06:20:16 PM »
I'm going to downgrade to Python 3.3.5 and see if Python 3.4 is the problem.

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
Re: any working pyglet roguelikes?
« Reply #7 on: April 02, 2014, 06:32:18 PM »
I still have the same problem.

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: any working pyglet roguelikes?
« Reply #8 on: April 02, 2014, 06:36:59 PM »
Maybe it's a hardware incompatibility problem. Do you happen to have an ATI card? SO has people with similar problems: http://stackoverflow.com/questions/9693934/cant-draw-sprites-in-pyglet
Everyone you will ever meet knows something you don't.
 - Bill Nye

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
Re: any working pyglet roguelikes?
« Reply #9 on: April 02, 2014, 07:07:39 PM »
Bam! That worked.


From the linked thread:
Quote
For my installation it occurs only when 'v2i' is used; replacement with 'v2f' is a temporary workaround. For example, the sample files worked once I modified lines 368 & 372 of sprite.py since they were affected by this v2i bug.

I changed those two references and it now works.  I do have an AMD video card.  I will push to github in a few minutes.

joeclark77

  • Rogueliker
  • ***
  • Posts: 90
  • Karma: +0/-0
    • View Profile
Re: any working pyglet roguelikes?
« Reply #10 on: April 02, 2014, 07:22:17 PM »
Thanks for your help!

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: any working pyglet roguelikes?
« Reply #11 on: April 02, 2014, 07:29:01 PM »
Thanks for your help!

No problem, glad that I could help :)
Everyone you will ever meet knows something you don't.
 - Bill Nye