植物大战僵尸中文版修改器python实现

#阳光edx+5560
import win32gui
import win32process
import win32api,ctypes
import tkinter as tk
main=tk.Tk()
main.title("植物大战僵尸修改器            ------豆腐西蓝花")
main.geometry('800x400')
def sun_func():
    window_handle = win32gui.FindWindow(None, "植物大战僵尸中文版")
    process_id = win32process.GetWindowThreadProcessId(window_handle)[1]
    process_handle = win32api.OpenProcess(0x1f0fff, False, process_id)
    kernel32 = ctypes.windll.LoadLibrary(r"C:\Windows\System32\kernel32.dll")
    date1 = ctypes.c_long()
    kernel32.ReadProcessMemory(int(process_handle), 0x006A9EC0, ctypes.byref(date1), 4, None)  
    date2 = ctypes.c_long()
    kernel32.ReadProcessMemory(int(process_handle), date1.value + 0x768, ctypes.byref(date2), 4, None)
    date3 = ctypes.c_long()
    kernel32.ReadProcessMemory(int(process_handle), date2.value + 0x5560, ctypes.byref(date3), 4, None)
    sun = 5000
    kernel32.WriteProcessMemory(int(process_handle), date2.value + 0x5560, ctypes.byref(ctypes.c_long(int(sun))), 4,
                                None)
    kernel32.CloseHandle(int(process_handle))
def cold():
    window_handle = win32gui.FindWindow(None, "植物大战僵尸中文版")
    process_id = win32process.GetWindowThreadProcessId(window_handle)[1]
    process_handle = win32api.OpenProcess(0x1f0fff, False, process_id)
    kernel32 = ctypes.windll.LoadLibrary(r"C:\Windows\System32\kernel32.dll")
    date1 = ctypes.c_long()
    kernel32.ReadProcessMemory(int(process_handle), 0x0048728c+3, ctypes.byref(date1), 1, None)  
    kernel32.WriteProcessMemory(int(process_handle), 0x0048728c+3, ctypes.byref(ctypes.c_int8(0xf)), 1,None)
    kernel32.CloseHandle(int(process_handle))

sun_button=tk.Button(main,text='修改阳光',width=15,height=2,command=sun_func,bg="#ddffff")
cold_button=tk.Button(main,text='修改冷却',width=15,height=2,command=cold,bg="#ddffff")

cold_button.pack()
sun_button.pack()
main.mainloop()
if __name__ == '__main__':
    pass


新手小白,结合网上的教程,简单写了一个python版的植物大战僵尸修改,冷却的问题因为机器码长度限制,改成了f倍,就是15倍,试用了一下,还不错。dll文件应该位置都是一样的吧,应该能直接用,比较捡漏

ps:仅用于学习交流,如有侵权,请联系作者删除

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现植物大战僵尸游戏需要一定的游戏开发经验和技术,需要使用一些游戏引擎和库。在Python中可以使用Pygame等游戏引擎来实现这个游戏。 以下是一个简单的实现植物大战僵尸游戏的示例代码: ```python import pygame import random # 初始化pygame pygame.init() # 游戏窗口大小 window_width = 800 window_height = 600 # 设置窗口标题 pygame.display.set_caption("植物大战僵尸") # 加载背景音乐 pygame.mixer.music.load("background_music.mp3") pygame.mixer.music.set_volume(0.5) pygame.mixer.music.play(-1) # 加载音效 sun_sound = pygame.mixer.Sound("sun_sound.wav") zombie_sound = pygame.mixer.Sound("zombie_sound.wav") plant_sound = pygame.mixer.Sound("plant_sound.wav") # 加载图片 background_image = pygame.image.load("background_image.jpg") sunflower_image = pygame.image.load("sunflower_image.png") peashooter_image = pygame.image.load("peashooter_image.png") sun_image = pygame.image.load("sun_image.png") zombie_image = pygame.image.load("zombie_image.png") pea_image = pygame.image.load("pea_image.png") # 设置字体 font = pygame.font.Font(None, 36) # 定义植物类 class Plant(pygame.sprite.Sprite): def __init__(self, x, y, image): super().__init__() self.image = image self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.health = 100 def update(self): pass # 定义太阳花类 class Sunflower(Plant): def __init__(self, x, y): super().__init__(x, y, sunflower_image) self.sun_timer = pygame.time.get_ticks() def update(self): current_time = pygame.time.get_ticks() if current_time - self.sun_timer >= 10000: self.sun_timer = current_time sun = Sun(random.randint(self.rect.x, self.rect.x + self.rect.width), self.rect.y + self.rect.height) all_sprites.add(sun) suns.add(sun) # 定义豌豆射手类 class Peashooter(Plant): def __init__(self, x, y): super().__init__(x, y, peashooter_image) self.shoot_timer = pygame.time.get_ticks() def update(self): current_time = pygame.time.get_ticks() if current_time - self.shoot_timer >= 1000: self.shoot_timer = current_time pea = Pea(self.rect.x + self.rect.width, self.rect.y + self.rect.height // 2) all_sprites.add(pea) peas.add(pea) # 定义阳光类 class Sun(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = sun_image self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y def update(self): self.rect.y += 2 if self.rect.y >= window_height: self.kill() # 定义豌豆类 class Pea(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = pea_image self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y def update(self): self.rect.x += 5 for zombie in zombies: if pygame.sprite.collide_rect(self, zombie): zombie.health -= 10 self.kill() if zombie.health <= 0: zombie.kill() zombie_sound.play() # 定义僵尸类 class Zombie(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = zombie_image self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.health = 100 def update(self): self.rect.x -= 2 if self.rect.x <= 0: self.kill() game_over() # 定义游戏结束函数 def game_over(): pygame.mixer.music.stop() zombie_sound.stop() plant_sound.stop() game_over_text = font.render("Game Over", True, (255, 0, 0)) game_over_rect = game_over_text.get_rect(center=(window_width // 2, window_height // 2)) screen.blit(game_over_text, game_over_rect) pygame.display.update() pygame.time.wait(3000) pygame.quit() exit() # 创建屏幕 screen = pygame.display.set_mode((window_width, window_height)) # 定义精灵组 all_sprites = pygame.sprite.Group() sunflowers = pygame.sprite.Group() peashooters = pygame.sprite.Group() suns = pygame.sprite.Group() peas = pygame.sprite.Group() zombies = pygame.sprite.Group() # 创建植物 sunflower1 = Sunflower(100, 100) all_sprites.add(sunflower1) sunflowers.add(sunflower1) peashooter1 = Peashooter(200, 200) all_sprites.add(peashooter1) peashooters.add(peashooter1) # 游戏循环 clock = pygame.time.Clock() while True: # 处理事件 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: pos = pygame.mouse.get_pos() if pos[1] < 100: continue x = pos[0] // 100 * 100 y = pos[1] // 100 * 100 if random.randint(1, 10) == 1: sun = Sun(random.randint(x, x + 100), y) all_sprites.add(sun) suns.add(sun) sun_sound.play() else: peashooter = Peashooter(x, y) all_sprites.add(peashooter) peashooters.add(peashooter) plant_sound.play() # 更新精灵组 all_sprites.update() # 绘制背景 screen.blit(background_image, (0, 0)) # 绘制阳光值 sun_value = font.render("阳光值: " + str(len(suns)), True, (255, 255, 255)) screen.blit(sun_value, (10, 10)) # 绘制精灵组 all_sprites.draw(screen) # 生成僵尸 if len(zombies) < 5 and random.randint(1, 100) == 1: zombie = Zombie(window_width, random.randint(100, window_height - 100)) all_sprites.add(zombie) zombies.add(zombie) # 更新屏幕 pygame.display.update() # 控制帧率 clock.tick(60) ``` 这个示例代码实现了一个简单的植物大战僵尸游戏,包括植物、阳光、豌豆、僵尸等元素,并使用了Pygame游戏引擎来实现游戏逻辑和界面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值