def draw_gridpts(self): cursorloc = self.nearest(tpl.tdiff(pg.mouse.get_pos(), self.sc_loc)) for y in range(self.shape[1]): for x in range(self.shape[0]): #z = self.grid_xy((x,y)).height()-1 tile_loc = tpl.tsum(self.sc_loc, self.grid_xy((x,y)).loc_px) if (x,y) == cursorloc: gameDisplay.blit(self.marker_red, tpl.tdiff(tile_loc, (6,1))) else: gameDisplay.blit(self.marker_yellow, tpl.tdiff(tile_loc, (6,1)))
def draw(self): #Update current pixel position if not self.path: self.loc_px = self.hexgrid.grid_xy(self.loc_xy).loc_px #Update animation frames self.animsubframe += 1 if self.animsubframe >= 6: self.animsubframe = 0 self.animframe += 1 if self.animframe >= self.animattr[self.animset][1]: self.animframe = 0 #Update location (jump) if self.jump: if len(self.jump) > 1: if self.jump[0] == self.jump[1]: self.animset = "crouch" self.animframe = 0 else: self.animset = "stand" if self.loc_xy != self.path[0] and self.jump[1][1] < self.jump[0][1]: self.loc_xy = self.path[0] self.loc_px = self.jump[0] self.jump = self.jump[1:] if not self.jump: self.path = self.path[1:] #Update location (walk/run) else: mvmt = self.mvspd while mvmt > 0 and self.path and not self.jump: dh = self.hexgrid.height_diff(self.loc_xy, self.path[0]) if self.path and m.fabs(dh) >= 2: if dh <= -2: self.jump = self.hexgrid.jump(self.loc_xy, self.path[0]) if dh >= 2: self.jump = self.hexgrid.jump(self.path[0], self.loc_xy)[::-1] break self.animset = "stand" self.loc_xy = self.path[0] #print(self.path) dist_wp = tpl.tdist(self.loc_px, self.hexgrid.grid_xy(self.path[0]).loc_px) if dist_wp <= mvmt: self.loc_px = self.hexgrid.grid_xy(self.path[0]).loc_px self.path = self.path[1:] mvmt -= dist_wp else: self.loc_px = tpl.tsum(self.loc_px, tpl.tmult(tpl.tdir(self.loc_px, self.hexgrid.grid_xy(self.path[0]).loc_px), self.mvspd)) mvmt = 0 #If not moving, reset to stand anim if not self.path and not self.jump: self.animset = "stand" #Blit pawn to display self.pawn.fill(pg.Color(0,0,0,0)) self.pawn.blit(self.pawnsheet, (0,0), (self.pawndim[0]*self.animframe, self.pawndim[1]*self.animattr[self.animset][0], self.pawndim[0], self.pawndim[1])) gameDisplay.blit(self.pawn, tpl.tsum(tpl.tdiff(self.loc_px, (self.pawndim[0]/2+3,101)), self.hexgrid.sc_loc))
def draw_highlight(self, loc_xy, color): loc_px = tpl.tdiff(tpl.tsum(self.grid_xy(loc_xy).loc_px, self.sc_loc), (33, 10)) gameDisplay.blit(self.highlight[color], loc_px)
def draw_cursor_mini(self, loc_xy): loc_px = tpl.tdiff(tpl.tsum(self.grid_xy(loc_xy).loc_px, self.sc_loc), (16, 3)) gameDisplay.blit(self.cursor_mini, loc_px)
def draw_cursor(self, loc_xy): loc_px = tpl.tdiff(tpl.tsum(self.grid_xy(loc_xy).loc_px, self.sc_loc), (33, 10)) gameDisplay.blit(self.cursor, loc_px)
def nearest_mouse(self): return self.nearest(tpl.tdiff(pg.mouse.get_pos(), self.sc_loc))