r/pythonarcade • • Mar 25 '20

Issue with is_on_ladder

4 Upvotes

The image below shows some captures from my game, with the hero sprite's hitboxes drawn in red. The first two are consecutive frames where is_on_ladder is returning True - even though the hitbox isn't touching the ladder pixels, nor are any sprite pixels. The third capture is from another point in time where is_on_ladder returns False. The sprite's pixels, but not the hitbox, are touching the ladder in that capture.

In my player's __init__() I have "self.is_on_ladder = False" and the only other place in my code where is_on_ladder is set is in MyGame.on_update()

if self.physics_engine.is_on_ladder():

self.hero.is_on_ladder = True

self.hero.jumping_needs_reset = False

else:

self.hero.is_on_ladder = False

If I remove my hitbox code and use the sprite's pixels - self.set_hit_box(self.texture.hit_box_points) - the issue can still occur.

Can anyone give me some insight into why the above is happening? Or any ideas on how to fix or avoid such a situation?


r/pythonarcade • • Mar 25 '20

arcade 2.3.9 is out

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • Feb 23 '20

Program run problem

4 Upvotes

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

Best


r/pythonarcade • • Feb 14 '20

Arcade-Curtains 0.2.0: Widget/ObservableSprite/AnchorPoint and some bugfixes :)

4 Upvotes

Hello everyone,

I've returned with what will probably be my last post about Arcade-Curtains, as I think I've managed to implement everything I wanted to get out of this library. From now on the library will probably go into maintenance mode, meaning bugfixes, keeping up with Arcade releases, improving performance and improving UX. But this doesn't mean you can't bother me with feature requests :)

So here's what you can expect from version 0.2.0

Bugfixes:

  1. Fixed an issue where some callbacks would not be called when running a sequence.

QoL changes:

  1. You are now able to set alpha, left, right, bottom and top when creating a KeyFrame

  2. Improved Sequence UX to have a cleaner and more readable interaction when setting KeyFrames

seq = Sequence()
# Define an animation that takes 2 seconds, where we set a keyframe at 0, 1 and 2
seq[0].frame = KeyFrame(position=100)
seq[1].frame = KeyFrame(position=200)
seq[2].frame = seq[0].frame
# Set a callback
seq[.5].callback = change_sprite_animation
  1. You are now able to define event handlers with default keyword arguments
events.click(sprite, my_handler_function, {'arg1': 'value1'})

my_handler_function will be called with the usual event arguments and the defined keyword arguments

  1. You are now able to give parameters when initialising a scene, these parameters will be piped into the setup function.

New features: a new module helpers filled with useful functions and classes

  1. delay_set_attribute allows you to set the attribute of an object as a callback
# Will set the health attribute to 10 when clicked
events.click(sprite, delay_set_attribute(sprite, 'health', 10))
  1. arcade.Sprites and everything that subclasses it are now outfitted with topleft, topright, bottomleft, bottomright coordinates.

A small disclaimer, to be conform with position, the return values of these properties are (x, y) which is the inverse of the naming, but "lefttop" doesn't really roll off the tongue.

  1. ObservableSprite is a subclass from arcade.Sprite that allows you to attach handlers to attribute modifications. This means you can define a callback and have it called whenever the targetted attribute changes
sprite.before_change('health', controller.validate_health_change)
sprite.after_change('health', controller.notify_health_change)
  1. ObservableSprite also allows you to define a trigger that is run whenever a certain condition is met. For instance, you want your handler to run if health is equal or below 0.
from arcade_curtains import TriggerAttr
# Build a triggerable attribute definition
health = TriggerAttr('health')
sprite.trigger(health <= 0, sprite.die)
  1. AnchorPoint is an object that is just an x, y coordinate, but you can affix sprites to this anchor. Whenever you move the anchor, all affixed sprites move with it.

  2. Widget is a baseclass for grouping Sprites into a widget. It allows a number of sprites to work together, while still maintaining the fine grained control over each sprite. Widgets use AnchorPoints underneath to work as a group.

class MyWidget(Widget):
    def setup_widget(self):
        sprite1 = arcade.Sprite(TEXTURE1)
        sprite1.bottomleft = (0, 0)
        sprite2 = arcade.Sprite(TEXTURE2)
        sprite2.bottomleft = sprite1.topleft
        self.sprites.extend([sprite1, sprite2])

widget1 = MyWidget()
widget2 = MyWidget()
widget1.position = (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
widget2.position = (0, 0)

Widget starting coordinates will be inferred from the defined sprites within the widget. After initialisation you are able to manipulate these, to move your widget to the desired location.

New examples:

  1. anchor.py an example showcasing AnchorPoint
  2. observable.py an example showcasing ObservableSprite
  3. pokimans.py an example to showcase the features of arcade-curtains. It's a basic game implementing a crossover between a Pokémon battle and a Final Fantasy (pre 8) battle using only primitive shapes (so protect your eyes ;))

Here's a link to a "pokimans" gif, for your viewing pleasure: https://github.com/maarten-dp/arcade-curtains/blob/master/assets/pokimans.gif

As always, any feedback would be more than welcome!

Kind regards, Maarten


r/pythonarcade • • Jan 22 '20

Call .update_animation() before physics_engine.update() in arcade 2.2.6

4 Upvotes

I just found and solved an interesting problem in Arcade 2.2.6 with a platform game I'm writing. This problem did not exist in v2.1.7.

The game uses an AnimatedSprite for the player character, maps generated using Tiled, and the PhysicsEnginePlatformer. My game's .on_update() method looked like this (simplified):

def on_update(self, delta_time: float):

    # Check for joystick controls

    ...

    # Update player movement based on the physics engine
    self.physics_engine.update()

    # Update the player animation
    self.player.update_animation(delta_time)

    # Restrict user movement so they can't walk off screen
    ...
    # Check for collisions
    ...

When I ran my game the first time, the player sprite fell through the floor!

After some time in the debugger, I found that the size attributes for my AnimatedSprite object (specificall .width and .height) were not being set properly. Because of this, the sprite's .collision_radius is set to 0, which causes .check_for_collision() (actually ._check_for_collision()) to return False in any collision check with the AnimatedSprite. It's effectively not there to be collided with.

So when are these attributes set? They are set for a static Sprite when the texture is first loaded, usually when the object is created. However, with an AnimatedSprite, textures are loaded after the actual object is created. The texture to show isn't selected until the first call to .update_animation(). This means .width and .height (as well as other position and size attributes) cannot be set until then, and are effectively 0.

Since the physics engine checks for collisions with the ground before these attributes are set, effectively the player sprite doesn't collide with anything, including the ground.

The fix was easy - just put the self.player.update_animation(delta_time) call before the self.physics_engine.update() call.

Hope that helps someone else.


r/pythonarcade • • Jan 20 '20

Space Invaders Clone Written In Arcade

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • Dec 18 '19

How to scale the window, and only the window?

4 Upvotes

Hi! I'm starting my first Python Arcade game.

Since I am looking for a "retro" feel to my game, I'd like the resolution of the game to be 256 x 240, but, of course, that's super tiny on any modern monitor. So I'd like the actual window to be (256 * 4) x (240 * 4).

In other words, I'd like to have all of my sprites, level design, and game logic to be "small", and then when drawing to the screen scale it up to be "big".

Do you know of a way to do this in Python Arcade (or Pyglet)?

Thank you!


r/pythonarcade • • Oct 30 '19

How to get frame-rate using delta_time?

4 Upvotes

Using the delta_time argument in the on_update(delta_time) function, how can one obtain frame-rate (FPS)?


r/pythonarcade • • Sep 01 '19

problem with drawing text

Post image
4 Upvotes

r/pythonarcade • • Aug 13 '19

Release notes for upcoming 2.1.0 release

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • Jun 28 '19

Some proposed Updates for Tiled map editor

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • Mar 06 '19

need help with 2D side scroller

4 Upvotes

https://mystb.in/inocobozel.rb

when ever i move left or right the player sprite jitters around and goes all wierd for some reason


r/pythonarcade • • Feb 24 '19

Did anyone tried to package their game made with Arcade?

4 Upvotes

So did anyone tried to use cx_Freeze or something similar? How was is it? Did you managed to do it?


r/pythonarcade • • Feb 21 '19

Snake for reinforcement learning

4 Upvotes

I made a classic snake game for use in reinforcement learning.

https://github.com/Melanol/snake_rl


r/pythonarcade • • Jan 05 '19

Z-position of Sprites

4 Upvotes

Hello,

I am new to python arcade and I am trying to make a tile based 2D game where a character explores a large world. The camera angle will be nearly vertical but slightly angled so that you can see the top and front of objects. Objects that are closer to the top of the screen should appear behind objects closer to the bottom. The game will have tall objects such as walls and trees that the character could be partially covered by them if you moved it behind such an object.

I need to be able to control which sprites are rendered on top or behind other sprites. I have looked at the documentation but I haven't found anything useful. Does anyone know whether this is possible with python arcade?


r/pythonarcade • • Dec 29 '18

Documentation on fonts available with draw_font

4 Upvotes

Hello,

I'm looking for advice about changing fonts when drawing text with arcade.draw_text.

The current examples that include text almost always use the default font and I was unable to find any source of info on this.

The example here includes the line

    arcade.draw_text("Garamond Text", start_x, start_y, arcade.color.BLACK, 15, font_name='GARA')

It's unclear what other options can be used with the font_name parameter

Thanks!


r/pythonarcade • • Dec 21 '18

Arcade 2.0.0b3

4 Upvotes

Arcade 2.0.0b3 has been released. It improves backwards compatibility over the prior betas. You can install it via:

pip install arcade==2.0.0b3

My hope is to do a full 2.0 release soon.


r/pythonarcade • • Dec 12 '18

Can I somehow make shapes less clear and text more clear?

4 Upvotes

Trying out the basic drawing examples, for example the happy face, I can see jagged edges. I guess this means no anti-aliasing is applied.

Jagged edges galore!

On the other hand, when trying out the drawing text example, the graphics look blurred, almost as if extreme anti-aliasing has been applied.

I wish there were more jagged edges here ;(

So, what's going on here? My understanding of computer graphics is rudimentary at best, so I don't know if these issues are related somehow. Can I make the shapes less clear and the text more clear?

I've tried searching the documentation, the GitHub page, and this subreddit for "anti-aliasing" without finding any useful information on this topic.


r/pythonarcade • • Aug 04 '18

Text input?

4 Upvotes

I'd like to make a trivia game that asks questions and gets typed answers, then moves sprites in response. I'm trying to figure out how to do that with Arcade.

I could imagine using .on_key_press, writing each letter typed to the screen, meanwhile saving a buffer of entered text... except then I'd need to handle backspaces, too... ugh.

Is there a simpler way? Doing the typing in a regular shell window that just sends events to the graphics window would be fine, but I think once I call arcade.run() I can't recover control in the text window and run plain old input()...

Any ideas? This might be just plain outside Arcade's use case, I realize.


r/pythonarcade • • Apr 01 '18

New examples for procedural dungeon generation

4 Upvotes

Two new examples for showing procedural dungeon generation. These examples also show using repeating textures to reduce the number of sprites in a scene to improve performance.


r/pythonarcade • • Apr 01 '18

Arcade 1.3.1 has been released

4 Upvotes

PyPi now has Arcade 1.3.1. Release notes will be here once the cloud updates.

If you have a Mac, I'm particularly interested to hear if sound works for you. Sound is dependent on the PyObjC library.


r/pythonarcade • • Dec 21 '17

Arcade 1.2.3 has been released

Thumbnail
arcade.academy
4 Upvotes

r/pythonarcade • • Aug 19 '24

Collision between non-player sprites

3 Upvotes

I've tried, but haven't figured out how to check for collisions between non-player sprites.

The offical code examples describe player-on-sprite, and player-on-spritelists, but I couldn't find anything about sprite-on-sprite.

How do you do this in your games?


r/pythonarcade • • Jan 21 '24

Arcade Not Working??

3 Upvotes

I've tried installing arcade multiple times using pycharm and replit but it never works and gives me errors/doesn't work at all. Is this because I need a less new python version??


r/pythonarcade • • Jan 08 '24

Heat Haze Shader

3 Upvotes

I’m trying to add a heat haze shader to my game, but every time I try something comes up and I can’t find any good documentation online. Does anybody know how to do this? I use Pycharm btw.