Author Topic: Announcing: SkeletonGame - Making PyProcGame programming a little easier  (Read 15203 times)

Mark Jarzewiak

  • Wizard
  • *****
  • Posts: 244
  • Mark Jarzewiak
    • View Profile
Oh, didn't see this yesterday.  Sorry, been busy at work.  I've been waiting to release my Pinbot 2.0 code until after this so will go ahead and release it this weekend.  It will hopefully be useful as an example of how powerful Michael's framework is, as I have very little code of my own compared to how much functionality I've got.

I do want to say that I am new-ish to python, so while it's an example, it might in places be an example of what NOT to do :)

Dan

Interested in seeing your development.  Possibly going to borrow a Nascar or CFTBL and try out some reruling while I shop my FH and do some PF touchup, then I'm gonna try a FH x.0

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Dan's code has a few pieces I pulled out at the last minute (e.g., the skillshot mode), but by and large looking here might give you a reasonable sense of how a "naked" game looks:

https://github.com/mjocean/PyProcGameHD-SkeletonGame/tree/master/SampleGame

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Okay, I have posted the start of a display architecture "user's guide" to assist in using the DMD in PyProcGameHD (and it also details how things work in PyProcGame, and contrasts some differences between PyProcGame and PyProcGameHD).

You can find it here:
http://mjocean.github.io/PyProcGameHD-SkeletonGame/DMD_Tutorial.html

It is incomplete, but it's a start, and hopefully will help... I have a LOT more to add :)

More docs coming. Mostly about dmd examples and differences from the other versions.


Nice to know you listen to me, sometimes. ;-)

On a serious note there are some things that are different and if you migrate existing code, you will likely run into some issues, but none will be true show stoppers, they will just require some modifications.  In addition, there is code you can likely pull out if you wanted to, but would be necessary to do so. The professor and I will be happy to provide guidance and assistance for those who decide to move to the HD framework.

As I have mentioned before, the biggest changes that could effect code are around the assetManager and whether you are using fonts before that is done and that fact that layers are now have transparent rather than having a black background.  However, there is a great opportunity for you in the process to see where you have lower layers being drawn that are likely not supposed to be, and that would be due to not using the 'opaque' feature properly.  Fixing that in this process will improve performance of your machine. However, it will likely not find all of the places.

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
I've made another pass over the docs, and added some sorely missing pieces. There's a lot to document, and in this last pass I tried to shorten some passages for the sake of clarity.

You can find the docs and the GitHub repo, here:  http://pinballprogramming.com

Thanks
- Michael

Curbfeeler

  • Wizard
  • *****
  • Posts: 239
  • Dan - Des Moines, IA
    • View Profile
Hi guys.  Sorry for the delay.  I'm not great at GIT, but here is my Pinbot project for now.  Lots of gameplay videos here and on pinside if you want to follow along with the code and get an idea of what is possible using Michael's framework and a surprisingly tiny amount of code. 

I still need to figure out how to make Michael's procgame into a github submodule, so for now that folder is missing, but at least you can see my code (as promised).

http://github.com/Curbfeeler/Pinbot-AdvGame

Dan

PJmckevitt

  • Jr. Member
  • **
  • Posts: 27
    • View Profile
Hello, I tried to do a install of the PyprocgameHD+Skeleton today. On the step Import procgame.game I receive an error

>>> import procgame.game
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "procgame\game\__init__.py", line 11, in <module>
    from basicgame import *
  File "procgame\game\basicgame.py", line 2, in <module>
    from ..dmd import DisplayController, font_named
  File "procgame\dmd\__init__.py", line 18, in <module>
    from dmd import *
  File "procgame\dmd\dmd.py", line 4, in <module>
    from sdl2_displaymanager import sdl2_DisplayManager
  File "procgame\dmd\sdl2_displaymanager.py", line 7, in <module>
    import sdl2.ext
  File "C:\Python26\lib\site-packages\sdl2\ext\__init__.py", line 15, in <module>
    from .draw import *
  File "C:\Python26\lib\site-packages\sdl2\ext\draw.py", line 8, in <module>
    from .sprite import SoftwareSprite
  File "C:\Python26\lib\site-packages\sdl2\ext\sprite.py", line 9, in <module>
    from .image import load_image
  File "C:\Python26\lib\site-packages\sdl2\ext\image.py", line 14, in <module>
    from .. import sdlimage
  File "C:\Python26\lib\site-packages\sdl2\sdlimage.py", line 29, in <module>
    os.getenv("PYSDL2_DLL_PATH"))
  File "C:\Python26\lib\site-packages\sdl2\dll.py", line 51, in __init__
    raise RuntimeError("could not find any library for %s" % libinfo)
RuntimeError: could not find any library for SDL2_image

After install I tried running the sample game T2Game.py. I changed the config.yam SDL2 path to reflect my setup as in the instructions. C:\Python26\DLLs\sdl2
I get similar error
C:\P-ROC\PyProcGameHD\SampleGame>python T2Game.py
Traceback (most recent call last):
  File "T2Game.py", line 8, in <module>
    import procgame.game
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\game\__init__.py", line 11, in <module>
    from basicgame import *
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\game\basicgame.py", line 2, in <module>
    from ..dmd import DisplayController, font_named
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\dmd\__init__.py", line 18, in <module>
    from dmd import *
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\dmd\dmd.py", line 4, in <module>
    from sdl2_displaymanager import sdl2_DisplayManager
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\dmd\sdl2_displaymanager.py", line 7, in <module>
    import sdl2.ext
  File "C:\Python26\lib\site-packages\sdl2\ext\__init__.py", line 15, in <module>
    from .draw import *
  File "C:\Python26\lib\site-packages\sdl2\ext\draw.py", line 8, in <module>
    from .sprite import SoftwareSprite
  File "C:\Python26\lib\site-packages\sdl2\ext\sprite.py", line 9, in <module>
    from .image import load_image
  File "C:\Python26\lib\site-packages\sdl2\ext\image.py", line 14, in <module>
    from .. import sdlimage
  File "C:\Python26\lib\site-packages\sdl2\sdlimage.py", line 29, in <module>
    os.getenv("PYSDL2_DLL_PATH"))
  File "C:\Python26\lib\site-packages\sdl2\dll.py", line 51, in __init__
    raise RuntimeError("could not find any library for %s" % libinfo)
RuntimeError: could not find any library for SDL2_image

I can still run my original non PyprocgameHD+Skeleton Games by copying the "PROCGAME" Folder from the "PyProcgame" master folder and placing it in my games root folder. As per recommendations in the instrucitons.

What is the obvious thing that I'm missing?
Thanks for the help and for creating these tools for the community!

Rosh

  • Moderator
  • ****
  • Posts: 667
  • Josh Kugler
    • View Profile
the new version of the framework requires a couple of SDL2 extensions be installed, which appears to be the issue that you are missing sdl2_image.   Have you installed it? I believe SDL2_image is a separate install from SDL2.


PJmckevitt

  • Jr. Member
  • **
  • Posts: 27
    • View Profile
Thanks for the input. I reinstalled the latest version of PySDL2 0.9.3. I do have the dlls for  SDL2_ttf-2.0.12 and SDL2-2.0.3-win32-x86 in C:\Python26\DLLs\sdl2. I placed the dlls from SDL2_image-2.0.0-win32-x86 in the Python26\DLLS\SDL2 as well.

Now I get the error below. I think you can see the Virtual DMD window flash quickly on then off before the error. I also get the warning that OPENCV is not available. I did install and set the environment variable %OPENCV_DIR% and placed the bin folder in the PATH.

C:\P-ROC\PyProcGameHD\SampleGame>PYTHON T2Game.py
WARNING no font_path set in ./config.yaml!
2015-05-31 12:47:18,023 - root - ERROR - OpenCV is not available on your system.  The MovieLayer (mp4) support is unavailable
2015-05-31 12:47:18,039 - root - ERROR - OpenCV is not available on your system.  The Movie (mp4) support is unavailable
2015-05-31 12:47:18,055 - game.sound - INFO - Initializing sound...
Desktop init begun.
****************
WINDOW SET
****************
Traceback (most recent call last):
  File "T2Game.py", line 106, in <module>
    run_proc_game(T2Game)
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\game\skeletongame.py", line 74, in run_proc_game
    game = game_class()
  File "T2Game.py", line 43, in __init__
    super(T2Game, self).__init__('config/T2.yaml', self.curr_file_path)
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\game\skeletongame.py", line 101, in __init__
    super(SkeletonGame, self).__init__(machineType)
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\game\basicgame.py", line 41, in __init__
    self.desktop = Desktop()
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\desktop\desktop_pysdl2.py", line 65, in __init__
    dot_sprite = sdl2_DisplayManager.inst().load_texture(os.path.join(dmd_grid_path,'dmdgrid32x32.png'))
  File "C:\P-ROC\PyProcGameHD\SampleGame\procgame\dmd\sdl2_displaymanager.py", line 502, in load_texture
    tsurface = sdl2.ext.image.load_image(fname)
  File "C:\Python26\lib\site-packages\sdl2\ext\image.py", line 67, in load_image
    imgsurface = sdlimage.IMG_Load(name)
WindowsError: exception: access violation reading 0x00000000

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Did you install SDL_image 2.0?  1.2 will not work and could cause such a problem, I suspect. I also believe it needs to be the 32bit version.

https://www.libsdl.org/projects/SDL_image/

PJmckevitt

  • Jr. Member
  • **
  • Posts: 27
    • View Profile
I did install SDL_image 2.0. By install I mean I placed the contents of the runtime binaries in the c:\Python26\dlls\sdl2. Not sure if that is correct.

Steps I performed
1.One Click install
2. Check One Click install - print 6
3. Installed PySDL - PySDL2-0.9.3 - ran python setup.py install
4. Installed SDL2 - placed Dlls in C:\Python26\DLLs\sdl2 -
Runtime Binaries - SDL2 - placed dlls in folder
                            SDL2_image-2.0.0-win32-x86  - placed dlls in folder
                            SDL2_ttf-2.0.12-win32-x86 - placed dlls in folder
5. Installed PyOSC - python setup.py install
6. PYSDL2_DLL_PATH - I did not do anything with this. I changed the path in the config.yaml
7. OpenCsv - followed install instruction. Created environment variable and edit Path
8. libffmpeg - I installed FFMPEG and set PATH variables.Not sure if this is correct.
9. Installed PyProcGameHD from Git using python setup.py develop

I might make a fresh Windows 7 image and start over. This image did have older versions of Pyprocgame and PyprocgameHD before I started. I did rerun the one click installer. Should I use the Linux Installer instead. I don't mind using Linux.



Rosh

  • Moderator
  • ****
  • Posts: 667
  • Josh Kugler
    • View Profile
Looks like the image it is trying to load is failing, probably the splash screen, check those settings and make sure the file exists

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Announcing: SkeletonGame - Making PyProcGame programming a little easier
« Reply #41 on: May 31, 2015, 07:29:41 PM »
No need to run Linux and the fact the old install there is surely no problem (you can switch back and forth and I do, regularly).

The problem must be with the SDL image. I'll do some googling and see what I can't find. You do have the dmd grid image, right?  I'm quite sure that when it can't find a file it doesn't  give this error, so I'll keep digging
« Last Edit: May 31, 2015, 07:38:48 PM by MOcean »

PJmckevitt

  • Jr. Member
  • **
  • Posts: 27
    • View Profile
thanks,

I do have the dmdgrid32x32. I think ROSH is right. I just noticed the first assets in the assets.yaml is loading.jpg and that isn't in the assets folder. I didnt realize that the assets weren't included in the sample game. I googled the error and it mention passing a NULL, which would make sense being there are no media files in the folder.

Is there any way I could get a copy of the media files to test if the sample games works.

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
The traceback showed the problem being dmdgrid32x32.png, though..?  Any image will do for loading.png and if you delete the line that specifies the splash screen image from the asset_list.yaml, then it won't use one.

That said, I'll send you a PM shortly.

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Michael,
One of the ideas I have been kicking around for my Popeye machine is including a few small video screens on the sides of the upper playfield.  Could these be supported by PyProcGameHD as is, or would supporting multiple monitors require some extensive re-coding?
Thanks,
Uncivil Engineer