“Tabrakan Pygame” Kode Jawaban

tabrakan pemeriksaan pygame

def is_collided_with(self, sprite):
    return self.rect.colliderect(sprite.rect)
Innocent Impala

Tabrakan Pygame


player_rectangle = pygame.Rect(top, left, width, height)

player_rectangle.colliderect(rect_you_want_to_test_is_being_overlapped) 
# Returns True or False if your rect collides with the rect given

player_rectangle.collidelist(list_of_rects)
# Tests if the player rect collides with a list of rects, returns index of 
# rect, give -1 if no rect collides.

Elated Emu

Tabrakan titik pygame

Object_1 = pg.Rect(x, y, width, height)
Point = (x, y) #If this doesn't work, then change parenthesis to brackets

if Object_1.collidepoint(Point):
    #Do something
Victorious Vulture

Jawaban yang mirip dengan “Tabrakan Pygame”

Pertanyaan yang mirip dengan “Tabrakan Pygame”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya