[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] 'Shining Sea' source code



> I had to change all font.render() calls to enable anti-aliasing, to
> sidestep a bug in Ubuntu's pygame (segmentation faults when rendering
> non-anti-aliased spaces).  The game starts, but I cannot control
> anything. I believe you mentioned W, A, S, D keys?  Nothing happens.  When
> I kill
> the game, I get this traceback:
> if pygame.mixer.music.get_busy(): KeyboardInterrupt
> (BTW there's no sound or music.)

>I restarted the game and immediatly clicked New Game and couldn't move.
>Ah... I never heard sound or music.

This is weird! It runs on my machine, on Windows. How about if you insert
the line "print 'I should be jumping'" after line 548 of the main program,
"Shining Sea.py"? That should print a message every time you hit Space to
jump. And how about the RightShift and Enter keys; do they do anything?
There should be visual and sound effects in all three cases.

At the top of the program I've got:
CONTROLS_UP = K_w

And in the main loop (Game.WanderingScreen) it says (excerpted):
        done = False
        while not done:
            ## Handle physics.
            self.SimulationStep()
            ## Handle events.
            keys_pressed = pygame.key.get_pressed() ## Keys that're down.
            for event in pygame.event.get():
                if event.type == QUIT:
                    done = True
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        done = True
                        self.game_state = "Title Screen"
                    elif event.key == CONTROLS_JUMP:
                        self.player.Jump()
                        Conch.j.PlaySound("jump")
            ## Allow the player to move in 8 directions using the arrow keys.
            move_x, move_y = 0, 0
            if keys_pressed[ CONTROLS_UP ]:
                move_y = 1
(Etc.)

So, in theory, if you're pressing the W key when pygame.key.get_pressed()
is called, then keys_pressed[ CONTROLS_UP ] should be True, which should
trigger movement. And it does on my machine.

I made the ZIP file directly from a working set of code and just zipped up
the whole directory, with all the music etc.. Is there some reason the
code wouldn't be portable? Hmm... the music is in MIDI; does Ubuntu's
Pygame support that?

The sound code is in Conch.py, which is included and normally works. I
notice I have a copy of it in C:\Python24; could that have something to do
with it working on my machine, as little sense as that makes?

Another hypothesis: something about the line "self.clock.tick(15)". If the
clock were somehow off, then the worldsim's "time_interval" variable would
be messed up. Movement only happens when game-time passes. Even if no time
is passing, there should still be a walking animation when you use WASD.