arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Broken examples (collection for 3.0)

Open MiCurry opened this issue 1 year ago • 10 comments

Some examples are broken due to the 3.0 camera updates. So far there are:

  • [x] arcade/examples/procedural_caves_bsp.py - Camera 'Jitters'
  • [x] arcade/examples/procedural_caves_cellular.py - AttributeError: module 'arcade.camera' has no attribute 'controllers'
  • [x] arcade/examples/full_screen_example.py - When swapping from fullscreen.
  • [x] arcade/examples/gl/custom_sprite.py
  • [ ] arcade/examples/camera_platform.py (resize doesn't work right)
  • [ ] arcade/examples/easing_example_2.py (due to other 3.0 changes)
  • [ ] arcade/examples/turn_and_move.py due to rotation direction changes
  • [ ] arcade/examples/minimap_camera.py
  • [ ] arcade/examples/light_demo.py

A few broken examples are listed in this comment. Others are listed in the comments below.

procedural_caves_bsp.py

Running python -m arcade.examples.procedural_caves_bsp the camera 'Jitters':

https://github.com/pythonarcade/arcade/assets/2590700/ed9a40db-a610-4155-9c8d-a8b1131f820c

procedural_caves_cellular.py

Running python -m arcade.examples.procedural_caves_cellular ends up in an attribute error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 350, in <module>
    main()
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 346, in main
    arcade.run()
  File "/Users/miles/programs/arcade/arcade/window_commands.py", line 146, in run
    pyglet.app.run(window._draw_rate)
  File "/usr/local/lib/python3.11/site-packages/pyglet/app/__init__.py", line 80, in run
    event_loop.run(interval)
  File "/usr/local/lib/python3.11/site-packages/pyglet/app/base.py", line 165, in run
    timeout = self.idle()
              ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyglet/app/base.py", line 226, in idle
    self.clock.call_scheduled_functions(dt)
  File "/usr/local/lib/python3.11/site-packages/pyglet/clock.py", line 217, in call_scheduled_functions
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "/Users/miles/programs/arcade/arcade/application.py", line 386, in _dispatch_updates
    self.dispatch_event('on_update', delta_time)
  File "/usr/local/lib/python3.11/site-packages/pyglet/window/__init__.py", line 676, in dispatch_event
    super().dispatch_event(*args)
  File "/usr/local/lib/python3.11/site-packages/pyglet/event.py", line 380, in dispatch_event
    if handler(*args):
       ^^^^^^^^^^^^^^
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 129, in on_update
    game_view.setup()
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 209, in setup
    self.scroll_to_player(1.0)
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 314, in scroll_to_player
    arcade.camera.controllers.simple_follow_2D(speed, position, self.camera_sprites.view_data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'arcade.camera' has no attribute 'controllers'

MiCurry avatar Jun 19 '24 13:06 MiCurry

I haven't done much digging, but I believe the problematic code is in the scrolling section of on_update:

https://github.com/pythonarcade/arcade/blob/cf291ec55c103dd8d22e8efb1ca28d12baadee2f/arcade/examples/procedural_caves_bsp.py#L430-L457

When I removed that code, the jitters went away.

MiCurry avatar Jun 19 '24 13:06 MiCurry

Slightly related the procedural_caves_cellular.py example also appears to be broken. I can create another issue for this if that would be better.

python -m arcade.examples.procedural_caves_cellular

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 350, in <module>
    main()
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 346, in main
    arcade.run()
  File "/Users/miles/programs/arcade/arcade/window_commands.py", line 146, in run
    pyglet.app.run(window._draw_rate)
  File "/usr/local/lib/python3.11/site-packages/pyglet/app/__init__.py", line 80, in run
    event_loop.run(interval)
  File "/usr/local/lib/python3.11/site-packages/pyglet/app/base.py", line 165, in run
    timeout = self.idle()
              ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyglet/app/base.py", line 226, in idle
    self.clock.call_scheduled_functions(dt)
  File "/usr/local/lib/python3.11/site-packages/pyglet/clock.py", line 217, in call_scheduled_functions
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "/Users/miles/programs/arcade/arcade/application.py", line 386, in _dispatch_updates
    self.dispatch_event('on_update', delta_time)
  File "/usr/local/lib/python3.11/site-packages/pyglet/window/__init__.py", line 676, in dispatch_event
    super().dispatch_event(*args)
  File "/usr/local/lib/python3.11/site-packages/pyglet/event.py", line 380, in dispatch_event
    if handler(*args):
       ^^^^^^^^^^^^^^
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 129, in on_update
    game_view.setup()
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 209, in setup
    self.scroll_to_player(1.0)
  File "/Users/miles/programs/arcade/arcade/examples/procedural_caves_cellular.py", line 314, in scroll_to_player
    arcade.camera.controllers.simple_follow_2D(speed, position, self.camera_sprites.view_data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'arcade.camera' has no attribute 'controllers'

MiCurry avatar Jun 19 '24 13:06 MiCurry

Both are definitely related to changes applied when the new camera was added. These used to call arcade.set_viewport to do the scrolling but this function is now removed because the naming is highly misleading and camera can do this work much easier.

einarf avatar Jun 19 '24 17:06 einarf

Yup, the example updates were not thorough enough. I will have to give them all another pass-over. Thank you for making the issue.

DragonMoffon avatar Jun 20 '24 01:06 DragonMoffon

arcade\examples\full_screen_example.py

When swapping from fullscreen.

  File "arcade\camera\camera_2d.py", line 502, in projection
    self._projection_data.rect = value * _z
                                 ~~~~~~^~~~
TypeError: can't multiply sequence by non-int of type 'float'

einarf avatar Jun 22 '24 17:06 einarf

arcade\examples\gl\custom_sprite.py

  File "arcade\examples\gl\custom_sprite.py", line 160, in on_mouse_drag
    self.cam.pos = self.cam.pos[0] - dx, self.cam.pos[1] - dy
                   ^^^^^^^^^^^^

einarf avatar Jun 22 '24 19:06 einarf

arcade/examples/camera_platform.py is also broken

einarf avatar Jun 27 '24 19:06 einarf

Another fix we (I) need to do in the examples is change them from saying cam to saying camera. Paul Craven mentioned it a while ago, and I forgot to write it down.

EDIT: this is now fixed in a coming PR

DragonMoffon avatar Jun 28 '24 23:06 DragonMoffon

arcade/examples/easing_example_2.py

AttributeError: 'Player' object has no attribute 'face_point'
Exception ignored on calling ctypes callback function: <function Win32Window._get_window_proc.<locals>.f at 0x000001F91DE95800>
Traceback (most recent call last):
  File "C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade_dragon\.libs\Lib\site-packages\pyglet\window\win32\__init__.py", line 792, in f
    result = event_handler(msg, wParam, lParam)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade_dragon\.libs\Lib\site-packages\pyglet\window\win32\__init__.py", line 864, in _event_key
    self.dispatch_event(ev, symbol, modifiers)
  File "C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade_dragon\.libs\Lib\site-packages\pyglet\window\__init__.py", line 676, in dispatch_event
    super().dispatch_event(*args)
  File "C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade_dragon\.libs\Lib\site-packages\pyglet\event.py", line 392, in dispatch_event
    raise e
  File "C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade_dragon\.libs\Lib\site-packages\pyglet\event.py", line 387, in dispatch_event
    if getattr(self, event_type)(*args):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade_dragon\arcade\examples\easing_example_2.py", line 109, in on_key_press
    self.player_sprite.face_point(point)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Player' object has no attribute 'face_point'

DragonMoffon avatar Jun 29 '24 11:06 DragonMoffon

Note on a few examples the resizing is a bit broken.

If they have a camera that isn't positioned every update (like a gui camera) add this line in the on_resize method

self.<camera in question>.position = self.center

or better completely remove the camera and just use the default camera i.e.

self.default_camera.use()

which is positioned and resized correctly at all times

DragonMoffon avatar Jun 29 '24 12:06 DragonMoffon

All done and verified.

einarf avatar Jul 10 '24 22:07 einarf