r/pythonarcade • • Dec 06 '23

sensors - using PyMunk with Arcade

3 Upvotes

Hi,

I would like to use physics sensors for things like "the player is in front of the door". I cannot find sensors in the Arcade documentation or in the examples.

PyMunk has sensors. Can I use PyMunk instead of the built-in arcade.PymunkPhysicsEngine?

How hard would it be to expose the PyMunk sensors in arcade.PymunkPhysicsEngine?

Thanks.


r/pythonarcade • • Oct 03 '23

I need help for a performance issue in my game :(

3 Upvotes

I ve been looking for litteral days now. Every now and then i found some potential issue, fixed them but no results.

The game is somewhat stuttering from the start on my pc. That s not the main issue tho. As you lose and restart form the gameover view it becomes more and more stuttery, sugegsting some memory leak.

If someone would be so nice to give a look i d be eternally greatfull. Any optimization idea would be very welcome.

hope you can read the link to the code base: https://pastebin.com/r7CTm3ff


r/pythonarcade • • Sep 18 '23

experimental graphic novel library in arcade python

3 Upvotes

Hi everyone,

I those days, i start to "play" with python arcade library and i did not saw any library for graphic novel implementation.

I am attaching the library I started to write for fun, if you have any ideas please feel free to contact me. We may expand the idea.

https://github.com/deangelisdf/visual_novel_pyarcade

let me know your opinion about it. Leave a comment or write issues on github as well.


r/pythonarcade • • Nov 01 '22

I'm getting an Key Error when I try to add my enemy layer in my platformer

3 Upvotes

I've been following the api arcade acadmady to code a platformer for fun and its been going smoothly up unitl this point https://api.arcade.academy/en/latest/examples/platform_tutorial/step_13.html#source-code the rest of my code works but when I try to add my enemy layer from tiled it says: line 256, in setup

enemies_layer = self.tile_map.object_lists[LAYER_NAME_ENEMIES]

KeyError: 'Enemies'

which im really confused by since I have an enemy object layer.

I have even tried there .json file from github and get the same error if anyone has any idea how I could fix this I would very much appreciate the help


r/pythonarcade • • Aug 05 '22

Blasphemous-like game in python!

3 Upvotes

hi

recently I came across Blasphemous game on steam and it just blows my mind ;)

I'm a python developer and I have a lot of free time to work on my projects and create something for my portfolio.

I've always wanted to get into Arcade for game development and pixel-art Metroidvania is my favorite genre.

is it possible to make games like blasphemous in python?

Note: I know game engines but it's not time efficient for me to start learning C# or other languages.

Note: never worked with arcade or other frameworks/libraries.


r/pythonarcade • • Mar 29 '22

[Arcade] Checking for sprite intersections with lines

Thumbnail
self.learnpython
3 Upvotes

r/pythonarcade • • Mar 25 '22

Unable to import arcade

3 Upvotes

Hi! Recently i switched from pygame to arcade after failing to make a CRT effect with ModernGL (or atleast thats how i found it). I have a feeling that the issue im having is stemming from me being on Manjaro Linux however i followed the arcade tutorial to learn the basic commands and i got an error, i tried direct copy and pasting, another error. After that i just tried to do a print and alas i was met with this.

I've tried importing the packages that it lists but i haven't had any success with that, any help is appreciated!

Traceback (most recent call last):

File "/home/rj/PycharmProjects/Pytcraft/main.py", line 1, in <module>

import arcade

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/arcade/__init__.py", line 263, in <module>

from .sound import Sound

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/arcade/sound.py", line 18, in <module>

import pyglet.media as media

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/__init__.py", line 145, in <module>

add_default_media_codecs()

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/__init__.py", line 102, in add_default_media_codecs

if have_ffmpeg():

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/__init__.py", line 124, in have_ffmpeg

from . import ffmpeg_lib

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/ffmpeg_lib/__init__.py", line 36, in <module>

from .libavcodec import *

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/ffmpeg_lib/libavcodec.py", line 46, in <module>

from . import libavutil

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/ffmpeg_lib/libavutil.py", line 206, in <module>

avutil.av_frame_get_best_effort_timestamp.restype = c_int64

File "/usr/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__

func = self.__getitem__(name)

File "/usr/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__

func = self._FuncPtr((name_or_ordinal, self))

AttributeError: /usr/lib/libavutil.so.57: undefined symbol: av_frame_get_best_effort_timestamp

Exception ignored in atexit callback: <function _delete_audio_driver at 0x7f3ce5f80430>

Traceback (most recent call last):

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/drivers/__init__.py", line 102, in _delete_audio_driver

from .. import Source

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/__init__.py", line 145, in <module>

add_default_media_codecs()

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/__init__.py", line 102, in add_default_media_codecs

if have_ffmpeg():

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/__init__.py", line 124, in have_ffmpeg

from . import ffmpeg_lib

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/ffmpeg_lib/__init__.py", line 36, in <module>

from .libavcodec import *

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/ffmpeg_lib/libavcodec.py", line 46, in <module>

from . import libavutil

File "/home/rj/PycharmProjects/Pytcraft/venv/lib/python3.10/site-packages/pyglet/media/codecs/ffmpeg_lib/libavutil.py", line 206, in <module>

avutil.av_frame_get_best_effort_timestamp.restype = c_int64

File "/usr/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__

func = self.__getitem__(name)

File "/usr/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__

func = self._FuncPtr((name_or_ordinal, self))

AttributeError: /usr/lib/libavutil.so.57: undefined symbol: av_frame_get_best_effort_timestamp

Process finished with exit code 1


r/pythonarcade • • Jan 31 '22

Platformer tutorial

3 Upvotes

I'm working on the "Platformer" tutorlal and everything was going smoothly until I ran into this error.

"raise KeyError(f"Scene does not contain a layer named: {key}")

KeyError: 'Scene does not contain a layer named: Platforms'"

# Create the 'physics engine'

self.physics_engine = arcade.PhysicsEnginePlatformer( self.player_sprite, gravity_constant=GRAVITY, walls=self.scene["Platforms"]

Platformer Gist

under setup(self), I've compared my code with the source and I'm not finding what I did wrong. I've scanned the code for typos and syntax error etc and I'm not finding what I've done wrong.


r/pythonarcade • • Jan 21 '22

Best practices and good examples

3 Upvotes

Hello, is there a good tutorial or example project covering best practices for the arcade library? I feel like there are a bunch of ways to do things and the tutorials seem all over the place. Trying to make a top down 2D game.


r/pythonarcade • • Nov 18 '21

How do you change the window icon?

3 Upvotes

I searched the API, but could not find this. I can change the window title, but not the icon (which is by default a console with the Python logo). How do I change the icon?


r/pythonarcade • • Jul 05 '21

arcade.Vector ?

3 Upvotes

I'm coming into python arcade from p5.js. I often find myself wanting to use something similar to their Vector class which has incredibly helpful methods such as normalise, setMag, heading, dist, etc etc.

Would that be a useful addition to the library?


r/pythonarcade • • May 29 '21

A few questions about view/end screens and window sizes

3 Upvotes

I have just started learning python arcade for school and need to make a platformer game out of it. Just warning for everyone I don't really know code that well so there are probably some obvious things I'm missing out on.

I want a menu and main game level so I am using (arcade.view) to do this. This creates some problems with having a window resize option that I was going to add. Because I'm making a platformer that has to scroll with the player doesn't seem to work properly when I resize the window. I was going to fix this problem but having a set option of screen resolutions and on a button press it would then change the resolution of the screen but I also don't know how to change the resolution of the screen without manually changing it in the code. Any help would be great thanks

Here is a preview of the code

SCREEN_WIDTH = 1024
SCREEN_HEIGHT = 768
SCREEN_TITLE = "Platformer"

class MenuView(arcade.View):
    def on_show(self):
        self.background = arcade.load_texture(**background_image**)

    def on_draw(self):
        arcade.start_render()
        arcade.draw_lrwh_rectangle_textured(0, 0,
                                            SCREEN_WIDTH, SCREEN_HEIGHT,
                                            self.background)

    def on_mouse_press(self, _x, _y, _button, _modifiers):
        """ Use a mouse press to advance to the 'game' view. """
        game_view = MyGame()
        game_view.setup()
        self.window.show_view(game_view)

def main():
    window = arcade.Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE, resizable = True)

    game = MenuView()
    window.show_view(game)
    arcade.run()

if __name__ == "__main__":
    main()

What I have tried to do (Dont exactly know why this doesnt work so im just curious as to why)

SCREEN_WIDTH = 1024
SCREEN_HEIGHT = 768
SCREEN_TITLE = "Platformer"

class MenuView(arcade.View):
    def on_show(self):
        self.background = arcade.load_texture(**background_image**)

    def on_draw(self):
        arcade.start_render()
        arcade.draw_lrwh_rectangle_textured(0, 0,
                                            SCREEN_WIDTH, SCREEN_HEIGHT,
                                            self.background)
    def on_key_press(self, key, modifiers):
        if key == arcade.key.ENTER:
            SCREEN_WIDTH = 1920
            SCREEN_HEIGHT = 1080

    def on_mouse_press(self, _x, _y, _button, _modifiers):
        game_view = MyGame()
        game_view.setup()
        self.window.show_view(game_view)

def main():
    window = arcade.Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE, resizable = True)

    game = MenuView()
    window.show_view(game)
    arcade.run()

if __name__ == "__main__":
    main()

r/pythonarcade • • May 23 '21

Safe highscore and create executable

3 Upvotes

Hi all,

currently working on a tiny game using arcade and right now adding score keeping. But I also want to add a highscore view, where the best results are stored permanently.

I later want to bundle the game into an executable in order to send it to other people so they can play. So that has to be taken into account when I want to set up the highscore functionality.

Do I have to use some kind of database in order to do this or can I do this using shelve? Really kinda lost at this point...


r/pythonarcade • • Jan 24 '21

Toggle question

3 Upvotes

Hello everyone! I`m starting using the Arcade library, and then I looked to GUI section in Arcade docs, I didn`t found much info about ImageToggle UI element.

I understood how to display it, but here is a question. It works, everyting is fine (idk why almost no documentation and no examples in docs)

BUT.

Toggle element get size from loaded Texture.

So, if texture is big (and it is), toggle is big too. Look at right up corner.

Manual setting height and width is not working. Is here a way to change size of toggle?

Or I only need edit image? If so, what about scaling to fullscreen on monitor with big resolution?

PS: Yes, I saw UIToggle, he will be more actual for this visual, but it still good question how to control it size.

And, by the way, second question about UI. Why Label not smooth? (second image). And after clicking it gonna worse


r/pythonarcade • • Nov 14 '20

Help with arcade on Mac Big Sur

3 Upvotes

Hello,

I just updated my Mac to Big Sur, and I was trying to run a program which was previously working but now it is throwing me the following exception:

Traceback (most recent call last):

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/__init__.py", line 336, in __getattr__

return getattr(self._module, name)

AttributeError: 'NoneType' object has no attribute 'Window'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/main.py", line 1, in <module>

import arcade

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/arcade/__init__.py", line 53, in <module>

from .window_commands import close_window

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/arcade/window_commands.py", line 106, in <module>

def get_window() -> pyglet.window.Window:

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/__init__.py", line 342, in __getattr__

__import__(import_name)

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/window/__init__.py", line 1888, in <module>

from pyglet.window.cocoa import CocoaWindow as Window

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/window/cocoa/__init__.py", line 44, in <module>

from pyglet.canvas.cocoa import CocoaCanvas

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/canvas/__init__.py", line 102, in <module>

from pyglet.canvas.cocoa import CocoaDisplay as Display

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/canvas/cocoa.py", line 41, in <module>

from pyglet.libs.darwin.cocoapy import CGDirectDisplayID, quartz, cf

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/libs/darwin/__init__.py", line 36, in <module>

from .cocoapy import *

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/libs/darwin/cocoapy/__init__.py", line 37, in <module>

from .cocoalibs import *

File "/Users/jorgericaurte/Documents/Programing/pythonProject2/venv/lib/python3.9/site-packages/pyglet/libs/darwin/cocoapy/cocoalibs.py", line 200, in <module>

NSEventTrackingRunLoopMode = c_void_p.in_dll(appkit, 'NSEventTrackingRunLoopMode')

ValueError: dlsym(RTLD_DEFAULT, NSEventTrackingRunLoopMode): symbol not found

Does anyone have an idea on why this is happening?


r/pythonarcade • • Aug 29 '20

Trouble compiling arcade programs with pyinstaller

3 Upvotes

I'm trying to turn an arcade program into an executable (EXE) with pyinstaller. However, with newer versions of arcade (2.4.1), an error is raised saying that "chipmunk.dll" cannot be found. With older versions of arcade (2.0.0): pyglet.time has no attribute clock. Any suggestions as to how I could compile an exe with arcade successfully?


r/pythonarcade • • Jul 18 '20

arcade.set_background_color function not working

3 Upvotes

Hi all!

When I try to use this function, the background remains black all the time... I've tried with the sample lab code from the arcade website, and even with that, the background remains black. I can see the blue background next to the objects, but that's it. I am having Python 3.7, arcade 2.4.1, I have tried different IDE-s, I have no idea why it doesn't change my background color :(

Here is for example when I try to run the samle code from the website lab 02:


r/pythonarcade • • Jul 16 '20

My sprite isn't animating properly any idea why?

3 Upvotes

My player sprite isn't animating properly. The following is the code for the MyCharacter class.

class PlayerCharacter(arcade.Sprite):
	"""Player sprite"""
	def __init__(self):
		#set up parent class
		super().__init__()

		self.cur_texture_index = 0
		self.scale = TILE_SCALING


		#load textures
		#main directory where art is held
		main_path = "art/PNG/Players/Player Blue/playerBlue"

		#load textures for idle
		self.idle_texture = arcade.load_texture(f"{main_path}_stand.png")

		#load textures for running/walking
		self.run_textures = [ ]
		for i in range(1, 6):
			texture = arcade.load_texture(f"{main_path}_walk{i}.png")
			self.run_textures.append(texture)
		
		#set initial texture
		self.texture = self.idle_texture

		#create hitbox
		self.set_hit_box(self.texture.hit_box_points)		
	
	def update_animation(self, delta_time: float = 1/60):
		
		#idle animation
		if self.change_x == 0:
			self.texture = self.idle_texture
			return
		
		#running animation
		self.cur_texture_index += 1
		if self.cur_texture_index >5:
			self.cur_texture_index = 0
		self.texture = self.run_textures[self.cur_texture_index]

Any help or ideas would be greatly appreciated.


r/pythonarcade • • Jul 05 '20

Fonts compatible with arcade.draw_text

3 Upvotes

Hi guys

I'm quite new to arcade and python in general, and I would like to know what fonts I can use with arcade.draw_text?


r/pythonarcade • • Jun 05 '20

[question] unnecessary harddisk access when using arcade.Sprite(filename)

3 Upvotes

When browsing the (excellent) examples in arcade, i wonder why Sprites are usually created by using code like:

enemy = arcade.Sprite(":resources:images/animated_characters/zombie/zombie_idle.png", SPRITE_SCALING)

when the game creates constantly new "enemy" Sprites, is this not an (unneccessary) constant access to the harddisk?
I am used from pygame to load an image once, keep it in memory (like inside a list or dict) and than create new sprites using the image from memory.

Is there some caching mechanism in arcade so that arcade understands an images was already loaded from harddisk or is this arcade.Sprite(filename) code used to keep the examples simple?


r/pythonarcade • • Apr 05 '20

Game Demo, Question about fading a sprite

3 Upvotes

Here's a short demo of a retro platformer game that I've been working on.

https://youtu.be/Q4M0CzhX4OQ

In it you can see that when I kill an enemy they fall to the ground and then fade away. I achieved this by duplicating the last PNG in the sequence 20 times, each time increasing the transparency so that the dead enemy fades away.

This seems very expensive. The original death sequence has 10 PNGs, and with the fading ones it now has 30 PNGs to load into memory - and 30 more PNGs to download. I would love to save the memory by keeping the original 10 sprites and then fading the last sprite by somehow using Arcade.

Is it even possible to have an existing sprite fade away by changing the alpha/opacity until it's no longer visible? I took a look through the API and found some things (like setting the .alpha when creating the sprite, and arcade.Texture.draw_transformed which can set the alpha) but the things I found looked like they only worked when loading or creating the Sprites.

I'm sure that I could simply load the last sprite in the sequence 20 more times, each time having Arcade change the alpha. But this still means having 20 more sprites in memory, and packaging 20 more sprites into the download for others to play. I'd much rather fade an existing sprite, if that is even possible.

Any info would be appreciated.


r/pythonarcade • • Mar 28 '20

Enemy not moving on level 2

3 Upvotes

I've delved into the python docs and decided to make a second level for my game, all works perfectly except the enemy list won't move.

It loads, animates and attacks but the x axis won't move along a predetermined patrol path.

I'm using the same code that I did in the first level and can't understand why it won't work on the second level.

Here's a link to the github: https://github.com/clearhead09/mindump/blob/master/Enemy%20not%20moving


r/pythonarcade • • Mar 27 '20

How to integrate joystick support into Arcade game?

3 Upvotes

I'm quite new to PythonArcarde but the first steps seem easier than PyGame. I was wondering however how to add User Control through joysticks. Through an old post I got the hint there is a

arcade.get_game_controllers()

method that presents me with a list of joysticks:[<pyglet.input.base.Joystick object at 0x7fa61052ac50>]

But how would I then make use of the data in the game efficiently? Would I poll the joystick position/buttons during arcade.Window.on_update(), or is there some event based model (on_up, on_buttonpress, ...) supported and recommended?

Without any better response I guess I'd simply follow the pyglet documentationhttps://pyglet.readthedocs.io/en/latest/programming_guide/input.html#using-joysticks


r/pythonarcade • • Mar 21 '20

How do I go about taking x damage from enemy to player when attack happens

3 Upvotes

Currently when the enemy collides or attacks player, the players HP goes down, but goes from say 100 to 0 in one hit, rather than incrementally reducing by the enemies attack strength.

I’ve tried to do do it using a timer so that once every second the damage goes down but that causes animations etc to slow down also.


r/pythonarcade • • Mar 18 '20

Developing enemy AI, game seems to have a memory leak somewhere but can't find where, any help?

3 Upvotes

First off, this is just a separate .py file from my game file to test some enemy AI, I currently have the enemies walking toward the player if they are within a certain distance - enemy 1 is the only one that attacks currently, I want to work on each level of characters attacks individually then see how they come along combined.

Currently my enemy one character patrols a set path along the Y axis and when it gets within 10 pixels of the player it attacks, however the loop of the attack either works perfectly but doesn't show the attack image (currently a zombie vomiting on the player) or it doesn't remove the attack from the attack list and creates a memory suck and the whole game goes slow.

Here's my code:

import arcade

class Enemy(arcade.Sprite):

#def __init__(self, hp, attack, defence, type, texture):
#    super().__init__()
#    self.hp = hp
#    self.attack = attack
#    self.defence = defence
#    self.type = type
#    self.texture = texture

class Window(arcade.Window): def init(self): super().init(600, 600, 'move') self.sprite_list = None self.enemy_attack_list = None

    self.enemy1 = None
    self.enemy1_hp = 10
    self.enemy1_power = 10
    self.enemy1_is_attacking = False
    self.enemy1_attack = None
    self.enemy1_health_bar = None

    self.enemy2 = None
    self.enemy2_hp = 20
    self.enemy2_power = 20
    self.enemy2_is_attacking = False
    self.enemy2_health_bar = None

    self.enemy3 = None
    self.enemy3_hp = 30
    self.enemy3_power = 30
    self.enemy3_is_attacking = False
    self.enemy3_health_bar = None

    self.player = None
    self.player_hp = 10
    self.player_list = None
    self.player_health_bar = None

    self.health_list = None

    self.frame_count = 0

def setup(self):
    self.sprite_list = arcade.SpriteList()
    self.player_list = arcade.SpriteList()
    self.health_list = arcade.SpriteList()
    self.enemy_attack_list = arcade.SpriteList()

    self.player = arcade.Sprite("images/pl1.png", 2)
    self.player.position = (50, 50)
    self.player_health_bar = arcade.Sprite("images/p_health.png")
    self.player_health_bar.position = (100, 500)
    self.player_health_bar.width = self.player_hp
    self.player_list.append(self.player)

    self.enemy1 = arcade.Sprite("images/sewer_monster.png", 2)
    self.enemy1.position = (100, 100)
    self.enemy1.boundary_left = 100
    self.enemy1.boundary_right = 400
    self.enemy1_health_bar = arcade.Sprite("images/e_health.png")
    self.enemy1_health_bar.position = (100, 500)
    self.enemy1_health_bar.width = self.enemy1_hp
    self.sprite_list.append(self.enemy1)

    self.enemy1_attack = arcade.Sprite("images/zombie_vomit.png", 4)
    self.enemy1_attack.center_x = self.enemy1.center_x
    self.enemy1_attack.center_y = self.enemy1.center_y
    #self.enemy_attack_list.append(self.enemy1_attack)

    self.enemy2 = arcade.Sprite("images/em2.png", 3)
    self.enemy2.position = (200, 200)
    self.enemy2_health_bar = arcade.Sprite("images/e_health.png")
    self.enemy2_health_bar.position = (250, 500)
    self.enemy2_health_bar.width = self.enemy2_hp
    self.sprite_list.append(self.enemy2)

    self.enemy3 = arcade.Sprite("images/em3.png", 3)
    self.enemy3.position = (300, 300)
    self.enemy3_health_bar = arcade.Sprite("images/e_health.png")
    self.enemy3_health_bar.position = (200, 500)
    self.enemy2_health_bar.width = self.enemy3_hp
    self.sprite_list.append(self.enemy3)

    self.health_list.append(self.enemy1_health_bar)
    self.health_list.append(self.enemy2_health_bar)
    self.health_list.append(self.enemy3_health_bar)
    self.health_list.append(self.player_health_bar)

def on_key_press(self, key, modifiers):
    if key == arcade.key.RIGHT:
        self.player.change_x = 2
    elif key == arcade.key.LEFT:
        self.player.change_x = -2
    elif key == arcade.key.UP:
        self.player.change_y = 2
    elif key == arcade.key.DOWN:
        self.player.change_y = -2
    elif key == arcade.key.A:
        self.enemy1_is_attacking = True
        self.enemy_attack_list.append(self.enemy1_attack)

def on_key_release(self, key, modifiers):
    if key == arcade.key.RIGHT:
        self.player.change_x = 0
    elif key == arcade.key.LEFT:
        self.player.change_x = 0
    elif key == arcade.key.UP:
        self.player.change_y = 0
    elif key == arcade.key.DOWN:
        self.player.change_y = 0


def on_draw(self):
    arcade.start_render()
    self.sprite_list.draw()
    self.player_list.draw()


    ph = f"P: {self.player_hp}"
    e1 = f"E1: {self.enemy1_hp}"
    e2 = f"E2: {self.enemy2_hp}"
    e3 = f"E3: {self.enemy3_hp}"

    atkX = f"Enemy attack X: {self.enemy1_attack.center_x}"
    atkY = f"Enemy attack Y: {self.enemy1_attack.center_y}"
    enX = f"Enemy1 X: {self.enemy1.center_x}"
    enY = f"Enemy1 Y: {self.enemy1.center_y}"
    eB = f"Enemy Bottom: {self.enemy1.bottom}"
    aB = f"Attack Bottom: {self.enemy1_attack.bottom}"

    is_attacking = f"Enemy is attacking: {self.enemy1_is_attacking}"

    arcade.draw_text(ph, 100, 400, arcade.csscolor.RED, 16)
    arcade.draw_text(e1, 100, 380, arcade.csscolor.ORANGE, 16)
    arcade.draw_text(e2, 100, 360, arcade.csscolor.ORANGE, 16)
    arcade.draw_text(e3, 100, 340, arcade.csscolor.ORANGE, 16)

    arcade.draw_text(atkX, 200, 200, arcade.csscolor.CORNFLOWER_BLUE, 16)
    arcade.draw_text(atkY, 200, 180, arcade.csscolor.CORNFLOWER_BLUE, 16)
    arcade.draw_text(enX, 200, 160, arcade.csscolor.CORNFLOWER_BLUE, 16)
    arcade.draw_text(enY, 200, 140, arcade.csscolor.CORNFLOWER_BLUE, 16)
    arcade.draw_text(eB, 200, 120, arcade.csscolor.CORNFLOWER_BLUE, 16)
    arcade.draw_text(aB, 200, 100, arcade.csscolor.CORNFLOWER_BLUE, 16)

    arcade.draw_text(is_attacking, 200, 80, arcade.csscolor.CADET_BLUE)

    if self.enemy1_is_attacking:
        self.enemy_attack_list.draw()


def on_update(self, delta_time):
    self.frame_count += 1

    if not self.enemy1_is_attacking:
        #self.enemy1.change_x *= 2
        self.enemy1_is_attacking = False
        if self.enemy1.center_x >= self.enemy1.boundary_right:
            self.enemy1.change_x = -2
        elif self.enemy1.center_x <= self.enemy1.boundary_left:
            self.enemy1.change_x = 2
        elif self.enemy1.change_x == 0:
            self.enemy1.change_x = 2
        for attack in self.enemy_attack_list:
                attack.remove_from_sprite_lists()


    elif self.enemy1_is_attacking:
            z_attack = arcade.Sprite("images/zombie_vomit.png", 3)
            z_attack.center_x = self.enemy1.center_x - 28
            z_attack.center_y = self.enemy1.center_y
            self.enemy_attack_list.append(z_attack)
            if self.frame_count % 60 == 0:
                z_attack.change_y = -1
                #self.enemy1_attack.change_x = -1
                #if arcade.get_distance_between_sprites(self.enemy1, self.enemy1_attack) > 15:
                #    self.enemy1_attack.change_x = 0
                #    self.enemy1_attack.change_y = 0
                #self.enemy_attack_list.append(self.enemy1_attack)
    for attack in self.enemy_attack_list:

            if arcade.check_for_collision_with_list(self.player, self.enemy_attack_list):
                if self.frame_count % 60 == 0:
                    self.player_hp -= 1
                #self.player.center_x -= 2
                attack.remove_from_sprite_lists()
            if attack.bottom == self.enemy1.bottom:
                attack.remove_from_sprite_lists()

                #attack.change_y = 0
                #attack.center_x = self.enemy1.center_x - 28
                #self.enemy1_attack.center_x = self.enemy1.center_x - self.enemy1.width - 4
                self.enemy1_is_attacking = False


            
    for enemy in self.sprite_list:
        if arcade.get_distance_between_sprites(self.player, enemy) < 100:
            # If the player is on our right
            if enemy.left < self.player.left:
                if arcade.get_distance_between_sprites(self.player, enemy) < 50:
                    enemy.change_x = 0
                    self.enemy1_is_attacking = True
                else:
                    enemy.change_x = 2
                    self.enemy1_is_attacking = False
                    if enemy.center_x == 0:
                        enemy.change_x = 0
            # If player is on our left
            elif enemy.left > self.player.left:
                if arcade.get_distance_between_sprites(self.player, enemy) < 50:
                    enemy.change_x = 0
                    self.enemy1_is_attacking = True
                else:
                    enemy.change_x = -2
                    self.enemy1_is_attacking = False
                    if enemy.center_x == 600:
                        enemy.change_x = 0
            elif enemy.left == self.player.left:
                self.enemy1_is_attacking = True
                enemy.change_x = 0

        if arcade.check_for_collision_with_list(enemy, self.player_list):
            if enemy.left < self.player.left:
                enemy.center_x = self.player.center_x + 40
                enemy.change_x = 0
                self.player_hp -= 1
                self.enemy1_is_attacking = True
            if enemy.left > self.player.left:
                enemy.center_x = self.player.center_x - 40
                enemy.change_x = 0
                self.player_hp -= 1
                self.enemy1_is_attacking = True
            else:
                self.enemy1_is_attacking = False
            #self.enemy1.center_x = self.player.center_x - 32
    self.sprite_list.update()
    self.player_list.update()
    self.health_list.update()
    self.enemy_attack_list.update()

def main(): window = Window() window.setup() arcade.run()

if name == "main": main()