2022-04-04から1日間の記事一覧

Pygame入門 画像をSpriteにして動かす

import pygame import sys SCREEN = pygame.Rect(0, 0, 400, 400) WHITE = (255, 255, 255) class Ball(pygame.sprite.Sprite): def __init__(self, image_file, pos, speed): pygame.sprite.Sprite.__init__(self) x, y = pos vx, vy = speed self.image = …

Pygame入門 画像を動かす

import pygame import sys SCREEN = pygame.Rect(0, 0, 400, 400) FPS = 30 WHITE = (255, 255, 255) def main(): pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode(SCREEN.size) ball = pygame.image.load('ball.png') ball_wi…

Pygame入門 図形(四角)を動かす

import pygame import sys SCREEN_SIZE = (400, 400) WHITE = (255, 255, 255) RED = (255, 0, 0) FPS = 1 def main(): pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode(SCREEN_SIZE) ball = pygame.Rect(100, 100, 10, 10) wh…