Anonymous
Как объединить все окна и выходные данные моего Python Cookie Clicker в одно окно
Сообщение
Anonymous » 14 янв 2025, 13:29
Я написал код для этой игры-кликера, и все, что мне нужно, это количество файлов cookie, которые должны быть в окне, и все окна, которые должны быть связаны в одно подвижное окно.
Это код для игры: р>
Код: Выделить всё
import tkinter as tk
from tkinter import *
import time
from PIL import Image, ImageTk
import datetime
from tkinter import filedialog, Text
import os
import numpy as np
import urllib3
import sys
import io
def info():
print("Double click purchases need 50 clicks!")
print("Triple Click purchases need 10,000 clicks!")
def on_click(event=None):
print("image clicked")
def uiPrint():
info()
print(click)
blankLine()
info()
click = 0
mult = 1
dcp1 = 0
def blankLine():
for i in range(20):
print("")
def purchaseDoubleClicksCommand():
global click
global mult
if click < 50:
print("Not enough clicks!")
blankLine()
elif click >= 50:
mult = mult*2
click = click - 50
print("Double Clicks Purchased!")
blankLine()
def purchaseTripeClicksCommand():
global click
global mult
if click < 10000:
print("Not enough clicks!")
blankLine()
elif click >= 10000:
mult = mult*3
click = click - 10000
print("Triple Clicks Purchased!")
blankLine()
def buttonCommand():
global click
global mult
click += 1*mult
uiPrint()
if click == 100:
print('''Achievement Unlocked: Junior Clicker!
BONUS 100 clicks!''')
click += 100
elif click == 400:
print ('''Achievement Unlocked: Little Ninja Clicks!
BONUS 200!''')
click += 300
elif click == 1500:
print ('''Achievement Unlocked: Click Ninja Master!
QUAD CLICKS!''')
mult = mult * 4
elif click == 3000:
print ('''Achievement Unlocked: Jackie Chan Style!
8 TIMES THE CLICKS!''')
mult = mult * 8
class App(Frame):
root = tk.Tk()
image = Image.open("Cookiev2.jpg")
photo = ImageTk.PhotoImage(image)
master = Tk()
b = tk.Button(root, image=photo, command=buttonCommand)
b.pack()
purchaseDoubleClickButton = Button(master, text="Purchase Double Clicks (Costs 50)", command = purchaseDoubleClicksCommand)
purchaseDoubleClickButton.pack()
TripeClicks = Button(master, text="Purchase Triple Clicks (Costs 10,000) ", command = purchaseTripeClicksCommand)
TripeClicks.pack()
##################
print (click)
class RedirectText(io.StringIO):
def __init__(self, text_widget):
super().__init__()
self.text_widget = text_widget
def write(self, message):
self.text_widget.insert(tk.END, message)
self.text_widget.see(tk.END) # Scroll to the end of the text widget
def flush(self):
pass # No need to implement flush for this example
class App:
def __init__(self, root):
self.root = root
self.root.title("Clicks")
self.text_widget = tk.Text(root, wrap='word')
self.text_widget.pack(expand=True, fill='both')
# Redirect stdout to the text widget
self.redirect_output()
# Example print commands
print("Clck the Cookie To Begin")
def redirect_output(self):
# Redirect standard output to the Text widget
sys.stdout = RedirectText(self.text_widget)
if __name__ == "__main__":
root = tk.Tk()
app = App(root)
##################
root.mainloop()
Я пытался добавить больше окон, но это привело к поломке кода, и теперь я застрял в том, как заставить это работать так, как я хочу.
Подробнее здесь:
https://stackoverflow.com/questions/793 ... er-into-on
1736850597
Anonymous
Я написал код для этой игры-кликера, и все, что мне нужно, это количество файлов cookie, которые должны быть в окне, и все окна, которые должны быть связаны в одно подвижное окно. Это код для игры: р> [code]import tkinter as tk from tkinter import * import time from PIL import Image, ImageTk import datetime from tkinter import filedialog, Text import os import numpy as np import urllib3 import sys import io def info(): print("Double click purchases need 50 clicks!") print("Triple Click purchases need 10,000 clicks!") def on_click(event=None): print("image clicked") def uiPrint(): info() print(click) blankLine() info() click = 0 mult = 1 dcp1 = 0 def blankLine(): for i in range(20): print("") def purchaseDoubleClicksCommand(): global click global mult if click < 50: print("Not enough clicks!") blankLine() elif click >= 50: mult = mult*2 click = click - 50 print("Double Clicks Purchased!") blankLine() def purchaseTripeClicksCommand(): global click global mult if click < 10000: print("Not enough clicks!") blankLine() elif click >= 10000: mult = mult*3 click = click - 10000 print("Triple Clicks Purchased!") blankLine() def buttonCommand(): global click global mult click += 1*mult uiPrint() if click == 100: print('''Achievement Unlocked: Junior Clicker! BONUS 100 clicks!''') click += 100 elif click == 400: print ('''Achievement Unlocked: Little Ninja Clicks! BONUS 200!''') click += 300 elif click == 1500: print ('''Achievement Unlocked: Click Ninja Master! QUAD CLICKS!''') mult = mult * 4 elif click == 3000: print ('''Achievement Unlocked: Jackie Chan Style! 8 TIMES THE CLICKS!''') mult = mult * 8 class App(Frame): root = tk.Tk() image = Image.open("Cookiev2.jpg") photo = ImageTk.PhotoImage(image) master = Tk() b = tk.Button(root, image=photo, command=buttonCommand) b.pack() purchaseDoubleClickButton = Button(master, text="Purchase Double Clicks (Costs 50)", command = purchaseDoubleClicksCommand) purchaseDoubleClickButton.pack() TripeClicks = Button(master, text="Purchase Triple Clicks (Costs 10,000) ", command = purchaseTripeClicksCommand) TripeClicks.pack() ################## print (click) class RedirectText(io.StringIO): def __init__(self, text_widget): super().__init__() self.text_widget = text_widget def write(self, message): self.text_widget.insert(tk.END, message) self.text_widget.see(tk.END) # Scroll to the end of the text widget def flush(self): pass # No need to implement flush for this example class App: def __init__(self, root): self.root = root self.root.title("Clicks") self.text_widget = tk.Text(root, wrap='word') self.text_widget.pack(expand=True, fill='both') # Redirect stdout to the text widget self.redirect_output() # Example print commands print("Clck the Cookie To Begin") def redirect_output(self): # Redirect standard output to the Text widget sys.stdout = RedirectText(self.text_widget) if __name__ == "__main__": root = tk.Tk() app = App(root) ################## root.mainloop() [/code] Я пытался добавить больше окон, но это привело к поломке кода, и теперь я застрял в том, как заставить это работать так, как я хочу. Подробнее здесь: [url]https://stackoverflow.com/questions/79354686/how-do-i-combine-all-the-windows-and-outputs-in-my-python-cookie-clicker-into-on[/url]