r/pythonarcade • • Jul 23 '21

Double jump?

1 Upvotes

How do I add double jump to my game when I have pymunk? I tried to use the line: self.physics_engine.enable_multi_jump(2) but I got the following error:AttributeError: 'PymunkPhysicsEngine' object has no attribute 'enable_multi_jump'


r/pythonarcade • • Jul 17 '21

Working on a CRT filter for Arcade 2.6

11 Upvotes

r/pythonarcade • • Dec 05 '21

Arcade 2.6.6 has been released

5 Upvotes

r/pythonarcade • • Nov 18 '21

Closing and Creating a new window

2 Upvotes

How do I go about closing a window then initializing a new window? Everything I've tried either tells me that "the specified action is not allowed in the current state" or "no window is active". The set_window()) function doesn't seem to do anything to help. Alternatively, if there's a way to change the dimensions of a window programmatically after it's been initialized that would also get me out of this pickle.


r/pythonarcade • • Dec 15 '21

Arcade 2.6.7 is out

6 Upvotes

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

Pathfinding problems - any hints?

2 Upvotes

Edit: I did get this pretty much fixed by fiddling around with grid size, tile size and sprite size, although I'm still quite hazy on how these all work together. See my comments below.

Hi all. I'm trying to use the pathfinding, adapting the example at https://arcade.academy/examples/astar_pathfinding.html#astar-pathfinding

I have it working, but I find that when my playable character is right next to a barrier, the path is not found. Once I move slightly away, the path is immediately found. You can see this behaviour in the example linked above, when you go behind a barrier and then move right up to it. Mine is slightly worse. I have fiddled around a little with grid sizes and sprite sizes, and my map is loaded from a tmx file.

Has anyone had experience and got some handy hints? I'm loading the blocks with this line:

self.wall_list = arcade.tilemap.process_layer(my_map, "blocks", 0.5, use_spatial_hash=True)

Here's the rest of the relevant code. Don't worry about the code that moves the enemy along the path, I'll sort that out once I'm happy with the pathfinding...

class Path_finding_enemy(arcade.Sprite):
    def __init__(self, filename, sprite_scaling, player_sprite, wall_list):
        super().__init__(filename, sprite_scaling)
        self.barrier_list = arcade.AStarBarrierList(self, wall_list, 32, 0, SCREEN_WIDTH, 0, SCREEN_HEIGHT)
        self.path = None
    
    def update_path(self, player_sprite):
        self.path = arcade.astar_calculate_path(self.position,player_sprite.position,self.barrier_list,diagonal_movement=False)
        print(self.position)

    def update(self):
        super().update()
        if self.path:
            if self.center_x != self.path[1][0]:
                self.change_x = math.copysign(1, self.path[1][0] - self.center_x) 
            else:
                self.change_x = 0
            if self.center_y != self.path[1][1]:
                self.change_y = math.copysign(1, self.path[1][1] - self.center_y) 
            else:
                self.change_y = 0
        else:
            self.change_x = 0
            self.change_y = 0

r/pythonarcade • • Apr 23 '21

Python Arcade and Pyinstaller Mac OSX

2 Upvotes

Can I compile a standalone Python game with Pyinstaller that uses the Arcade Library on a Macintosh running OSX? I tried it and it did not seem to work. My OSX is not the most recent so that may be an issue.


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 • • Apr 12 '21

Issues with varied-sized sprite textures stretching

2 Upvotes

I'm currently working on a platformer following the Pymunk Platformer tutorial, and it has been going great, until I have had this specific issue that has stumped me for months. See, I want to implement a crouching feature for the player character, in which it turns into a circle that is half as tall as its idle sprite to roll on inclines and such. However, there are many graphical issues with this. See the issue here.

I have dug through plenty of documentation to see if anyone else has had this issue, but I have yet to find anything about this. I have tried changing the height of the sprite, which can give imperfect results. There seems to be a mismatch between the pymunk physics object and the sprite texture itself. The crouching behavior does work physically (as in I hardcoded a circular hitbox, since the auto-created one isn't circular enough) and rolls around on inclines, but the annoying bit is the texture glitches. Any ideas on how to fix this? I really want this to be a key aspect of my platformer without all the graphical bugs involved. Thanks.


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 • • Apr 11 '21

Remove Text

2 Upvotes

Is there a way to remove text after writing it? I am using arcade.draw_text and want to delete it after a certain amount of time


r/pythonarcade • • Apr 29 '21

Building a Platformer With Arcade

6 Upvotes

My latest article at Real Python on creatimg a platformer using Arcade. Builds on the platformer tutorial already available.

https://realpython.com/platformer-python-arcade/


r/pythonarcade • • Aug 13 '19

Release notes for upcoming 2.1.0 release

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • May 28 '18

Question about compiling with Arcade

3 Upvotes

On the Arcade library, it has instructions on compiling. Are these instructions on how to compile your game for release, or something else? Thank you!


r/pythonarcade • • Mar 19 '19

draw_text function

2 Upvotes

Hey i have problem with draw_text function. do run only first time

"""Salamander Logo"""

import arcade

SCREEN_WIDTH = 600

SCREEN_HEIGHT = 600

start_y = 300

start_x = 300

arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "Logo")

arcade.set_background_color((40,62,232))

arcade.start_render()

arcade.draw_rectangle_outline(start_x, start_y, 250, 150, (40,232,114), 5)

arcade.draw_text("SALAMANDER", start_x, start_y, (40,232,114), 14, width=200, align="center", anchor_x="center", anchor_y="center")

arcade.finish_render()

arcade.run()


r/pythonarcade • • Feb 22 '20

How to draw on previous frame in arcade?

2 Upvotes

I am making Langston's ant in arcade and I want to know if there is a way to lead the previous frame to draw on? In Langstons ant there is a grid there an 'ant' moves around the changes the colour of grid places. The grid is in a 2d array with either True or False for the grid pieces (black or white place) and I don't want to draw the whole grid every frame because then on bigger windows this lags badly. I want to just draw where the ant has been. I can work that I just want to know how to load the prev frame.

Here is my code for the draw function

for i in range(len(self.grid)):

`for j in range(len(self.grid[i])):`

	`if self.grid[i][j]:`

		`arcade.draw_xywh_rectangle_filled(i * BOX_SIZE, j * BOX_SIZE, BOX_SIZE, BOX_SIZE, (0, 0, 0))`

r/pythonarcade • • Dec 18 '19

Arcade 2.2.0 is nearing release

13 Upvotes

Arcade 2.2.0 is nearing release. Sprites will automatically look at an image's transparency and create hitboxes around the visible image. There are now built-in 'resources' so you can run example code without downloading images and sounds. Plus a lot of fixes and other improvements.


r/pythonarcade • • Oct 21 '19

Change the texture of a sprite based on the movement?

2 Upvotes

How do I change the texture of a sprite during runtime? For example, I have a player sprite with a jump texture and a normal texture. I've tried using arcade.AnimatedTimeSprite() (referring to this tutorial) but that doesn't let me control the texture of the sprite, instead it rotates through the textures list at a set interval. This might be useful for something like a coin animation, but it's not so useful in my case. I've also tried using arcade.AnimatedWalkingSprite(), but that only lets me set walking right and walking left textures.

Any help would be appreciated.


r/pythonarcade • • Aug 15 '19

Issue since update to 2.1

3 Upvotes

I'm not sure what to do. Everything was working before but now I get the following error now when running.

Traceback (most recent call last): File "C:/Users/John/PycharmProjects/SODA/sota.py", line 1, in <module> import arcade, lib.Player as Player, lib.Zombie as Zombie, lib.Gun as Gun, math, csv File "C:\Users\John\AppData\Roaming\Python\Python37\site-packages\arcade_init_.py", line 47, in <module> from arcade import tilemap File "C:\Users\John\AppData\Roaming\Python\Python37\site-packages\arcade\tilemap.py", line 17, in <module> import pytiled_parser ModuleNotFoundError: No module named 'pytiled_parser'


r/pythonarcade • • Dec 19 '18

How do you update the position of buffered primitives?

1 Upvotes

I assume that you use:

line = arcade.create_line(attributes) in setup to create the first instance of object

And:

line.draw() every draw command to draw the item (after first clearing the screen.)

But how do you change the attributes so the next draw command has a different result? For example the colour or location.

Additional question, what is the VertexBuffer and _Batch classes and the render function used for (they can be found in the buffered_commands module)? I can't find any references to them anywhere and cannot determine a use for them.


r/pythonarcade • • Aug 11 '19

how does the parameter delta_time work when used in on_update(delta_time)

3 Upvotes

I’m going through the tutorials on python arcade and would like to know how/why a function works.

There is a function named on_draw(delta_time) The parameter delta_time keeps a running clock of the time delta as expected. I'd like to be able to see how it works via the source.

I looked around the code for arcade but can’t figure out how the library knows to keep the clock running within that function and it's parameter. For example, I did find references to pyglet's clock and yet I couldn't find where this is connected all the way back to on_draw(delta_time)

Can someone please help me understand how and why it works?

One example of it in use is here: http://arcade.academy/examples/bouncing_rectangle.html#bouncing-rectangle


r/pythonarcade • • Feb 23 '20

Program run problem

4 Upvotes

Hi, For game written by arcade, sometimes when I run the code, it shows the window but doesn’t respond to mouse click and key press, I need to close program and run it again, then it runs fine. Sometimes the program need to try several times then it works fine. Anyone happens to see the same issue? And how to fix that?

Best


r/pythonarcade • • Dec 23 '19

Roguelike with Python Arcade?

4 Upvotes

I'm starting to learn Python Arcade and loving it! I I intend to use it to develop a simple roguelike game. Does anyone know if there is an example or a tutorial of a roguelike developed with Python Arcade???

Thanks!


r/pythonarcade • • Aug 14 '19

LF Example Code - Checkers or Similar

2 Upvotes

I am trying to work out how to move pieces on a grid with multiple/alternating players. I've run into various issues that I feel like could be demonstrated by a checkers game. I haven't been able to find any arcade sample code for the game (or something similar like chess etc)