【Python游戏】Python各大游戏合集:超级玛丽、天天酷跑、我的世界、魔塔、雷霆战机 | 附带源码

article/2025/10/6 11:54:04

相关文件

关注小编,私信小编领取哟!
当然别忘了一件三连哟~~

公众号:Python日志
可以关注小编公众号,会不定时的发布一下Python小技巧,还有很多资源可以免费领取哟!!
源码领取:加Python学习交流群:773162165 可以领取哟

开发工具

Python版本:3.7.8
相关模块:
pytorch模块;
pyqt5模块;
numpy模块;
pyttsx3模块;
以及一些python自带的模块。

环境搭建

安装Python并添加到环境变量,pip安装需要的相关模块即可。

一:超级玛丽

效果展示
在这里插入图片描述
在这里插入图片描述
部分源码

class Box(pg.sprite.Sprite):def __init__(self, x, y, type, group=None, name=c.MAP_BOX):pg.sprite.Sprite.__init__(self)self.frames = []self.frame_index = 0self.load_frames()self.image = self.frames[self.frame_index]self.rect = self.image.get_rect()self.rect.x = xself.rect.y = yself.rest_height = yself.animation_timer = 0self.first_half = True   # First half of animation cycleself.state = c.RESTINGself.y_vel = 0self.gravity = 1.2self.type = typeself.group = groupself.name = namedef load_frames(self):sheet = setup.GFX['tile_set']frame_rect_list = [(384, 0, 16, 16), (400, 0, 16, 16), (416, 0, 16, 16), (400, 0, 16, 16), (432, 0, 16, 16)]for frame_rect in frame_rect_list:self.frames.append(tools.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))def update(self, game_info):self.current_time = game_info[c.CURRENT_TIME]if self.state == c.RESTING:self.resting()elif self.state == c.BUMPED:self.bumped()def resting(self):time_list = [375, 125, 125, 125]if (self.current_time - self.animation_timer) > time_list[self.frame_index]:self.frame_index += 1if self.frame_index == 4:self.frame_index = 0self.animation_timer = self.current_timeself.image = self.frames[self.frame_index]def bumped(self):self.rect.y += self.y_velself.y_vel += self.gravityif self.rect.y > self.rest_height + 5:self.rect.y = self.rest_heightself.state = c.OPENEDif self.type == c.TYPE_MUSHROOM:self.group.add(powerup.Mushroom(self.rect.centerx, self.rect.y))elif self.type == c.TYPE_FIREFLOWER:self.group.add(powerup.FireFlower(self.rect.centerx, self.rect.y))elif self.type == c.TYPE_LIFEMUSHROOM:self.group.add(powerup.LifeMushroom(self.rect.centerx, self.rect.y))self.frame_index = 4self.image = self.frames[self.frame_index]def start_bump(self, score_group):self.y_vel = -6self.state = c.BUMPEDif self.type == c.TYPE_COIN:self.group.add(coin.Coin(self.rect.centerx, self.rect.y, score_group))
class Coin(pg.sprite.Sprite):def __init__(self, x, y, score_group):pg.sprite.Sprite.__init__(self)self.frames = []self.frame_index = 0self.load_frames()self.image = self.frames[self.frame_index]self.rect = self.image.get_rect()self.rect.centerx = xself.rect.bottom = y - 5self.gravity = 1self.y_vel = -15self.animation_timer = 0self.initial_height = self.rect.bottom - 5self.score_group = score_groupdef load_frames(self):sheet = setup.GFX[c.ITEM_SHEET]frame_rect_list = [(52, 113, 8, 14), (4, 113, 8, 14), (20, 113, 8, 14), (36, 113, 8, 14)]for frame_rect in frame_rect_list:self.frames.append(tools.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))def update(self, game_info):self.current_time = game_info[c.CURRENT_TIME]self.spinning()def spinning(self):self.image = self.frames[self.frame_index]self.rect.y += self.y_velself.y_vel += self.gravityif (self.current_time - self.animation_timer) > 80:if self.frame_index < 3:self.frame_index += 1else:self.frame_index = 0self.animation_timer = self.current_timeif self.rect.bottom > self.initial_height:self.kill()class FlashCoin(pg.sprite.Sprite):def __init__(self, x, y):pg.sprite.Sprite.__init__(self)self.frame_index = 0self.frames = []self.load_frames()self.image = self.frames[self.frame_index]self.rect = self.image.get_rect()self.rect.x = xself.rect.y = yself.animation_timer = 0def load_frames(self):sheet = setup.GFX[c.ITEM_SHEET]frame_rect_list = [(1, 160, 5, 8), (9, 160, 5, 8),(17, 160, 5, 8), (9, 160, 5, 8)]for frame_rect in frame_rect_list:self.frames.append(tools.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))def update(self, current_time):time_list = [375, 125, 125, 125]if self.animation_timer == 0:self.animation_timer = current_timeelif (current_time - self.animation_timer) > time_list[self.frame_index]:self.frame_index += 1if self.frame_index == 4:self.frame_index = 0self.animation_timer = current_timeself.image = self.frames[self.frame_index]class StaticCoin(pg.sprite.Sprite):def __init__(self, x, y):pg.sprite.Sprite.__init__(self)self.frame_index = 0self.frames = []self.load_frames()self.image = self.frames[self.frame_index]self.rect = self.image.get_rect()self.rect.x = xself.rect.y = yself.animation_timer = 0def load_frames(self):sheet = setup.GFX[c.ITEM_SHEET]frame_rect_list = [(3, 98, 9, 13), (19, 98, 9, 13),(35, 98, 9, 13), (51, 98, 9, 13)]for frame_rect in frame_rect_list:self.frames.append(tools.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))def update(self, game_info):self.current_time = game_info[c.CURRENT_TIME]time_list = [375, 125, 125, 125]if self.animation_timer == 0:self.animation_timer = self.current_timeelif (self.current_time - self.animation_timer) > time_list[self.frame_index]:self.frame_index += 1if self.frame_index == 4:self.frame_index = 0self.animation_timer = self.current_timeself.image = self.frames[self.frame_index]

二:天天酷跑

效果展示
在这里插入图片描述
在这里插入图片描述
部分源码

class Role: #人物def __init__(self,surface=None,y=None):self.surface=surfaceself.y=yself.w=(surface.get_width())/12self.h=surface.get_height()/2self.currentFrame=-1self.state=0        #0代表跑步状态,1代表跳跃状态,2代表连续跳跃self.g=1            #重力加速度self.vy=0           #y轴速度       self.vy_start=-20   #起跳开始速度def getRect(self):return (0,self.y+12,self.w,self.h)class Object:  #障碍物def __init__(self,surface,x=0,y=0):self.surface=surfaceself.x=xself.y=yself.w=surface.get_width()self.h=surface.get_height()self.currentFrame=random.randint(0,6)self.w = 100self.h = 100def getRect(self):return (self.x,self.y,self.w,self.h)def collision(self,rect1,rect2):#碰撞检测if (rect2[0]>=rect1[2]-20) or (rect1[0]+40>=rect2[2])or (rect1[1]+rect1[3]<rect2[1]+20) or (rect2[1]+rect2[3]<rect1[1]+20):return Falsereturn Trueclass Bg:   #背景def __init__(self,surface):self.surface=surfaceself.dx=-10self.w=surface.get_width()self.rect=surface.get_rect()def initGame():global bg,role,clock,gameState,surObject,surGameOver,score,myFont,myFont1,objectList#分数初始化score=0#初始化objectList=[]#加载字体myFont=pygame.font.Font("./freesansbold.ttf",32)myFont1=pygame.font.Font("./freesansbold.ttf",64)   # 创建时钟对象 (可以控制游戏循环频率)clock = pygame.time.Clock()#初始化游戏状态gameState=0#游戏背景surBg=pygame.image.load("image/bg.bmp").convert_alpha()bg=Bg(surBg)#结束画面surGameOver=pygame.image.load("image/gameover.bmp").convert_alpha()#人物图片surRole=pygame.image.load("image/role.png").convert_alpha()  role=Role(surRole,508-85)#障碍物图片surObject=pygame.image.load("image/object.png").convert_alpha()  def addObject():global surObject,object,objectList,objectrate=4#是否生成障碍物if not random.randint(0,300)<rate:returny=random.choice([height-100,height-200,height-300,height-400])object=Object(surObject,width+40,y)objectList.append(object)def updateLogic():global gameState,score#键盘事件处理for event in pygame.event.get():if event.type == pygame.QUIT:sys.exit()elif event.type==pygame.KEYDOWN:#空格键跳跃if gameState==0:if event.key==pygame.K_SPACE:if role.state==0:role.state=1role.vy=role.vy_startelif role.state==1:role.state=2role.vy=role.vy_startelif gameState==1:if event.key==pygame.K_SPACE:#重新开始游戏initGame()if gameState==0:#背景的移动   bg.dx+=10if bg.dx==1200:bg.dx=0 #人物的移动  if role.state==0:    role.currentFrame+=1if role.currentFrame==12:role.currentFrame=0  else:role.y+=role.vyrole.vy+=role.g if role.y>=508-85:role.y=508-85role.state=0#障碍物的移动addObject()for object in objectList:object.x-=10     #障碍物移动# 障碍物超出屏幕,移除障碍物if object.x+object.w<=0:objectList.remove(object)score+=10    #避开障碍物,加10分print("移除了一个目标")   #碰撞检测if object.collision(role.getRect(),object.getRect()):if(object.currentFrame==6):objectList.remove(object)score+=100  #吃金币加100分print(score)print("吃了一个金币")else: gameState=1   #游戏失败print("发生了碰撞!")

三:我的世界

效果展示
在这里插入图片描述
部分代码展示

class Model(object):def __init__(self):# A Batch is a collection of vertex lists for batched rendering.self.batch = pyglet.graphics.Batch()# A TextureGroup manages an OpenGL texture.self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())# A mapping from position to the texture of the block at that position.# This defines all the blocks that are currently in the world.self.world = {}# Same mapping as `world` but only contains blocks that are shown.self.shown = {}# Mapping from position to a pyglet `VertextList` for all shown blocks.self._shown = {}# Mapping from sector to a list of positions inside that sector.self.sectors = {}# Simple function queue implementation. The queue is populated with# _show_block() and _hide_block() callsself.queue = deque()self._initialize()def _initialize(self):""" Initialize the world by placing all the blocks."""n = 80  # 1/2 width and height of worlds = 1  # step sizey = 0  # initial y heightfor x in xrange(-n, n + 1, s):for z in xrange(-n, n + 1, s):# create a layer stone an grass everywhere.self.add_block((x, y - 2, z), GRASS, immediate=False)self.add_block((x, y - 3, z), STONE, immediate=False)if x in (-n, n) or z in (-n, n):# create outer walls.for dy in xrange(-2, 3):self.add_block((x, y + dy, z), STONE, immediate=False)# generate the hills randomlyo = n - 10for _ in xrange(120):a = random.randint(-o, o)  # x position of the hillb = random.randint(-o, o)  # z position of the hillc = -1  # base of the hillh = random.randint(1, 6)  # height of the hills = random.randint(4, 8)  # 2 * s is the side length of the hilld = 1  # how quickly to taper off the hillst = random.choice([GRASS, SAND, BRICK])for y in xrange(c, c + h):for x in xrange(a - s, a + s + 1):for z in xrange(b - s, b + s + 1):if (x - a) ** 2 + (z - b) ** 2 > (s + 1) ** 2:continueif (x - 0) ** 2 + (z - 0) ** 2 < 5 ** 2:continueself.add_block((x, y, z), t, immediate=False)s -= d  # decrement side length so hills taper offdef hit_test(self, position, vector, max_distance=8):""" Line of sight search from current position. If a block isintersected it is returned, along with the block previously in the lineof sight. If no block is found, return None, None.Parameters----------position : tuple of len 3The (x, y, z) position to check visibility from.vector : tuple of len 3The line of sight vector.max_distance : intHow many blocks away to search for a hit."""m = 8x, y, z = positiondx, dy, dz = vectorprevious = Nonefor _ in xrange(max_distance * m):key = normalize((x, y, z))if key != previous and key in self.world:return key, previousprevious = keyx, y, z = x + dx / m, y + dy / m, z + dz / mreturn None, Nonedef exposed(self, position):""" Returns False is given `position` is surrounded on all 6 sides byblocks, True otherwise."""x, y, z = positionfor dx, dy, dz in FACES:if (x + dx, y + dy, z + dz) not in self.world:return Truereturn Falsedef add_block(self, position, texture, immediate=True):""" Add a block with the given `texture` and `position` to the world.Parameters----------position : tuple of len 3The (x, y, z) position of the block to add.texture : list of len 3The coordinates of the texture squares. Use `tex_coords()` togenerate.immediate : boolWhether or not to draw the block immediately."""if position in self.world:self.remove_block(position, immediate)self.world[position] = textureself.sectors.setdefault(sectorize(position), []).append(position)if immediate:if self.exposed(position):self.show_block(position)self.check_neighbors(position)def remove_block(self, position, immediate=True):""" Remove the block at the given `position`.Parameters----------position : tuple of len 3The (x, y, z) position of the block to remove.immediate : boolWhether or not to immediately remove block from canvas."""del self.world[position]self.sectors[sectorize(position)].remove(position)if immediate:if position in self.shown:self.hide_block(position)self.check_neighbors(position)

四:魔塔游戏

效果展示
在这里插入图片描述
在这里插入图片描述
部分代码展示

ef init_actions():# QUIT:def quit(e):global runningrunning = Falsereturn True# 注册事件action_control.register_action('QUIT', pygame.QUIT, quit)action_control.register_action('BOOK', pygame.KEYUP, global_var.get_value('BOOK').action)action_control.register_action('STARTMENU', pygame.KEYUP, global_var.get_value('STARTMENU').action)action_control.register_action('BACKPACK', pygame.KEYUP, global_var.get_value('BACKPACK').action)action_control.register_action('SAVE', pygame.KEYUP, global_var.get_value('SAVE').action)action_control.register_action('LOAD', pygame.KEYUP, global_var.get_value('LOAD').action)action_control.register_action('FLY', pygame.KEYUP, global_var.get_value('FLY').action)action_control.register_action('HELP', pygame.KEYUP, global_var.get_value('HELP').action)action_control.register_action('Shop1', pygame.KEYUP, global_var.get_value('Shop1').action)action_control.register_action('Shop2', pygame.KEYUP, global_var.get_value('Shop2').action)action_control.register_action('TEXTBOX', pygame.KEYUP, global_var.get_value('TEXTBOX').action)action_control.register_action('CHOICEBOX', pygame.KEYUP, global_var.get_value('CHOICEBOX').action)action_control.register_action('SHOWDAMAGE', pygame.KEYUP, global_var.get_value('SHOWDAMAGE').action)action_control.register_action('STATUSBAR', pygame.KEYUP, global_var.get_value('STATUSBAR').action)action_control.register_action('CURTAIN', pygame.KEYUP, global_var.get_value('CURTAIN').action)WriteLog.info(__name__, "事件全部注册完成")def init_sound():Music = music.MusicWrapper()global_var.set_value("Music", Music)WriteLog.info(__name__, "初始化音效完成")def init_event_flow():EVENTFLOW = EventFlow()global_var.set_value("EVENTFLOW", EVENTFLOW)EVENT = Event()global_var.set_value("EVENT", EVENT)EVENT.get_event_flow_module()EVENTFLOW.get_event_module()WriteLog.info(__name__, "初始化事件流完成")def init_function():FUNCTION = global_var.get_value("FUNCTION")FUNCTION.init_var()WriteLog.info(__name__, "初始化function完成")# DEBUG(开关在sysconf.py,如果开启将会启动控制台)
if DEBUG:import threadingdef console():while running:r = input()try:print(eval(r))except:try:exec(r)except Exception as e:print("error:", str(e))t = threading.Thread(target=console)t.start()init()
init_actions()
init_sound()
init_event_flow()
init_function()
clock = pygame.time.Clock()STARTMENU = global_var.get_value("STARTMENU")# 主程序
while running:# a = pygame.time.get_ticks()# 展示开始菜单if STARTMENU.new_game == True:STARTMENU.open()STARTMENU.new_game = False# 默认开启显伤show_damage = global_var.get_value("SHOWDAMAGE")show_damage.open()# 默认开启状态栏status_bar = global_var.get_value("STATUSBAR")status_bar.open()# 地图确保为active状态CurrentMap.active = True# 载入初始事件EVENTFLOW = global_var.get_value("EVENTFLOW")with open(os.path.join(os.getcwd(),"project", "start_text.json")) as f:start_text = json.load(f)EVENTFLOW.insert_action(start_text["startText"])pygame.display.update()# 背景RootScreen.flush(screen)  # 显示刷新到屏幕action_control.action_render()  # 检查动作消息# b = pygame.time.get_ticks()# print(b - a)

五:雷霆战机

效果展示
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
部分代码展示

class Menu(object):"""每个页面的父类"""def __init__(self, image, music):#设置背景音乐pygame.mixer.music.load(music)pygame.mixer.music.set_volume(0.4)pygame.mixer.music.play(-1)#设置屏幕大小self.screen = pygame.display.set_mode(SCREEN_RECT.size)#设置标题pygame.display.set_caption("雷霆战机 公众号:Python日志  学习交流群:685237705")#加载传入的图片并获取位置大小self.image = pygame.image.load(image)self.rect = self.image.get_rect()def event(self):#遍历所有事件for event in pygame.event.get():#点击游戏右上角的×关闭游戏if event.type == pygame.QUIT:pygame.quit()exit()#按下Esc键关闭游戏if event.type == pygame.KEYDOWN:if event.key == pygame.K_ESCAPE:pygame.quit()exit()#获取鼠标是否点击和位置self.mouse_press = pygame.mouse.get_pressed()self.mouse_pos = pygame.mouse.get_pos()@staticmethoddef clicks():#点击按钮时播放声音pygame.mixer.music.load("./music/mouse.mp3")#设置声音大小pygame.mixer.music.set_volume(0.5)#0为不循环播放,start为从音频的什么时候开始。pygame.mixer.music.play(loops=0, start=0.5)#500毫秒的时间慢慢退出pygame.mixer.music.fadeout(500)class MainMenu(Menu):"""游戏主菜单"""def __init__(self):#加载背景音乐和图片music = "./music/menu1.mp3"image = "./images/background2.png"super().__init__(image, music)def update_menu(self):while True:#调用父类的事件方法super().event()#加载按钮并获取位置start = pygame.image.load("./images/start1.png")start_rect = start.get_rect()rule = pygame.image.load("./images/rule1.png")rule_rect = rule.get_rect()# 开始键和查看键位置定位start_rect.centerx = SCREEN_RECT.centerxstart_rect.y = SCREEN_RECT.height * 0.3rule_rect.centerx = SCREEN_RECT.centerxrule_rect.y = SCREEN_RECT.height * 0.45#判断鼠标的横纵坐标是否在按钮图片范围内if (start_rect.left < self.mouse_pos[0] < start_rect.right) and (start_rect.top < self.mouse_pos[1] < start_rect.bottom):#在图片范围内则更换图片start = pygame.image.load("./images/start2.png")#按下鼠标左键,触发父类的私有方法发出鼠标声,并跳转页面if self.mouse_press[0]:Menu.clicks()GameType().update_menu()if (rule_rect.left < self.mouse_pos[0] < rule_rect.right) and (rule_rect.top < self.mouse_pos[1] < rule_rect.bottom):rule = pygame.image.load("./images/rule2.png")if self.mouse_press[0]:Menu.clicks()RuleMenu().update_menu()#更新背景、开始按钮、规则按钮self.screen.blit(self.image, self.rect)self.screen.blit(start, start_rect)self.screen.blit(rule, rule_rect)pygame.display.update()class GameType(Menu):"""游戏模式选择"""def __init__(self):music = "./music/type1.mp3"image = "./images/background4.png"super().__init__(image, music)def update_menu(self):while True:super().event()type1 = pygame.image.load("./images/first1.png")type1_rect = type1.get_rect()type2 = pygame.image.load("./images/second1.png")type2_rect = type2.get_rect()type3 = pygame.image.load("./images/third1.png")type3_rect = type3.get_rect()return_picture = pygame.image.load("./images/return5.png")return_rect = return_picture.get_rect()type1_rect.centerx = SCREEN_RECT.centerxtype1_rect.y = SCREEN_RECT.height * 0.15type2_rect.centerx = type1_rect.centerxtype2_rect.y = SCREEN_RECT.height * 0.3type3_rect.centerx = SCREEN_RECT.centerxtype3_rect.y = SCREEN_RECT.height * 0.45return_rect.x = 10return_rect.y = 10#调用自己的静态私有方法获取记录record1 = self.__record(str(1))record2 = self.__record(str(2))# 开始模式一if (type1_rect.left < self.mouse_pos[0] < type1_rect.right) and (type1_rect.top < self.mouse_pos[1] < type1_rect.bottom):type1 = pygame.image.load("./images/first2.png")if self.mouse_press[0]:Menu.clicks()plane_main_1.Game().start_game()#开始模式二if (type2_rect.left < self.mouse_pos[0] < type2_rect.right) and (type2_rect.top < self.mouse_pos[1] < type2_rect.bottom):type2 = pygame.image.load("./images/second2.png")if self.mouse_press[0]:Menu.clicks()#用获取的记录判断能否开启游戏关卡if 0 <= int(record1) <= 3:plane_main_2.Game().start_game()else:#不可以则调用禁止类的,显示禁止页面ProhibitMenu().update_menu()#开始模式三if (type3_rect.left < self.mouse_pos[0] < type3_rect.right) and (type3_rect.top < self.mouse_pos[1] < type3_rect.bottom):type3 = pygame.image.load("./images/third2.png")if self.mouse_press[0]:Menu.clicks()if 0 <= int(record2) <= 3:plane_main_3.Game().start_game()else:ProhibitMenu().update_menu()if return_rect.left < self.mouse_pos[0] < return_rect.right and (return_rect.top < self.mouse_pos[1] < return_rect.bottom):return_picture = pygame.image.load("./images/return6.png")if self.mouse_press[0]:Menu.clicks()MainMenu().update_menu()self.screen.blit(self.image, self.rect)self.screen.blit(type1, type1_rect)self.screen.blit(type2, type2_rect)self.screen.blit(type3, type3_rect)self.screen.blit(return_picture, return_rect)pygame.display.update()

http://chatgpt.dhexx.cn/article/WFk4DeMm.shtml

相关文章

13个Python小游戏(含源码),开始敲起来,玩吧!

来源丨网络 经常听到有朋友说&#xff0c;学习编程是一件非常枯燥无味的事情。其实&#xff0c;大家有没有认真想过&#xff0c;可能是我们的学习方法不对&#xff1f; 比方说&#xff0c;你有没有想过&#xff0c;可以通过打游戏来学编程&#xff1f; 今天我想跟大家分享几个P…

30个Python小游戏,上班摸鱼我能玩一天【内附源码】

大家好&#xff0c;我是辣条。 今天给大家带来30个py小游戏&#xff0c;一定要收藏&#xff01; 目录 有手就行 1、吃金币 2、打乒乓 3、滑雪 4、并夕夕版飞机大战 5、打地鼠 简简单单 6、小恐龙 7、消消乐 8、俄罗斯方块 9、贪吃蛇 普普通通 10、24点小游戏 1…

iosetup mysql_InnoDB: Error: io_setup() failed with EAGAIN after 5 attempts

在一台服务器中以各数据库的备份文件为数据文件启动多个MySQL实例供SQL Review使用。 之前运行一直没有问题(最多的时候有23个MySQL实例同时运行)&#xff0c;后来新配置了一台服务器&#xff0c;启动其对应的实例时失败。 部分错误日志如下&#xff1a; …… 140505 16:05:59 …

linux系统中socket错误码:EINTR和EAGAIN的处理

目录 人为重启被中断的系统调用 安装信号时设置 SA_RESTART属性 忽略信号 永远阻塞的系统调用&#xff0c;被信号中断&#xff0c;导致其不继续等待&#xff0c;转而去执行signal_handler 1、什么是慢系统调用&#xff1f; 该术语适用于那些可能永远阻塞的系统调用。永远阻…

iosetup mysql_InnoDB: Error: io_setup() failed with EAGAIN

最近安装好了MySQL之后&#xff0c;在启动MySQL服务时无法正常启动MySQL。提示没有更新/var/lib/mfailedZDB.pid并退出。该MySQL与Oracle位于同一主机。有些内核参数进行过调整应该也是使用与MySQL。下面是该问题的具体描述。 1、故障现象SZDB:/usr/src/mysql_src # /etc/init.…

blocking socket 读写返回 EAGAIN

非阻塞的 socket 读写操作返回 EAGAIN&#xff0c;表示当前已经读完内核缓冲区或者写满内核缓冲区&#xff0c;需要等待下一次 select/poll/epoll 事件到来时再操作。 对于阻塞的 socket 读写操作&#xff0c;如果内核缓冲区是空&#xff0c;read 将一直阻塞&#xff1b;如果不…

【Linux Socket C++】为什么IO复用需要用到非阻塞IO?EAGAIN的简单介绍与应用

目录 为什么IO复用需要非阻塞的IO EAGAIN的介绍 EAGAIN的应用 为什么IO复用需要非阻塞的IO 我们可以先看一下官方的回答&#xff1a; 在Linux命令行输入&#xff1a;man 2 select 找到[BUGS]&#xff0c;如下&#xff1a; 官方给予的回答是这样的&#xff1a; Under Lin…

avcodec_receive_frame始终返回EAGAIN

今天我们研究一个问题&#xff1a; avcodec_receive_frame()始终返回EAGAIN 根本的解决方案还需要深入debug&#xff0c;但是这个函数很太复杂&#xff0c;需要些时间和耐心&#xff1b; 目前在不考虑编解码性能的情况下&#xff0c;能work around的方法只有一个&#xff0c;那…

APK加固(梆梆助手)

前言&#xff1a;朋友在使用梆梆时出现Apk加固后安装失败的现象&#xff0c;所以自己写篇小白文 1.进入梆梆官网&#xff08;注册&#xff09; 2.下载梆梆助手&#xff08;点击加固工具&#xff09; 本人电脑是Windows系统&#xff08;下载&#xff09; 3.安装后&#xff0c…

使用360进行apk加固并进行2次签名整体流程

因新版360加固助手需要付费才能进行自动签名&#xff0c;故只能自己手动来签名了~ 1.使用Android studio进行首次签名并打包apk 首先选择build下该选项 选择apk 如果没有key&#xff0c;则点击新建 需要输入key存储的位置&#xff0c;key store密码&#xff0c;key别名&#…

Android-APK加固-简单版

Android-APK加固-简单版 Proguard的使用与配置介绍开启proguard常用配置 加固大体思路 源码&#xff08;浅析&#xff09;思路 撸码解密工具类-AES&#xff08;解密时用&#xff09;工具类-Zip&#xff08;压缩、解压&#xff09;工具类-Utils&#xff08;反射操作&#xff09;…

Android Apk加固后手动签名

手动签名 &#xff1a; 不用任何第三方可视化工具签名 &#xff0c;使用命令做签名。手动签名原因&#xff1a;以前加固签名都是使用第三方工具操作&#xff0c;最近发现工具都开始收费了&#xff0c;免费的羊毛没得薅了&#xff0c;收费价格极高 5000/年/App, &#xff08;加固…

手写apk加固

手写apk加固 加壳解压原apk并加密重命名dex文件对壳文件操作打包压缩成apk文件签名 脱壳运行解压原apk, 解密原dex文件加载原dex文件 demo下载 apk加固的目的其实就是对app的核心代码做防护工作&#xff0c;避免被其他人反编译&#xff1b; 废话不多说了&#xff0c;直接开始! …

android apk 加固后重新签名

针对于加固平台在加固的过程中不能配置签名文件&#xff0c;加固后的apk需要进行重新签名才能安装&#xff0c;并发布到应用市场。 第一步&#xff0c;用AS对项目进行打包&#xff0c;生成签名的apk文件。 第二步&#xff0c;使用加固平台&#xff0c;对apk包进行加固&#xff…

Android Apk加固原理解析

前言 为什么要加固 对APP进行加固&#xff0c;可以有效防止移动应用被破解、盗版、二次打包、注入、反编译等&#xff0c;保障程序的安全性、稳定性。 常见的加固方案有很多&#xff0c;本文主要介绍如果通过对dex文件进行加密来达到apk加固的目的&#xff1b; APK加固整体…

apk加固后再签名

目录 前言v1签名v1v2签名 前言 apk更新之前需要做安全检测&#xff0c;检测之前一版会做加固处理&#xff0c;加固后还需要重新进行签名。本文介绍一下v1签名和v1v2签名两种方式。 有文章说需要把apk原来的签名文件&#xff0c;即META-INF文件夹删除&#xff0c;实测不删好像也…

Android apk 加固混淆的作用之解决apk报毒

现在市面上对apk的安全合规管控越来越严格了&#xff0c;也就要求了apk在上架之前一定要做合规检测和加固处理。对apk就是加固的好处&#xff0c;可以提高apk的安全性&#xff0c;提高apk被逆向分析破解的门槛&#xff0c;同时通过加固保护可以提高过安全合规的检测。由于APP加…

简书 android 加固,Android apk加固(加壳)整理

一、Dex加壳由来 最近在学习apk加密&#xff0c;在网上看了一篇《Android中的Apk的加固(加壳)原理解析和实现》&#xff0c;我发现原文把整个apk都写入到dex文件中&#xff0c;如果apk小还好&#xff0c;当原APK大于200M&#xff0c;客户端解壳很费劲&#xff0c;打开后应用就卡…

019 Android加固之APK加固的原理和实现

文章目录 前言加载Activity遇到的问题APK的启动过程替换ClassLoader流程获取ActivityThread类对象获取AppBindData类对象mBoundApplication获取LoadedApk类对象info获取info对象中的ClassLoader 设计傀儡dex文件手工加固APK代码实现APK加固实现步骤 总结 前言 动态加载dex之后…

【Android 安全】Android 应用 APK 加固总结 ( 加固原理 | 应用加固完整的实现方案 | 源码资源 )

文章目录 一、 APK 加固原理1、 Android 应用反编译2、 ProGuard 混淆3、 多 dex 加载原理4、 代理 Application 开发5、Java 工具开发6、Application 替换 二、 应用加固完整的实现方案1、 代理 Application( 1 ) ProxyApplication( 2 ) OpenSSL 解码 Kotlin 类( 3 ) 反射工具…