Add pathing enemies to pathmap, etc.
This commit is contained in:
parent
0b4565f504
commit
da052ac6f0
@ -17,11 +17,6 @@ def main():
|
||||
pygame.init()
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
screen = pygame.display.set_mode((screen_width,screen_height))
|
||||
pygame.display.set_caption('Arctic Masher')
|
||||
|
||||
bottomBar = pygame.Rect(0, screen_height - bottomBarHeight, screen_width, bottomBarHeight)
|
||||
|
||||
players["1"] = (Player(
|
||||
"1",
|
||||
5,
|
||||
@ -53,7 +48,7 @@ def main():
|
||||
(pygame.K_KP_1, "sw"),
|
||||
(pygame.K_KP_4, "w"),
|
||||
(pygame.K_KP_7, "nw"),
|
||||
(pygame.K_KP_0, "p"),
|
||||
(pygame.K_RSHIFT, "p"),
|
||||
],
|
||||
))
|
||||
# players["3"] = (Player(
|
||||
@ -74,6 +69,12 @@ def main():
|
||||
# ],
|
||||
# ))
|
||||
|
||||
|
||||
gameWindow = pygame.display.set_mode((screen_width,screen_height))
|
||||
pygame.display.set_caption('Arctic Masher')
|
||||
|
||||
bottomBar = pygame.Rect(0, screen_height - bottomBarHeight, screen_width, bottomBarHeight)
|
||||
|
||||
mapgen.generateMap()
|
||||
|
||||
sprite_sheet_image = pygame.image.load('assets/penguin.png').convert_alpha()
|
||||
@ -106,20 +107,20 @@ def main():
|
||||
enemy.runAI()
|
||||
|
||||
# Rendering
|
||||
screen.fill(bg_color)
|
||||
pygame.draw.rect(screen, bar_color, bottomBar)
|
||||
gameWindow.fill(bg_color)
|
||||
pygame.draw.rect(gameWindow, bar_color, bottomBar)
|
||||
for column in gameMap:
|
||||
for spot in column:
|
||||
if not spot:
|
||||
continue
|
||||
elif isinstance(spot, Block):
|
||||
pygame.draw.rect(screen, spot.color, spot.sprite)
|
||||
pygame.draw.rect(gameWindow, spot.color, spot.sprite)
|
||||
elif isinstance(spot, Enemy):
|
||||
screen.blit(spot.sprite, ((tile*spot.renderPos[0])+2, (tile*spot.renderPos[1])+2))
|
||||
gameWindow.blit(spot.sprite, ((tile*spot.renderPos[0])+2, (tile*spot.renderPos[1])+2))
|
||||
elif isinstance(spot, Player):
|
||||
screen.blit(frame_0, ((tile*spot.renderPos[0])+2, (tile*spot.renderPos[1])+2))
|
||||
gameWindow.blit(frame_0, ((tile*spot.renderPos[0])+2, (tile*spot.renderPos[1])+2))
|
||||
scoreSurface = game_font.render(f'player {spot.id} kills: {spot.kills} lives: {spot.lives}', False, black)
|
||||
screen.blit(scoreSurface, (500*int(spot.id) - 400, screen_height - bottomBarHeight + 20))
|
||||
gameWindow.blit(scoreSurface, (500*int(spot.id) - 400, screen_height - bottomBarHeight + 20))
|
||||
try:
|
||||
spot.renderPos = ((spot.x - spot.renderPos[0])/3 + spot.renderPos[0], (spot.y - spot.renderPos[1])/3 + spot.renderPos[1])
|
||||
except:
|
||||
|
@ -97,6 +97,8 @@ class Enemy:
|
||||
class Smart(Enemy):
|
||||
def __init__(self, id, x, y):
|
||||
Enemy.__init__(self, id, x, y)
|
||||
self.SMART = True
|
||||
self.usesPathMap = True
|
||||
self.deathColor = red
|
||||
self.trackedPlayer = False
|
||||
self.trackingCounter = 0
|
||||
@ -152,8 +154,8 @@ class Mage(Enemy):
|
||||
randomWeights = randomizeMovement(weightsx, weightsy, diff, 0.15)
|
||||
weightsx = randomWeights[0]
|
||||
weightsy = randomWeights[1]
|
||||
movementx = random.choices([-1, 0, 1], weightsx)[0] * random.randint(1,4)
|
||||
movementy = random.choices([-1, 0, 1], weightsy)[0] * random.randint(1,4)
|
||||
movementx = random.choices([-1, 0, 1], weightsx)[0] * random.randint(1,2)
|
||||
movementy = random.choices([-1, 0, 1], weightsy)[0] * random.randint(1,2)
|
||||
self.move(movementx, movementy)
|
||||
self.AITime = random.randint(150, 200)
|
||||
except Exception as error:
|
||||
|
@ -1,6 +1,6 @@
|
||||
import pygame
|
||||
|
||||
bg_color = pygame.Color('lightsalmon')
|
||||
bg_color = pygame.Color('lightsalmon3')
|
||||
bar_color = pygame.Color('white')
|
||||
red = pygame.Color('brown4')
|
||||
blue = pygame.Color('cadetblue3')
|
||||
|
@ -23,7 +23,7 @@ def buildPathMap(x, y):
|
||||
newY = tile[1] + j
|
||||
if (i != 0 or j != 0) and not checkOOBounds((newX,newY)) and not pathMap[newX][newY]:
|
||||
pathMap[newX][newY] = (newX,newY,(-i,-j))
|
||||
if not gameMap[newX][newY]:
|
||||
if not gameMap[newX][newY] or hasattr(gameMap[newX][newY], "usesPathMap"):
|
||||
newTiles.add(pathMap[newX][newY])
|
||||
if len(currentTiles) < 1:
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user