comparison orpg/mapper/grid.py @ 71:449a8900f9ac ornery-dev

Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
author sirebral
date Thu, 20 Aug 2009 03:00:39 -0500
parents 072ffc1d466f
children 54446a995007 6081bdc2b8d5
comparison
equal deleted inserted replaced
70:52a5fa913008 71:449a8900f9ac
105 x = topLeft.x + ((self.unit_size - mini_width) / 2) 105 x = topLeft.x + ((self.unit_size - mini_width) / 2)
106 y = topLeft.y + ((self.unit_size_y - mini_height) /2) 106 y = topLeft.y + ((self.unit_size_y - mini_height) /2)
107 else: 107 else:
108 x = topLeft.x 108 x = topLeft.x
109 y = topLeft.y 109 y = topLeft.y
110 return cmpPoint(int(x),int(y)) # Set the pos attribute 110 return cmpPoint(int(x),int(y)) # Set the pos attribute
111 else: return cmpPoint(int(pos.x),int(pos.y)) 111 else: return cmpPoint(int(pos.x),int(pos.y))
112 112
113 def set_rect_mode(self): 113 def set_rect_mode(self):
114 "switch grid to rectangular mode" 114 "switch grid to rectangular mode"
115 self.mode = GRID_RECTANGLE 115 self.mode = GRID_RECTANGLE
207 # this is at grid co-ordinate (0, height/2) 207 # this is at grid co-ordinate (0, height/2)
208 # the top corner of the first diamond is grid co-ord (width/2, 0) 208 # the top corner of the first diamond is grid co-ord (width/2, 0)
209 # and therefore (per transformation above) is at iso co-ord (iso_unit_size, 0) 209 # and therefore (per transformation above) is at iso co-ord (iso_unit_size, 0)
210 # the bottom corner of the first diamond is grid co-ord (width/2, height) 210 # the bottom corner of the first diamond is grid co-ord (width/2, height)
211 # and therefore (per transformation above) is at iso co-ord (0, iso_unit_size) 211 # and therefore (per transformation above) is at iso co-ord (0, iso_unit_size)
212
213 # the calculation is now as simple as the rectangle case, but using iso co-ords 212 # the calculation is now as simple as the rectangle case, but using iso co-ords
214 return cmpPoint(floor(iso_x/iso_unit_size), floor(iso_y/iso_unit_size)) 213 return cmpPoint(floor(iso_x/iso_unit_size), floor(iso_y/iso_unit_size))
215 else: return None 214 else: return None
216 215
217 def get_top_corner_iso(self, iso_pos): 216 def get_top_corner_iso(self, iso_pos):