Zmiana poruszania
This commit is contained in:
parent
e3a9f52e6e
commit
bf74cff257
@ -2,6 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/game.py" beforeDir="false" afterPath="$PROJECT_DIR$/game.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/waiter.py" beforeDir="false" afterPath="$PROJECT_DIR$/waiter.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
@ -21,11 +22,11 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/game.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="266">
|
||||
<caret line="59" column="33" selection-start-line="59" selection-start-column="33" selection-end-line="59" selection-end-column="33" />
|
||||
<state relative-caret-position="140">
|
||||
<caret line="57" column="33" selection-start-line="57" selection-start-column="29" selection-end-line="57" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -83,11 +84,11 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1281">
|
||||
<caret line="97" lean-forward="true" selection-start-line="97" selection-end-line="97" />
|
||||
<state relative-caret-position="210">
|
||||
<caret line="67" column="74" selection-start-line="67" selection-start-column="74" selection-end-line="67" selection-end-column="74" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
@ -123,8 +124,8 @@
|
||||
<option value="$PROJECT_DIR$/table.py" />
|
||||
<option value="$PROJECT_DIR$/orderTable.py" />
|
||||
<option value="$PROJECT_DIR$/pool.py" />
|
||||
<option value="$PROJECT_DIR$/waiter.py" />
|
||||
<option value="$PROJECT_DIR$/game.py" />
|
||||
<option value="$PROJECT_DIR$/waiter.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -428,25 +429,25 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Images/tlo.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/game.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="57" column="33" selection-start-line="57" selection-start-column="29" selection-end-line="57" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1281">
|
||||
<caret line="97" lean-forward="true" selection-start-line="97" selection-end-line="97" />
|
||||
<state relative-caret-position="210">
|
||||
<caret line="67" column="74" selection-start-line="67" selection-start-column="74" selection-end-line="67" selection-end-column="74" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Images/tlo.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/game.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="266">
|
||||
<caret line="59" column="33" selection-start-line="59" selection-start-column="33" selection-end-line="59" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
5
game.py
5
game.py
@ -35,7 +35,8 @@ class Game(object):
|
||||
self.row.append(table)
|
||||
self.tableList.append(table)
|
||||
elif i == 4 and b == 9:
|
||||
self.row.append(Waiter(self, i * 50, b * 50))
|
||||
self.waiter = Waiter(self, i * 50, b * 50)
|
||||
self.row.append(self.waiter)
|
||||
self.waiterNumberInGrid.x = i
|
||||
self.waiterNumberInGrid.y = b
|
||||
elif (((b > 0 and b < 6) and (i > 0 and i < 9)) and not((i==1 or i == 8) and (b==1 or b==5))) \
|
||||
@ -54,7 +55,7 @@ class Game(object):
|
||||
sys.exit(0)
|
||||
|
||||
self.draw()
|
||||
self.grid[int(self.waiterNumberInGrid.y)][int(self.waiterNumberInGrid.x)].move(self)
|
||||
self.waiter.move(self)
|
||||
pygame.display.flip()
|
||||
#print(self.waiterNumberInGrid)
|
||||
self.fpsClock.tick(10)
|
||||
|
78
waiter.py
78
waiter.py
@ -9,6 +9,8 @@ class Waiter(object):
|
||||
self.size= self.game.screen.get_size()
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.positionX = int(x / 50)
|
||||
self.positionY = int(y / 50)
|
||||
self.image = pygame.image.load("./Images/waiter.png").convert()
|
||||
self.image.set_colorkey((255, 255, 255))
|
||||
self.type = "waiter"
|
||||
@ -16,60 +18,62 @@ class Waiter(object):
|
||||
|
||||
|
||||
def moveLeft(self, game):
|
||||
if int(game.waiterNumberInGrid.x) != 0:
|
||||
collisionObject = game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x-1)]
|
||||
if self.positionX != 0:
|
||||
collisionObject = game.grid[self.positionY][self.positionX - 1]
|
||||
if collisionObject.type == "gridElement":
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x - 1)].x += 50
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)].x -= 50
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x - 1)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)] = \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x-1)]
|
||||
game.waiterNumberInGrid.x -= 1
|
||||
game.grid[self.positionY][self.positionX - 1].x += 50
|
||||
game.grid[self.positionY][self.positionX].x -= 50
|
||||
game.grid[self.positionY][self.positionX - 1], \
|
||||
game.grid[self.positionY][self.positionX] = \
|
||||
game.grid[self.positionY][self.positionX], \
|
||||
game.grid[self.positionY][self.positionX - 1]
|
||||
self.positionX -= 1
|
||||
print(self.positionX)
|
||||
self.lastStep.append("Left")
|
||||
else:
|
||||
pass
|
||||
def moveRight(self, game):
|
||||
if int(game.waiterNumberInGrid.x) != game.x-1:
|
||||
collisionObject = game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x + 1)]
|
||||
if self.positionX != game.x-1:
|
||||
collisionObject = game.grid[self.positionY][self.positionX + 1]
|
||||
if collisionObject.type == "gridElement":
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x + 1)].x -= 50
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)].x += 50
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x + 1)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)] = \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x + 1)]
|
||||
game.waiterNumberInGrid.x += 1
|
||||
game.grid[self.positionY][self.positionX + 1].x -= 50
|
||||
game.grid[self.positionY][self.positionX].x += 50
|
||||
game.grid[self.positionY][self.positionX + 1], \
|
||||
game.grid[self.positionY][self.positionX] = \
|
||||
game.grid[self.positionY][self.positionX], \
|
||||
game.grid[self.positionY][self.positionX + 1]
|
||||
self.positionX += 1
|
||||
print(self.positionX)
|
||||
self.lastStep.append("Right")
|
||||
else:
|
||||
pass
|
||||
|
||||
def moveUp(self, game):
|
||||
if int(game.waiterNumberInGrid.y) != 0:
|
||||
collisionObject = game.grid[int(game.waiterNumberInGrid.y-1)][int(game.waiterNumberInGrid.x)]
|
||||
if self.positionY != 0:
|
||||
collisionObject = game.grid[self.positionY - 1][self.positionX]
|
||||
if collisionObject.type == "gridElement":
|
||||
game.grid[int(game.waiterNumberInGrid.y-1)][int(game.waiterNumberInGrid.x)].y += 50
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)].y -= 50
|
||||
game.grid[int(game.waiterNumberInGrid.y-1)][int(game.waiterNumberInGrid.x)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)] = \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y-1)][int(game.waiterNumberInGrid.x)]
|
||||
game.waiterNumberInGrid.y -= 1
|
||||
game.grid[self.positionY - 1][self.positionX].y += 50
|
||||
game.grid[self.positionY][self.positionX].y -= 50
|
||||
game.grid[self.positionY - 1][self.positionX], \
|
||||
game.grid[self.positionY][self.positionX] = \
|
||||
game.grid[self.positionY][self.positionX], \
|
||||
game.grid[self.positionY - 1][self.positionX]
|
||||
self.positionY -= 1
|
||||
self.lastStep.append("Up")
|
||||
else:
|
||||
pass
|
||||
|
||||
def moveDown(self, game):
|
||||
if int(game.waiterNumberInGrid.y) != game.y-1:
|
||||
collisionObject = game.grid[int(game.waiterNumberInGrid.y + 1)][int(game.waiterNumberInGrid.x)]
|
||||
if self.positionY != game.y-1:
|
||||
collisionObject = game.grid[self.positionY + 1][self.positionX]
|
||||
if collisionObject.type == "gridElement":
|
||||
game.grid[int(game.waiterNumberInGrid.y + 1)][int(game.waiterNumberInGrid.x)].y -= 50
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)].y += 50
|
||||
game.grid[int(game.waiterNumberInGrid.y + 1)][int(game.waiterNumberInGrid.x)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)] = \
|
||||
game.grid[int(game.waiterNumberInGrid.y)][int(game.waiterNumberInGrid.x)], \
|
||||
game.grid[int(game.waiterNumberInGrid.y + 1)][int(game.waiterNumberInGrid.x)]
|
||||
game.waiterNumberInGrid.y += 1
|
||||
game.grid[self.positionY + 1][self.positionX].y -= 50
|
||||
game.grid[self.positionY][self.positionX].y += 50
|
||||
game.grid[self.positionY + 1][self.positionX], \
|
||||
game.grid[self.positionY][self.positionX] = \
|
||||
game.grid[self.positionY][self.positionX], \
|
||||
game.grid[self.positionY + 1][self.positionX]
|
||||
self.positionY += 1
|
||||
self.lastStep.append("Down")
|
||||
else:
|
||||
pass
|
||||
@ -93,5 +97,5 @@ class Waiter(object):
|
||||
def draw(self):
|
||||
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
|
||||
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
|
||||
print(self.lastStep)
|
||||
#print(self.lastStep)
|
||||
self.game.screen.blit(self.image, (self.x, self.y))
|
||||
|
Loading…
Reference in New Issue
Block a user