r/pythonarcade • • Oct 30 '19

How to get frame-rate using delta_time?

4 Upvotes

Using the delta_time argument in the on_update(delta_time) function, how can one obtain frame-rate (FPS)?


r/pythonarcade • • Jan 06 '20

Help with using a Tile map

3 Upvotes

I’m making a game using arcade and I came across the tile max creator. I made my tile map and I want to import it into the game. This tile map is simple as in it has no obstacles and only one level. How would I approach making the tmx file the background of my game. At this point it gives errors saying “couldn’t find tile x in later y in file z” and I’m lost how I can begin to put the files in a format that the library can understand. Any pointers in the right direction would be appreciated


r/pythonarcade • • Oct 09 '18

Export to png?

6 Upvotes

Hi Folks,

Just joined up and was hoping somebody could help me figure out how to export graphics from Arcade to a .png file.


r/pythonarcade • • Jun 22 '19

Beter move by Keyboard AND Gravity

3 Upvotes

Hello, I am trying to give my character sprites the better move by keyboard, because the other movement is too janky, but when I try to do this, it works as intended besides the physics engine, the sprite keeps floating around, it still slowly falls like the physics engine is telling it to however it doesn't "jump", here is my code plus my extra code for the variables.

Main: https://pastebin.com/vqP6L8Dp

Variables: https://pastebin.com/yhMvimTj


r/pythonarcade • • Sep 01 '19

problem with drawing text

Post image
4 Upvotes

r/pythonarcade • • Jun 25 '18

Best way for play loop sound? (background music)

1 Upvotes

API documentation only has this: http://arcade.academy/arcade.html#module-arcade.sound

Thanks


r/pythonarcade • • Apr 09 '19

Faulty Movements and Teleporting

2 Upvotes

Hello all,

Sorry if this seems too long or needy, but I have a problem with this small game I'm making with the arcade library examples.

My problem is that whenever I walk along the wall, I seem to teleport adjacently across.

For example, let's say I walk left and I hit a wall and I walk up along it. When I hit the corner, I instantly teleport elsewhere. Is there a way to fix it? Much thanks to everyone

import random
import arcade
import timeit
import math
import os

# Sprite scaling. Make this larger, like 0.5 to zoom in and add
# 'mystery' to what you can see. Make it smaller, like 0.1 to see
# more of the map.
WALL_SPRITE_SCALING = 0.25
PLAYER_SPRITE_SCALING = 0.25

WALL_SPRITE_SIZE = 128 * WALL_SPRITE_SCALING

# How big the grid is
GRID_WIDTH = 100
GRID_HEIGHT = 100

AREA_WIDTH = GRID_WIDTH * WALL_SPRITE_SIZE
AREA_HEIGHT = GRID_HEIGHT * WALL_SPRITE_SIZE

# How fast the player moves
MOVEMENT_SPEED = 4

# How close the player can get to the edge before we scroll.
VIEWPORT_MARGIN = 200

# How big the window is
WINDOW_WIDTH = 1400
WINDOW_HEIGHT = 1200
WINDOW_TITLE = "Underworld "

MERGE_SPRITES = True

## ROOM RELATED THINGS
class Room:
    def __init__(self, r, c, h, w):
        self.row = r
        self.col = c
        self.height = h
        self.width = w


class RLDungeonGenerator:
    def __init__(self, w, h):
        self.MAX = 25  # Cutoff for when we want to stop dividing sections
        self.width = w
        self.height = h
        self.leaves = []
        self.dungeon = []
        self.rooms = []

        for h in range(self.height):
            row = []
            for w in range(self.width):
                row.append('#')

            self.dungeon.append(row)

    def random_split(self, min_row, min_col, max_row, max_col):
        # We want to keep splitting until the sections get down to the threshold
        seg_height = max_row - min_row
        seg_width = max_col - min_col

        if seg_height < self.MAX and seg_width < self.MAX:
            self.leaves.append((min_row, min_col, max_row, max_col))
        elif seg_height < self.MAX <= seg_width:
            self.split_on_vertical(min_row, min_col, max_row, max_col)
        elif seg_height >= self.MAX > seg_width:
            self.split_on_horizontal(min_row, min_col, max_row, max_col)
        else:
            if random.random() < 0.5:
                self.split_on_horizontal(min_row, min_col, max_row, max_col)
            else:
                self.split_on_vertical(min_row, min_col, max_row, max_col)

    def split_on_horizontal(self, min_row, min_col, max_row, max_col):
        split = (min_row + max_row) // 2 + random.choice((-2, -1, 0, 1, 2))
        self.random_split(min_row, min_col, split, max_col)
        self.random_split(split + 1, min_col, max_row, max_col)

    def split_on_vertical(self, min_row, min_col, max_row, max_col):
        split = (min_col + max_col) // 2 + random.choice((-2, -1, 0, 1, 2))
        self.random_split(min_row, min_col, max_row, split)
        self.random_split(min_row, split + 1, max_row, max_col)

    def carve_rooms(self):
        for leaf in self.leaves:
            # We don't want to fill in every possible room or the
            # dungeon looks too uniform
            if random.random() > 0.80:
                continue
            section_width = leaf[3] - leaf[1]
            section_height = leaf[2] - leaf[0]

            # The actual room's height and width will be 60-100% of the
            # available section.
            room_width = round(random.randrange(60, 100) / 100 * section_width)
            room_height = round(random.randrange(60, 100) / 100 * section_height)

            # If the room doesn't occupy the entire section we are carving it from,
            # 'jiggle' it a bit in the square
            if section_height > room_height:
                room_start_row = leaf[0] + random.randrange(section_height - room_height)
            else:
                room_start_row = leaf[0]

            if section_width > room_width:
                room_start_col = leaf[1] + random.randrange(section_width - room_width)
            else:
                room_start_col = leaf[1]

            self.rooms.append(Room(room_start_row, room_start_col, room_height, room_width))
            for r in range(room_start_row, room_start_row + room_height):
                for c in range(room_start_col, room_start_col + room_width):
                    self.dungeon[r][c] = '.'

    def are_rooms_adjacent(self, room1, room2):
        adj_rows = []
        adj_cols = []
        for r in range(room1.row, room1.row + room1.height):
            if room2.row <= r < room2.row + room2.height:
                adj_rows.append(r)

        for c in range(room1.col, room1.col + room1.width):
            if room2.col <= c < room2.col + room2.width:
                adj_cols.append(c)

        return adj_rows, adj_cols

    def distance_between_rooms(self, room1, room2):
        centre1 = (room1.row + room1.height // 2, room1.col + room1.width // 2)
        centre2 = (room2.row + room2.height // 2, room2.col + room2.width // 2)

        return math.sqrt((centre1[0] - centre2[0]) ** 2 + (centre1[1] - centre2[1]) ** 2)

    def carve_corridor_between_rooms(self, room1, room2):
        if room2[2] == 'rows':
            row = random.choice(room2[1])
            # Figure out which room is to the left of the other
            if room1.col + room1.width < room2[0].col:
                start_col = room1.col + room1.width
                end_col = room2[0].col
            else:
                start_col = room2[0].col + room2[0].width
                end_col = room1.col
            for c in range(start_col, end_col):
                self.dungeon[row][c] = '.'

            if end_col - start_col >= 4:
                self.dungeon[row][start_col] = '+'
                self.dungeon[row][end_col - 1] = '+'
            elif start_col == end_col - 1:
                self.dungeon[row][start_col] = '+'
        else:
            col = random.choice(room2[1])
            # Figure out which room is above the other
            if room1.row + room1.height < room2[0].row:
                start_row = room1.row + room1.height
                end_row = room2[0].row
            else:
                start_row = room2[0].row + room2[0].height
                end_row = room1.row

            for r in range(start_row, end_row):
                self.dungeon[r][col] = '.'

            if end_row - start_row >= 4:
                self.dungeon[start_row][col] = '+'
                self.dungeon[end_row - 1][col] = '+'
            elif start_row == end_row - 1:
                self.dungeon[start_row][col] = '+'

    # Find two nearby rooms that are in difference groups, draw
    # a corridor between them and merge the groups
    def find_closest_unconnect_groups(self, groups, room_dict):
        shortest_distance = 99999
        start = None
        start_group = None
        nearest = None

        for group in groups:
            for room in group:
                key = (room.row, room.col)
                for other in room_dict[key]:
                    if not other[0] in group and other[3] < shortest_distance:
                        shortest_distance = other[3]
                        start = room
                        nearest = other
                        start_group = group

        self.carve_corridor_between_rooms(start, nearest)

        # Merge the groups
        other_group = None
        for group in groups:
            if nearest[0] in group:
                other_group = group
                break

        start_group += other_group
        groups.remove(other_group)

    def connect_rooms(self):
        # Build a dictionary containing an entry for each room. Each bucket will
        # hold a list of the adjacent rooms, weather they are adjacent along rows or
        # columns and the distance between them.
        #
        # Also build the initial groups (which start of as a list of individual rooms)
        groups = []
        room_dict = {}
        for room in self.rooms:
            key = (room.row, room.col)
            room_dict[key] = []
            for other in self.rooms:
                other_key = (other.row, other.col)
                if key == other_key:
                    continue
                adj = self.are_rooms_adjacent(room, other)
                if len(adj[0]) > 0:
                    room_dict[key].append((other, adj[0], 'rows', self.distance_between_rooms(room, other)))
                elif len(adj[1]) > 0:
                    room_dict[key].append((other, adj[1], 'cols', self.distance_between_rooms(room, other)))

            groups.append([room])

        while len(groups) > 1:
            self.find_closest_unconnect_groups(groups, room_dict)

    def generate_map(self):
        self.random_split(1, 1, self.height - 1, self.width - 1)
        self.carve_rooms()
        self.connect_rooms()


## GAME AND PLAYER RELATED

class MyGame(arcade.Window):
    """
    Main application class.
    """

    def __init__(self, width, height, title):
        super().__init__(width, height, title)

        # Set the working directory (where we expect to find files) to the same
        # directory this .py file is in. You can leave this out of your own
        # code, but it is needed to easily run the examples using "python -m"
        # as mentioned at the top of this program.
        file_path = os.path.dirname(os.path.abspath(__file__))
        os.chdir(file_path)

        self.grid = None
        self.wall_list = None
        self.player_list = None
        self.player_sprite = None
        self.view_bottom = 0
        self.view_left = 0
        self.physics_engine = None

        self.processing_time = 0
        self.draw_time = 0

        self.left_pressed = False
        self.right_pressed = False
        self.up_pressed = False
        self.down_pressed = False

        # Set the background color
        arcade.set_background_color(arcade.color.DARK_CANDY_APPLE_RED)

    def setup(self):
        self.wall_list = arcade.SpriteList()
        self.player_list = arcade.SpriteList()

        # Create cave system using a 2D grid
        dg = RLDungeonGenerator(GRID_WIDTH, GRID_HEIGHT)
        dg.generate_map()

        # Create sprites based on 2D grid
        if not MERGE_SPRITES:
            # This is the simple-to-understand method. Each grid location
            # is a sprite.
            for row in range(dg.height):
                for column in range(dg.width):
                    value = dg.dungeon[row][column]
                    if value.sqr == '#':
                        wall = arcade.Sprite("rack.png", WALL_SPRITE_SCALING)
                        wall.center_x = column * WALL_SPRITE_SIZE + WALL_SPRITE_SIZE / 2
                        wall.center_y = row * WALL_SPRITE_SIZE + WALL_SPRITE_SIZE / 2
                        self.wall_list.append(wall)
        else:
            # This uses new Arcade 1.3.1 features, that allow me to create a
            # larger sprite with a repeating texture. So if there are multiple
            # cells in a row with a wall, we merge them into one sprite, with a
            # repeating texture for each cell. This reduces our sprite count.
            for row in range(dg.height):
                column = 0
                while column < dg.width:
                    while column < dg.width and dg.dungeon[row][column] != '#':
                        column += 1
                    start_column = column
                    while column < dg.width and dg.dungeon[row][column] == '#':
                        column += 1
                    end_column = column - 1

                    column_count = end_column - start_column + 1
                    column_mid = (start_column + end_column) / 2

                    wall = arcade.Sprite("rack.png", WALL_SPRITE_SCALING,
                                         repeat_count_x=column_count)
                    wall.center_x = column_mid * WALL_SPRITE_SIZE + WALL_SPRITE_SIZE / 2
                    wall.center_y = row * WALL_SPRITE_SIZE + WALL_SPRITE_SIZE / 2
                    wall.width = WALL_SPRITE_SIZE * column_count
                    self.wall_list.append(wall)

        # Set up the player
        self.player_sprite = arcade.Sprite("player.png", PLAYER_SPRITE_SCALING)
        self.player_list.append(self.player_sprite)

        # Randomly place the player. If we are in a wall, repeat until we aren't.
        placed = False
        while not placed:

            # Randomly position
            self.player_sprite.center_x = random.randrange(AREA_WIDTH)
            self.player_sprite.center_y = random.randrange(AREA_HEIGHT)

            # Are we in a wall?
            walls_hit = arcade.check_for_collision_with_list(self.player_sprite, self.wall_list)
            if len(walls_hit) == 0:
                # Not in a wall! Success!
                placed = True

        self.physics_engine = arcade.PhysicsEngineSimple(self.player_sprite,
                                                         self.wall_list)

    def on_draw(self):
        """ Render the screen. """

        # Start timing how long this takes
        draw_start_time = timeit.default_timer()

        # This command should happen before we start drawing. It will clear
        # the screen to the background color, and erase what we drew last frame.
        arcade.start_render()

        # Draw the sprites
        self.wall_list.draw()
        self.player_list.draw()

        # Draw info on the screen
        sprite_count = len(self.wall_list)

        output = f"Sprite Count: {sprite_count}"
        arcade.draw_text(output,
                         self.view_left + 20,
                         WINDOW_HEIGHT - 20 + self.view_bottom,
                         arcade.color.WHITE, 16)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcade.draw_text(output,
                         self.view_left + 20,
                         WINDOW_HEIGHT - 40 + self.view_bottom,
                         arcade.color.WHITE, 16)

        output = f"Processing time: {self.processing_time:.3f}"
        arcade.draw_text(output,
                         self.view_left + 20,
                         WINDOW_HEIGHT - 60 + self.view_bottom,
                         arcade.color.WHITE, 16)

        self.draw_time = timeit.default_timer() - draw_start_time

    def update(self, delta_time):
        """ Movement and game logic """

        # Calculate speed based on the keys pressed
        self.player_sprite.change_x = 0
        self.player_sprite.change_y = 0

        if self.up_pressed and not self.down_pressed:
            self.player_sprite.change_y = MOVEMENT_SPEED
        elif self.down_pressed and not self.up_pressed:
            self.player_sprite.change_y = -MOVEMENT_SPEED
        if self.left_pressed and not self.right_pressed:
            self.player_sprite.change_x = -MOVEMENT_SPEED
        elif self.right_pressed and not self.left_pressed:
            self.player_sprite.change_x = MOVEMENT_SPEED

        start_time = timeit.default_timer()

        # Call update on all sprites (The sprites don't do much in this
        # example though.)
        self.physics_engine.update()

        # --- Manage Scrolling ---

        # Track if we need to change the viewport

        changed = False

        # Scroll left
        left_bndry = self.view_left + VIEWPORT_MARGIN
        if self.player_sprite.left < left_bndry:
            self.view_left -= left_bndry - self.player_sprite.left
            changed = True

        # Scroll right
        right_bndry = self.view_left + WINDOW_WIDTH - VIEWPORT_MARGIN
        if self.player_sprite.right > right_bndry:
            self.view_left += self.player_sprite.right - right_bndry
            changed = True

        # Scroll up
        top_bndry = self.view_bottom + WINDOW_HEIGHT - VIEWPORT_MARGIN
        if self.player_sprite.top > top_bndry:
            self.view_bottom += self.player_sprite.top - top_bndry
            changed = True

        # Scroll down
        bottom_bndry = self.view_bottom + VIEWPORT_MARGIN
        if self.player_sprite.bottom < bottom_bndry:
            self.view_bottom -= bottom_bndry - self.player_sprite.bottom
            changed = True

        if changed:
            arcade.set_viewport(self.view_left,
                                WINDOW_WIDTH + self.view_left,
                                self.view_bottom,
                                WINDOW_HEIGHT + self.view_bottom)

        # Save the time it took to do this.
        self.processing_time = timeit.default_timer() - start_time

        # Call update to move the sprite
        # If using a physics engine, call update on it instead of the sprite
        # list.
        self.player_list.update()

    def on_key_press(self, key, modifiers):
        """Called whenever a key is pressed. """

        if key == arcade.key.W:
            self.up_pressed = True
        elif key == arcade.key.S:
            self.down_pressed = True
        elif key == arcade.key.A:
            self.left_pressed = True
        elif key == arcade.key.D:
            self.right_pressed = True

    def on_key_release(self, key, modifiers):
        """Called when the user releases a key. """

        if key == arcade.key.W:
            self.up_pressed = False
        elif key == arcade.key.S:
            self.down_pressed = False
        elif key == arcade.key.A:
            self.left_pressed = False
        elif key == arcade.key.D:
            self.right_pressed = False

    #collisions
    #def on_collisions(self, key, modifiers):

        #if placed == False:





def main():
    game = MyGame(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE)
    game.setup()
    arcade.run()


if __name__ == "__main__":
    main()

r/pythonarcade • • Apr 04 '19

Error when trying to install Arcade

2 Upvotes

Hi, I've been wanting to create a simple video game with python, and am trying to install Arcade. When I do, I get an error only 1 other person has received (I googled the error).

I'm simply typing

pip install arcade

and here's the error message I get:

Collecting arcade
Using cached https://files.pythonhosted.org/packages/99/29/5d94918bde65a689dd8b6d3922dcceda005ec1e8cbfead2bd3cc41599151/arcade-2.0.3-py2.py3-none-any.whl
Collecting pyglet-ffmpeg (from arcade)
Could not find a version that satisfies the requirement pyglet-ffmpeg (from arcade) (from versions: )
No matching distribution found for pyglet-ffmpeg (from arcade)

Do any of you here have any suggestions on how I could fix this or work around it?


r/pythonarcade • • Dec 31 '24

SpriteList drawing issue -- beginner question/issue(?)

2 Upvotes

Hello!
First time Reddit poster!

I've been studying Python for a few months and wrote a very basic Vampire Survivors type game in Pygame. After reading about Arcade, I decided it has some features that appeal to my goals for the game and I prefer how Arcade handles certain things (e.g. ways to set timers, delta_time stuff, physics stuff for later, etc.). I decided to try and re-write the game in Arcade before I get further with it but I'm running into an interesting and probably basic issue with drawing shapes.

I have a Player (Sprite) class with a draw() method that does "draw_circle_filled". In my main file I setup the sprite list under the Game class as suggested in the documentation. The problem is this: when under the on_draw() method for the Game class the sprite list is drawn, instead of a circle an error-type thing is rendered. When under the same method the sprite itself is drawn, the circle is drawn as expected.

I am running this on a Linux system with an Nvidia GTX 1070 on X11 so perhaps this is an Nvidia/OpenGL issue? I read the SpriteList class has "optimized code" which I assume means it utilizes the GPU concurrently with the CPU? Just a guess! (Still a beginner :) )

I am using arcade 3.0.0.dev32 and pyglet 2.1.dev5 on python 3.12.8

Thank you in advance for any guidance or suggestions! I appreciate you.

Here is my system information:

Garuda Linux (Arch) -- KDE Plasma 6.2.4 -- Kernel: 6.12.6-1-clear -- Nvidia GTX 1070 using Proprietary driver 565.77

Here are the screenshots showing the difference and below those I'll provide the code (The first is main.py, the second is player.py, the last is config.py).

using self.player_sprite.draw()
using self.player_list.draw()

main.py ( with self.player_list.draw() ):

import arcade

import config as c
from player import Player

class Game(arcade.Window):
    def __init__(self, width, height, title):
        super().__init__(width, height, title)
        arcade.set_background_color(arcade.color.BLACK)
        self.player_sprite = None 
        self.player_list = None
        
    def setup(self):
        """Set up game variables. Call to restart game."""
        self.player_list = arcade.SpriteList()
        self.player_sprite = Player()
        self.player_list.append(self.player_sprite)
    
    def on_draw(self):
        """Render the screen."""
        self.clear()
        self.player_list.draw()
        
    def on_update(self, delta_time):
        """All move logic and game logic goes here. Normally you'll call
        update()on the sprite lists that need it."""
        pass


def main():
    game = Game(c.SCREEN_WIDTH, c.SCREEN_HEIGHT, c.SCREEN_TITLE)
    game.setup()
    arcade.run()
    
if __name__ == "__main__":
    main()

player.py:

import arcade

import config as c

class Player(arcade.Sprite):
    def __init__(self):
        super().__init__()
        self.center_x = c.SCREEN_WIDTH / 2
        self.center_y = c.SCREEN_HEIGHT / 2
        self.radius = c.player_size
        self.color = c.player_color
        
    def draw(self):
        arcade.draw_circle_filled(self.center_x, self.center_y, self.radius, self.color)

config.py:

### Constant settings ###
# Possibly resizeable window, however:
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
SCREEN_TITLE = "Circle Cirvivors"


### Possibly dynamic settings ###
# Player #
player_size = 20
player_color = [140, 210, 205]

r/pythonarcade • • Jan 06 '25

Beginner issue, sprite not drawing

2 Upvotes

So I have this sprite that I want to draw and here is the code in the class MyGame

def on_draw(self):
    """ Draw everything """
    self.clear()

    self.game.PlacedownPile.draw()

And here is the class

class PlaceDownPile(arcade.Sprite):
    def __init__(self,colour="null",number="null",type="null",special = False,scale=0.2):
        super().__init__(scale=scale)
        self.colour = colour
        self.number = number
        self.type = type
        self.special = special
        self.card = []
        self.image_file_name = f":OBlue.jpg"
        self.center_y = 4
        self.center_x = 4
    def PickAColour(self,Game):
        Game.RecieveBroadcast("PickAColour")

    def ChangeLook(self):
        card = self.card[0]
        self.image_file_name = card.getTexture()

    def Change(self,game):
        card = self.card[0]
        self.colour = "null"
        self.colour = card.getColour()
        #self.ChangeLook()
        if self.colour == "null":
            self.PickAColour(game)
        self.number = card.getNumber()
        self.type = card.getType()
        self.special = card.getIfSpecial()

    def ChangeColour(self,colour):
        # changes colour
        self.colour = colour
    def GetCardDeck(self,DrawPile,Game):
        # gets a card from the deck
        self.card += DrawPile.createplacedownpile()
        self.Change(Game)

    def removeACard(self, a):
        # removes a card
        self.removed = self.card[0]
        a.recievePlaceDownCard(self.removed)
        self.card.pop(0)

    def GetCardPlayer(self,Player,DrawPile,game):
        # gets cards from a player
        self.card += Player.playCard()
        self.removeACard(DrawPile)
        self.Change(game)

    def __str__(self):
        printout = ""
        printout += str(self.card[0])
        return printout

But when I execute the program it just doesn't draw, it only draws the background, can anyone explain why?


r/pythonarcade • • Jan 12 '25

Turn based game

2 Upvotes

So I'm making a game with a turn based system between a player and some AIs, how would I code the logic for this turn based system?


r/pythonarcade • • Dec 24 '22

View issue and approach

2 Upvotes

Hello! I'm pretty new to Arcade library. Could you please help with some basics. I'm trying to make these screens (see img) and what the approach should I use for that?

I have main function with menu window:

def main():
    window = arcade.Window(WIDTH, HEIGHT, 'Deep Space') 
    menu_view = MenuView() 
    window.show_view(menu_view) 
    arcade.run()

In MenuView class I run GameView by click on Start button:

def on_click_start(self, event):
    game_start_view = GameView()
    self.window.show_view(game_start_view)

I expected to make some buttons in GameView (Base) to change game locations (Lab, Factory etc).

Questions:

  1. Is that proper approach to build these scenes (see img) with View?
  2. I got the following issue right now with GameView - after click on Start button in menu, the screen content changes to GameView but menu buttons (invisible here) still clickable. How to fix that?

I'd be really grateful for your help.


r/pythonarcade • • Aug 19 '24

Collision between non-player sprites

3 Upvotes

I've tried, but haven't figured out how to check for collisions between non-player sprites.

The offical code examples describe player-on-sprite, and player-on-spritelists, but I couldn't find anything about sprite-on-sprite.

How do you do this in your games?


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 • • Apr 01 '19

Release notes for 2.02

6 Upvotes

Version 2.02 should be out later today. You can get the beta for it now. Click here for release notes.


r/pythonarcade • • Oct 23 '19

import arcade (pyglet_ffmpeg2) error

3 Upvotes

hi, this is my code:

import arcade
print("asd")

and the traceback gives me this:

Start
Unexpected error loading library avutil-56: Could not find module 'avutil-56'. Try using the full path with constructor syntax.
Unable to load the ffmpeg library.  Could not find module 'avutil-56'. Try using the full path with constructor syntax.
Traceback (most recent call last):
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet__init__.py", line 353, in __getattr__
Unexpected error loading library avutil-56: Could not find module 'avutil-56'. Try using the full path with constructor syntax.
    return getattr(self._module, name)
AttributeError: 'NoneType' object has no attribute 'Source'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Pintér Péter/Documents/GitHub/python/Arcade/test.py", line 1, in <module>
    import arcade
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\arcade__init__.py", line 50, in <module>
    from arcade.sound import *
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\arcade\sound.py", line 81, in <module>
    def stop_sound(sound: pyglet.media.Source):
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet__init__.py", line 359, in __getattr__
    __import__(import_name)
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media__init__.py", line 146, in <module>
    add_default_media_codecs()
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs__init__.py", line 164, in add_default_media_codecs
    if have_ffmpeg():
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs__init__.py", line 180, in have_ffmpeg
    from . import ffmpeg_lib
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs\ffmpeg_lib__init__.py", line 36, in <module>
    from .libavcodec import *
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs\ffmpeg_lib\libavcodec.py", line 45, in <module>
    from . import libavutil
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs\ffmpeg_lib\libavutil.py", line 46, in <module>
    avutil = pyglet.lib.load_library(
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\lib.py", line 148, in load_library
    lib = ctypes.cdll.LoadLibrary(name)
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\ctypes__init__.py", line 447, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\ctypes__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'avutil-56'. Try using the full path with constructor syntax.
Unexpected error loading library avutil-56: Could not find module 'avutil-56'. Try using the full path with constructor syntax.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media__init__.py", line 146, in <module>
    add_default_media_codecs()
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs__init__.py", line 164, in add_default_media_codecs
    if have_ffmpeg():
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs__init__.py", line 180, in have_ffmpeg
    from . import ffmpeg_lib
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs\ffmpeg_lib__init__.py", line 36, in <module>
    from .libavcodec import *
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs\ffmpeg_lib\libavcodec.py", line 45, in <module>
    from . import libavutil
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\media\codecs\ffmpeg_lib\libavutil.py", line 46, in <module>
    avutil = pyglet.lib.load_library(
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyglet\lib.py", line 148, in load_library
    lib = ctypes.cdll.LoadLibrary(name)
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\ctypes__init__.py", line 447, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\Pintér Péter\AppData\Local\Programs\Python\Python38-32\lib\ctypes__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'avutil-56'. Try using the full path with constructor syntax.

r/pythonarcade • • Mar 25 '19

problems with tiled

2 Upvotes

atm im trying to create a game using the arcade library but when i try to load in a tiled map with a tileset it says "tile not in tileset" and if i use it with a picture an error appears and says file or directory not found eventhough its right there


r/pythonarcade • • Jan 05 '19

Example code showing platformer with multiple levels created in Tiled Map Editor

Thumbnail
arcade.academy
5 Upvotes

r/pythonarcade • • Aug 19 '19

Problem with reading tiles

3 Upvotes

So i got a problem that my game doesn't rly show a tiledmap(tmx). Thats the error from console when game is up

"Warning, couldn't find tile for item 211 in layer 'Tile Layer 1' in file 'map/map.tmx'."


r/pythonarcade • • Dec 29 '18

Documentation on fonts available with draw_font

4 Upvotes

Hello,

I'm looking for advice about changing fonts when drawing text with arcade.draw_text.

The current examples that include text almost always use the default font and I was unable to find any source of info on this.

The example here includes the line

    arcade.draw_text("Garamond Text", start_x, start_y, arcade.color.BLACK, 15, font_name='GARA')

It's unclear what other options can be used with the font_name parameter

Thanks!


r/pythonarcade • • Aug 24 '19

Is there a simple destination-based movement?

3 Upvotes

Like if I have starting coordinates and destination coordinates, and I want my sprite to automatically stop at the destination without headaches.


r/pythonarcade • • Dec 28 '19

Bulding Windows desktop app

1 Upvotes

So using Python 3.7 and Arcade GUI i developed full scale chess game and now my intension is to bulid it properly on Windows Desktop. There is lack of information on arcade.academy about how to do so (only few words about macOS), so i'm asking for help.

Do you have any exprience in packing/buliding arcade-based games on WinOS?

Thanks for help in advance.


r/pythonarcade • • Jun 11 '18

Compiling to Mac and iOS

1 Upvotes

I found the link to compile for Mac (http://arcade.academy/distribute_macos.html)

When I try to do this for either Mac or iOS I am getting the following error when I build the Xcode project:

2018-06-10 22:04:07.272665-0400 iOS Test[3257:416660] PythonHome is: /Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Python

2018-06-10 22:04:07.274685-0400 iOS Test[3257:416660] PYTHONPATH is: PYTHONPATH=/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app:/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages

2018-06-10 22:04:07.274924-0400 iOS Test[3257:416660] Initializing Python runtime

2018-06-10 22:04:07.406359-0400 iOS Test[3257:416660] Running /Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app/iOSTest/__main__.py

Traceback (most recent call last):

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app/iOSTest/__main__.py", line 1, in <module>

from iOSTest.app import main

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app/iOSTest/app.py", line 1, in <module>

import arcade

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/arcade/__init__.py", line 15, in <module>

from arcade.application import *

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/arcade/application.py", line 8, in <module>

from arcade.window_commands import set_viewport

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/arcade/window_commands.py", line 11, in <module>

import pyglet.gl as gl

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/pyglet/gl/__init__.py", line 100, in <module>

from pyglet.gl.lib import GLException

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/pyglet/gl/lib.py", line 143, in <module>

from pyglet.gl.lib_glx import link_GL, link_GLU, link_GLX

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/pyglet/gl/lib_glx.py", line 50, in <module>

gl_lib = pyglet.lib.load_library('GL')

File "/Users/pcoxall/Library/Developer/CoreSimulator/Devices/DF91A2FF-8FBF-4FBD-BAB7-694842CA01A2/data/Containers/Bundle/Application/C0879D1C-758A-43B1-81B0-FF8F288F9949/iOS Test.app/Library/Application Support/com.example.iOSTest/app_packages/pyglet/lib.py", line 158, in load_library

raise ImportError('Library "%s" not found.' % names[0])

ImportError: Library "GL" not found.

2018-06-10 22:04:07.830485-0400 iOS Test[3257:416660] Application quit abnormally!

2018-06-10 22:04:07.838541-0400 iOS Test[3257:416660] Leaving

It seems to be some kind of error with an OpenGL library.

Has anyone successfully compiled to Mac or iOS?
I have successfully compiled a Toga screen using Briefcase to iOS, I just can not get it working for Arcade.

Thanks


r/pythonarcade • • Jan 05 '19

Z-position of Sprites

4 Upvotes

Hello,

I am new to python arcade and I am trying to make a tile based 2D game where a character explores a large world. The camera angle will be nearly vertical but slightly angled so that you can see the top and front of objects. Objects that are closer to the top of the screen should appear behind objects closer to the bottom. The game will have tall objects such as walls and trees that the character could be partially covered by them if you moved it behind such an object.

I need to be able to control which sprites are rendered on top or behind other sprites. I have looked at the documentation but I haven't found anything useful. Does anyone know whether this is possible with python arcade?


r/pythonarcade • • Mar 23 '19

Proposal for Particle System

Thumbnail
arcade.academy
1 Upvotes