文末有福利领取哦~
👉一、Python所有方向的学习路线
Python所有方向的技术点做的整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。
👉二、Python必备开发工具
👉三、Python视频合集
观看零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。
👉 四、实战案例
光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。(文末领读者福利)
👉五、Python练习题
检查学习结果。
👉六、面试资料
我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。
👉因篇幅有限,仅展示部分资料,这份完整版的Python全套学习资料已经上传
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
class ManagerTree:
“”“管理树类”“”
__screen_size = (900, 600)
screen = pygame.display.set_mode(__screen_size, DOUBLEBUF, 32)
fruit_list = []
fruit_image = pygame.image.load(Tree.fruit).convert_alpha()
fruit_width = fruit_image.get_width()
fruit_height = fruit_image.get_height()
type = 0 # 0树界面,1加精力界面
energy_full = False # 精力已满标志 初始未满
money_empty = False # 银币不足
def load\_text(self, text, position, txt_size=25, txt_color=(255, 255, 255)):
my_font = pygame.font.SysFont(None, txt_size)
text_screen = my_font.render(text, True, txt_color)
self.screen.blit(text_screen, position)
def draw\_tree(self, energy_num, money_num):
"""画tree"""
Tree(Tree.tree, (0, 600)).draw(self.screen) # 画树
Tree(Tree.energy_num, Tree.energy_num_position).draw(self.screen) # 画精力
# print("energy", energy\_num)
if energy_num > 30:
self.load_text(str(30) + '/30', (22, 55), 21)
else:
self.load_text(str(energy_num)+'/30', (22, 55), 21)
# print("money", money\_num)
Tree(Tree.money, (15, 135)).draw(self.screen) # 画银币
self.load_text(str(money_num), (32, 124), 21)
for i in range(0, 10): # 画果子
Tree(Tree.fruit, Tree.position[i]).draw(self.screen)
self.load_text(str(i+1), (Tree.position[i][0]+15, Tree.position[i][1]-47))
if self.type == 1:
Tree(Tree.energy_buy, Tree.energy_buy_position).draw(self.screen)
if self.energy_full:
self.load_text("energy is full!", (430, 310), 30, (255, 0, 0))
pygame.display.flip()
pygame.time.delay(500)
self.energy_full = False
if self.money_empty:
self.load_text("money is not enough!", (410, 310), 30, (255, 0, 0))
pygame.display.flip()
pygame.time.delay(500)
self.money_empty = False
**2.4 制作鼠标点击效果**
def mouse\_select(self, button, level, energy_num, money_num):
"""鼠标点击"""
if button.type == MOUSEBUTTONDOWN:
mouse_down_x, mouse_down_y = button.pos
print(button.pos)
if level == 0:
if self.type == 0: # 树界面
for i in range(0, 10):
if Tree.position[i][0] < mouse_down_x < Tree.position[i][0] + self.fruit_width \
and Tree.position[i][1] - self.fruit_height < mouse_down_y < Tree.position[i][1]:
if energy_num <= 0:
self.type = 1
else:
level = i + 1
if Tree.energy_num_position[0] < mouse_down_x < Tree.energy_num_position[0]+60 \
and Tree.energy_num_position[1]-60 < mouse_down_y < Tree.energy_num_position[1]: # 精力60\*60
SoundPlay(SoundPlay.click)
self.type = 1
else: # 加精力弹窗界面
if 408 < mouse_down_x < 600 and 263 < mouse_down_y < 313: # 点加精力按钮
SoundPlay(SoundPlay.click_button)
if money_num < 50:
self.money_empty = True
if energy_num >= 30:
self.energy_full = True
elif energy_num < 30 and money_num >= 50:
energy_num += 5
money_num -= 50
elif 619 < mouse_down_x < 638 and 158 < mouse_down_y < 177: # 点叉号
self.type = 0
if button.type == MOUSEBUTTONUP:
pass
return level, energy_num, money_num
**2.5 制作出现元素**
class Element(pygame.sprite.Sprite):
“”" 元素类 “”"
# 图标元组,包括6个小动物,
animal = (‘pic2/fox.png’, ‘pic2/bear.png’, ‘pic2/chick.png’, ‘pic2/eagle.png’, ‘pic2/frog.png’, ‘pic2/cow.png’)
ice = ‘pic2/ice.png’ # 冰层
brick = ‘pic2/brick.png’ # 砖
frame = ‘pic2/frame.png’ # 选中框
bling = (“pic2/bling1.png”, “pic2/bling2.png”, “pic2/bling3.png”, “pic2/bling4.png”, “pic2/bling5.png”,
“pic2/bling6.png”, “pic2/bling7.png”, “pic2/bling8.png”, “pic2/bling9.png”) # 消除动画
ice_eli = ('pic2/ice0.png', 'pic2/ice1.png', 'pic2/ice2.png', 'pic2/ice3.png', 'pic2/ice4.png', 'pic2/ice5.png',\
'pic2/ice6.png', 'pic2/ice7.png', 'pic2/ice8.png') # 消除冰块动画
# 得分图片
score_level = ('pic2/good.png', 'pic2/great.png', 'pic2/amazing.png', 'pic2/excellent.png', 'pic2/unbelievable.png')
none_animal = 'pic2/noneanimal.png' # 无可消除小动物
stop = 'pic2/exit.png' # 暂停键
stop_position = (20, 530)
def \_\_init\_\_(self, icon, position):
super().__init__()
self.image = pygame.image.load(icon).convert_alpha()
self.rect = self.image.get_rect()
self.rect.topleft = position # 左上角坐标
self.speed = [0, 0]
self.init_position = position
def move(self, speed):
self.speed = speed
self.rect = self.rect.move(self.speed)
if self.speed[0] != 0: # 如果左右移动
if abs(self.rect.left-self.init_position[0]) == self.rect[2]:
self.init_position = self.rect.topleft
self.speed = [0, 0]
else:
if abs(self.rect.top-self.init_position[1]) == self.rect[3]:
self.init_position = self.rect.topleft
self.speed = [0, 0]
def draw(self, screen):
screen.blit(self.image, self.rect)
class Board(pygame.sprite.Sprite):
step_board = ‘pic2/step.png’ # 剩余步数板子
step = (‘pic2/0.png’, ‘pic2/1.png’, ‘pic2/2.png’, ‘pic2/3.png’, ‘pic2/4.png’, ‘pic2/5.png’,
‘pic2/6.png’, ‘pic2/7.png’, ‘pic2/8.png’, ‘pic2/9.png’, )
task_board = ‘pic2/task.png’ # 任务板子
ok = ‘pic2/ok.png’ # ok勾
# 关数板子
levelBoard = (‘pic2/level0.png’, ‘pic2/level1.png’, ‘pic2/level2.png’, ‘pic2/level3.png’, ‘pic2/level4.png’, ‘pic2/level5.png’,
‘pic2/level6.png’, ‘pic2/level7.png’, ‘pic2/level8.png’, ‘pic2/level9.png’, ‘pic2/level10.png’)
# xxx = ‘pic2/x.png’ # 叉掉
test = ‘pic2/test.png’
success_board = ‘pic2/successtest1.png’ # 过关成功板子
fail_board = ‘pic2/failBoard.png’ # 任务失败
step_add = ‘pic2/step_add.png’ # 增加步数
next = “pic2/next.png” # 下一关按钮
replay = “pic2/replay.png” # 重玩图片
stars = ‘pic2/startest.png’ # 星星图片
money = ‘pic2/money.png’ # 银币
energy = ‘pic2/energ.png’ # 精力
button_position = [[300, 465], [500, 465]]
starts_position = [[280+50, 340], [375+38, 340], [460+35, 340]]
def \_\_init\_\_(self, icon, position):
super().__init__()
self.image = pygame.image.load(icon).convert_alpha()
self.speed = [0, 45]
self.rect = self.image.get_rect()
self.rect.bottomleft = position # 左下角为坐标值
def move(self):
self.rect = self.rect.move(self.speed)
if self.rect.bottom >= 543:
self.speed = [0, -45]
if self.speed == [0, -45] and self.rect.bottom <= 450:
self.speed = [0, 0]
def draw(self, screen):
screen.blit(self.image, self.rect)
**2.6 数组**
class Manager:
“”" 数组类 “”"
__screen_size = (900, 600)
screen = pygame.display.set_mode(__screen_size, DOUBLEBUF, 32)
__brick_size = 50
__bg = pygame.image.load(‘pic2/bg.png’).convert()
stop_width = 63
selected = [-1, -1] # 现选中[row, col]
exchange_sign = -1 # 未交换标志
last_sel = [-1, -1] # 上一次选中[row, col]
change_value_sign = False # 是否交换值标志,初始不交换
death_sign = True # 死图标志,初始不是死图
boom_sel = [-1, -1] # 四连消特效小动物所在位置 row,col
level = 0 # 当前关卡数 初始第0关
money = 100 # 金币
energy_num = 30 # 精力值
num_sign = True
type = 2 # 0代表游戏中; 1代表完成任务,过关; -1代表步数用完,任务未完成,过关失败; 2代表未游戏状态,板子界面
reset_mode = True # 是否重新布局(每关布局)
init_step = 15 # 每关规定步数
step = init_step # 代表游戏所剩余的步数
score = 0 # 得数
min = 20 # 分数中间值1
max = 50 # 分数中间值2
animal_num = [0, 0, 0, 0, 0, 0] # 本关消除各小动物的个数
ice_num = 0
success_board = Board(Board.success_board, [200, 0]) # 过关成功板
fail_board = Board(Board.fail_board, [200, 0]) # 任务失败板
height, width = 9, 9
row, col = 5, 5
ice_list = [[-1 for col in range(21)]for row in range(21)] # -1不画,1画冰
animal = [[-1 for col in range(21)]for row in range(21)] # -2消除的,-1不画,0-4小动物
list_x, list_y = (__screen_size[0] - 11 * __brick_size) / 2, (__screen_size[1] - 11 * __brick_size) / 2 # 矩阵坐标
def \_\_init\_\_(self, width, height):
self.height = height
self.width = width
self.list_x = (Manager.__screen_size[0] - self.width \* Manager.__brick_size) / 2
self.list_y = (Manager.__screen_size[1] - self.height \* Manager.__brick_size) / 2
self.row, self.col = Manager.xy_rc(self.list_x, self.list_y)
self.list_x, self.list_y = Manager.rc_xy(self.row, self.col)
self.ice_list = [[-1 for col in range(21)]for row in range(21)]
self.animal = [[-1 for col in range(21)]for row in range(21)]
self.reset_animal()
def reset\_animal(self):
for row in range(self.row, self.row + self.height):
for col in range(self.col, self.col + self.width):
self.animal[row][col] = random.randint(0, 5)
@staticmethod
def rc\_xy(row, col):
"""row col 转 x,y坐标"""
return int(Manager.list_x + (col-Manager.col)\*Manager.__brick_size), int\
(Manager.list_y+(row-Manager.row)\*Manager.__brick_size)
@staticmethod
def xy\_rc(x, y):
"""x,y坐标转row col"""
return int((y-Manager.list_y)/Manager.__brick_size+Manager.row), int\
((x-Manager.list_x)/Manager.__brick_size+Manager.col)
@staticmethod
def draw\_brick(x, y):
brick = Element(Element.brick, (x, y))
Manager.screen.blit(brick.image, brick.rect)
def draw\_task(self, task_animal_num, which_animal, \
board_position=(400, 90), animal_position=(430, 35), txt_position=(455, 60)):
**2.7 制作人物画板**
"""画任务板子"""
txt_size = 24
txt_color = (0, 0, 0)
Board(Board.task_board, board_position).draw(self.screen)
if which_animal == 6:
task_animal = Element(Element.ice, animal_position)
else:
task_animal = Element(Element.animal[which_animal], animal_position)
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!