Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- screen = pygame.display.set_mode((810,810))
- (width,height) = (359,255)
- (wallwidth,wallheight) = 50,50
- x = 0
- y = 0
- wx = 700
- wy = 700
- color = (0,0,0)
- pygame.display.set_caption( 'da biggest BALLER!waw' )
- dontfaqwiththeshaq = pygame.image.load('shaq_fu.webp').convert()
- shaqcraq = pygame.image.load('the biggest bird.jpg').convert()
- class Sprite(pygame.sprite.Sprite):
- def __init__(self,image,x,y):
- super().__init__()
- self.image = pygame.Surface([width,height])
- self.x = x
- self.y = y
- pygame.draw.rect(self.image, color, pygame.Rect(0, 0, width,height))
- self.rect = self.image.get_rect()
- def render(self,image):
- pygame.draw.rect(screen,color,(x,y,width,height))
- object_ = Sprite(dontfaqwiththeshaq, x, y)
- object_.rect.x = x
- object_.rect.y = y
- all_sprites_list = pygame.sprite.Group()
- all_sprites_list.add(object_)
- class Wall(pygame.sprite.Sprite):
- def __init__(self,wimage,wx,wy):
- super().__init__()
- self.wimage = pygame.Surface([wallwidth,wallheight])
- self.wx = wx
- self.wy = wy
- pygame.draw.rect(self.wimage,color,pygame.Rect(0,0,wallwidth,wallheight))
- self.rect = self.wimage.get_rect()
- def render(self,wimage):
- pygame.draw.rect(screen,color,(wx,wy,wallwidth,wallheight))
- wallblock = Wall(shaqcraq,wx,wy)
- wallblock.rect.x = wx
- wallblock.rect.y = wy
- all_sprites_list.add(wallblock)
- wrect = wallblock.rect
- rect = object_.rect
- collidelist = pygame.sprite.spritecollide(object_,all_sprites_list,False)
- running = True
- delta_time = 0.1
- x += 50 * delta_time
- y += 50 * delta_time
- clock = pygame.time.Clock()
- while running:
- all_sprites_list.update()
- screen.blit(shaqcraq,(0,0))
- object_.render(screen)
- wallblock.render(screen)
- screen.blit(dontfaqwiththeshaq,(x,y))
- keys = pygame.key.get_pressed()
- if keys[pygame.K_LEFT]:
- x -=30
- if keys[pygame.K_RIGHT]:
- x +=30
- if keys[pygame.K_DOWN]:
- y +=30
- if keys[pygame.K_UP]:
- y -=30
- for sprite in collidelist:
- color = (0,255,255)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- pygame.display.flip()
- delta_time = clock.tick(60) / 1000
- delta_time = max(0.001, min(0.1, delta_time))
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement