def __init__(self, hdc_main, file_path): ##Load button## self.button = Button(hdc_main, file_path, "purple") ##Load tokens## build_wall_file = "Wall_build_token.bmp" wheat_build_file = "Wheat_build_token.bmp" self.token_file = [build_wall_file, wheat_build_file] self.token_hbmp = [None, None] self.token_hdc = [None, None] for i in range(2): self.token_hbmp[i] = wf.LoadImage( c_void_p(), LPCWSTR(file_path + self.token_file[i]), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) ##LOAD HDC## self.token_hdc[i] = windll.gdi32.CreateCompatibleDC(hdc_main) ##COPY IMAGES INTO HDC## windll.gdi32.SelectObject(self.token_hdc[i], self.token_hbmp[i]) ##Define dictionaries## self.direction = { "right": wf.r_build, "left": wf.l_build, "up": wf.u_build, "down": wf.d_build } ##Define dictionary for button placement when building self.build = { "Wall": 0, "Wheat": 1 } ##Identify the index for the token
def __init__(self, hdc_main, file_path): ##Initialize hdc, and load image## barrel_file = "Wheat_Barrel.bmp" self.hbmp = wf.LoadImage( c_void_p(), LPCWSTR(file_path + barrel_file), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) self.hdc = windll.gdi32.CreateCompatibleDC( hdc_main) #Make hdc similar to the reference hdc windll.gdi32.SelectObject(self.hdc, self.hbmp) #Copy image into hdc self.button = Button(hdc_main, file_path, "red") #Load Button self.out_of_bounds = False ##Change to False when finished self.Amount = 0 self.Character = "W" ##LOAD REGIONS## points = [(102, 155), (17, 155), (15, 150), (13, 148), (13, 147), (11, 142), (10, 141), (10, 140), (8, 135), (8, 134), (7, 133), (7, 130), (5, 130), (4, 127), (3, 124), (2, 118), (3, 118), (2, 108), (1, 107), (0, 90), (0, 82), (1, 69), (2, 61), (3, 56), (3, 54), (2, 54), (3, 49), (4, 45), (5, 42), (7, 42), (7, 40), (8, 37), (9, 35), (10, 32), (11, 30), (12, 28), (13, 25), (14, 23), (15, 21), (16, 19), (103, 19), (104, 21), (105, 23), (106, 25), (107, 28), (108, 30), (109, 32), (110, 35), (111, 38), (112, 40), (112, 42), (114, 42), (115, 45), (116, 48), (117, 52), (117, 54), (116, 54), (117, 62), (118, 70), (119, 80), (119, 94), (118, 104), (117, 112), (116, 118), (117, 118), (116, 124), (115, 127), (114, 130), (112, 130), (112, 132), (111, 135), (110, 138), (109, 140), (108, 143), (107, 145), (106, 147), (105, 150), (104, 151), (103, 152)] ##TRANSLATE POINTS INTO REGION## Rgn = POINT * len(points) temp = [] for i in range(len(points)): temp.append(POINT(points[i][0], points[i][1])) out = Rgn(*temp) self.Region = wf.CreatePolygonRgn(out, len(out), wf.WINDING) ##DEFINE THE TARGET BOX## self.tboxUL = POINT(50, 80) self.tboxUR = POINT(wf.tile_w - 50, 80) self.tboxLL = POINT(50, wf.tile_h - 20) self.tboxLR = POINT(wf.tile_w - 50, wf.tile_h - 20) ##DEFINE REFERENCE POSITION## self.position = POINT( int(wf.tile_w / 2 - wf.tree1_w / 2) + 600, wf.tile_h - wf.tree1_h + 900) self.tile_position = (int(self.position.x / wf.tile_w), int(self.position.y / wf.tile_h) ) ##Define tile position
class Build_Button_Sprite_1: def __init__(self, hdc_main, file_path): ##Load button## self.button = Button(hdc_main, file_path, "purple") ##Load tokens## build_wall_file = "Wall_build_token.bmp" wheat_build_file = "Wheat_build_token.bmp" self.token_file = [build_wall_file, wheat_build_file] self.token_hbmp = [None, None] self.token_hdc = [None, None] for i in range(2): self.token_hbmp[i] = wf.LoadImage( c_void_p(), LPCWSTR(file_path + self.token_file[i]), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) ##LOAD HDC## self.token_hdc[i] = windll.gdi32.CreateCompatibleDC(hdc_main) ##COPY IMAGES INTO HDC## windll.gdi32.SelectObject(self.token_hdc[i], self.token_hbmp[i]) ##Define dictionaries## self.direction = { "right": wf.r_build, "left": wf.l_build, "up": wf.u_build, "down": wf.d_build } ##Define dictionary for button placement when building self.build = { "Wall": 0, "Wheat": 1 } ##Identify the index for the token def Target_box(self, x_shit, y_shift, number=None): ##Return nothing## return [POINT(), POINT(), POINT(), POINT()] def Draw(self, hdc, object_string, x_shift, y_shift, player): text = ["E", "9", "-"] ##GGOOBPCC## if player.Tool_selection == wf.Empty_Hand: if object_string[2] == "-" and object_string[ 4:6] == "B" + player.Character[0]: ##Update position for button depending on where player is facing position = POINT(self.direction[player.direction].x + x_shift, self.direction[player.direction].y + y_shift) self.button.Draw_Button(hdc, position.x, position.y, text[int(player.Character[0])]) ##Draw token depending on selection## position.x = position.x + wf.button_w windll.gdi32.BitBlt(hdc, position, 50, 50, self.token_hdc[ self.build[player.build_objects[player.build_object]]], 0, 0, wf.SRCCOPY) ##Add button to background return 0 return -1
def __init__(self,hdc_main,file_path_main,Wall): ##Initialize hdc, and load image## wall_vertical_file="Wall_vertical.bmp" wall_horizontal_file="Wall_horizontal.bmp" ##Load Image## hbmp_vertical=wf.LoadImage(c_void_p(),LPCWSTR(file_path_main+wall_vertical_file),wf.IMAGE_BITMAP,0,0,8192|wf.LR_DEFAULTSIZE|wf.LR_LOADFROMFILE) hbmp_horizontal=wf.LoadImage(c_void_p(),LPCWSTR(file_path_main+wall_horizontal_file),wf.IMAGE_BITMAP,0,0,8192|wf.LR_DEFAULTSIZE|wf.LR_LOADFROMFILE) self.hbmp=[hbmp_vertical,hbmp_horizontal] ##Load hdcs## hdc_vertical=windll.gdi32.CreateCompatibleDC(hdc_main) #Make vertical hdc similar to the reference hdc hdc_horizontal=windll.gdi32.CreateCompatibleDC(hdc_main) #Make horizontal hdc similar to the reference hdc self.hdc=[hdc_vertical,hdc_horizontal] windll.gdi32.SelectObject(self.hdc[0],self.hbmp[0]) #Copy vertical image into hdc windll.gdi32.SelectObject(self.hdc[1],self.hbmp[1]) #Copy horizontal image into hdc self.button=Button(hdc_main,file_path_main,"red") #Load Button ##LOAD REGION## points_vertical=[(20,8),(21,7),(24,6),(25,6),(28,7),(29,8),(29,299),(20,299)] points_horizontal=[(0,2),(2,0),(7,0),(9,2),(10,2),(12,0),(17,0),(19,2),(20,2), (22,0),(27,0),(29,2),(30,2),(32,0),(37,0),(39,2),(40,2), (42,0),(47,0),(49,2),(50,2),(52,0),(57,0),(59,2),(60,2), (62,0),(67,0),(69,2),(70,2),(72,0),(77,0),(79,2),(80,2), (82,0),(87,0),(89,2),(90,2),(92,0),(97,0),(99,2),(100,2), (102,0),(107,0),(109,2),(110,2),(112,0),(117,0),(119,2),(120,2), (122,0),(127,0),(129,2),(130,2),(132,0),(137,0),(139,2),(140,2), (142,0),(147,0),(149,2),(150,2),(152,0),(157,0),(159,2),(160,2), (162,0),(167,0),(169,2),(170,2),(172,0),(177,0),(179,2),(180,2), (182,0),(187,0),(189,2),(190,2),(192,0),(197,0),(199,2),(199,104), (0,104)] points=[points_vertical,points_horizontal] ##TRANSLATE POINTS INTO REGION## self.Region=[None,None] for i in range(2): Rgn=POINT*len(points[i]) temp=[] for j in range(len(points[i])): temp.append(POINT(points[i][j][0],points[i][j][1])) out=Rgn(*temp) self.Region[i]=wf.CreatePolygonRgn(out,len(out),wf.WINDING) ##DEFINE THE TARGET BOX## self.Wall_target_boxes=[ws.FourPoint(),ws.FourPoint(),ws.FourPoint(),ws.FourPoint()] ##Facing right self.Wall_target_boxes[0].WallUL=POINT(0,0) self.Wall_target_boxes[0].WallUR=POINT(wf.wall_vertical_w,0) self.Wall_target_boxes[0].WallLL=POINT(0,wf.tile_h) self.Wall_target_boxes[0].WallLR=POINT(wf.wall_vertical_w,wf.tile_h) ##Facing left self.Wall_target_boxes[1].WallUL=POINT(wf.tile_w-wf.wall_vertical_w,0) self.Wall_target_boxes[1].WallUR=POINT(wf.tile_w,0) self.Wall_target_boxes[1].WallLL=POINT(wf.tile_w-wf.wall_vertical_w,wf.tile_h) self.Wall_target_boxes[1].WallLR=POINT(wf.tile_w,wf.tile_h) ##Facing up self.Wall_target_boxes[2].WallUL=POINT(0,wf.tile_h-int(wf.wall_horizontal_h/4)) self.Wall_target_boxes[2].WallUR=POINT(wf.tile_w,wf.tile_h-int(wf.wall_horizontal_h/4)) self.Wall_target_boxes[2].WallLL=POINT(0,wf.tile_h) self.Wall_target_boxes[2].WallLR=POINT(wf.tile_w,wf.tile_h) ##Facing down self.Wall_target_boxes[3].WallUL=POINT(0,0) self.Wall_target_boxes[3].WallUR=POINT(wf.tile_w,0) self.Wall_target_boxes[3].WallLL=POINT(0,int(wf.wall_horizontal_h/4)) self.Wall_target_boxes[3].WallLR=POINT(wf.tile_w,int(wf.wall_horizontal_h/4)) ##DEFINE REFERENCE POSITIONS## self.position=[POINT(0,wf.tile_h-wf.wall_vertical_h), ##Define dictionary for where to put the walls POINT(wf.tile_w-wf.wall_vertical_w,wf.tile_h-wf.wall_vertical_h), POINT(0,wf.tile_h-wf.wall_horizontal_h), POINT(0,-int(wf.wall_horizontal_h*3/4))] self.direction={"0":wf.r_build,"1":wf.l_build,"2":wf.u_build,"3":wf.d_build} ##Define dictionary for button placement self.wall_type=Wall
class Wall_Sprite_1(object): def __init__(self,hdc_main,file_path_main,Wall): ##Initialize hdc, and load image## wall_vertical_file="Wall_vertical.bmp" wall_horizontal_file="Wall_horizontal.bmp" ##Load Image## hbmp_vertical=wf.LoadImage(c_void_p(),LPCWSTR(file_path_main+wall_vertical_file),wf.IMAGE_BITMAP,0,0,8192|wf.LR_DEFAULTSIZE|wf.LR_LOADFROMFILE) hbmp_horizontal=wf.LoadImage(c_void_p(),LPCWSTR(file_path_main+wall_horizontal_file),wf.IMAGE_BITMAP,0,0,8192|wf.LR_DEFAULTSIZE|wf.LR_LOADFROMFILE) self.hbmp=[hbmp_vertical,hbmp_horizontal] ##Load hdcs## hdc_vertical=windll.gdi32.CreateCompatibleDC(hdc_main) #Make vertical hdc similar to the reference hdc hdc_horizontal=windll.gdi32.CreateCompatibleDC(hdc_main) #Make horizontal hdc similar to the reference hdc self.hdc=[hdc_vertical,hdc_horizontal] windll.gdi32.SelectObject(self.hdc[0],self.hbmp[0]) #Copy vertical image into hdc windll.gdi32.SelectObject(self.hdc[1],self.hbmp[1]) #Copy horizontal image into hdc self.button=Button(hdc_main,file_path_main,"red") #Load Button ##LOAD REGION## points_vertical=[(20,8),(21,7),(24,6),(25,6),(28,7),(29,8),(29,299),(20,299)] points_horizontal=[(0,2),(2,0),(7,0),(9,2),(10,2),(12,0),(17,0),(19,2),(20,2), (22,0),(27,0),(29,2),(30,2),(32,0),(37,0),(39,2),(40,2), (42,0),(47,0),(49,2),(50,2),(52,0),(57,0),(59,2),(60,2), (62,0),(67,0),(69,2),(70,2),(72,0),(77,0),(79,2),(80,2), (82,0),(87,0),(89,2),(90,2),(92,0),(97,0),(99,2),(100,2), (102,0),(107,0),(109,2),(110,2),(112,0),(117,0),(119,2),(120,2), (122,0),(127,0),(129,2),(130,2),(132,0),(137,0),(139,2),(140,2), (142,0),(147,0),(149,2),(150,2),(152,0),(157,0),(159,2),(160,2), (162,0),(167,0),(169,2),(170,2),(172,0),(177,0),(179,2),(180,2), (182,0),(187,0),(189,2),(190,2),(192,0),(197,0),(199,2),(199,104), (0,104)] points=[points_vertical,points_horizontal] ##TRANSLATE POINTS INTO REGION## self.Region=[None,None] for i in range(2): Rgn=POINT*len(points[i]) temp=[] for j in range(len(points[i])): temp.append(POINT(points[i][j][0],points[i][j][1])) out=Rgn(*temp) self.Region[i]=wf.CreatePolygonRgn(out,len(out),wf.WINDING) ##DEFINE THE TARGET BOX## self.Wall_target_boxes=[ws.FourPoint(),ws.FourPoint(),ws.FourPoint(),ws.FourPoint()] ##Facing right self.Wall_target_boxes[0].WallUL=POINT(0,0) self.Wall_target_boxes[0].WallUR=POINT(wf.wall_vertical_w,0) self.Wall_target_boxes[0].WallLL=POINT(0,wf.tile_h) self.Wall_target_boxes[0].WallLR=POINT(wf.wall_vertical_w,wf.tile_h) ##Facing left self.Wall_target_boxes[1].WallUL=POINT(wf.tile_w-wf.wall_vertical_w,0) self.Wall_target_boxes[1].WallUR=POINT(wf.tile_w,0) self.Wall_target_boxes[1].WallLL=POINT(wf.tile_w-wf.wall_vertical_w,wf.tile_h) self.Wall_target_boxes[1].WallLR=POINT(wf.tile_w,wf.tile_h) ##Facing up self.Wall_target_boxes[2].WallUL=POINT(0,wf.tile_h-int(wf.wall_horizontal_h/4)) self.Wall_target_boxes[2].WallUR=POINT(wf.tile_w,wf.tile_h-int(wf.wall_horizontal_h/4)) self.Wall_target_boxes[2].WallLL=POINT(0,wf.tile_h) self.Wall_target_boxes[2].WallLR=POINT(wf.tile_w,wf.tile_h) ##Facing down self.Wall_target_boxes[3].WallUL=POINT(0,0) self.Wall_target_boxes[3].WallUR=POINT(wf.tile_w,0) self.Wall_target_boxes[3].WallLL=POINT(0,int(wf.wall_horizontal_h/4)) self.Wall_target_boxes[3].WallLR=POINT(wf.tile_w,int(wf.wall_horizontal_h/4)) ##DEFINE REFERENCE POSITIONS## self.position=[POINT(0,wf.tile_h-wf.wall_vertical_h), ##Define dictionary for where to put the walls POINT(wf.tile_w-wf.wall_vertical_w,wf.tile_h-wf.wall_vertical_h), POINT(0,wf.tile_h-wf.wall_horizontal_h), POINT(0,-int(wf.wall_horizontal_h*3/4))] self.direction={"0":wf.r_build,"1":wf.l_build,"2":wf.u_build,"3":wf.d_build} ##Define dictionary for button placement self.wall_type=Wall def Target_box(self,x_shift,y_shift,direction): ##Return the shifted target box shiftedboxUL=POINT(self.Wall_target_boxes[direction].WallUL.x+x_shift,self.Wall_target_boxes[direction].WallUL.y+y_shift) shiftedboxUR=POINT(self.Wall_target_boxes[direction].WallUR.x+x_shift,self.Wall_target_boxes[direction].WallUR.y+y_shift) shiftedboxLL=POINT(self.Wall_target_boxes[direction].WallLL.x+x_shift,self.Wall_target_boxes[direction].WallLL.y+y_shift) shiftedboxLR=POINT(self.Wall_target_boxes[direction].WallLR.x+x_shift,self.Wall_target_boxes[direction].WallLR.y+y_shift) return [shiftedboxUL,shiftedboxUR,shiftedboxLL,shiftedboxLR] def Draw(self,hdc,object_string,x_shift,y_shift,Player): ##IF TILE NEEDS OBJECT THEN ADD## i=self.wall_type if object_string[2]=="W" and int(object_string[3])==i: j=int(i/2) ##Shift the reference position to desired tile position_new=POINT(self.position[i].x+x_shift,self.position[i].y+y_shift) ##Copy Object onto tile windll.gdi32.OffsetRgn(self.Region[j],position_new) ##Shift the region to draw the tree windll.gdi32.SelectClipRgn(hdc,self.Region[j]) ##Select the shifted region for copying the tree windll.gdi32.BitBlt(hdc,position_new,wf.wall_w[j],wf.wall_h[j],self.hdc[j],0,0,wf.SRCCOPY) ##Add tree to background ##Reset class object and hdc windll.gdi32.SelectClipRgn(hdc,None) ##Remove Clipping Region windll.gdi32.OffsetRgn(self.Region[j],-position_new.x,-position_new.y) ##Return the region back ##ADD BUTTON IF APPLICABLE## ##GGOOBPCC## if object_string[4:6]=="B"+Player.Character[0] and Player.Tool_selection==wf.Axe: text=["E","9"] ##Pick Button placement## position_new=POINT(self.direction[object_string[3]].x+x_shift, self.direction[object_string[3]].y+y_shift) self.button.Draw_Button(hdc,position_new.x,position_new.y,text[int(Player.Character[0])]) return 0 return -1
def __init__(self, hdc_main, file_path): ##Initialize hdc, and load image## tree_file = "Tree_1.bmp" self.hbmp = wf.LoadImage( c_void_p(), LPCWSTR(file_path + tree_file), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) self.hdc = windll.gdi32.CreateCompatibleDC( hdc_main) #Make hdc similar to the reference hdc windll.gdi32.SelectObject(self.hdc, self.hbmp) #Copy image into hdc self.button = Button(hdc_main, file_path, "red") #Load Button ##LOAD REGION## points = [(70, 1), (71, 2), (72, 10), (71, 13), (72, 15), (72, 27), (73, 28), (73, 29), (72, 39), (74, 43), (74, 48), (77, 47), (80, 47), (81, 49), (81, 51), (79, 53), (78, 54), (75, 54), (75, 56), (73, 57), (72, 57), (72, 59), (74, 59), (74, 67), (75, 68), (74, 71), (76, 72), (74, 75), (75, 76), (75, 78), (77, 79), (75, 83), (73, 86), (78, 86), (79, 89), (81, 87), (81, 84), (78, 84), (81, 81), (81, 78), (83, 77), (86, 77), (88, 75), (89, 76), (90, 79), (90, 82), (88, 84), (88, 95), (89, 94), (90, 92), (91, 96), (93, 96), (94, 98), (92, 99), (91, 104), (90, 102), (89, 102), (87, 105), (82, 105), (81, 107), (80, 108), (77, 108), (76, 109), (74, 108), (74, 123), (76, 121), (78, 125), (79, 125), (80, 124), (83, 122), (82, 126), (87, 124), (89, 123), (91, 124), (94, 122), (97, 123), (98, 129), (97, 130), (96, 130), (94, 128), (92, 128), (92, 129), (94, 133), (92, 133), (91, 131), (90, 132), (90, 134), (91, 137), (89, 136), (87, 137), (83, 136), (82, 136), (80, 134), (78, 133), (76, 132), (75, 133), (76, 134), (78, 135), (79, 139), (78, 139), (78, 141), (76, 143), (77, 144), (74, 145), (74, 163), (76, 164), (76, 166), (78, 163), (80, 163), (81, 161), (82, 162), (84, 163), (85, 163), (86, 163), (88, 164), (89, 162), (89, 155), (87, 153), (88, 153), (91, 153), (92, 151), (96, 152), (99, 153), (95, 157), (99, 158), (101, 159), (105, 160), (104, 161), (104, 166), (100, 168), (97, 168), (95, 169), (91, 171), (86, 172), (85, 173), (82, 173), (83, 174), (83, 176), (85, 178), (85, 181), (86, 182), (84, 183), (82, 183), (80, 185), (79, 183), (77, 182), (78, 181), (78, 178), (77, 179), (76, 181), (74, 180), (74, 196), (75, 197), (74, 198), (77, 199), (75, 201), (77, 202), (79, 204), (78, 205), (77, 208), (74, 212), (76, 213), (78, 212), (79, 209), (82, 208), (83, 205), (84, 203), (85, 206), (87, 204), (88, 203), (89, 200), (91, 200), (91, 197), (87, 196), (86, 194), (86, 192), (83, 191), (84, 190), (87, 191), (89, 189), (90, 187), (92, 188), (98, 191), (94, 191), (95, 186), (97, 180), (98, 177), (100, 178), (100, 180), (101, 180), (104, 177), (104, 179), (103, 184), (104, 191), (100, 187), (99, 190), (99, 193), (101, 193), (99, 196), (99, 200), (100, 202), (105, 202), (107, 200), (112, 200), (115, 206), (111, 206), (109, 208), (106, 209), (107, 211), (110, 212), (111, 213), (113, 214), (114, 219), (116, 218), (117, 222), (118, 225), (112, 224), (112, 222), (108, 221), (108, 219), (106, 220), (104, 226), (101, 225), (101, 224), (95, 221), (98, 220), (99, 217), (101, 216), (102, 213), (99, 212), (96, 211), (95, 212), (91, 214), (88, 216), (88, 217), (84, 217), (83, 219), (80, 220), (82, 221), (80, 223), (79, 225), (76, 226), (74, 223), (74, 236), (78, 235), (80, 235), (81, 234), (83, 236), (84, 238), (83, 239), (83, 241), (84, 242), (83, 244), (81, 242), (80, 243), (79, 245), (78, 245), (77, 246), (80, 247), (83, 247), (82, 248), (83, 249), (82, 251), (83, 252), (79, 253), (79, 254), (80, 254), (83, 257), (84, 255), (91, 255), (93, 256), (96, 255), (97, 254), (98, 255), (99, 255), (100, 254), (101, 255), (103, 253), (105, 255), (108, 254), (107, 253), (109, 252), (111, 247), (112, 245), (113, 246), (115, 244), (116, 246), (117, 245), (118, 248), (119, 249), (118, 252), (119, 253), (124, 252), (124, 253), (126, 257), (124, 258), (123, 259), (120, 259), (120, 261), (117, 261), (116, 262), (112, 263), (112, 264), (114, 264), (113, 267), (111, 265), (111, 266), (109, 268), (107, 264), (106, 267), (105, 266), (105, 264), (104, 264), (103, 266), (101, 266), (101, 264), (95, 264), (94, 265), (93, 264), (91, 264), (87, 263), (87, 268), (88, 269), (85, 272), (83, 272), (82, 274), (80, 272), (79, 274), (78, 275), (79, 278), (81, 278), (83, 277), (86, 276), (87, 277), (91, 277), (91, 273), (93, 274), (93, 272), (95, 271), (96, 271), (99, 271), (99, 273), (103, 273), (104, 272), (106, 272), (106, 274), (110, 275), (111, 274), (112, 275), (112, 278), (113, 279), (112, 280), (109, 279), (109, 282), (102, 281), (102, 284), (101, 285), (96, 282), (94, 282), (94, 284), (91, 285), (90, 285), (89, 284), (87, 283), (87, 285), (85, 286), (83, 288), (85, 289), (84, 290), (84, 293), (79, 294), (77, 296), (77, 299), (80, 297), (87, 295), (95, 294), (96, 293), (99, 293), (102, 292), (104, 292), (105, 291), (109, 290), (110, 289), (113, 289), (115, 291), (116, 290), (117, 293), (127, 293), (128, 294), (132, 293), (134, 295), (136, 291), (137, 292), (136, 296), (137, 299), (136, 300), (135, 299), (135, 298), (134, 298), (134, 302), (133, 302), (132, 301), (131, 301), (130, 303), (129, 300), (125, 302), (124, 303), (123, 305), (122, 302), (119, 305), (118, 302), (116, 302), (115, 306), (114, 303), (112, 306), (110, 305), (108, 303), (107, 306), (100, 305), (99, 303), (98, 303), (96, 305), (95, 305), (93, 303), (92, 305), (90, 305), (89, 303), (88, 303), (87, 306), (83, 306), (80, 304), (80, 306), (76, 306), (76, 328), (78, 331), (80, 333), (80, 335), (82, 335), (68, 339), (66, 339), (57, 336), (58, 335), (59, 333), (60, 332), (61, 330), (62, 329), (64, 329), (65, 328), (65, 298), (63, 296), (62, 298), (59, 299), (53, 299), (52, 300), (50, 300), (45, 301), (44, 302), (43, 305), (41, 306), (40, 308), (37, 309), (36, 313), (35, 310), (31, 310), (31, 309), (33, 307), (32, 306), (35, 303), (34, 302), (34, 299), (31, 299), (31, 301), (27, 301), (26, 303), (25, 302), (23, 301), (22, 304), (20, 302), (19, 304), (16, 304), (15, 305), (15, 307), (14, 308), (10, 308), (6, 306), (9, 305), (8, 304), (9, 303), (11, 303), (12, 300), (8, 300), (6, 302), (5, 300), (2, 301), (0, 300), (0, 297), (3, 294), (4, 295), (9, 295), (10, 294), (10, 293), (8, 289), (9, 288), (10, 284), (11, 288), (15, 287), (19, 285), (19, 281), (20, 280), (22, 280), (23, 278), (24, 280), (26, 281), (26, 286), (29, 289), (29, 290), (30, 291), (31, 291), (32, 289), (34, 288), (35, 292), (38, 291), (39, 290), (42, 293), (43, 292), (55, 291), (63, 288), (62, 287), (62, 285), (63, 284), (63, 282), (61, 282), (60, 283), (59, 282), (59, 280), (57, 278), (56, 278), (56, 280), (53, 281), (52, 282), (51, 281), (46, 281), (44, 283), (43, 281), (40, 277), (39, 279), (37, 277), (36, 279), (34, 277), (33, 281), (32, 280), (31, 283), (30, 280), (29, 280), (27, 278), (27, 274), (29, 276), (30, 274), (32, 276), (33, 273), (34, 272), (35, 269), (37, 270), (42, 269), (43, 267), (39, 266), (45, 266), (46, 264), (48, 266), (51, 266), (50, 270), (54, 270), (54, 271), (58, 273), (60, 271), (59, 269), (62, 268), (62, 267), (60, 265), (59, 262), (55, 264), (56, 259), (59, 260), (59, 255), (55, 256), (53, 258), (54, 260), (53, 262), (49, 263), (46, 262), (42, 261), (43, 258), (38, 259), (31, 259), (30, 264), (26, 266), (25, 266), (24, 268), (22, 267), (20, 261), (17, 261), (14, 262), (13, 260), (12, 261), (11, 263), (6, 262), (8, 260), (6, 259), (8, 258), (8, 257), (7, 254), (10, 255), (11, 252), (12, 255), (14, 256), (15, 253), (19, 253), (25, 252), (26, 251), (26, 250), (24, 249), (26, 249), (27, 245), (26, 244), (33, 244), (31, 250), (33, 250), (33, 251), (37, 250), (38, 249), (39, 247), (40, 250), (45, 251), (46, 249), (43, 247), (44, 246), (52, 245), (54, 246), (52, 247), (54, 248), (55, 249), (59, 249), (61, 248), (63, 247), (65, 247), (65, 244), (63, 244), (62, 246), (60, 245), (61, 244), (59, 244), (58, 246), (57, 244), (52, 244), (52, 245), (47, 246), (45, 245), (45, 242), (44, 243), (39, 241), (34, 241), (32, 243), (30, 242), (31, 241), (29, 241), (27, 243), (26, 241), (20, 239), (18, 240), (15, 241), (15, 239), (13, 239), (13, 238), (11, 237), (14, 236), (12, 235), (13, 233), (15, 234), (16, 231), (20, 232), (20, 234), (23, 234), (24, 232), (26, 235), (29, 235), (30, 233), (31, 235), (34, 236), (36, 234), (37, 237), (38, 232), (39, 236), (40, 233), (42, 235), (46, 233), (49, 236), (51, 235), (55, 237), (56, 239), (58, 234), (60, 235), (60, 237), (61, 236), (66, 237), (67, 229), (66, 229), (64, 231), (61, 230), (59, 232), (58, 230), (57, 231), (56, 229), (51, 229), (52, 227), (47, 226), (40, 229), (42, 226), (43, 226), (43, 225), (39, 224), (40, 223), (41, 221), (42, 222), (43, 220), (46, 222), (47, 218), (49, 219), (51, 220), (56, 221), (61, 222), (61, 219), (57, 218), (55, 217), (60, 216), (61, 214), (67, 215), (67, 209), (61, 208), (59, 206), (60, 202), (63, 202), (63, 198), (67, 198), (67, 193), (64, 195), (57, 196), (56, 198), (59, 199), (59, 201), (57, 204), (54, 204), (54, 202), (53, 201), (52, 204), (51, 204), (50, 202), (47, 201), (46, 199), (44, 200), (43, 202), (41, 201), (40, 204), (39, 203), (35, 206), (34, 203), (33, 205), (30, 205), (30, 208), (28, 207), (30, 204), (28, 203), (29, 201), (32, 201), (32, 199), (36, 200), (36, 196), (38, 197), (40, 196), (42, 196), (42, 195), (43, 195), (45, 194), (46, 193), (48, 193), (49, 191), (48, 189), (44, 191), (43, 190), (39, 190), (39, 189), (36, 189), (33, 188), (30, 189), (28, 188), (24, 186), (25, 184), (25, 182), (29, 182), (30, 181), (32, 182), (34, 182), (34, 184), (37, 183), (42, 183), (42, 179), (40, 178), (41, 174), (39, 173), (43, 172), (44, 169), (50, 168), (48, 169), (46, 170), (44, 176), (48, 176), (47, 177), (48, 179), (48, 180), (49, 180), (40, 183), (53, 181), (52, 186), (56, 186), (55, 181), (58, 182), (58, 180), (61, 181), (63, 183), (63, 188), (67, 189), (67, 181), (61, 181), (62, 179), (66, 178), (63, 177), (61, 176), (61, 174), (57, 174), (59, 172), (58, 168), (61, 169), (62, 165), (63, 163), (67, 163), (67, 148), (65, 143), (63, 145), (64, 148), (63, 149), (63, 150), (65, 151), (64, 153), (62, 153), (62, 156), (61, 152), (59, 153), (58, 155), (56, 154), (58, 153), (58, 152), (52, 152), (53, 150), (55, 151), (57, 150), (55, 146), (49, 146), (48, 148), (47, 145), (46, 145), (45, 148), (43, 146), (41, 147), (40, 149), (39, 145), (38, 146), (37, 148), (33, 148), (35, 146), (32, 145), (35, 144), (36, 141), (37, 143), (38, 142), (39, 142), (39, 138), (41, 140), (45, 140), (45, 142), (47, 140), (49, 141), (51, 139), (55, 140), (56, 139), (62, 139), (63, 138), (65, 139), (65, 137), (63, 136), (67, 134), (67, 131), (65, 130), (63, 129), (64, 128), (67, 124), (66, 123), (61, 123), (60, 131), (59, 128), (57, 129), (56, 132), (55, 130), (52, 131), (51, 133), (50, 132), (51, 129), (54, 128), (50, 127), (49, 126), (45, 125), (42, 126), (40, 123), (38, 124), (39, 121), (40, 115), (41, 113), (42, 116), (44, 117), (48, 116), (49, 113), (50, 116), (52, 115), (52, 118), (56, 118), (56, 114), (58, 117), (59, 116), (62, 116), (62, 114), (64, 112), (65, 110), (64, 108), (62, 110), (60, 109), (64, 105), (59, 106), (60, 102), (56, 103), (55, 104), (54, 102), (50, 102), (52, 99), (53, 93), (55, 96), (57, 96), (58, 95), (64, 95), (63, 98), (66, 97), (66, 93), (64, 92), (65, 89), (64, 87), (67, 86), (67, 85), (65, 84), (66, 82), (65, 78), (64, 76), (63, 74), (67, 73), (65, 72), (60, 70), (63, 69), (61, 68), (57, 67), (60, 66), (56, 62), (55, 58), (57, 57), (58, 55), (59, 57), (60, 58), (61, 62), (63, 64), (64, 67), (66, 65), (67, 66), (69, 65), (69, 63), (68, 63), (68, 60), (66, 59), (67, 57), (69, 59), (70, 58), (68, 56), (68, 54), (66, 52), (67, 47), (70, 46), (69, 45), (66, 44), (69, 43), (69, 42), (66, 40), (69, 39), (68, 35), (67, 32), (70, 31), (68, 29), (68, 26), (69, 25), (68, 19), (70, 19), (67, 15), (69, 13), (69, 3)] ##TRANSLATE POINTS INTO REGION## Rgn = POINT * len(points) temp = [] for i in range(len(points)): temp.append(POINT(points[i][0], points[i][1])) out = Rgn(*temp) self.Region = wf.CreatePolygonRgn(out, len(out), wf.WINDING) ##DEFINE THE TARGET BOX## self.tboxUL = POINT(50, 80) self.tboxUR = POINT(wf.tile_w - 50, 80) self.tboxLL = POINT(50, wf.tile_h - 20) self.tboxLR = POINT(wf.tile_w - 50, wf.tile_h - 20) ##DEFINE REFERENCE POSITION## self.position = POINT(int(wf.tile_w / 2 - wf.tree1_w / 2), wf.tile_h - wf.tree1_h)
class Tree_Sprite_1: def __init__(self, hdc_main, file_path): ##Initialize hdc, and load image## tree_file = "Tree_1.bmp" self.hbmp = wf.LoadImage( c_void_p(), LPCWSTR(file_path + tree_file), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) self.hdc = windll.gdi32.CreateCompatibleDC( hdc_main) #Make hdc similar to the reference hdc windll.gdi32.SelectObject(self.hdc, self.hbmp) #Copy image into hdc self.button = Button(hdc_main, file_path, "red") #Load Button ##LOAD REGION## points = [(70, 1), (71, 2), (72, 10), (71, 13), (72, 15), (72, 27), (73, 28), (73, 29), (72, 39), (74, 43), (74, 48), (77, 47), (80, 47), (81, 49), (81, 51), (79, 53), (78, 54), (75, 54), (75, 56), (73, 57), (72, 57), (72, 59), (74, 59), (74, 67), (75, 68), (74, 71), (76, 72), (74, 75), (75, 76), (75, 78), (77, 79), (75, 83), (73, 86), (78, 86), (79, 89), (81, 87), (81, 84), (78, 84), (81, 81), (81, 78), (83, 77), (86, 77), (88, 75), (89, 76), (90, 79), (90, 82), (88, 84), (88, 95), (89, 94), (90, 92), (91, 96), (93, 96), (94, 98), (92, 99), (91, 104), (90, 102), (89, 102), (87, 105), (82, 105), (81, 107), (80, 108), (77, 108), (76, 109), (74, 108), (74, 123), (76, 121), (78, 125), (79, 125), (80, 124), (83, 122), (82, 126), (87, 124), (89, 123), (91, 124), (94, 122), (97, 123), (98, 129), (97, 130), (96, 130), (94, 128), (92, 128), (92, 129), (94, 133), (92, 133), (91, 131), (90, 132), (90, 134), (91, 137), (89, 136), (87, 137), (83, 136), (82, 136), (80, 134), (78, 133), (76, 132), (75, 133), (76, 134), (78, 135), (79, 139), (78, 139), (78, 141), (76, 143), (77, 144), (74, 145), (74, 163), (76, 164), (76, 166), (78, 163), (80, 163), (81, 161), (82, 162), (84, 163), (85, 163), (86, 163), (88, 164), (89, 162), (89, 155), (87, 153), (88, 153), (91, 153), (92, 151), (96, 152), (99, 153), (95, 157), (99, 158), (101, 159), (105, 160), (104, 161), (104, 166), (100, 168), (97, 168), (95, 169), (91, 171), (86, 172), (85, 173), (82, 173), (83, 174), (83, 176), (85, 178), (85, 181), (86, 182), (84, 183), (82, 183), (80, 185), (79, 183), (77, 182), (78, 181), (78, 178), (77, 179), (76, 181), (74, 180), (74, 196), (75, 197), (74, 198), (77, 199), (75, 201), (77, 202), (79, 204), (78, 205), (77, 208), (74, 212), (76, 213), (78, 212), (79, 209), (82, 208), (83, 205), (84, 203), (85, 206), (87, 204), (88, 203), (89, 200), (91, 200), (91, 197), (87, 196), (86, 194), (86, 192), (83, 191), (84, 190), (87, 191), (89, 189), (90, 187), (92, 188), (98, 191), (94, 191), (95, 186), (97, 180), (98, 177), (100, 178), (100, 180), (101, 180), (104, 177), (104, 179), (103, 184), (104, 191), (100, 187), (99, 190), (99, 193), (101, 193), (99, 196), (99, 200), (100, 202), (105, 202), (107, 200), (112, 200), (115, 206), (111, 206), (109, 208), (106, 209), (107, 211), (110, 212), (111, 213), (113, 214), (114, 219), (116, 218), (117, 222), (118, 225), (112, 224), (112, 222), (108, 221), (108, 219), (106, 220), (104, 226), (101, 225), (101, 224), (95, 221), (98, 220), (99, 217), (101, 216), (102, 213), (99, 212), (96, 211), (95, 212), (91, 214), (88, 216), (88, 217), (84, 217), (83, 219), (80, 220), (82, 221), (80, 223), (79, 225), (76, 226), (74, 223), (74, 236), (78, 235), (80, 235), (81, 234), (83, 236), (84, 238), (83, 239), (83, 241), (84, 242), (83, 244), (81, 242), (80, 243), (79, 245), (78, 245), (77, 246), (80, 247), (83, 247), (82, 248), (83, 249), (82, 251), (83, 252), (79, 253), (79, 254), (80, 254), (83, 257), (84, 255), (91, 255), (93, 256), (96, 255), (97, 254), (98, 255), (99, 255), (100, 254), (101, 255), (103, 253), (105, 255), (108, 254), (107, 253), (109, 252), (111, 247), (112, 245), (113, 246), (115, 244), (116, 246), (117, 245), (118, 248), (119, 249), (118, 252), (119, 253), (124, 252), (124, 253), (126, 257), (124, 258), (123, 259), (120, 259), (120, 261), (117, 261), (116, 262), (112, 263), (112, 264), (114, 264), (113, 267), (111, 265), (111, 266), (109, 268), (107, 264), (106, 267), (105, 266), (105, 264), (104, 264), (103, 266), (101, 266), (101, 264), (95, 264), (94, 265), (93, 264), (91, 264), (87, 263), (87, 268), (88, 269), (85, 272), (83, 272), (82, 274), (80, 272), (79, 274), (78, 275), (79, 278), (81, 278), (83, 277), (86, 276), (87, 277), (91, 277), (91, 273), (93, 274), (93, 272), (95, 271), (96, 271), (99, 271), (99, 273), (103, 273), (104, 272), (106, 272), (106, 274), (110, 275), (111, 274), (112, 275), (112, 278), (113, 279), (112, 280), (109, 279), (109, 282), (102, 281), (102, 284), (101, 285), (96, 282), (94, 282), (94, 284), (91, 285), (90, 285), (89, 284), (87, 283), (87, 285), (85, 286), (83, 288), (85, 289), (84, 290), (84, 293), (79, 294), (77, 296), (77, 299), (80, 297), (87, 295), (95, 294), (96, 293), (99, 293), (102, 292), (104, 292), (105, 291), (109, 290), (110, 289), (113, 289), (115, 291), (116, 290), (117, 293), (127, 293), (128, 294), (132, 293), (134, 295), (136, 291), (137, 292), (136, 296), (137, 299), (136, 300), (135, 299), (135, 298), (134, 298), (134, 302), (133, 302), (132, 301), (131, 301), (130, 303), (129, 300), (125, 302), (124, 303), (123, 305), (122, 302), (119, 305), (118, 302), (116, 302), (115, 306), (114, 303), (112, 306), (110, 305), (108, 303), (107, 306), (100, 305), (99, 303), (98, 303), (96, 305), (95, 305), (93, 303), (92, 305), (90, 305), (89, 303), (88, 303), (87, 306), (83, 306), (80, 304), (80, 306), (76, 306), (76, 328), (78, 331), (80, 333), (80, 335), (82, 335), (68, 339), (66, 339), (57, 336), (58, 335), (59, 333), (60, 332), (61, 330), (62, 329), (64, 329), (65, 328), (65, 298), (63, 296), (62, 298), (59, 299), (53, 299), (52, 300), (50, 300), (45, 301), (44, 302), (43, 305), (41, 306), (40, 308), (37, 309), (36, 313), (35, 310), (31, 310), (31, 309), (33, 307), (32, 306), (35, 303), (34, 302), (34, 299), (31, 299), (31, 301), (27, 301), (26, 303), (25, 302), (23, 301), (22, 304), (20, 302), (19, 304), (16, 304), (15, 305), (15, 307), (14, 308), (10, 308), (6, 306), (9, 305), (8, 304), (9, 303), (11, 303), (12, 300), (8, 300), (6, 302), (5, 300), (2, 301), (0, 300), (0, 297), (3, 294), (4, 295), (9, 295), (10, 294), (10, 293), (8, 289), (9, 288), (10, 284), (11, 288), (15, 287), (19, 285), (19, 281), (20, 280), (22, 280), (23, 278), (24, 280), (26, 281), (26, 286), (29, 289), (29, 290), (30, 291), (31, 291), (32, 289), (34, 288), (35, 292), (38, 291), (39, 290), (42, 293), (43, 292), (55, 291), (63, 288), (62, 287), (62, 285), (63, 284), (63, 282), (61, 282), (60, 283), (59, 282), (59, 280), (57, 278), (56, 278), (56, 280), (53, 281), (52, 282), (51, 281), (46, 281), (44, 283), (43, 281), (40, 277), (39, 279), (37, 277), (36, 279), (34, 277), (33, 281), (32, 280), (31, 283), (30, 280), (29, 280), (27, 278), (27, 274), (29, 276), (30, 274), (32, 276), (33, 273), (34, 272), (35, 269), (37, 270), (42, 269), (43, 267), (39, 266), (45, 266), (46, 264), (48, 266), (51, 266), (50, 270), (54, 270), (54, 271), (58, 273), (60, 271), (59, 269), (62, 268), (62, 267), (60, 265), (59, 262), (55, 264), (56, 259), (59, 260), (59, 255), (55, 256), (53, 258), (54, 260), (53, 262), (49, 263), (46, 262), (42, 261), (43, 258), (38, 259), (31, 259), (30, 264), (26, 266), (25, 266), (24, 268), (22, 267), (20, 261), (17, 261), (14, 262), (13, 260), (12, 261), (11, 263), (6, 262), (8, 260), (6, 259), (8, 258), (8, 257), (7, 254), (10, 255), (11, 252), (12, 255), (14, 256), (15, 253), (19, 253), (25, 252), (26, 251), (26, 250), (24, 249), (26, 249), (27, 245), (26, 244), (33, 244), (31, 250), (33, 250), (33, 251), (37, 250), (38, 249), (39, 247), (40, 250), (45, 251), (46, 249), (43, 247), (44, 246), (52, 245), (54, 246), (52, 247), (54, 248), (55, 249), (59, 249), (61, 248), (63, 247), (65, 247), (65, 244), (63, 244), (62, 246), (60, 245), (61, 244), (59, 244), (58, 246), (57, 244), (52, 244), (52, 245), (47, 246), (45, 245), (45, 242), (44, 243), (39, 241), (34, 241), (32, 243), (30, 242), (31, 241), (29, 241), (27, 243), (26, 241), (20, 239), (18, 240), (15, 241), (15, 239), (13, 239), (13, 238), (11, 237), (14, 236), (12, 235), (13, 233), (15, 234), (16, 231), (20, 232), (20, 234), (23, 234), (24, 232), (26, 235), (29, 235), (30, 233), (31, 235), (34, 236), (36, 234), (37, 237), (38, 232), (39, 236), (40, 233), (42, 235), (46, 233), (49, 236), (51, 235), (55, 237), (56, 239), (58, 234), (60, 235), (60, 237), (61, 236), (66, 237), (67, 229), (66, 229), (64, 231), (61, 230), (59, 232), (58, 230), (57, 231), (56, 229), (51, 229), (52, 227), (47, 226), (40, 229), (42, 226), (43, 226), (43, 225), (39, 224), (40, 223), (41, 221), (42, 222), (43, 220), (46, 222), (47, 218), (49, 219), (51, 220), (56, 221), (61, 222), (61, 219), (57, 218), (55, 217), (60, 216), (61, 214), (67, 215), (67, 209), (61, 208), (59, 206), (60, 202), (63, 202), (63, 198), (67, 198), (67, 193), (64, 195), (57, 196), (56, 198), (59, 199), (59, 201), (57, 204), (54, 204), (54, 202), (53, 201), (52, 204), (51, 204), (50, 202), (47, 201), (46, 199), (44, 200), (43, 202), (41, 201), (40, 204), (39, 203), (35, 206), (34, 203), (33, 205), (30, 205), (30, 208), (28, 207), (30, 204), (28, 203), (29, 201), (32, 201), (32, 199), (36, 200), (36, 196), (38, 197), (40, 196), (42, 196), (42, 195), (43, 195), (45, 194), (46, 193), (48, 193), (49, 191), (48, 189), (44, 191), (43, 190), (39, 190), (39, 189), (36, 189), (33, 188), (30, 189), (28, 188), (24, 186), (25, 184), (25, 182), (29, 182), (30, 181), (32, 182), (34, 182), (34, 184), (37, 183), (42, 183), (42, 179), (40, 178), (41, 174), (39, 173), (43, 172), (44, 169), (50, 168), (48, 169), (46, 170), (44, 176), (48, 176), (47, 177), (48, 179), (48, 180), (49, 180), (40, 183), (53, 181), (52, 186), (56, 186), (55, 181), (58, 182), (58, 180), (61, 181), (63, 183), (63, 188), (67, 189), (67, 181), (61, 181), (62, 179), (66, 178), (63, 177), (61, 176), (61, 174), (57, 174), (59, 172), (58, 168), (61, 169), (62, 165), (63, 163), (67, 163), (67, 148), (65, 143), (63, 145), (64, 148), (63, 149), (63, 150), (65, 151), (64, 153), (62, 153), (62, 156), (61, 152), (59, 153), (58, 155), (56, 154), (58, 153), (58, 152), (52, 152), (53, 150), (55, 151), (57, 150), (55, 146), (49, 146), (48, 148), (47, 145), (46, 145), (45, 148), (43, 146), (41, 147), (40, 149), (39, 145), (38, 146), (37, 148), (33, 148), (35, 146), (32, 145), (35, 144), (36, 141), (37, 143), (38, 142), (39, 142), (39, 138), (41, 140), (45, 140), (45, 142), (47, 140), (49, 141), (51, 139), (55, 140), (56, 139), (62, 139), (63, 138), (65, 139), (65, 137), (63, 136), (67, 134), (67, 131), (65, 130), (63, 129), (64, 128), (67, 124), (66, 123), (61, 123), (60, 131), (59, 128), (57, 129), (56, 132), (55, 130), (52, 131), (51, 133), (50, 132), (51, 129), (54, 128), (50, 127), (49, 126), (45, 125), (42, 126), (40, 123), (38, 124), (39, 121), (40, 115), (41, 113), (42, 116), (44, 117), (48, 116), (49, 113), (50, 116), (52, 115), (52, 118), (56, 118), (56, 114), (58, 117), (59, 116), (62, 116), (62, 114), (64, 112), (65, 110), (64, 108), (62, 110), (60, 109), (64, 105), (59, 106), (60, 102), (56, 103), (55, 104), (54, 102), (50, 102), (52, 99), (53, 93), (55, 96), (57, 96), (58, 95), (64, 95), (63, 98), (66, 97), (66, 93), (64, 92), (65, 89), (64, 87), (67, 86), (67, 85), (65, 84), (66, 82), (65, 78), (64, 76), (63, 74), (67, 73), (65, 72), (60, 70), (63, 69), (61, 68), (57, 67), (60, 66), (56, 62), (55, 58), (57, 57), (58, 55), (59, 57), (60, 58), (61, 62), (63, 64), (64, 67), (66, 65), (67, 66), (69, 65), (69, 63), (68, 63), (68, 60), (66, 59), (67, 57), (69, 59), (70, 58), (68, 56), (68, 54), (66, 52), (67, 47), (70, 46), (69, 45), (66, 44), (69, 43), (69, 42), (66, 40), (69, 39), (68, 35), (67, 32), (70, 31), (68, 29), (68, 26), (69, 25), (68, 19), (70, 19), (67, 15), (69, 13), (69, 3)] ##TRANSLATE POINTS INTO REGION## Rgn = POINT * len(points) temp = [] for i in range(len(points)): temp.append(POINT(points[i][0], points[i][1])) out = Rgn(*temp) self.Region = wf.CreatePolygonRgn(out, len(out), wf.WINDING) ##DEFINE THE TARGET BOX## self.tboxUL = POINT(50, 80) self.tboxUR = POINT(wf.tile_w - 50, 80) self.tboxLL = POINT(50, wf.tile_h - 20) self.tboxLR = POINT(wf.tile_w - 50, wf.tile_h - 20) ##DEFINE REFERENCE POSITION## self.position = POINT(int(wf.tile_w / 2 - wf.tree1_w / 2), wf.tile_h - wf.tree1_h) def Target_box(self, x_shift, y_shift, number=None): ##Return the shifted target box shiftedboxUL = POINT(self.tboxUL.x + x_shift, self.tboxUL.y + y_shift) shiftedboxUR = POINT(self.tboxUR.x + x_shift, self.tboxUR.y + y_shift) shiftedboxLL = POINT(self.tboxLL.x + x_shift, self.tboxLL.y + y_shift) shiftedboxLR = POINT(self.tboxLR.x + x_shift, self.tboxLR.y + y_shift) return [shiftedboxUL, shiftedboxUR, shiftedboxLL, shiftedboxLR] def Draw(self, hdc, object_string, x_shift, y_shift, Player): ##IF TILE NEEDS OBJECT THEN ADD## text = ["E", "9"] if object_string[2] == "T": ##Shift the reference position to desired tile position_new = POINT(self.position.x + x_shift, self.position.y + y_shift) ##Copy Object onto tile windll.gdi32.OffsetRgn( self.Region, position_new) ##Shift the region to draw the tree windll.gdi32.SelectClipRgn( hdc, self.Region) ##Select the shifted region for copying the tree windll.gdi32.BitBlt(hdc, position_new, wf.tree1_w, wf.tree1_h, self.hdc, 0, 0, wf.SRCCOPY) ##Add tree to background ##Reset class object and hdc windll.gdi32.SelectClipRgn(hdc, None) ##Remove Clipping Region windll.gdi32.OffsetRgn(self.Region, -position_new.x, -position_new.y) ##Return the region back ##CHECK TO SEE IF BUTTON NEEDS TO BE DRAWN## if object_string[ 4] == "B" and Player.Tool_selection == wf.Axe and Player.Character[ 0] == object_string[5]: ##Position the button## position_new.x = position_new.x + int(wf.tile_w / 2) position_new.y = position_new.y + wf.tile_h - 40 ##DRAW BUTTON## self.button.Draw_Button(hdc, position_new.x, position_new.y, text[int(Player.Character[0])]) ##Return 1 if button was drawn return 1 else: ##Return 0 if object was drawn return 0 else: ##Return -1 if nothing was drawn return -1
def __init__(self, hdc_main, file_path): ##Initialize hdc, and load image## Wheat_Stalk_file = "Wheat_Stalk1.bmp" Tile_file = "Grass_1.bmp" #"Temp_background.bmp" self.stalk_hbmp = wf.LoadImage( c_void_p(), LPCWSTR(file_path + Wheat_Stalk_file), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) self.hbmp = wf.LoadImage( c_void_p(), LPCWSTR(file_path + Tile_file), #Load tile image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) self.hdc = windll.gdi32.CreateCompatibleDC( hdc_main) #Make hdc similar to the reference hdc self.stalk_hdc = windll.gdi32.CreateCompatibleDC( hdc_main) #Make hdc similar to the reference hdc windll.gdi32.SelectObject(self.hdc, self.hbmp) #Copy image into hdc windll.gdi32.SelectObject(self.stalk_hdc, self.stalk_hbmp) #Copy image into hdc self.button = Button(hdc_main, file_path, "red") #Load Button ##LOAD REGION## points = [(26, 200), (24, 193), (22, 191), (21, 191), (21, 189), (19, 189), (18, 188), (16, 188), (9, 186), (5, 185), (3, 185), (2, 184), (2, 183), (11, 183), (12, 184), (14, 184), (19, 186), (21, 188), (21, 180), (20, 176), (19, 172), (18, 169), (17, 166), (12, 166), (12, 167), (8, 167), (8, 169), (6, 171), (6, 172), (5, 172), (5, 171), (7, 169), (7, 166), (8, 165), (15, 165), (16, 166), (17, 165), (13, 158), (14, 158), (16, 160), (11, 138), (9, 138), (4, 143), (4, 144), (3, 144), (2, 145), (2, 148), (1, 147), (4, 139), (4, 137), (6, 135), (10, 135), (9, 133), (8, 129), (7, 124), (7, 120), (4, 120), (4, 116), (3, 115), (3, 112), (2, 111), (4, 111), (4, 110), (3, 109), (3, 108), (2, 107), (3, 106), (2, 105), (2, 102), (3, 101), (2, 100), (5, 100), (5, 101), (6, 102), (6, 104), (7, 105), (7, 106), (8, 108), (8, 109), (7, 110), (9, 112), (10, 120), (9, 121), (9, 122), (22, 173), (22, 170), (22, 165), (23, 165), (13, 85), (10, 84), (10, 83), (9, 76), (8, 75), (10, 75), (10, 74), (9, 73), (9, 72), (8, 71), (9, 70), (8, 69), (8, 66), (9, 65), (8, 64), (11, 64), (12, 68), (13, 69), (12, 70), (14, 72), (14, 73), (13, 74), (15, 76), (16, 84), (15, 85), (16, 99), (17, 100), (20, 100), (21, 94), (22, 94), (22, 99), (21, 100), (21, 103), (20, 104), (17, 105), (17, 106), (18, 107), (26, 172), (27, 171), (27, 165), (28, 164), (28, 162), (27, 161), (26, 152), (27, 147), (28, 156), (29, 156), (29, 122), (25, 122), (23, 124), (22, 124), (22, 121), (21, 121), (21, 119), (22, 119), (23, 118), (29, 118), (29, 72), (25, 68), (24, 68), (24, 67), (20, 63), (20, 62), (18, 60), (18, 59), (15, 56), (14, 56), (14, 55), (12, 55), (12, 54), (16, 54), (21, 56), (21, 57), (23, 59), (24, 59), (25, 60), (25, 62), (27, 64), (27, 66), (29, 66), (29, 30), (28, 30), (27, 29), (27, 20), (28, 19), (27, 18), (27, 16), (28, 15), (27, 14), (27, 12), (28, 11), (28, 9), (31, 9), (31, 10), (32, 11), (32, 19), (33, 20), (33, 29), (31, 31), (31, 87), (34, 84), (34, 83), (38, 79), (42, 78), (44, 78), (44, 79), (42, 79), (41, 80), (38, 81), (38, 84), (34, 88), (34, 89), (32, 91), (32, 96), (31, 97), (31, 109), (34, 109), (34, 110), (33, 111), (32, 111), (31, 173), (34, 170), (42, 118), (39, 118), (38, 117), (36, 116), (36, 115), (34, 112), (36, 111), (40, 115), (43, 115), (51, 60), (51, 50), (53, 48), (53, 44), (54, 43), (55, 39), (57, 39), (57, 41), (58, 42), (58, 43), (56, 45), (57, 46), (57, 48), (56, 48), (55, 49), (56, 50), (57, 50), (56, 59), (53, 60), (47, 101), (50, 98), (57, 98), (57, 99), (52, 100), (52, 101), (51, 102), (50, 102), (46, 106), (45, 109), (42, 132), (45, 132), (47, 130), (52, 130), (52, 132), (49, 133), (46, 133), (45, 134), (41, 135), (36, 171), (37, 170), (38, 167), (39, 166), (39, 168), (41, 170), (42, 169), (54, 138), (56, 136), (55, 135), (55, 132), (57, 127), (57, 126), (58, 125), (60, 125), (60, 121), (61, 120), (60, 119), (61, 118), (61, 117), (63, 117), (64, 115), (64, 114), (67, 114), (67, 118), (65, 120), (64, 125), (64, 129), (63, 129), (62, 132), (62, 134), (57, 135), (56, 136), (57, 137), (48, 161), (57, 161), (57, 164), (58, 164), (58, 165), (56, 165), (56, 164), (55, 163), (51, 163), (51, 164), (46, 164), (41, 175), (41, 183), (47, 182), (56, 182), (56, 183), (54, 183), (41, 186), (40, 188), (37, 195), (36, 196), (36, 199)] ##TRANSLATE POINTS INTO REGION## Rgn = POINT * len(points) temp = [] for i in range(len(points)): temp.append(POINT(points[i][0], points[i][1])) out = Rgn(*temp) self.number_of_stalks = 12 self.spacing_x = [0, 20, 40, 60, 80, 100, 0, 20, 40, 60, 80, 100] self.spacing_y = [0, 0, 0, 0, 0, 0, 120, 120, 120, 120, 120, 120] self.Single_Region = wf.CreatePolygonRgn(out, len(out), wf.WINDING) self.Region = wf.CreatePolygonRgn(out, len(out), wf.WINDING) self.Temp_Region = [ wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING), wf.CreatePolygonRgn(out, len(out), wf.WINDING) ] ##Combine Shifted Regions## for i in range(self.number_of_stalks): position = POINT(self.spacing_x[i], self.spacing_y[i]) ##Create Regions for making image windll.gdi32.OffsetRgn(self.Temp_Region[i], position) ##Copy Object onto tile windll.gdi32.OffsetRgn(self.Single_Region, position) windll.gdi32.CombineRgn(self.Region, self.Region, self.Single_Region, wf.RGN_OR) windll.gdi32.OffsetRgn(self.Single_Region, -position.x, -position.y) ##DEFINE REFERENCE POSITION## self.position = POINT(int(wf.tile_w / 2 - wf.tree1_w / 2), wf.tile_h - wf.tree1_h) for i in range(self.number_of_stalks): ##Shift the reference position to desired tile position_new = POINT() #POINT(self.position.x,self.position.y) ##Copy Object onto tile windll.gdi32.OffsetRgn( self.Temp_Region[i], position_new) ##Shift the region to draw the tree windll.gdi32.SelectClipRgn( self.hdc, self.Temp_Region[i] ) ##Select the shifted region for copying the tree windll.gdi32.BitBlt(self.hdc, position_new.x + self.spacing_x[i], position_new.y + self.spacing_y[i], wf.tree1_w, wf.tree1_h, self.stalk_hdc, 0, 0, wf.SRCCOPY) ##Add tree to background ##Reset class object and hdc windll.gdi32.SelectClipRgn(self.hdc, None) ##Remove Clipping Region windll.gdi32.OffsetRgn(self.Temp_Region[i], -position_new.x, -position_new.y) ##Return the region back ##DEFINE THE TARGET BOX## self.tboxUL = POINT(10, 10) self.tboxUR = POINT(wf.tile_w - 10, 10) self.tboxLL = POINT(10, wf.tile_h - 10) self.tboxLR = POINT(wf.tile_w - 10, wf.tile_h - 10)
class Barrel_Sprite_1: def __init__(self, hdc_main, file_path): ##Initialize hdc, and load image## barrel_file = "Wheat_Barrel.bmp" self.hbmp = wf.LoadImage( c_void_p(), LPCWSTR(file_path + barrel_file), #Load image wf.IMAGE_BITMAP, 0, 0, 8192 | wf.LR_DEFAULTSIZE | wf.LR_LOADFROMFILE) self.hdc = windll.gdi32.CreateCompatibleDC( hdc_main) #Make hdc similar to the reference hdc windll.gdi32.SelectObject(self.hdc, self.hbmp) #Copy image into hdc self.button = Button(hdc_main, file_path, "red") #Load Button self.out_of_bounds = False ##Change to False when finished self.Amount = 0 self.Character = "W" ##LOAD REGIONS## points = [(102, 155), (17, 155), (15, 150), (13, 148), (13, 147), (11, 142), (10, 141), (10, 140), (8, 135), (8, 134), (7, 133), (7, 130), (5, 130), (4, 127), (3, 124), (2, 118), (3, 118), (2, 108), (1, 107), (0, 90), (0, 82), (1, 69), (2, 61), (3, 56), (3, 54), (2, 54), (3, 49), (4, 45), (5, 42), (7, 42), (7, 40), (8, 37), (9, 35), (10, 32), (11, 30), (12, 28), (13, 25), (14, 23), (15, 21), (16, 19), (103, 19), (104, 21), (105, 23), (106, 25), (107, 28), (108, 30), (109, 32), (110, 35), (111, 38), (112, 40), (112, 42), (114, 42), (115, 45), (116, 48), (117, 52), (117, 54), (116, 54), (117, 62), (118, 70), (119, 80), (119, 94), (118, 104), (117, 112), (116, 118), (117, 118), (116, 124), (115, 127), (114, 130), (112, 130), (112, 132), (111, 135), (110, 138), (109, 140), (108, 143), (107, 145), (106, 147), (105, 150), (104, 151), (103, 152)] ##TRANSLATE POINTS INTO REGION## Rgn = POINT * len(points) temp = [] for i in range(len(points)): temp.append(POINT(points[i][0], points[i][1])) out = Rgn(*temp) self.Region = wf.CreatePolygonRgn(out, len(out), wf.WINDING) ##DEFINE THE TARGET BOX## self.tboxUL = POINT(50, 80) self.tboxUR = POINT(wf.tile_w - 50, 80) self.tboxLL = POINT(50, wf.tile_h - 20) self.tboxLR = POINT(wf.tile_w - 50, wf.tile_h - 20) ##DEFINE REFERENCE POSITION## self.position = POINT( int(wf.tile_w / 2 - wf.tree1_w / 2) + 600, wf.tile_h - wf.tree1_h + 900) self.tile_position = (int(self.position.x / wf.tile_w), int(self.position.y / wf.tile_h) ) ##Define tile position def Update_Position(self, shiftx, shifty): self.position = POINT(shiftx, shifty) self.tile_position = (int(self.position.x / wf.tile_w), int(self.position.y / wf.tile_h) ) ##Define tile position return 0 def Fill_barrel(self, Player, amount): ##Remove wheat from player resource and add to the barrel## if Player.resource["Wheat"] >= amount: self.Amount = self.Amount + amount Player.resource["Wheat"] = Player.resource["Wheat"] - amount return 0 ##If attempting to add more resources than the player has return -1 def Empty_barrel(self, Player, amount): ##Remove wheat from player resource and add to the barrel## if self.Amount >= amount: self.Amount = self.Amount - amount Player.resource["Wheat"] = Player.resource["Wheat"] + amount return 0 ##If attempting to remove more resources than are in the barrel return -1 def Target_box_Shifted(self, x_shift, y_shift, number=None): ##Return the shifted target box shiftedboxUL = POINT(self.tboxUL.x + x_shift, self.tboxUL.y + y_shift) shiftedboxUR = POINT(self.tboxUR.x + x_shift, self.tboxUR.y + y_shift) shiftedboxLL = POINT(self.tboxLL.x + x_shift, self.tboxLL.y + y_shift) shiftedboxLR = POINT(self.tboxLR.x + x_shift, self.tboxLR.y + y_shift) return [shiftedboxUL, shiftedboxUR, shiftedboxLL, shiftedboxLR] def Target_box(self, changex=None, changey=None, Type=None): if self.out_of_bounds == True: return [POINT(0, 0), POINT(0, 0), POINT(0, 0), POINT(0, 0)] ##Return the shifted target box x_shift = self.position.x y_shift = self.position.y shiftedboxUL = POINT(self.tboxUL.x + x_shift, self.tboxUL.y + y_shift) shiftedboxUR = POINT(self.tboxUR.x + x_shift, self.tboxUR.y + y_shift) shiftedboxLL = POINT(self.tboxLL.x + x_shift, self.tboxLL.y + y_shift) shiftedboxLR = POINT(self.tboxLR.x + x_shift, self.tboxLR.y + y_shift) return [shiftedboxUL, shiftedboxUR, shiftedboxLL, shiftedboxLR] def Draw(self, hdc, object_string, reference_tile, Player): if self.out_of_bounds == True: return -1 text = ["E", "9"] ##Copy Object onto tile position_new = POINT(self.position.x - reference_tile.x * wf.tile_w, self.position.y - reference_tile.y * wf.tile_h) windll.gdi32.OffsetRgn( self.Region, position_new) ##Shift the region to draw the barrel windll.gdi32.SelectClipRgn( hdc, self.Region) ##Select the shifted region for copying the barrel windll.gdi32.BitBlt(hdc, position_new, wf.barrel1_w, wf.barrel1_h, self.hdc, 0, 0, wf.SRCCOPY) ##Add tree to background ##Reset class object and hdc windll.gdi32.SelectClipRgn(hdc, None) ##Remove Clipping Region windll.gdi32.OffsetRgn(self.Region, -position_new.x, -position_new.y) ##Return the region back ##CHECK TO SEE IF BUTTON NEEDS TO BE DRAWN## if object_string[ 4] == "B" and Player.Tool_selection == wf.Axe and Player.Character[ 0] == object_string[5]: ##Position the button## position_new = POINT() position_new.x = position_new.x + int(wf.tile_w / 2) position_new.y = position_new.y + wf.tile_h - 40 ##DRAW BUTTON## self.button.Draw_Button(hdc, position_new.x, position_new.y, text[int(Player.Character[0])]) ##Return 1 if button was drawn return 1 else: ##Return 0 if object was drawn return 0