Merge remote-tracking branch 'origin/passingEvents' into passingEvents

This commit is contained in:
Michał Czekański 2020-04-06 00:49:20 +02:00
commit a0abfdf11e
19 changed files with 34 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -18,7 +18,7 @@
"name" : "cranberry",
"position" : {
"x": 7,
"y": 1
"y": 3
},
"isPickupable" : true,
"effect" : {
@ -56,8 +56,23 @@
"name" : "rock",
"position" : {
"x": 13,
"y": 1
"y": 2
},
"isPickupable" : false
},
{
"name" : "mushroom",
"position" : {
"x": 14,
"y": 3
},
"isPickupable": true,
"effect" : {
"hp": -50,
"stamina": 0,
"thirst": 0,
"hunger": 25
}
}
]

View File

@ -9,7 +9,7 @@ class Player(Entity):
statistics: Statistics
def __init__(self, spawnpoint, size):
super().__init__("player.jpg", size, (spawnpoint[0] * size, spawnpoint[1] * size))
super().__init__("player.png", size, (spawnpoint[0] * size, spawnpoint[1] * size))
# Where the player is facing, 0 - north, 1
self.rotation = Rotations.NORTH
self.statistics = Statistics(100, 0, 0, 100)
@ -28,9 +28,14 @@ class Player(Entity):
def getFacingCoord(self):
if self.rotation == Rotations.NORTH:
return (0, -1)
return self.rect.x, self.rect.y - (self.rect.h)
elif self.rotation == Rotations.SOUTH:
pass
return self.rect.x, self.rect.y + (self.rect.h)
elif self.rotation == Rotations.EAST:
return self.rect.x + (self.rect.h), self.rect.y
elif self.rotation == Rotations.WEST:
return self.rect.x - (self.rect.h), self.rect.y
# Returns given statistic
def getStatistic(self, stat):
if stat.value == StatisticNames.HP:

View File

@ -1,5 +1,6 @@
import pygame
from src.entities.Pickupable import Pickupable
from src.entities.Player import Rotations
# Player can move every given milliseconds
@ -38,7 +39,11 @@ class EventManager:
def handlePlayerControls(self, keys):
# Key names are temporary
# TODO: Load key bindings from JSON
if keys[pygame.K_SPACE]:
object = self.game.map.getEntityOnCoord(self.player.getFacingCoord())
if type(object) is Pickupable:
object.on_pickup(self.player)
self.game.map.removeSpriteFromMap(object)
if keys[pygame.K_w]:
self.player.rotate(Rotations.NORTH)
if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w):

View File

@ -42,7 +42,7 @@ class Map:
for entity in entityListJson:
try:
if entity["isPickupable"]:
actualEntities.append(Pickupable(entity["name"] + ".jpg",
actualEntities.append(Pickupable(entity["name"] + ".png",
self.tileSize,
(entity["position"]["x"] * self.tileSize, entity["position"]["y"] * self.tileSize),
Statistics(entity["effect"]["hp"],
@ -50,7 +50,7 @@ class Map:
entity["effect"]["thirst"],
entity["effect"]["stamina"])))
else:
actualEntities.append(Entity(entity["name"] + ".jpg",
actualEntities.append(Entity(entity["name"] + ".png",
self.tileSize,
(entity["position"]["x"] * self.tileSize, entity["position"]["y"] * self.tileSize)))
except KeyError:
@ -67,7 +67,7 @@ class Map:
elif tile == '.':
self.screen.draw(TerrainTile(col, row, 'grass.png', self.tileSize), Locations.MAP, 0, 0)
elif tile == 'x':
object = TerrainTile(col, row, 'water.jpg', self.tileSize)
object = TerrainTile(col, row, 'water.png', self.tileSize)
self.screen.draw(object, Locations.MAP, 0, 0)
self.collidables.add(object)
elif tile == 'w':