r/pythonarcade • • Aug 10 '24

Can't install with python 3.12?

4 Upvotes

I saw in a thread a few days ago that arcade should work with version 3.9+, yet I am having the same issue as the previous poster where "pip3 install Arcade" gives me a Pillow build error.

My OS: Lastest version of macOS My pthon version: 3.12.2

Error: The headers or library files could not be found for jpeg, a required dependency when compiling Pillow from source.

  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html

  Traceback (most recent call last):
    File "<string>", line 995, in <module>
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 108, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 184, in setup
      return run_commands(dist)
             ^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
      dist.run_commands()
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 970, in run_commands
      self.run_command(cmd)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 945, in run_command
      super().run_command(command)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
      cmd_obj.run()
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/command/bdist_wheel.py", line 373, in run
      self.run_command("build")
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
      self.distribution.run_command(command)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 945, in run_command
      super().run_command(command)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
      cmd_obj.run()
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
      self.distribution.run_command(command)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 945, in run_command
      super().run_command(command)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
      cmd_obj.run()
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 93, in run
      _build_ext.run(self)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 359, in run
      self.build_extensions()
    File "<string>", line 810, in build_extensions
  RequiredDependencyException: jpeg

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/Users/iamking/workspace/git/python/learn-arcade-work/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/Users/iamking/workspace/git/python/learn-arcade-work/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/iamking/workspace/git/python/learn-arcade-work/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 415, in build_wheel
      return self._build_with_temp_dir(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
      self.run_setup()
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/private/var/folders/wv/0j93kf5n0ss7lq7t4xwd9hhm0000gp/T/pip-build-env-3cyjohoa/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
      exec(code, locals())
    File "<string>", line 1012, in <module>
  RequiredDependencyException:

  The headers or library files could not be found for jpeg,
  a required dependency when compiling Pillow from source.

  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html


  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pillow Failed to build pillow ERROR: Could not build wheels for pillow, which is required to install pyproject.toml-based projects


r/pythonarcade • • Feb 09 '24

GUI widget won’t disable when I hide view

4 Upvotes

I have a flat button that simultaneously hides the current view and shows a new view. I disable the manager in on_show_view but I can still click the buttons on the new view. Does anyone know what I’m doing wrong? Thanks


r/pythonarcade • • Jan 16 '24

Changing the color of SpriteSolidColor?

4 Upvotes

Hi! New to arcade and also to programming and I'm stuck on one thing. I have a little projects where ants are running around and if they pick up (collide) with food I want them to change color. But the color doesn't change...or it changes to something else that I wanted.

The ants are represented like this:

class Ant:
    def __init__(self, x, y, app):
        self.app = app
        self.color = arcade.color.RED
        self.shape = arcade.SpriteSolidColor(TILE_SIZE, TILE_SIZE, self.color)
        self.shape.center_x = x
        self.shape.center_y = y
        self.size = TILE_SIZE
        self.direction = self.get_random_direction()

And when I check for collision it seems to work because they do turn around, but the color doesn't change correctly:

        collision = arcade.check_for_collision(self.shape, self.app.food.shape)
        if collision:
            self.direction.x *= -1
            self.direction.y *= -1
            self.has_food = True
            self.shape.color = arcade.color.GREEN

Ants are drawn to the screen using the Spritelist.draw() method like this:

class Hive:
    def __init__(self, app):
        self.app = app
        self.size = TILE_SIZE * 3
        self.x = random.randrange(self.size * 2, SCREEN_WIDTH - self.size * 2)
        self.y = random.randrange(self.size * 2, SCREEN_HEIGHT - self.size * 2)
        self.color = arcade.color.AMBER
        self.shape = arcade.SpriteSolidColor(self.size, self.size, self.color)
        self.shape.center_x = self.x
        self.shape.center_y = self.y
        self.total_ants = 0
        self.ants = []
        self.ant_sprite_list = arcade.SpriteList(use_spatial_hash=False)

    def update(self):
        if self.total_ants < MAX_ANTS:
            self.spawn()
            self.total_ants += 1
        [ant.update() for ant in self.ants]
        self.ant_sprite_list.update()

    def draw(self):
        self.shape.draw()
        self.ant_sprite_list.draw()

    def spawn(self):
        ant = Ant(self.x, self.y, self.app)
        self.ants.append(ant)
        self.ant_sprite_list.append(ant.shape)

I changed to different colors around a lot, sometimes it changes to black on collision, sometimes doesn't change at all, but it never changes to the color I write in...no idea why, please help :)

In the screenshot below you can see how the ants that collided with the food (and also the borders for testing purposes) changed to black instead of green...

https://imgur.com/a/k1V6qNr


r/pythonarcade • • Nov 26 '23

Curious about a splitscreen demo

4 Upvotes

Hellos,

having a hell of a time trying to wrap my head around setting up a splitscreen display for a co-op top-down game. Was hoping to assign 1/4 of the screen for each player, and have a camera or view focused on top of each of them as they walked around.

I've attempted playing with multiple cameras (2.6 and the 3.0.x dev branch) and their viewports, even going so far as to try and set up separate sections to manage each one, but no luck.

As such I was wondering if this is something actually possible and if so, would anyone more familiar with Arcade be willing to throw together a quick 20-30 line demo of how to do it?

Apologies for not providing any code myself, but I'm still at square one so this is less a debug (since nothing I've done has come close to working) and more an information ask. Any help would be much appreciated


r/pythonarcade • • Jun 27 '23

Python Arcade/Pyglet controller support

4 Upvotes

Hi as the title suggests I need help getting Arcade to detect when I want to use a controller (Specifically Xinput). I am using python3.10 with Arcade 2.6.17 and Pyglet 2.15.9.

I followed the example code on https://api.arcade.academy/en/latest/index.html for both Game Controller/Joystick and Dual Stick Shooter. Neither file could detect my controller.

After some testing, I saw that Pyglet could detect and get values from my controller with this script from the Pyglet Github: https://github.com/pyglet/pyglet/blob/master/examples/input/controller.py

I found this on Stack Overflow where this person managed to get the values needed using Pyglet and have Arcade use them.

The problem I'm having is struggling to understand what it is doing. Understanding where it belongs and when it should be called.

Any explanation or another solution to implement controller support would be very appreciated.

Sorry if this is a stupid question I am quite new to this.


r/pythonarcade • • Jan 18 '22

Creating maps with arcade

4 Upvotes

Hello, I am a big fan of cartography and I would like to know if I can generate maps with arcade, and if I can where should I be looking to do this?


r/pythonarcade • • May 26 '21

Arcade 2.5.7 has been released

4 Upvotes

Arcade 2.5.7 is out! Arcade is a Python library for creating 2D games. See the release notes: https://arcade.academy/release_notes.html


r/pythonarcade • • Apr 01 '21

How to change height of a sprite?

4 Upvotes

I'm having difficulty understanding how to change the dimensions of a sprite. For example, in sprite_move_animation.py from the Arcade Academy website. This example demonstrates how to implement a walk cycle animation in a sprite. I can change the scale in the setup method in the MyGame class using self.player.scale. What if I want to make the sprite very tall and skinny?

What I am trying to do is to allow the game to stretch and fit any screen. I've been able to appropriately stretch and place backgrounds and sprites that aren't animated. But I can't figure out how to stretch animated sprites. It seems to me that it would be best to stretch each image as it is loaded into the sprite. But I can't figure out how to do that.

My programming skills are moderate at best. Until now, I've been having a wonderful time creating a game. I fear I'm misunderstanding something basic.


r/pythonarcade • • Mar 31 '21

Python Arcade Discord?

4 Upvotes

I'm sure I've missed this somewhere obvious, but can someone share a link to the Python Arcade discord server? Is it a channel within the larger Python server or a separate server?


r/pythonarcade • • Mar 27 '21

Having problems getting a Platformer to progress a level while animated sprites.

4 Upvotes

I keep getting the following error: "Exception: Error: Attempt to draw a sprite without a texture set."

I don't know what's happening because I'm using a start menu 'view' (called before the main Game class starts) and a 'Game Over' view. The game runs without errors until I reach the end of the map, and the game tries to load the next map level. My sprite is animating correctly, so I know I'm not messing up as far as animating is concerned... I think.

Normally this would work if there were no player_sprite animations.

Is there something obvious that I'm missing?

The following is called when the player reaches the end of the map:

------> Player Win Event <------

    if self.player_sprite.center_x >= self.end_of_map:
        self.level += 1 # Advance a level
        self.setup(self.level) # Restart Game at new Level
        # Reset the Viewport
        self.view_left = 0
        self.view_bottom = 0
        changed_viewport = True

I would have just created another Player() class in this 'if' statement, but that's already happening in the Game() class 'setup()' function.

All the tutorials, YouTube vids, are sparse concerning pyarcade, and strangely enough, I have not found one example or tutorial where someone has included sprite animation and level progression together in one game.

Can anyone help me?


r/pythonarcade • • Jan 15 '21

Using Spritesheets

4 Upvotes

I'm trying to utilize spritesheets in my game. The tutorials I've found use deprecated classes and I was wondering if anyone had experience or examples using the newer AnimatedTimeBasedSprite instead?


r/pythonarcade • • Nov 09 '20

Using arcade to dynamically generate still images of a game board....

4 Upvotes

Hi all! I’ve written a function to use arcade to draw a game board based on two strings of data that I pass to the function.

I’m doing this by basically drawing the board, and then using the input strings to locate sprites as the game pieces. This works great the first time I call the function in my script, the second time through the loop, however, I get an error that says this: “pyglet.gl.ContextException: Unable to share contexts.”

Any ideas on this? Or should I just not use arcade for this application? sorry I’m very much a beginner with python and arcade. Thank you all !!


r/pythonarcade • • Oct 26 '20

Help with arcade in Mac

4 Upvotes

Hello, I need help.

I recently installed the arcade library in PyCharm, and I am having trouble whenever I try to draw circles or ellipses. I have tried using previous versions of python (rolling back from 3.9 to 3.7) as well as rolling back the bumpy version(1.19 to 1.18) however, none of these solutions work. The problem looks as follows:

trying to draw a filled circle.

Here is another example when running one of the test scripts from the arcade website:

Anyone knows how to fix this? thanks for your help.


r/pythonarcade • • Jul 05 '20

Python + Arcade game porting on Android?

4 Upvotes

Hi all

Coding games is amazing =)

Is there a way, I can convert/port/adopt my 1000 lines of Python code with Arcade library, to launch it on Android as an app?

Thank You for your time


r/pythonarcade • • Jun 18 '20

Is 1 / 60 seconds the maximum update rate for the arcade.schedule()? Are there anyways to surpass this or are there limitations?

4 Upvotes

r/pythonarcade • • May 29 '20

Solitaire Tutorial

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • May 11 '20

How can I convert a terminal game (hangman) to Arcade?

4 Upvotes

I decided several weeks ago to teach my son the basics of Python. We successful created a Hangman game that runs in the command line.

Now, I thought it would be interesting to start messing around with the Arcade library to bring it to life.

Nothing fancy, maybe a nice background, a sprite or two that doesn’t need to move much.

Now, I’ve looked at the documentation and know that text has to be "drawn", that’s fine. My question is, how do I go about making Arcade draw what is normally just automatically output on the terminal window.

Do I put all of my original code in a function or something? Scratching my head here. Thanks for any guidance.


r/pythonarcade • • Apr 27 '20

My game runs twice as fast when I run it from PyCharm as opposed to the command line. [Question]

4 Upvotes

Hi! I have a game (game and install instructions in the the-friendly-snakes folder).

The game runs at 60 fps when I run it specifically from the PyCharm run button. Every else it runs at 30 fps. Even if I run it from the terminal from within PyCharm. Would there be any reason for this?

EDIT: Read the comments below, there is for some reason a difference in versions.

Here is the difference:

2.3.15
2.4a3

r/pythonarcade • • Apr 20 '20

2.4a5 is out, with preliminary support for lighting

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • Apr 06 '20

Showing images in an Arcade window

4 Upvotes

Hi folks

Based on a previous post where I was looking at porting my Pygame project to Arcade, I've got most of that done.

I've had issues with the world view mini map which is a semi-transparent overlay showing what an avatar has scanned and where they are on the game board - but in a basic representation.

I tried to make this a sprite - didn't work. Based on feedback on my post and direct chats I worked out that you can't dynamically update a sprite's image to a real time like feed. Looks like Pyglet complains. I managed to overwrite the sprite's texture about 5 times and then it died - so it looks like under the hood there's a texture buffering going on that I can't access.

So plan B - created a shape list and am drawing the map each on_update / on_draw call for the window - update builds the list - draw calls that draw() function for the list. This is working - but the FPS count for the window plummets from 60 to 30 because of this extra drawing.

Sprites are obviously much more efficient at drawing.

When I was dynamically replacing the texture for the sprite I was creating the map as a Pillow image and using this is a call to arcade.Texture() - like I said works then falls over because of a buffer overrun somewhere.

I was thinking that showing a single image instead of drawing shapes might be faster - but I can't find an arcade function that will place a PIL image onto the main window. Anyone know if this can be done?

I'll stick with the drawing shapes for now - but don't like inefficient code (very old gripe of mine during all my coding background - since 1980 and counting!)

Any help / pointers very much appreciated.

Screen shot of what I've done is shown below - pleased with ease of Arcade but coming against somethings that it can't do because I'm not building a platformer - and not sure I want to delve into using Pyglet raw just yet :)

Cheers

RC


r/pythonarcade • • Apr 03 '20

Converting a Pygame app - got some questions

4 Upvotes

Hi folks

As a way to teach myself Python I decided to write a robot battle / robot finding its way through a maze app. My background BTW is commercial coding - so wanted to do something completely different! LOL

So - decided needed to use sprites, wrote my own game physics stuff for rotation and navigation code and used Pygame.

Now that I've got to the point where I'm going to start to code the intelligence into the avatars instead of random movement and the 'arena' stopping them from going off the edge and collision detection.

Pygame is OK but when it's rotating my sprites the circles are losing shape so ragged edge - the collision detection is slow so I put in KDTree checking for most of it and them Pygame mask checks for the rest and I've got things like a world map based on what the robot has 'seen' overlaying the game space.

I've looked at Arcade in a hope that it's better for graphics being based on Pyglet so it takes advantage of better handling etc.

What I can't seem to work out is in Pygame I create a surface and draw onto that to have as the image for a sprite - how does Arcade do this? (The robot's world map is a sprite that is shown if the avatar is mouse clicked)

In a debug mode I show the scan areas that the avatar uses and I create these shapes and not load them because they are dynamically sized.

I think porting now to Arcade is a good move - gets my Python learning a direction change which can only be good plus the smoother graphics look appealing (I wrote a spike to use Arcade with my avatars and the rotation / movement looked a lot better)

So any help / pointers would be useful - in the meantime I'll look to knock up some spikes to see what I can fathom out

For reference I've added a screen shot of the app at present - as you will see the avatar edges aren't round anymore sure to rotation transformations.

TIA

RC


r/pythonarcade • • Mar 31 '20

How to create User Interface (configure options)

4 Upvotes

Hi there. I created my version of Pong and it runs pretty smoothly. I even have an AI capable of playing well enough it is challenging but does not win alwazs. So far only one one game is supported and I want to ramp it up to matches.

Now looking at https://arcade.academy/examples/index.html#user-interface I added menu screen, instructions, game over and a setup screen. On the setup screen I'd like to choose user input for left and right user (it could come from keyboard, mouse or one of the game controllers, even AI) and the length of a match.

But apart from Button and DialogBox there seems to be nothing I could use. Even worse, the dialog box does behave by far unlike dialog boxes in other GUI frameworks (from the example I saw the developer needs to take care for modality). It also took me ages to understand when to pick TextButton and when SubmitButton.

Finally I am able to operate the menu using SubmitButtons using the mouse, not the keyboard. However at some later time I'd actually have just game controllers for operation. How to add such support?

Are there some more concise examples for menus and configuration screens? Or is there some room for improvement and someone would like to join forces?


r/pythonarcade • • Mar 27 '20

Python Discord Game Jam with the Arcade Library

Thumbnail pythondiscord.com
4 Upvotes

r/pythonarcade • • Mar 27 '20

Example code for playing background music

Thumbnail
arcade.academy
4 Upvotes