python – How to remove a sprite from a group?

I am trying to make a chess game with Pygame, but am unable to remove the chess piece when it is captured. Stack Overflow already has a question on this here. But this code doesn’t seem to work. When I iterate through the list, it ends up deleting many pieces.

for piece in piece_group_black:
    if piece.location.all() == selects.location.all():

Say I move white piece to capture black , this code ends up deleting a lot of pieces.

for piece in piece_group_black:
    if piece.location.all() == selects.location.all():
        pieceremove = piece


This removes a random piece. Same happens for when I use the code given in the answers. They just don’t work.

python – How can i make a sprite appear middle of your cursor? Pygame

I made a sprite (hitmarker) to appear middle of your mouse when you click on a sprite (egg), but the hitmarker sprite appears at the right bottom of your mouse like this:

My Result

however, I wanna make it appear like this:

What i wanna make

I tried screen.blit(hitmarker, (pygame.mouse.get_pos()))
but it appears at the right bottom of your mouse.

Source Code:

import pygame, sys, time
from pygame.locals import *
from millify import millify,prettify

music = open("music.txt", "r+")"soundtrack.wav")
x = int(
WHITE = 255,255,255
font = pygame.font.SysFont(None, 44)
cpsecond = open("clickpersecond.txt", "r+")
cps = int(
baltotal = open("totalbal.txt", "r+")
totalbal = int(
totalbalM = prettify(totalbal, '.')
clock = pygame.time.Clock()
w = 800
h = 600
screen = pygame.display.set_mode((w,h))
pygame.display.set_caption('Tap Simulator')
Loop = True
background = pygame.image.load("Background.jpg")
egg = pygame.image.load("egg.png")
resized_egg = pygame.transform.scale(egg, (282, 352))
text = font.render(f'Your total clicks are {totalbalM}', True, WHITE),0.0)
volume = pygame.image.load("volume.png")
mute = pygame.image.load("mute.png")
resized_volume = pygame.transform.scale(volume, (100, 100))
resized_mute = pygame.transform.scale(mute, (100,100))
icon = pygame.image.load("ico.ico")
hitmarker = pygame.image.load("hitmarker.png")
resized_hitmarker = pygame.transform.scale(hitmarker, (50, 50))


while Loop:
    for event in pygame.event.get():
        if event.type == QUIT:
            Loop = False
        if event.type == MOUSEBUTTONDOWN:
            if event.button == 1: # 1 == left click
                egg_rect = resized_egg.get_rect(topleft = (260,150))
                vol_rect = volume.get_rect(topleft = (700,500))
                if vol_rect.collidepoint(event.pos):
                    x += 1
                    if x > 2:
                        x = 1
                if egg_rect.collidepoint(event.pos):
                    totalbal += cps
                    totalbalM = prettify(totalbal, '.')
                    screen.blit(background, (0,0))
                    if x == 1:
                        screen.blit(resized_volume, (700,500))
                    if x == 2:
                    screen.blit(text, (235,557))
                    screen.blit(resized_egg, (260,150))
                    screen.blit(resized_hitmarker, (pygame.mouse.get_pos()))
                    text = font.render(f'Your total clicks are {totalbalM}', True, WHITE)
                    print("Your total clicks are", totalbalM, end="r")

    #print(pygame.mouse.get_pos()) #to get mouse pos
    screen.blit(background, (0,0))
    screen.blit(resized_volume, (700,500))
    if x == 0:
        screen.blit(background, (0,0))# (...) draw something different
    elif x == 1:
        screen.blit(resized_volume, (700,500))
    elif x == 2:
        screen.blit(background, (0,0))
    screen.blit(text, (235,557))    
    screen.blit(resized_egg, (260,150))

with open("totalbal.txt", "w") as baltotal:

with open("music.txt", "w") as music:

Remove sprite reference before build in Unity

All the the characters in my 2D game have SpriteRenderers to animate the characters. Some of the characters are only active in their scenes sometimes, so I load their sprites asynchronously based on game state.

During edit mode, I have at least one sprite from an animation assigned to each sprite renderer so I can tell where the game object is. The problem is that including even a single sprite will load up the entire sprite atlas at runtime if I allow the SpriteRenderer.sprite to be set.

Is there an efficient way to unset the SpriteRenderer.sprite for a build, but not during edit time? Is there a better way to handle this?

godot – How to change FPS when using a sprite sheet and AnimationPlayer?

AnimationPlayer has a playback_speed that you can use the way as the speed_scale property of the AnimatedSprite.

However, there is no way to manipulate the speed of the individual animation themselves. That is, you cannot change the speed of the animations, only the speed of the player.

Suffice to say that the animations are not encoded in frames, but time in seconds instead.

By the way, I remind you that with Property Tracks and Call Method Tracks, the AnimationPlayer can manipulate other nodes, including AnimatedSprite.

gui – which c# framework to use for a sprite sheet maker software

gui – which c# framework to use for a sprite sheet maker software – Game Development Stack Exchange

collision detection – How to transfrom CollisionPolygon2D according to the Vertex Shader applied to a Sprite?

Consider this:

* KinematicBody2D
- * Sprite
- * CollisionPolygon2D

And a vertex shader:

shader_type canvas_item;

void vertex() {
    VERTEX.y += sin(2.0 * TIME) * 10.0;

When the vertex shader is added to the CanvasItem.material of the Sprite and the CollisionPolygon2D they both move at the same time:

enter image description here

But if one modifies the shader like that:

void vertex() {
  VERTEX.y += sin(UV.y * 2.0 * TIME) * 10.0;

It produces that:

enter image description here

How to transfrom CollisionPolygon2D according to the Vertex Shader applied to the Sprite?

2d – How to handle player slowness while moving up and down in a Top Down game with angled ortho camera and angled sprite due to stretching of ground?

enter image description here

So i’m making a 2D top down game setup in 3D using tilted Sprites and angled orthographic camera.

My camera setup is as shown.

In my game I have the floor flat on the X/Z plane with walls/characters rotated +45 degrees about the X axis. The orthographic camera is pointing down also at 45 degrees about the x axis, parallel with my walls/characters.

As a result, I dont see any distortion for players/characters since they face the camera directly on, while the ground however sees a distortion of sqrt(2) shorter. This makes sense considering how an orthographic camera works. To fix this, I’ve made my Tilemap set up with X:1 Y:1 Z:Sqrt(2) so that each tile is stretched on the Z axis by Sqrt(2) to compensate for this distortion.

All looks well with only one problem now… foreshortening with regards to movement: Forward and backwards movements of objects/characters along the z axis are perceived to be slower than movements left/right on the x axis. This makes sense because while each tile is perceived to be a square in the camera view thanks to scaling Z on the tilemap by sqrt(2), the real world tile is, well, sqrt(2) times taller than its width, so obviously it takes longer to travel forwards / backwards.

How do i correct this?

godot – How do I change a sprite using code from another node?

I’m trying to make a program in Godot where the player can put a bunch of images into a folder, and when the button is pressed, have the image appear as a sprite on the screen. With the current code, the directory for the image is printed when the button is pressed, but the image sprite simply does not appear. No error messages come up either, so I’m stumped as to what the problem is. Here is the code:

extends Button

func _pressed():
    var cards_order = () #creates the array
    var path = "assets/cards/" #defines a path
    var dir = #creates a directory #sets the directory to the defined path
    dir.list_dir_begin() #begins listing the directory
    while true:
        var file_name = dir.get_next() #sets the var "file_name" to the next entry in the directory
        if file_name == "":
        #break the while loop when get_next() returns ""
        elif !file_name.begins_with(".") && !file_name.ends_with(".import"):
        #get_next() returns a string so this can be used to load the images into an array. Also stops .import files from being added
            cards_order.append(load(path + file_name)) #loads the next file into the array
    randomize() #changes the randomization
    cards_order.shuffle() #shuffles the array
    var card_sprite = cards_order.front() #sets card_sprite as the first item in the array
    $"/root/CardSprite".texture = load(card_sprite.get_path())

Any help with this would be greatly appreciated!

LibGDX Shader that converts sprite to single colour with blurred edges

I made a shader which turns all the colours of the texture to black but I also want it to be blurred at the edges where the opaque sprite turns transparent.

Original texture with desired output.

enter image description here

#ifdef GL_ES
    precision mediump float;

varying vec4 v_color;
varying vec2 v_texCoords;

uniform sampler2D u_texture;

void main() {
  vec4 c = v_color * texture2D(u_texture, v_texCoords);
  gl_FragColor = vec4(0,0,0, c.a);

A simple gaussian blur with good performance is what I want.

This shadertoy shader looks ideal:

I managed to convert the above mentioned shadertoy to GLSL which works fine, but I don’t know how to make it first turn the texture black before blurring.

#ifdef GL_ES
    #define PRECISION mediump
    precision PRECISION float;
    precision PRECISION int;

varying vec4 v_color;
varying vec2 v_texCoords;

uniform sampler2D u_texture;
uniform vec2 resolution;

void main() {
    float Pi = 6.28318530718; // Pi*2
    float Directions = 16.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
    float Quality = 4.0; // BLUR QUALITY (Default 4.0 - More is better but slower)
    float Size = 8.0; // BLUR SIZE (Radius)
    vec2 Radius = Size / resolution.xy;
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = v_texCoords;
    // Pixel colour
    vec4 Color = texture2D(u_texture, uv);
    // Blur calculations
    for( float d=0.0; d<Pi; d+=Pi/Directions) {
        for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality) {
            Color += texture2D( u_texture, uv+vec2(cos(d),sin(d))*Radius*i);        
    // Output to screen
    Color /= Quality * Directions - 15.0;
    gl_FragColor =  Color;

(Unity Engine) Is it possible to make 2d animation bones perfectly straight within the sprite editor

I am experimenting with pixel perfect camera and 2d animation. I noticed in the skinning editor that there is no option to edit bone coordinates. When I make an ik it extended the arm making it noticeable that the bones weren’t perfectly aligned. so im wondering if it is possible to make a bone perfectly vertical/horizontal within the skinning editor.

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive New Proxy Lists Every Day Proxies123