1
これはPythonのいくつかの基本を理解した後にコーディングするのが比較的新しく、私はpygameでoopを適用しようとしています 私はこのコードを持っています。表示されますpython-pygame rectangle描画/レンダリングしません
import pygame
import time
pygame.init()
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("EXAMPLE")
clock = pygame.time.Clock()
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
FPS = 30
class Puddles(pygame.sprite.Sprite):
puddle_width = 100
puddle_height = 20
def __init__(self,color,x,y):
pygame.sprite.Sprite.__init__(self)
self.x = x
self.y = y
self.color = color
self.image = pygame.Surface((Puddles.puddle_width,Puddles.puddle_height))
self.image.fill(self.color)
self.rect = self.image.get_rect()
self.rect.x = self.x # i think problem's here because if I type specific integers for x and y the tile will appear
self.rect.y = self.y
all_sprites = pygame.sprite.Group()
puddle1 = Puddles(red, 400, 600)
all_sprites.add(puddle1)
gameExit = False
while not gameExit:
clock.tick(FPS)
for event in pygame.event.get():
print event
if event.type == pygame.QUIT:
gameExit = True
all_sprites.update()
screen.fill(white)
all_sprites.draw(screen)
pygame.display.flip()
pygame.quit()
quit()
どのようなアイデアですか?それは画面の外ですので、予め おかげ:)
ありがとう!どのような愚かな間違いを私は作った! (400,600)(600は端です)私はランダムにこれらの数字を入れて、私はそれが動作するかどうかをチェックしたかった – Aris
と43-46行が誤ってそこにいるのは、これが初めての質問です。答えをありがとう! – Aris
@Aris私はあなたを助けることができてうれしいです! :) upvoteして受け入れてください。 – skrx