Ich brauche Hilfe bei einem Problem mit einem Tetris-Spiel, das ich mache. Die Blöcke der Tetris-Teile sind Pixel voneinander entfernt, sodass es wie ein einzelnes Quadrat aussieht.
Die Teile sind im Wesentlichen Klassen:
class Piece:
def __init__(self, name: str):
self.name = name
self.rotation = 0
self.x = GRID_W / 2
self.y = -2
self.color = COLORS[name]
@property
def cells(self):
rot = self.rotation % 4
# print("rot : ",rot)
shape = SHAPES[self.name][rot]
cells = [(self.x + cx, self.y + cy) for (cx, cy) in shape]
return cells
def draw_piece(self):
# for x, y in self.cells:
# pygame.draw.rect(screen,self.color,(x-1,y+3,26,26),0,3)
cells = self.cells
cell1 = cells[0]
cell2 = cells[1]
cell3 = cells[2]
cell4 = cells[3]
# print(cell1,cell2,cell3,cell4)
# print(cell1[0],cell2[0],cell3[0],cell4[0])
# print(cell1[1],cell2[1],cell3[1],cell4[1]) # KNOW [url=viewtopic.php?t=26065]PROBLEM[/url] THE CELLS ARE CORRECT BUT THE POSITION IS EACH CELL IS JUST PIXELS AWAY FROM EACH OTHER AND WHEN ALL 4 OF THE CELLS ARE TOGETHER IT MAKES
filling = 0
if fill is False:
filling = 1
elif fill is not False:
filling = 0
t = 0
for x,y in cells:
t += 1
print(cells)
if t == 2:
filling = 0
pygame.draw.rect(screen,self.color,(x * times +x_offs,y * times +y_offs,size_x,size_y),filling,roundness)
# pygame.draw.rect(screen,self.color,(cell1[0] * times +x_offs,cell1[1] * times +y_offs,size_x,size_y),filling,roundness)
# pygame.draw.rect(screen,self.color,(cell2[0] * times +x_offs,cell2[1] * times +y_offs,size_x,size_y),filling,roundness)
# pygame.draw.rect(screen,self.color,(cell3[0] * times +x_offs,cell3[1] * times +y_offs,size_x,size_y),filling,roundness)
# pygame.draw.rect(screen,self.color,(cell4[0] * times +x_offs,cell4[1] * times +y_offs,size_x,size_y),filling,roundness)
Ich brauche Hilfe bei einem [url=viewtopic.php?t=26065]Problem[/url] mit einem Tetris-Spiel, das ich mache. Die Blöcke der Tetris-Teile sind Pixel voneinander entfernt, sodass es wie ein einzelnes Quadrat aussieht. Die Teile sind im Wesentlichen Klassen: [code]class Piece: def __init__(self, name: str): self.name = name self.rotation = 0 self.x = GRID_W / 2 self.y = -2 self.color = COLORS[name]
def draw_piece(self): # for x, y in self.cells: # pygame.draw.rect(screen,self.color,(x-1,y+3,26,26),0,3) cells = self.cells cell1 = cells[0] cell2 = cells[1] cell3 = cells[2] cell4 = cells[3] # print(cell1,cell2,cell3,cell4) # print(cell1[0],cell2[0],cell3[0],cell4[0]) # print(cell1[1],cell2[1],cell3[1],cell4[1]) # KNOW [url=viewtopic.php?t=26065]PROBLEM[/url] THE CELLS ARE CORRECT BUT THE POSITION IS EACH CELL IS JUST PIXELS AWAY FROM EACH OTHER AND WHEN ALL 4 OF THE CELLS ARE TOGETHER IT MAKES filling = 0 if fill is False: filling = 1 elif fill is not False: filling = 0 t = 0 for x,y in cells: t += 1 print(cells) if t == 2: filling = 0 pygame.draw.rect(screen,self.color,(x * times +x_offs,y * times +y_offs,size_x,size_y),filling,roundness)
# pygame.draw.rect(screen,self.color,(cell1[0] * times +x_offs,cell1[1] * times +y_offs,size_x,size_y),filling,roundness) # pygame.draw.rect(screen,self.color,(cell2[0] * times +x_offs,cell2[1] * times +y_offs,size_x,size_y),filling,roundness) # pygame.draw.rect(screen,self.color,(cell3[0] * times +x_offs,cell3[1] * times +y_offs,size_x,size_y),filling,roundness) # pygame.draw.rect(screen,self.color,(cell4[0] * times +x_offs,cell4[1] * times +y_offs,size_x,size_y),filling,roundness) [/code] Kann jemand versuchen, mir zu helfen?
Dies ist ein neuronales Netzwerk, das ich versuchte, ich bin nicht allzu sicher über meinen Backpropogation, aber es scheint mindestens Antworten zu konvergieren, obwohl es bei 4 Zahlen und der...
Ich versuche, ein Pong-Spiel für zwei Personen zu erstellen, das von zwei verschiedenen Clients (möglicherweise auf zwei verschiedenen Computern) über eine TCP-Verbindung (Sockets) gespielt werden...
Also, ich programmiere einen 2D-Plattformer in Java, ich habe bereits eine Wallslide-Mechanik erstellt und der Walljump funktioniert auch, aber ich habe Probleme mit einem Detail im Walljump:...
Ich bin sehr verblüfft und ist ein wenig besorgt, um das folgende Verhalten zu entdecken, bei dem ich zwei Tests und zwei Vorrichtungen habe. import pytest