Added a method to interfaces.Map to get the neighbours of a given tile
This commit is contained in:
		@@ -5,6 +5,7 @@ from enum import Enum, auto
 | 
			
		||||
from math import sqrt
 | 
			
		||||
from random import choice, randint
 | 
			
		||||
from typing import List, Optional
 | 
			
		||||
from itertools import product
 | 
			
		||||
 | 
			
		||||
from .display.texturepack import TexturePack
 | 
			
		||||
from .translations import gettext as _
 | 
			
		||||
@@ -180,6 +181,13 @@ class Map:
 | 
			
		||||
        for entisave in d["entities"]:
 | 
			
		||||
            self.add_entity(dictclasses[entisave["type"]](**entisave))
 | 
			
		||||
 | 
			
		||||
    def large_neighbourhood(self, y, x):
 | 
			
		||||
        neighbours = []
 | 
			
		||||
        for dy, dx in product([-1, 0, 1], [-1, 0, 1]):
 | 
			
		||||
            if 0 < y+dy < self.height and 0 < x+dx < self.width:
 | 
			
		||||
                neighbours.append([y+dy, x+dx])
 | 
			
		||||
        return neighbours
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Tile(Enum):
 | 
			
		||||
    """
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user