flappy init
@@ -12,6 +12,7 @@ from fruit import Fruit
|
||||
from pickaxe import Pickaxe_Field
|
||||
from litris import Litris
|
||||
from menti_words import MentiWords
|
||||
from flappy import Flappy
|
||||
|
||||
|
||||
def run():
|
||||
@@ -73,6 +74,10 @@ def run():
|
||||
elif overlay.rb_int.get() == 11:
|
||||
menti = MentiWords(overlay)
|
||||
menti.execute_main_loop()
|
||||
elif overlay.rb_int.get() == 12:
|
||||
flappy = Flappy(overlay)
|
||||
flappy.execute_main_loop()
|
||||
flappy.flappy_pos_disc.run_mode = 'stop'
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
||||
@@ -33,7 +33,7 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.Emitter_Box = ttk.Combobox
|
||||
|
||||
self.RadioButtons = dict
|
||||
self.RadioButtonNames = ["Equip", "Crops", "Farm", "Magic", "Craft", "Mine", "Fruit", "Sodo", "PAxe", "Ltris", "Menti"]
|
||||
self.RadioButtonNames = ["Equip", "Crops", "Farm", "Magic", "Craft", "Mine", "Fruit", "Sodo", "PAxe", "Ltris", "Menti", "Flapp"]
|
||||
self.RadioButton1 = tk.Radiobutton
|
||||
self.RadioButton2 = tk.Radiobutton
|
||||
self.RadioButton3 = tk.Radiobutton
|
||||
@@ -45,12 +45,13 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.RadioButton9 = tk.Radiobutton
|
||||
self.RadioButton10 = tk.Radiobutton
|
||||
self.RadioButton11 = tk.Radiobutton
|
||||
self.RadioButton12 = tk.Radiobutton
|
||||
|
||||
self.StartButton = tk.Button
|
||||
self.StopButton = tk.Button
|
||||
self.PauseButton = tk.Button
|
||||
self.QuitButton = tk.Button
|
||||
self.TkPosition = '133x429+60+600'
|
||||
self.TkPosition = '133x454+60+600'
|
||||
self.setDaemon(True)
|
||||
self.StatusLabel = tk.Label
|
||||
|
||||
@@ -78,7 +79,7 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.rb_int = tk.IntVar(self.root, value=1)
|
||||
self.RadioButtons = dict()
|
||||
# var = tk.IntVar(value=1)
|
||||
for i in range(1, 12):
|
||||
for i in range(1, 13):
|
||||
self.RadioButtons[i] = tk.Radiobutton(self.rb_frame, text=self.RadioButtonNames[i - 1],
|
||||
variable=self.rb_int,
|
||||
value=i, command=self.radio_button_callback)
|
||||
@@ -338,6 +339,17 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.SpawnLabel.configure(text="")
|
||||
self.EnergyLabel.configure(text="")
|
||||
self.hide_mining_overlay()
|
||||
elif self.rb_int.get() == 12:
|
||||
self.EnergyEntry.configure(state=tk.DISABLED)
|
||||
self.energy_use.set('')
|
||||
self.SpawnEntry.configure(state=tk.DISABLED)
|
||||
self.spawn_use.set('')
|
||||
self.Emitter_Box.configure(state=tk.DISABLED)
|
||||
self.emitter_use.set('')
|
||||
self.EmitterLabel.configure(text="")
|
||||
self.SpawnLabel.configure(text="")
|
||||
self.EnergyLabel.configure(text="")
|
||||
self.hide_mining_overlay()
|
||||
def get_run_mode(self):
|
||||
return self.run_mode
|
||||
|
||||
|
||||
63
flappy.py
Normal file
@@ -0,0 +1,63 @@
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from time import time
|
||||
|
||||
import pydirectinput
|
||||
|
||||
from game_base_class import GameBase
|
||||
from pynput.keyboard import Key, Controller
|
||||
|
||||
from flappy_pos_discovery_thread import FlappyPosDiscovery
|
||||
|
||||
class Flappy(GameBase):
|
||||
|
||||
def __init__(self, overlay):
|
||||
super().__init__(overlay)
|
||||
|
||||
self.keyboard = Controller()
|
||||
|
||||
self.data_coordinates = np.zeros((20, 20), dtype=object)
|
||||
self.observation = np.zeros((20, 20), dtype=int)
|
||||
|
||||
self.colors = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
self.offset_left = 610
|
||||
self.offset_down = 40
|
||||
|
||||
self.fill_data_coordinates()
|
||||
|
||||
self.litris_reset_board = cv.imread("control_elements/sodoku_reset_button.jpg", cv.IMREAD_COLOR)
|
||||
|
||||
self.flappy_pos_disc = FlappyPosDiscovery()
|
||||
|
||||
self.move_mode = 1
|
||||
|
||||
def assess_playfield_and_make_move(self):
|
||||
#last_letter_received = time()
|
||||
while True:
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
#pydirectinput.mouseDown()
|
||||
#cv.waitKey(50)
|
||||
#pydirectinput.mouseUp()
|
||||
#cv.waitKey(250)
|
||||
'''
|
||||
if self.stone_id_thread.get_pick_up_status() == False:
|
||||
if (time() - last_letter_received) >= 5:
|
||||
self.field.reset_field()
|
||||
self.field.cleared_rows = 1
|
||||
last_letter_received = time()
|
||||
self.dig_point(1500, 980, 100)
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
continue
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
cv.waitKey(50)
|
||||
continue
|
||||
|
||||
|
||||
self.stone_id_thread.set_pick_up_status(False)
|
||||
'''
|
||||
|
||||
|
||||
BIN
flappy/flappy-mask.png
Normal file
|
After Width: | Height: | Size: 716 B |
BIN
flappy/flappy.jpg
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
flappy/flappy.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
flappy/gate-mask.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
flappy/gate.jpg
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
flappy/gate.png
Normal file
|
After Width: | Height: | Size: 436 KiB |
BIN
flappy/screen.jpg
Normal file
|
After Width: | Height: | Size: 530 KiB |
62
flappy_pos_discovery_thread.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import threading
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from window_capture import WindowCapture
|
||||
from vision import Vision
|
||||
from config_file import UserConfigs
|
||||
|
||||
class FlappyPosDiscovery(threading.Thread):
|
||||
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
self.config = UserConfigs()
|
||||
self.capture_window = WindowCapture(None, None, self.config)
|
||||
self.vision_stun = Vision()
|
||||
|
||||
self.needle_f = cv.imread("flappy/flappy.jpg")
|
||||
self.mask_f = cv.imread("flappy/flappy-mask.png")
|
||||
|
||||
self.needle_g = cv.imread("flappy/gate.png")
|
||||
self.mask_g = cv.imread("flappy/gate-mask.png")
|
||||
|
||||
self.run_mode = 'run'
|
||||
self.current_pet_height = 0
|
||||
self.next_gate_height = 0
|
||||
|
||||
self.start()
|
||||
|
||||
def run(self):
|
||||
while self.run_mode == 'run':
|
||||
self.position_detection()
|
||||
print("pet_pos: ", self.current_pet_height)
|
||||
print("next gate: ", self.next_gate_height)
|
||||
def get_actual_pet_height(self):
|
||||
return self.current_pet_height
|
||||
|
||||
def get_next_gate_height(self):
|
||||
return self.next_gate_height
|
||||
def callback(self):
|
||||
pass
|
||||
|
||||
def destroy(self):
|
||||
self.destroy()
|
||||
|
||||
def get_run_mode(self):
|
||||
return self.run_mode
|
||||
|
||||
|
||||
def position_detection(self):
|
||||
|
||||
screenshot = self.capture_window.get_screenshot()
|
||||
#screenshot = screenshot[580:845, 1148:1412]
|
||||
|
||||
rectangles_g = self.vision_stun.find(screenshot, self.needle_g, 0.9, 5, True, self.mask_g)
|
||||
rectangles_f = self.vision_stun.find(screenshot, self.needle_f, 0.9, 1, True, self.mask_f)
|
||||
if len(rectangles_g) == 0 or len(rectangles_f) == 0:
|
||||
return None
|
||||
self.current_pet_height = rectangles_f[1] + rectangles_f[3]
|
||||
self.next_gate_height = rectangles_g[1] + rectangles_g[3]
|
||||
# return pet height and next gate height
|
||||
|
||||
|
||||