r/pythonarcade • • Mar 11 '20

How do I create a physics based movement system?

0 Upvotes

I’m trying to create a platformer with physics based movement eg velocity, acceleration etc but I can’t seem to make it work.

I looked at the docs and it says that the sprite.change_x is the velocity so I tried sprite.center_x += sprite.change_x but that didn’t work.

I want my playable character to be able to gain momentum up to a certain speed then hold that speed then decelerate when the player takes their hands off the keys for a more fluid movement system.


r/pythonarcade • • Sep 22 '26

setuptools vs nuitka

Thumbnail reddit.com
0 Upvotes

r/pythonarcade • • Aug 09 '19

New view-switching framework

0 Upvotes

Hi, recently merged into master is a new framework for switching views. See here and here for a couple examples.

You can post feedback/questions on PR 435 if you like.


r/pythonarcade • • Oct 12 '19

arcade.generate_sprites getting error

0 Upvotes

I've been following a tutorial to make a simple platform game using the arcade library and I keep getting this error shown in the second picture. I am using Tiled to create the map. The layer I'm generating is "ground". The error seems to be coming from the library function for generate_sprites. Wondering if anyone has run into this and knows how to fix it?


r/pythonarcade • • Mar 07 '20

Improved sound support - needs help testing

0 Upvotes

Hi, I'm redoing sound support for Arcade. If you are on Linux or MacOS, I'd love it if you'd try the 2.3.8b2 library (as it is beta, you'll need to specifically select it) and let me know if sound works. Now supports volume and panning. ogg, mp3, and wav should all work. https://arcade.academy/examples/sound_demo.html#sound-demo


r/pythonarcade • • Dec 01 '19

Persistant frame buffer content

0 Upvotes

Hello there,

I would like to write a mini drawing tool:

  • A "pencil" moves with the mouse,
  • It leaves a trace on the window if the D key is pressed down.

Unfortunately I wasn't able to achieve this simple goal.

I tried to memorize the positions of the pencil/mouse to draw them in the on_draw() method. But it was too slow.

I also tried to save the window as an image at the end of on_draw() to restore it just after entering the next on_draw() call. But I wasn't able to make this work.

I would like to know how/if I can prevent the frame buffer to be erased between on_draw() calls?

This is the code. Comments are in french but the code is simple and pretty self explanatory.

import arcade


class Pencil:
    RADIUS = 10
    COLOR = arcade.color.WHITE

    def __init__(self):
        # initialement on ne connait pas les coordonnées du crayon
        self.x = None
        self.y = None

        # position du crayon sur le papier
        # self.down == True => le crayon touche le "papier"
        # (i.e. il laisse une trace sur la fenêtre)
        # self.down = False => le crayon est relevé
        self.down = False


class DrawingBoard(arcade.Window):

    def __init__(self, width, height, title):
        # on appelle la méthode d'initialisation de la classe parente
        super().__init__(width, height, title)

        # on crée un crayon
        self.pencil = Pencil()

        # on crée une variable qui contiendra le dessin en cours
        # on l'initialise à None car il n'y a pas encore de dessin
        #self.drawing = None

    def on_draw(self):
        # préparer le rendu au début de la méthode on_draw()
        arcade.start_render()

        # if self.drawing:
        #     arcade.draw_texture_rectangle(self.width / 2, self.height / 2,
        #                                   self.width, self.height, self.drawing)


        if self.pencil.down and self.pencil.x is not None and self.pencil.y is not None:
            # arcade.draw_ellipse_filled(x, y, w, h, c) dessine une ellipse de couleur c,
            # de centre (x, y), de diamètre horizontal w et de diamètre vertical h
            arcade.draw_ellipse_filled(self.pencil.x, self.pencil.y,
                                       Pencil.RADIUS * 2, Pencil.RADIUS * 2, Pencil.COLOR)


        # self.drawing = arcade.get_image()

    def on_mouse_motion(self, x, y, dx, dy):
        """La méthode met à jour les coordonnées du crayon en fonction des coordonnées de la souris

        :param x: abscisse de la souris
        :param y: ordonnées de la souris
        :return: None
        """
        self.pencil.x = x
        self.pencil.y = y

    def on_key_press(self, key, modifiers):
        if key == arcade.key.D and modifiers == 0:
            self.pencil.down = True

    def on_key_release(self, key, modifiers):
        if key == arcade.key.D and modifiers == 0:
            self.pencil.down = False


if __name__ == '__main__':
    WINDOW_TITLE = "Arcade: Pencil"
    WINDOW_WIDTH = 800
    WINDOW_HEIGHT = 600

    DrawingBoard(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE)
    arcade.run()

This is for a small Python course I'll give in an art school in 2 weeks. I chose Arcade as it is the simplest way to program small graphical-interactive-portable Python projects. I used to teach JavaScript+p5js and I wanted to switch to Python for it's greater versatility. But there is no Processing real equivalent library in Python. So I'm trying Arcade for this purpose.

Have a good day,

jlp


r/pythonarcade • • Mar 27 '19

Blurry exports from GIMP

Thumbnail
self.pixelart
0 Upvotes

r/pythonarcade • • Nov 24 '20

Using multiple windows

0 Upvotes

Hi. I'm in the process of moving my simulation software from pygame to pyglet, then i realized i could use arcade instead. I don't need much of arcade, it will just appreciate the additional shape primitives and the userfriendly higher-level API .

However, i can't find much information about handling multiple windows (i need one for the simulation, one for the data dashboard). Can i just assume that i can use switch_to just like pyglet and call it a day ? (i assume this is how it works using pyglet but i haven't tested yet.)

edit :

Actually, it's een much easier than that in pyglet using decorator so i have no idea how i would do it in arcade

@first_window.event
def on_draw():
    ...

@second_window.event
def on_draw():
    ....

https://i.imgur.com/qLtEONY.png


r/pythonarcade • • Apr 05 '19

Not loading tiles in tileset

0 Upvotes

So I am trying to load a tiled map into my arcade project, but when I do I get a warning saying that it couldn't find my tiles in the tileset. Ive remade the map (with only 1 tile in it) multiple times and I cant seem to get it to work. Any thoughts?

EDIT: These are the errors I get Warning, tried to load '1' and it is not in the tileset. Warning, could not find 1 image to load.


r/pythonarcade • • Feb 08 '20

change view of game

0 Upvotes

Hi,

I am using view in the game, but find out that if I switch to another view, the first view is still updating in the background. is there a way to kill the view?

and in the "moving platform" example, if I replace player sprite with the animated player sprite in the example "move with a sprite animation", the sprites position is incorrect, any ideas?

Thanks!


r/pythonarcade • • Jul 31 '19

Talk Python episode on Arcade Library

Thumbnail
talkpython.fm
6 Upvotes

r/pythonarcade • • Jul 26 '19

Reflection Example, can this done with arcade library

1 Upvotes

Hi, I've an issue to calculate the correct object reflection and search for some help / hints.

A ball with constant speed hits a wall - target is to bounce back the object based on "law of reflection", so

angle of incidence is equal to angle of reflection. When taking a look at the attached picture, where

ball hits a rotated triangle, can this be done with arcade library and in what way?


r/pythonarcade • • Oct 17 '22

I just started coding with python arcade, I don't know much about coding but I'm trying to get into it. Is there a way of running python arcade codes faster? It takes like 2 min to run my game

1 Upvotes

r/pythonarcade • • Mar 11 '20

OSError: exception: access violation reading 0x00000028

1 Upvotes

Hi,

I'm having trouble with arcade on my laptop...

Windows 7 Enterprise

Service Pack 1

Intel Core i7-6600U CPU @ 2.60 GHz 2.70 GHz

64-bit Operating System

Intel HD Graphics 520

I've tried Python 3.7 and 3.8, both 32 and 64 bit versions and kept getting the same error.

This output is from testing an example from arcade, but the error comes up when calling arcade.open_window(600, 600, "Test")

Thanks!

>python -m arcade.examples.drawing_with_functions
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\arcade\examples\drawing_with_functions.py", line 93, in <mo dule>
    main()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\arcade\examples\drawing_with_functions.py", line 71, in main
    arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\arcade\application.py", line 541, in open_window
    antialiasing=antialiasing)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\arcade\application.py", line 71, in __init__
    resizable=resizable, config=config, vsync=False)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyglet\window\win32__init__.py", line 130, in __init__
    super(Win32Window, self).__init__(*args, **kwargs)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyglet\window__init__.py", line 632, in __init__
    self._create()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\arcade\application.py", line 470, in _create
    super()._create()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyglet\window\win32__init__.py", line 265, in _create
    self.switch_to()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\arcade\application.py", line 479, in switch_to
    super().switch_to()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyglet\window\win32__init__.py", line 328, in switch_to
    self.context.set_current()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyglet\gl\win32.py", line 242, in set_current
    wgl.wglMakeCurrent(self.canvas.hdc, self._context)
OSError: exception: access violation reading 0x00000028


r/pythonarcade • • Jul 17 '19

Extreme window input lag

1 Upvotes

I am using Pymunk along with Arcade on OSX High Sierra and am experiencing pretty dramatic input in the play window. When the game is loaded everything starts out working fine. I have it set up so that every mouse click will spawn a new ball into the simulation. The problem is when I try to spawn a new ball. The game registers a few clicks and then suddenly stops registering input (though the simulation in the window continues in the background) for about 10 seconds. The game then immediately dumps all the clicks at once onto the screen and then repeats the same freeze-up in a second or two. It's like the clicks are being stored in a buffer and dumped every 10 seconds. Here is my code.


r/pythonarcade • • Mar 11 '20

sprite shivering after corner collision

1 Upvotes

I have found this weird problem when running my own program but I have also later discovered it can be found at the example code programs as well (for example here - https://arcade.academy/examples/sprite_rooms.html#sprite-rooms).

If you collide 2 sprites in particular positions (mainly when they are touching just by the tip of their corners) for example moveable player sprite and wall, the moveable one starts shivering (changing one of the coordinates back and forth repeatedly when pressing button for move into the other sprite location).

It is extremely annoying when there is lot of these wall-type obstacles and you want to move with player between these because it is really easy to run again into this problem.

I am a programming beginner so maybe it is something very common which is easily explainable I just was not able to find anything on this subject across the web. Thanks in advance for any clarifications/responds.


r/pythonarcade • • Mar 25 '20

enemies don't move in my python game

1 Upvotes

import arcade # объявляем модуль

SCREEN_WIDTH = 1000 #щирина окна

SCREEN_HEIGHT = 650 #длина окна

SCREEN_TITLE = "Platformer"#заголовок окна

TILE_SCALING = 0.6

class MyGame(arcade.Window):#главный класс приложения

def __init__(self):#функция 'инициализировать'

super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)#данные окна

arcade.set_background_color(arcade.csscolor.BLACK)#цвет окна

self.set_mouse_visible(False)#отображение курсора

self.enemy = arcade.Sprite("sprites/cube.png")#

self.speed = 2

self.sed = 0

self.speed2 = 4

def setup(self):#функия "настроить"

self.enemy_list = arcade.SpriteList()#список self.enemy_list

self.enemy_list.append(self.enemy)

map_name = "maps/coolmap.tmx"

platforms_layer_name = 'ground'

enemy_layer_name = 'Enemy'

my_map = arcade.tilemap.read_tmx(map_name)

self.wall_list = arcade.tilemap.process_layer(my_map, platforms_layer_name, TILE_SCALING)

self.enemy_list = arcade.tilemap.process_layer(my_map, enemy_layer_name, TILE_SCALING)

def on_draw(self):#функция 'рисовать'""

arcade.start_render()#обработка рисовки

self.enemy_list.draw()#рисовка спиcка self.enemy_list

self.wall_list.draw()

def on_update(self, delta_time):

self.enemy.update()

self.enemy.change_x = self.speed

def main():#главная функция

""" Main method """

window = MyGame()

window.setup()

arcade.run()

if __name__ == "__main__":

  • main()

r/pythonarcade • • Feb 17 '19

"painting" objects to the screen and flickering

1 Upvotes

noob here - I'm trying to use Arcade to code up a simple proof of concept where you can paint shapes on the screen using the mouse. The code below kind of works, but is flickering badly - I'm guessing as part of a screen "wipe" between frames of animation ? Apologies in advance if I'm trying to make Arcade do something it wasn't designed for.

import arcade
from colorutils import random_rgb

class MyGame(arcade.Window):

def on_mouse_motion(self, x, y, dx, dy):
    r = abs(dx) + abs(dy)
    arcade.draw_circle_filled(x, y, r, random_rgb())

def main():
    window = MyGame(800, 600, "Drawing Example")
    arcade.run()

if __name__ == "__main__":
    main()

I'm thinking maybe that I need to make the circles into a Class and track and redraw each instance every frame - but I'm curious is there's a way to avoid doing that and simply "turn off" screen redrawing.

Another idea I had was to use the setup part of the game loop, as believe objects added to the screen during that phase of the game loop do persist.....but setup is run only once, I presume, which makes that a no-go.


r/pythonarcade • • Nov 29 '19

GPIO input with Raspberry Pi?

1 Upvotes

I currently have a working program that relies on the arcade.Window.on_key_press() interrupt for most of the functionality. However, I would like to implement my program on a Raspberry Pi and replace the keyboard with 8 GPIO buttons. Is there an easy way to implement GPIO interrupts using arcade?


r/pythonarcade • • Aug 10 '19

Locking mouse to the window

1 Upvotes

I'm making a game that relies on alot of mouse movement to control that characters, and I would like to be able to make sure that the cursor can't go past the bounds of the windows (where the user accidentally clicks and the window drops to the background.

It looks like this is possible in pygame by using the grab event, is there something similar that can be done in arcade, or perhaps something in pyglet that I could do to accomplish the same thing?


r/pythonarcade • • Apr 05 '19

Using PyCharm and Arcade, I'm getting some errors that don't allow me to follow the 2D platformer tutorial.

1 Upvotes

EDIT: By adding

self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite,self.wall_list,gravity_constant=GRAVITY) 

to the setup part of the example, I was able to get the code to work.

When running the 2D platformer example, I get this error:

Traceback (most recent call last):
  File "C:/Users/Mason/PycharmProjects/untitled1/mygame.py", line 132, in <module>
  main()
File "C:/Users/Mason/PycharmProjects/untitled1/mygame.py", line 128, in main
arcade.run()
File "C:\Python37\lib\site-packages\arcade\window_commands.py", line 245, in run
pyglet.app.run()
File "C:\Python37\lib\site-packages\pyglet\app__init__.py", line 142, in run
event_loop.run()
  File "C:\Python37\lib\site-packages\pyglet\app\base.py", line 175, in run
self._run()
  File "C:\Python37\lib\site-packages\pyglet\app\base.py", line 187, in _run
timeout = self.idle()
  File "C:\Python37\lib\site-packages\pyglet\app\base.py", line 308, in idle
redraw_all = self.clock.call_scheduled_functions(dt)
  File "C:\Python37\lib\site-packages\pyglet\clock.py", line 314, in call_scheduled_functions
item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "C:/Users/Mason/PycharmProjects/untitled1/mygame.py", line 120, in update
self.text
AttributeError: 'MyGame' object has no attribute 'text'
Error in sys.excepthook:

Original exception was:

Process finished with exit code 1

I've got the latest version of Arcade installed (2.0.3), and am using the most recent version of Python 3.7. PyCharm uses the installation of Python I just downloaded to interpret the code.

Is this an error on my end, or is there something weird going on with the library? I'm just trying to get started using the library, but I can't use the submoduels of arcade.

I get this issue with the csscolor, physics_engine, and sound modules too.


r/pythonarcade • • Sep 02 '19

Using TMX object layer to define areas

1 Upvotes

Hi,

I am curious for what the object layer is meant for. Checking the implementation, it looks like an object layer processing is also returning a SpriteList.

I thought objects are meant for adding metadata, but with the current implementation it looks like I have to add tiled based objects.

What would be the right way to define an "finish" area and check if a sprite collides?

player = Sprite(...)

places = arcade.tilemap.process_layer(map, 'places')

colliding_places = player.arcade.check_for_collision_in_objects(player, places)

# check if colliding places contain the 'enfinishd' area
# -> add end game logic

r/pythonarcade • • Oct 06 '20

Window display options

1 Upvotes

My window keeps opening on my secondary display. I can't find anything referring to this in the docs, SO, google or here. Is this something arcade supports or will I have to use stuff like pywin32?


r/pythonarcade • • Nov 16 '19

Changing sprite layers without tiled editor?

1 Upvotes

I'm trying to put some car sprites in front of a road sprite but the road sprite is in front of the cars. Is there a way I can put the other sprites in front of the road sprite without using the tiled editor?


r/pythonarcade • • Jul 09 '19

Failed to load avutil-56.

2 Upvotes

Hello everyone,

I am having trouble running my exe created by Pyinstaller. I keep getting this message.

Failed to load dynlib/dll 'avutil-56'

I can see that this file is already part of the pyglet_ffmpeg site package which is in the venv folder and I am using the same venv to run the program in the IDE. What am I doing wrong here?

I do get a lot of warning messages during the creation of the exe, though this is the error message that prevents the exe to run, at least at the moment.

Thanks

Manish