Advertisement
giganciprogramowania

Pad

Jan 20th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. import pygame
  2.  
  3. SCREEN_WIDTH = 1024
  4. SCREEN_HEIGHT = 800
  5.  
  6. class Pad(pygame.sprite.Sprite):
  7.     def __init__(self):
  8.         super(Pad, self).__init__()
  9.         self.surf = pygame.image.load("images/pad.png")
  10.         self.moving = 0
  11.         self.resetPosition()
  12.  
  13.     #resetowanie pozycji
  14.     def resetPosition(self):
  15.         self.rect = pygame.Rect(SCREEN_WIDTH/2-70, SCREEN_HEIGHT-100, 140, 30)
  16.  
  17.     #poruszanie
  18.     def move(self, value):
  19.         speed = 10
  20.         self.rect.move_ip(value*speed, 0)
  21.         self.moving = value
  22.         if self.rect.left <= 0: self.rect.x = 0
  23.         if self.rect.right >= SCREEN_WIDTH: self.rect.x = SCREEN_WIDTH-140
  24.    
  25.     #aktualizacja
  26.     def update(self):
  27.         self.moving = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement