Giới thiệu sản phẩm
import pygame
import random
pygame.init()
screen = pygame.display.set_mode((991, 744))
clock = pygame.time.Clock()
class Player:
def __init__(self, screen, color, x, y, r):
self.__screen = screen
self.__color = color
self.__x = x
self.__y = y
self.__r = r
self.__speed = 5
self.__jumping = False
self.__jump_height = 180
self.__jump_speed = 10
self.__jump_count = 0
self.__on_ground = True
def draw(self):
pygame.draw.circle(self.__screen, self.__color, (self.__x, int(self.__y) - self.__r), self.__r)
def update(self):
if self.__jumping:
if self.__jump_count < self.__jump_height:
self.__y -= self.__jump_speed
self.__jump_count += self.__jump_speed
else:
self.__jumping = False
self.__jump_count = 0
elif not self.__on_ground:
if self.__y < 530:
self.__y += self.__jump_speed
else:
self.__y = 530
self.__on_ground = True
def start_jump(self):
if self.__on_ground:
self.__jumping = True
self.__on_ground = False
def move(self, direction):
if direction == 'Right':
self.__x += self.__speed
elif direction == 'Left':
self.__x -= self.__speed
self.__x = max(20, min(self.__x, 971))
def get_rect(self):
return pygame.Rect(self.__x - self.__r, self.__y - self.__r, self.__r * 2, self.__r * 2)
def update_and_draw(self):
self.update()
self.draw()
class TruongNgoaiVat:
def __init__(self, screen, color, x, y, width, height, speed):
self.__screen = screen
self.__color = color
self.__x = x
self.__y = y
self.__width = width
self.__height = height
self.__speed = speed
Hình ảnh sản phẩm

this is geometry dash, duh!
Đăng nhập để tham gia bình luận
Đăng nhập để tham gia bình luận