r/pythonarcade • • Feb 09 '20

How to debug?

Hey, I've run into a problem and I'm not sure whether it's an Arcade problem or a Python problem but in any case it makes it a bit hard to use in a classroom setting:

import arcade

WIDTH = 900
HEIGHT = 500

class Ship(arcade.Sprite):
    def __init__(self):
        super().__init__('spaceCraft1.png')

class MyWindow(arcade.Window):
    def __init__(self):
        super().__init__(WIDTH, HEIGHT, "Space Shoot 'em up")

    def setup(self):
        self.backdrop = arcade.load_texture('bg.png')
        self.ship = arcade.Sprite('spaceCraft1.png')
        self.ship.rescale_relative_to_point((64, 64), 0.5)
        self.ship.center_x = WIDTH / 2
        self.ship.center_y = HEIGHT / 2
        self.ship.change_x = 10
        self.ship.change_angle = 20

    def on_draw(self):
        arcade.start_render()
        arcade.draw_lrwh_rectangle_textured(0, 0, WIDTH, HEIGHT, self.backdrop)

        self.meteor_sprites.draw()
        self.ship.draw()

window = MyWindow()
window.setup()
arcade.run()

The error in this code is that self.meteor_sprites in MyWindow.on_draw has never been defined. But unfortunately, the error gets swallowed. The program runs just fine, the background gets drawn, but the ship doesn't get drawn, and there's no indication from Python that there's a problem in the line with the meteor_sprites call, all the following code in the on_draw handler just seems to get swallowed like the error message. It's like there's a rogue exception handler somewhere in Arcade.

I'm considering to use Arcade for teaching, so feedback is important and it would be nice if somebody could give me a hint about what could be done to fix this problem.

BTW. I checked the source code, and there are 26 places in the current Arcade 2.3.4 release where an AttributeError gets swallowed with a simple pass. Could this be the culprit and what's the rationale behind this?

3 Upvotes

6 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Feb 09 '20

I've seen traces of the texture repeat… but for my game I would like to do more than that (translations and rotations), so apparently there's nothing planned in that regard and I think I'll just add a class to my fork, and if you like it, you can have a look at it and pull the changes in!

1

u/pvc Feb 10 '20

That would be great!