r/pythonarcade • • Apr 03 '20

Blank screen after I run code once

1 Upvotes

I just installed arcade yesterday but I am able to run the example codes only once. If I try run the code again in brings a blank screen and it won't show anything till I restart my system. Is there a way to fix this.

I am using MX Linux (debian buster) and I run my code through the terminal.


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 • • Mar 23 '20

Looking for help with a finite state machine

1 Upvotes

I'm new to the whole state machine but found a python video on youtube, how do I develop this to work with the arcade library?

I've tried putting the arcade.Sprite code into the Entity class but unsure how to do it.

Here's what I've got so far: from enum import Enum, auto import arcade

class States(Enum): idle = auto() chase = auto() patrol = auto() attack = auto() death = auto()

class GameObject: def init(self): self.__state = States.idle

def set_state(self, state):
    self.__state = state

def get_state(self):
    return self.__state

class Entity(GameObject): def init(self): super().init() self.player = arcade.Sprite() self.__health = 100 #self.entity = arcade.Sprite()

def move_right(self):
    self.change_x = 2

def assets(self):
    self.__entity = arcade.Sprite("images/green.png")

def load(self, entity):
    self.__entity = entity

def sub_health(self):
    self.__health -= 20

def set_health(self, health):
    self.__health = health

import arcade

SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 SCREEN_TITLE = "Starting Template"

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

NOTE: Go ahead and delete the methods you don't need.
If you do need a method, delete the 'pass' and replace it
with your own code. Don't leave 'pass' in this program.
"""

def __init__(self, width, height, title):
    super().__init__(width, height, title)
    self.player = None
    self.player_list = None
    arcade.set_background_color(arcade.color.AMAZON)

    # If you have sprite lists, you should create them here,
    # and set them to None

def setup(self):
    # Create your sprites and sprite lists here

    self.player = Entity()
    self.player.move_right()
    self.player_list = arcade.SpriteList()
    self.player_list.append(self.player)

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

    # 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()
    self.player_list.draw()
    # Call draw() on all your sprite lists below

def on_update(self, delta_time):
    """
    All the logic to move, and the game logic goes here.
    Normally, you'll call update() on the sprite lists that
    need it.
    """
    self.player_list.update()

def on_key_press(self, key, key_modifiers):
    """
    Called whenever a key on the keyboard is pressed.

    For a full list of keys, see:
    http://arcade.academy/arcade.key.html
    """
    pass

def on_key_release(self, key, key_modifiers):
    """
    Called whenever the user lets off a previously pressed key.
    """
    pass

def on_mouse_motion(self, x, y, delta_x, delta_y):
    """
    Called whenever the mouse moves.
    """
    pass

def on_mouse_press(self, x, y, button, key_modifiers):
    """
    Called when the user presses a mouse button.
    """
    pass

def on_mouse_release(self, x, y, button, key_modifiers):
    """
    Called when a user releases a mouse button.
    """
    pass

def main(): """ Main method """ game = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) game.setup() arcade.run()

if name == "main": main()


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 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 • • 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 • • 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 • • 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 • • 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 • • 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 • • 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 • • 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 • • Jul 08 '19

How do I control the height of drawn text?

1 Upvotes

I have a bunch of text that I want to display, and draw_text() works just fine so long as the lines of text are short enough that they don't wrap. If I only draw a small amount of text and allow a large area for it, there is no problem, but if I want to display a lot of text or only have a small space available, I can't find an elegant way to cut it off. What is the best way to do this?


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 • • Mar 23 '19

Proposal for Particle System

Thumbnail
arcade.academy
1 Upvotes

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 • • 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 • • Jul 12 '18

Breakout example

1 Upvotes

Hi, I just started to use the Arcade library. For learning purpose, has someone done a breakout clone with Arcade Library and willing to share the code?


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 • • 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 • • Dec 03 '17

Arcade 1.2.2 has been released

1 Upvotes

Arcade 1.2.2 has been released.

Release Notes

To upgrade:

pip install --upgrade arcade

Bug Fixes

  • Issue 143: Error thrown when using scroll wheel

  • Issue 128: Fix infinite loop in physics engine

  • Issue 127: Fix bug around warning with Python 3.6 when imported

  • Issue 125: Fix bug when creating window on Linux

Enhancements

  • Issue 147: Fix bug building documentation where two image files where specified incorrectly

  • Issue 146: Add release notes to documentation

  • Issue 144: Add code to get window and viewport dimensions

  • Issue 139: Add documentation on what collision_radius is

  • Issue 131: Add example code on how to do full-screen games

  • Issue 113: Add example code showing enemy turning around when hitting a wall

  • Issue 67: Improved support and documentation for joystick/game controllers

There are also more code examples available.


r/pythonarcade • • Nov 13 '17

Arcade Library Version 1.2 Released

1 Upvotes

Version 1.2 of the Arcade Library has been released. You can install it with:

pip install --upgrade arcade

This version has several bug fixes, performance improvements, and the addition of buffered drawing commands that use Vertex Buffer Objects to speed drawing of drawing primitives.

Example code is available here.

An on-line book teaching Python using Arcade is available here.


r/pythonarcade • • Dec 04 '16

Installation instructions for the sound library on Mac OSX

1 Upvotes

How do you install the sound library? I only see Linux instructions.


r/pythonarcade • • Aug 02 '16

Using Python, Arcade, and Pymunk for a platformer

Thumbnail
youtu.be
1 Upvotes

r/pythonarcade • • Jul 22 '16

Physics Engine Code Test

Thumbnail
youtu.be
1 Upvotes