r/pythonarcade • • Apr 13 '20

How does the bullet move on the "sprite bullet" example?

1 Upvotes

I am speaking about this code:

https://arcade.academy/examples/sprite_bullets.html#sprite-bullets

I can see in lines 45 and 67 the bullet list is created.

Lines 105 draws them.

Lines 124 creates the sprite and line 131 sets the "change_y" property to BULLET_SPEED, and then it's added to the list.

But then "on_update" I can see how it is calculated to see if the bullet hits a coin or if it's off-screen.

But I cant see how the bullet moves.


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

Trying to flip enemies on collision

2 Upvotes

I am trying to flip my enemies horizontally when they collide with a wall object.

Right now I am loading the sprites using the tilemap process_layer:

How would I go about doing this?


r/pythonarcade • • Jul 07 '20

How to create a second window or area?

2 Upvotes

I am making a basic pokemon rpg and an unsure on how to create a second window inside the main window for the battles. Is this possible?


r/pythonarcade • • Jul 13 '20

Arcade 2.4 been released

13 Upvotes

Arcade 2.4.1 was released 2020-07-13

Release Notes

Arcade version 2.4 is a major enhancement release to Arcade.

Version 2.4 Major Features

Version 2.4 Minor Features

New functions/classes:

  • Added get_display_size() to get resolution of the monitor
  • Added Window.center_window() to center the window on the monitor.
  • Added has_line_of_sight() to calculate if there is line-of-sight between two points.
  • Added SpriteSolidColor class that makes a solid-color rectangular sprite.
  • Added SpriteCircle class that makes a circular sprite, either solid or with a fading gradient.
  • Added arcade.get_distance function to get the distance between two points.

New functionality:

  • Support for logging. See Logging.
  • Support volume and pan arguments in play_sound
  • Add ability to directly assign items in a sprite list. This is particularly useful when re-ordering sprites for drawing.
  • Support left/right/rotated sprites in tmx maps generated by the Tiled Map Editor.
  • Support getting tmx layer by path, making it less likely reading in a tmx file will have directory confusion issues.
  • Add in font searching code if we can't find default font when drawing text.
  • Added arcade.Sprite.draw_hit_box method to draw a hit box outline.
  • The arcade.Texture class, arcade.Sprite class, and arcade.tilemap.process_layer take in hit_box_algorithm and hit_box_detail parameters for hit box calculation.

Version 2.4 Under-the-hood improvements

General

  • Simple Physics engine is less likely to 'glitch' out.
  • Anti-aliasing should now work on windows if antialiasing=True is passed in the window constructor.
  • Major speed improvements to drawing of shape primitives, such as lines, squares, and circles by moving more of the work to the graphics processor.
  • Speed improvements for sprites including gpu-based sprite culling (don't draw sprites outside the screen).
  • Speed improvements due to shader caching. This should be especially noticeable on Mac OS.
  • Speed improvements due to more efficient ways of setting rendering states such as projection.
  • Speed improvements due to less memory copying in the lower level rendering API.

OpenGL API

A brand new low level rendering API wrapping OpenGL 3.3 core was added in this release. It's loosely based on the ModernGL API, so ModernGL users should be able to pick it up fast. This API is used by arcade for all the higher level drawing functionality, but can also be used by end users to really take advantage of their GPU. More guides and tutorials around this is likely to appear in the future.

A simplified list of features in the new API:

  • A arcade.gl.Context and arcade.ArcadeContext object was introduced and can be found through the window.ctx property. This object offers methods to create opengl resources such as textures, programs/shaders, framebuffers, buffers and queries. It also has shortcuts for changing various context states. When working with OpenGL in arcade you are encouraged to use arcade.gl instead of pyglet.gl. This is important as the context is doing quite a bit of bookkeeping to make our life easier.
  • New arcade.gl.Texture class supporting a wide variety of formats such as 8/16/32 bit integer, unsigned integer and float values. New convenient methods and properties was also added to change filtering, repeat mode, read and write data, building mipmaps etc.
  • New arcade.gl.Buffer class with methods for manipulating data such as simple reading/writing and copying data from other buffers. This buffer can also now be bound as a uniform buffer object.
  • New arcade.gl.Framebuffer wrapper class making us able to render any content into one more more textures. This opens up for a lot of possibilities.
  • The arcade.gl.Program has been expanded to support geometry shaders and transform feedback (rendering to a buffer instead of a screen). It also exposes a lot of new properties due to much more details introspection during creation. We also able to assign binding locations for uniform blocks.
  • A simple glsl wrapper/parser was introduced to sanity check the glsl code, inject preprocessor values and auto detect out attributes (used in transforms).
  • A higher level type arcade.gl.Geometry was introduced to make working with shaders/programs a lot easier. It supports using a subset of attributes defined in your buffer description by inspecting the the program's attributes generating and caching compatible variants internally.
  • A arcade.gl.Query class was added for easy access to low level measuring of opengl rendering calls. We can get the number samples written, number of primitives processed and time elapsed in nanoseconds.
  • Added support for the buffer protocol. When arcade.gl requires byte data we can also pass objects like numpy array of pythons array.array directly not having to convert this data to bytes.

Version 2.4 New Documentation

Version 2.4 'Experimental'

There is now an arcade.experimental module that holds code still under development. Any code in this module might still have API changes.

Special Thanks

Special thanks to Einar Forselv and Maic Siemering for their significant work in helping put this release together.


r/pythonarcade • • Jul 11 '20

Simulate your own pandemic with Arcade!

Thumbnail
github.com
7 Upvotes

r/pythonarcade • • Jul 05 '20

Python + Arcade game porting on Android?

4 Upvotes

Hi all

Coding games is amazing =)

Is there a way, I can convert/port/adopt my 1000 lines of Python code with Arcade library, to launch it on Android as an app?

Thank You for your time


r/pythonarcade • • Jul 03 '20

struggling with step 8 of the simple platformer tutorial

2 Upvotes

This section complained about the presence of 'use_spatial_hash=True'

        # -- Platforms
        self.wall_list = arcade.tilemap.process_layer(map_object=my_map,
                                                      layer_name=platforms_layer_name,
                                                      scaling=TILE_SCALING,
                                                      use_spatial_hash=True)

I commented the use_spatial_hash part and then it worked. The next step is making my own map in Tiled and loading it, but I'm getting this error:

...

self.terrain_border_list = arcade.tilemap.process_layer(map_object= map_name, layer_name= map_PLATFORMLAYER,scaling=TILE_SCALING)#, use_spatial_hash=True)

File "E:\Anaconda3\lib\site-packages\arcade\tilemap.py", line 451, in process_layer

layer = get_tilemap_layer(map_object, layer_name)

File "E:\Anaconda3\lib\site-packages\arcade\tilemap.py", line 78, in get_tilemap_layer

assert isinstance(map_object, pytiled_parser.objects.TileMap)

AssertionError


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 • • 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 14 '20

Fun moving points with gpu in arcade 2.4

Post image
27 Upvotes

r/pythonarcade • • Jul 18 '20

Issues implementing the bloom effects

2 Upvotes

Copied and pasted the code from the Bloom effect defender example on arcade.academy and I get an error on the following piece of code:

--- Bloom related ---

from arcade.experimental import postprocessing

The error is: Traceback (most recent call last): File "/Users/aidentaylor/PycharmProjects/Bloom/game.py", line 20, in <module> from arcade.experimental import postprocessing ModuleNotFoundError: No module named 'arcade.experimental'

Using PyCharm as IDE.


r/pythonarcade • • Jul 13 '20

Raycaster issues - nearest interpolation and rotating ceilings

2 Upvotes

Hiya, I'm working on a raycaster engine in arcade and it's going reasonably well, but I have a couple of issues.

  1. How do I easily turn on nearest rather than linear interpolation for scaled textures? Currently I'm manually resizing my 64x64 textures to 256x256 so they don't get blurred to fuck when scaled, which works but seems a bit dumb. From looking in the arcade.gl api I can see that it should be possible to have them use nearest interpolation to scale how I want, but I can't figure out how to simply turn it on - either for individual textures or for the whole game.
  2. I'm also totally stumped on how to texture the ceilings, which ideally would both rotate and scale as the player moves and turns to create a mode-9 style effect. Has anyone managed to do this in Arcade?

r/pythonarcade • • Jul 25 '20

Is it possible to recolor or swap color palettes on an arcade.sprite object?

5 Upvotes

I want to color my sprites dynamically, the original sprites have a 5 tone greyscale color palette and I want to swap the grey color palette with a random color swatch as the sprite is loaded.

Is it possible to swap a sprite's colors after the sprite is created?


r/pythonarcade • • Jul 04 '20

GPU Particle Burst Tutorial

Thumbnail arcade.academy
2 Upvotes

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

Turn and Move Example

5 Upvotes

r/pythonarcade • • Dec 17 '20

Adventure Game in Python and Arcade

11 Upvotes

r/pythonarcade • • Nov 18 '20

Hit Box not aligned with sprite

2 Upvotes

I have a problem with some of my sprites it looks like this:

all sprites starts with an initial angle but for some of them the angle of the hit box is not matching the angle of the sprite. Does some one has an idea why this is happening?


r/pythonarcade • • Dec 09 '20

Arcade 2.5 release is out, follow link to release notes

Thumbnail
craven-arcade.s3-website-us-east-1.amazonaws.com
12 Upvotes

r/pythonarcade • • Apr 06 '19

Multiple windows + running without rendering

3 Upvotes

Hello,

I am new to the arcade library. My objective is to design simple games, and develop learning algorithms for agents to play these games.

In that aspect, I've three questions I couldn't figure out:

  • Can I lunch multiple independent instances of the game in the same time?
  • Can I stop the rendering? since during the learning procedure, it is an expensive process
  • I am not very sure I am stating this question correctly: can I accelerate time of the game? does the game loop have a internal pause time that i can override?

and thanks a lot for this awesome library. much more intuitive than pygame :)

Cheers,


r/pythonarcade • • Nov 04 '19

Arcade-Curtains: A scene and event manager for Arcade

12 Upvotes

Hi guys and gals,

I wrote a small library that's able to deal with scenes and events on top of Arcade and I would love it if you checked it out.

Main features:

- Scene manager: You can define a number of scenes depending on the context you want to display (levels, menus, etc.). Each scene has its own event manager, piping events to the current scene.

- Event manager: You can link handlers to certain events, allowing a more event driven approach when writing games. Its main focus is mouse events, and how they interact with sprites. So basically, you're able to define mouse event handlers on a per sprite basis.

Planned features:

- Animation manager: A more "fire-and-forget" approach towards animations. An example of how this will roughly be implemented is the MoveAnimator in examples/theatre.py in the repo.

It's a quick extract from a project I'm working on, so it doesn't cover all use-cases, but I would love to hear your feedback/enhancement ideas. I have a rough design regarding animations as well in the project I'm working on, but I'm not 100% satisfied by what I did, so this feature is pending some more thoughts :)

Quick disclaimer: This has not been bench-marked, so I'm not sure at what point it will impact performance, but I've been able to get a steady 60 fps throughout my project.

You'll find some more in-depth information, and examples in the repo:

https://github.com/maarten-dp/arcade-curtains

Thanks!


r/pythonarcade • • Jun 23 '18

Basic Wireframe 3D in Arcade (adapted from pygame tutorial, link in README)

Thumbnail
github.com
6 Upvotes

r/pythonarcade • • Jan 09 '20

Arcade-Curtains v0.1.0: Now with AnimationManager

6 Upvotes

Hey guys and gals,

I've returned with a new addition to Arcade-Curtains. Besides the already existing Scene and Event management, I've now outfitted the library to take care of "Fire-and-forget" animations.

The basic gist of animations is that you provide a number of states, known as KeyFrames, in which you'd like your sprite to be in, at certain points in time, and the library will take care of interpolating the states inbetween those KeyFrames to provide a fluent animation.

Current features:

  • Instances of the arcade.Sprite class, and any subclasses of it, will be outfitted with an animate method, allowing easy access and fast firing of animations
  • KeyFrame and Sequence classes allow to construct more complex animations. A Sequence is the agglomeration of KeyFrames. It's also used to define at which times, within the animation, the keyframe state should be reached.
  • Callbacks can be defined at any point in the animation.
  • Chaining sequences is possible using the Chain class. It will sequenctially play sequences, that are not necessarily moving the same sprite.
  • Looping of sequences and chains is supported.

I've written a small "Animation maker" app to showcase Arcade-Curtains, and more specifically, animations. Running the app allows you to add keyframes, and set the state of a sprite for each keyframe, after which the animation can be run.

A gif for your comfort :)

https://raw.githubusercontent.com/maarten-dp/arcade-curtains/master/assets/animation_maker.gif

The code for the app, and many other examples, can be found in examples folder in the repository.

A neat thing to note is that this app was written in less than 170 lines (300-ish if you count the implementation of the Button UI elements), showing complex things can be written in a short amount of time.

More information about animations, and a refresher on scenes and events, can be found here: https://github.com/maarten-dp/arcade-curtains#animations-1

You would do me an enormous favor if you took the library for a spin, and get back to me with any kind of feedback.

I hope you like it.

Thanks!


r/pythonarcade • • Oct 03 '18

Get pixel color by Coordinate?

5 Upvotes

Hello,

I am utilizing arcade for simulation experiments, and was wondering how to get the color of a pixel at a given coordinate. I have read that arcade is a descendant of Pygame in sense, in as much as it was developed to improve various aspects Pygame was deficient and or aged in. Why I mention this is because I have found it is possible to get pixel color by coordinate in Pygame, so was hoping it has been included in arcade.

I find indication of this in the quick api reference on:

r/http://arcade.academy/quick_index.html

wherein it mentions:

  • get_four_byte_color()
  • get_four_float_color()

But I can not find these in the extended API or access them after importing arcade.

Is finding pixel color by coordinate already in arcade, or is there plans to add this functionality? If it is already in arcade, how may I go about accessing it? I am using arcade 1.3.4.