Eclipsed - entry submitted

My game is submitted!

It requires pygame, pyopengl, and numpy. (If you're on Ubuntu check out this post I made for installing tons of dependencies at once - some good info in the responses too.) I haven't used pyopengl since PyWeek 10, but the gameplay this time really called for 3D so I went for it.



Other than that, I don't have much to say. Just making this post so that people with bug reports have a place for them. Enjoy!

(log in to comment)

Comments

$ python run_game.py
Traceback (most recent call last):
  File "run_game.py", line 4, in <module>
    main.main()
  File "src/main.py", line 16, in main
    graphics.init()
  File "src/graphics.py", line 550, in init
    stars, moon, stone, relay, platform, dish, block, helmet, satellite, basin, mine, trashbin, launchpad, copter, barrel, hq, spindle, piston, medic, wings, artifact, splode, vbodata = cPickle.load(open(fname, "rb"))
AttributeError: 'drawable' object has no attribute '__dict__'
Looks like it's a bug in python 2.7.3. Fortunately it's an easy fix in this case. Delete the file data/graphics.pkl.
Oops, picked Save too early.

Looks like it's due to a bug in python 2.7.3. Fortunately it's an easy fix in this case. Delete the file data/graphics.pkl. The first time you run the game, it might take a minute or two to load because it's remaking all the graphical models. After that it should load quickly, though.

Let me know if that doesn't work. Thanks for trying the game!
Thanks! Now I get this:

Traceback (most recent call last):
  File "run_game.py", line 4, in <module>
    main.main()
  File "src/main.py", line 31, in main
    s.draw()
  File "src/scenes/menu.py", line 95, in draw
    hud.draw()
  File "src/hud.py", line 566, in draw
    b.draw()
  File "src/hud.py", line 66, in draw
    text.write(self.words, self.fontname, self.size, self.color, (x, y), None, 0, 1)
  File "src/text.py", line 166, in write
    texture = gettexture(text, fontname, size, color, bcolor)
  File "src/text.py", line 133, in gettexture
    textures[key] = Texture(text, fontname, size, color, bcolor)
  File "src/text.py", line 63, in __init__
    self.maketexture(surf)
  File "src/text.py", line 68, in maketexture
    numpy.reshape(pygame.surfarray.pixels3d(surf), [sw * sh, 3]),
  File "/Library/Python/2.7/site-packages/pygame/surfarray.py", line 190, in pixels3d
    return numpysf.pixels3d (surface)
  File "/Library/Python/2.7/site-packages/pygame/_numpysurfarray.py", line 133, in pixels3d
    return numpy_array(surface.get_view('3'), copy=False)
ValueError: unsupport colormasks for 3D reference array

Looks like you're doing really advanced stuff. Perhaps I don't have the right library versions.
I got a bug after playing for a while :(

Traceback (most recent call last):
  File "run_game.py", line 4, in <module>
    main.main()
  File "src/main.py", line 29, in main
    s.think(tdt, pygame.event.get(), pygame.key.get_pressed())
  File "src/scenes/game.py", line 127, in think
    obj.think(dtobj)
  File "src/things.py", line 157, in think
    self.arrive(self.target)
  File "src/things.py", line 114, in arrive
    where.receive(self)
  File "src/things.py", line 341, in receive
    state.stuff.remove(self)
ValueError: list.remove(x): x not in list
@Mat: Thanks. I suspect that's a one-time thing and won't happen again. The game should be saved in the background every 5 seconds, for just such an occasion. What happens if you just run the game again? Does the bug reappear? If so, I can give you a patch that should fix it.
@cyhawk: Sorry, I'm not able to figure out your issue. It's probably pygame related. If you want to spend some time on it, I can work with you to find a minimal problematic example to take to the pygame people. Otherwise, my only suggestion is to try a different pygame version.
Yup, now I get the bug as soon as I run the game :)
Okay it should be as simple as changing line 341 in src/things.py from this:

        state.stuff.remove(self)

to this:

        if self in state.stuff: state.stuff.remove(self)
Thanks. I'll take a closer look on the weekend!
Yep that fixed it.
Traceback (most recent call last):
  File "/Volumes/Mac2/Users/leif/Downloads/eclipsed/run_game.py", line 3, in <module>
    import main
  File "src/main.py", line 6, in <module>
    import scene, settings, scenes.game, scenes.menu, graphics, sound, state
  File "src/scenes/game.py", line 6, in <module>
    import scene, settings, random, graphics, camera, text, things, state, cursor, hud, lighting, info, sound
  File "src/graphics.py", line 8, in <module>
    import scene, settings, state, data
  File "src/state.py", line 2, in <module>
    import things, settings, info, text, sound, random, data
  File "src/things.py", line 320, in <module>
    class Material(Thing):
  File "src/things.py", line 341, in Material
    if self in state.stuff: state.stuff.remove(self)
NameError: name 'self' is not defined


After I did: if self in state.stuff: state.stuff.remove(self)
It looks like you got the indentation wrong. The indentation of that line should match the line previous to it, ie, with two tabs at the beginning of the line. Note that I used tabs, not spaces.

If you don't think that's it, please post your entire things.py file (on pastebin or wherever) exactly as it is and I'll take a look.
I'm testing on Windows now. I don't have a PrintScreen key, so I cannot show you, but something is wrong with depth testing. It almost looks like it's happening the wrong way around. The bottom of buildings is rendered on top of their tops. Much is covered by the moon itself. Does anyone happen to have a fix for this? (It's still sort of playable at least.)
F12 will take a screenshot.

A lot of OpenGL is unfamiliar to me, so it's very possible that I made a mistake. I pretty much just tried stuff until it worked. Basically all I do as far as depth is concerned is put this at the beginning of the draw loop:

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glEnable(GL_DEPTH_TEST)

And then this when it's time to draw the HUD:

    glDisable(GL_DEPTH_TEST)
Setting GL_DEPTH_SIZE to 32 fixes the weird rendering issues I was having. (Another game had a similar problem but the symptoms were a bit different.)

I also had to replace the call to pygame.surfarray.pixels3d() with a call to pygame.surfarray.array3d(). I'm not sure if the pixels_alpha() call on the next line also needs replacing with the array equivalent, but I did it anyway.

cyhawk, this might sort out your issues as well.
Whoops, I forgot to mention how to set GL_DEPTH_SIZE.

Add this line to graphics.py just before the pygame.display.set_mode() call:
        pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 32)
Thanks, that worked perfectly! I also had depth issues with another game (Hungry Hungry Werewolf). Looks like you and me have the stupidest video cards :).
If either of you could post a patch, or your version of the file, or email them to me at Cosmologicon@gmail.com I can incorporate them into the repo for any future users. :)
I only had to add the gl_set_attribute line before the set_mode line in graphics.py and it worked flawlessly.
Here's a diff of my two changes: https://gist.github.com/jerith/6658028
Thanks cyhawk, I had the very same problem and it's fixed now! I think I'm gonna finish the game now. And big congratulations to Cosmologicon, the victory was well deserved, you did amazing amazing job :)
Hmmhh... In 3rd level I started getting this errors:
Traceback (most recent call last):
  File "C:\Users\Marek\Downloads\pyweek\eclipsed-v2\eclipsed-v2\eclipsed\run_game.py", line 4, in <module>
    main.main()
  File "src\main.py", line 29, in main
    s.think(tdt, pygame.event.get(), pygame.key.get_pressed())
  File "src\scenes\game.py", line 127, in think
    obj.think(dtobj)
  File "src\things.py", line 157, in think
    self.arrive(self.target)
  File "src\things.py", line 114, in arrive
    where.receive(self)
  File "src\things.py", line 341, in receive
    state.stuff.remove(self)
ValueError: list.remove(x): x not in list

The worse thing is I cannot get rid of them, since when I run the game again the error comes again in about 1 second... That means I had better correct that then just erasing my saves (can happen again)...
@maral: Look about halfway up on this post, I posted a fix for that issue in response to Mat. Thanks for trying it again!
Awesome, (yeah, was too lazy too scroll and read everything :D) I think you should include this two fixes into the post-final version and put it here.