Advertisement
Karp_xD

Shopping

May 16th, 2022
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import pygame
  2. class shopp:
  3.     def __init__(self, x, y, image, defense, cost):
  4.         self.image = image
  5.         self.rect = self.image.get_rect()
  6.         self.rect.topleft = (x, y)
  7.         self.defense = defense
  8.         self.cost = cost
  9.         self.clicked = False
  10.     def draw(self, win):
  11.         action = False
  12.         #get mouse position
  13.         pos = pygame.mouse.get_pos()
  14.         #check mouseover and clicked conditions
  15.         if self.rect.collidepoint(pos):
  16.             if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False:
  17.                 self.clicked = True
  18.                 action = True
  19.         if pygame.mouse.get_pressed()[0] == 0:
  20.             self.clicked = False
  21.         #draw button on screen
  22.         win.blit(self.image, (self.rect.x, self.rect.y))
  23.         return action
  24. class suits():
  25.     def __init__(self, part, x, y):
  26.         self.x = x
  27.         self.y = y
  28.         self.part = part
  29.         self.rect = self.part.get_rect()
  30.         self.rect.topleft = (self.x, self.y)
  31.     def wear(self, win):
  32.         win.blit(self.part, (self.x, self.y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement