Exemple #1
0
def main():
    play_area = get_play_area(0)
    # print play_area
    offset.save_to_json((play_area[0], play_area[1]))
    reload(offset)
    # print offset.x, offset.y

    im = grab(play_area)
    im.save('adfsadsf.png', 'png')
    # # print is_spinner_screen()
    # # set_mouse_pos((720, 270))
    # # wait_for_needle()
    # # left_click()

    # if can_shop():
    # 	enter_shop()

    # time.sleep(3)

    # for i in range(12):
    # 	time.sleep(3)
    pos = win32api.GetCursorPos()
    x = pos[0] - offset.x
    y = pos[1] - offset.y
    print '[(%d, %d), %s]' % (x, y, str(getPixel(x, y)))
    print

    print on_retry_screen()
Exemple #2
0
def main():
	play_area = get_play_area(0)
	# print play_area
	offset.save_to_json((play_area[0], play_area[1]))
	reload(offset)
	# print offset.x, offset.y

	im = grab(play_area)
	im.save('adfsadsf.png', 'png')
	# # print is_spinner_screen()
	# # set_mouse_pos((720, 270))
	# # wait_for_needle()
	# # left_click()

	# if can_shop():
	# 	enter_shop()

	# time.sleep(3)

	# for i in range(12):
	# 	time.sleep(3)
	pos = win32api.GetCursorPos()
	x = pos[0] - offset.x
	y = pos[1] - offset.y
	print '[(%d, %d), %s]' % (x,y, str(getPixel(x,y)))
	print 

	print on_retry_screen()
Exemple #3
0
def get_play_area(monitor):
	'''
	Snaps an image of the chosen monitor (zero indexed). 
	Loops through the RGB pixels looking for the value 
	(244,222,176), which corresponds to the top left 
	most pixel of the game.

	It returns the coordinates of the playarea. 
	'''
	
	TOP_LEFT_PIXELS = (204,204,204)
	GREY_BORDER = (204,204,204)
	SCREEN_WIDTH = 719
	SCREEN_HEIGH = 479

	monitor_coords = getMonitorCoordinates(0) #set to whatever monitor you have the game screen on
	im = grab(monitor_coords)
	imageWidth, imHeight = im.size
	imageArray = im.getdata()

	for index, pixel in enumerate(imageArray):
		if pixel == TOP_LEFT_PIXELS:
			# getdata returns a flat array, so the below figures out
			# the 2d coords based on the index position.
			top = (index / imageWidth)
			left = (index % imageWidth)
			if (im.getpixel((left + 1, top + 1)) == GREY_BORDER and
				im.getpixel((left + 2, top + 2)) == GREY_BORDER):
				top += 5
				left += 5
				
				return (left, top, left + SCREEN_WIDTH, top + SCREEN_HEIGH) 

	raise Exception("Play area not in view." 
			"Make sure the game is visible on screen!")	
Exemple #4
0
def get_play_area(monitor):
    '''
	Snaps an image of the chosen monitor (zero indexed). 
	Loops through the RGB pixels looking for the value 
	(244,222,176), which corresponds to the top left 
	most pixel of the game.

	It returns the coordinates of the playarea. 
	'''

    TOP_LEFT_PIXELS = (204, 204, 204)
    GREY_BORDER = (204, 204, 204)
    SCREEN_WIDTH = 719
    SCREEN_HEIGH = 479

    monitor_coords = getMonitorCoordinates(
        0)  #set to whatever monitor you have the game screen on
    im = grab(monitor_coords)
    imageWidth, imHeight = im.size
    imageArray = im.getdata()

    for index, pixel in enumerate(imageArray):
        if pixel == TOP_LEFT_PIXELS:
            # getdata returns a flat array, so the below figures out
            # the 2d coords based on the index position.
            top = (index / imageWidth)
            left = (index % imageWidth)
            if (im.getpixel((left + 1, top + 1)) == GREY_BORDER
                    and im.getpixel((left + 2, top + 2)) == GREY_BORDER):
                top += 5
                left += 5

                return (left, top, left + SCREEN_WIDTH, top + SCREEN_HEIGH)

    raise Exception("Play area not in view."
                    "Make sure the game is visible on screen!")