'wozek'
3
ai-wozek/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
6
ai-wozek/.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
8
ai-wozek/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/wozek.iml" filepath="$PROJECT_DIR$/.idea/wozek.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
25
ai-wozek/.idea/runConfigurations/wozek.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="wozek" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||||
|
<module name="wozek" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="SDK_NAME" value="Python 3.10" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
|
<option name="IS_MODULE_SDK" value="false" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/wozek.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
7
ai-wozek/.idea/wozek.iml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
0
ai-wozek/README.md
Normal file
BIN
ai-wozek/car_parts.png
Normal file
After Width: | Height: | Size: 582 KiB |
4
ai-wozek/car_parts.png_Zone.Identifier
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[ZoneTransfer]
|
||||||
|
ZoneId=3
|
||||||
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/89fd002d-da8d-428b-8ab9-f34e46a152d2/car_parts.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125446Z&X-Amz-Expires=86400&X-Amz-Signature=5a6c7c1a4a9ace4b9847c1333519558594ff9acf8eef806f38e598003f86ffca&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22car_parts.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
BIN
ai-wozek/clothes.png
Normal file
After Width: | Height: | Size: 794 KiB |
4
ai-wozek/clothes.png_Zone.Identifier
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[ZoneTransfer]
|
||||||
|
ZoneId=3
|
||||||
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/bed19f02-21bb-4af5-9a42-7cc3365f2bf4/clothes.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125445Z&X-Amz-Expires=86400&X-Amz-Signature=f4586482e9493741e4b8acf756f10e3f879fc503bf0f4d05c1d4131aee65006a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22clothes.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
BIN
ai-wozek/forklift.png
Normal file
After Width: | Height: | Size: 334 KiB |
4
ai-wozek/forklift.png_Zone.Identifier
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[ZoneTransfer]
|
||||||
|
ZoneId=3
|
||||||
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/72d14743-46c1-4131-ad52-b8c020251781/DALL%C2%B7E%202024-03-13%2013.49.29%20-%20A%20cute%2C%20cartoonish%20forklift%20in%20a%20simple%2C%20colorful%20style%2C%20isolated%20on%20a%20white%20background%2C%20suitable%20for%20a%2032x32%20pixels%20square%20format.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125232Z&X-Amz-Expires=86400&X-Amz-Signature=47f29abd7d2833b597df60a061ece32135317b2715f4a5a5bd731d101328378a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22DALL%C2%B7E%202024-03-13%2013.49.29%20-%20A%20cute%2C%20cartoonish%20forklift%20in%20a%20simple%2C%20colorful%20style%2C%20isolated%20on%20a%20white%20background%2C%20suitable%20for%20a%2032x32%20pixels%20square%20format.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
BIN
ai-wozek/forkliftE.png
Normal file
After Width: | Height: | Size: 650 KiB |
BIN
ai-wozek/forkliftN.png
Normal file
After Width: | Height: | Size: 663 KiB |
BIN
ai-wozek/forkliftS.png
Normal file
After Width: | Height: | Size: 662 KiB |
BIN
ai-wozek/forkliftW.png
Normal file
After Width: | Height: | Size: 651 KiB |
BIN
ai-wozek/fruit.png
Normal file
After Width: | Height: | Size: 457 KiB |
4
ai-wozek/fruit.png_Zone.Identifier
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[ZoneTransfer]
|
||||||
|
ZoneId=3
|
||||||
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/bb36c777-c2d4-47c2-988b-532a79573e35/fruit.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125445Z&X-Amz-Expires=86400&X-Amz-Signature=f19271408b0122b54201104cb6b223d8421964134753883343dec7c677f11f37&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22fruit.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
BIN
ai-wozek/nuclear_waste.png
Normal file
After Width: | Height: | Size: 254 KiB |
4
ai-wozek/nuclear_waste.png_Zone.Identifier
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[ZoneTransfer]
|
||||||
|
ZoneId=3
|
||||||
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/7b680dc5-6ff4-4d66-a9fd-ee8b636e3bf1/nuclear_waste.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125444Z&X-Amz-Expires=86400&X-Amz-Signature=09442679e02fcce160ea1f20fd133696d8b766e1e728a06c853e03fe9b951e05&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22nuclear_waste.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
337
ai-wozek/wozek.py
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
import pygame
|
||||||
|
import sys
|
||||||
|
import random
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
class Node():
|
||||||
|
def __init__(self,position,rotation,action,parent):
|
||||||
|
self.position=position
|
||||||
|
self.rotation=rotation
|
||||||
|
self.action=action
|
||||||
|
self.parent=parent
|
||||||
|
|
||||||
|
# Initialize Pygame
|
||||||
|
pygame.init()
|
||||||
|
|
||||||
|
# Constants
|
||||||
|
TILE_SIZE = 96 # Size of a square tile in pixels
|
||||||
|
GRID_WIDTH, GRID_HEIGHT = 16,8 # Grid dimensions
|
||||||
|
SCREEN_WIDTH, SCREEN_HEIGHT = GRID_WIDTH * TILE_SIZE, GRID_HEIGHT * TILE_SIZE
|
||||||
|
FPS = 60 # Frames per second
|
||||||
|
|
||||||
|
# Setup display
|
||||||
|
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
||||||
|
pygame.display.set_caption('Forklift Game')
|
||||||
|
|
||||||
|
# Clock
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
|
# Function to load and scale images
|
||||||
|
def load_image(name, scale=None):
|
||||||
|
"""Loads an image and optionally scales it."""
|
||||||
|
image = pygame.image.load(name).convert_alpha()
|
||||||
|
if scale:
|
||||||
|
image = pygame.transform.scale(image, scale)
|
||||||
|
return image
|
||||||
|
|
||||||
|
# Placeholder for images (will be loaded after video mode set)
|
||||||
|
forklift_image_full = None
|
||||||
|
freight_images_full = None
|
||||||
|
|
||||||
|
# Game variables
|
||||||
|
forklift_pos = [7, 0]
|
||||||
|
rotation='E'# Adjusted starting position of the forklift
|
||||||
|
carrying_freight = False
|
||||||
|
carried_freight = None
|
||||||
|
freight_positions = {} # Dictionary to keep track of freight positions and types
|
||||||
|
|
||||||
|
# Load images
|
||||||
|
def load_images():
|
||||||
|
global forklift_image_full, freight_images_full
|
||||||
|
global rotation
|
||||||
|
if rotation=='E':
|
||||||
|
forklift_image_full = load_image('forkliftE.png', (TILE_SIZE, TILE_SIZE))
|
||||||
|
elif rotation=='W':
|
||||||
|
forklift_image_full = load_image('forkliftW.png', (TILE_SIZE, TILE_SIZE))
|
||||||
|
elif rotation=='N':
|
||||||
|
forklift_image_full = load_image('forkliftN.png', (TILE_SIZE, TILE_SIZE))
|
||||||
|
elif rotation=='S':
|
||||||
|
forklift_image_full = load_image('forkliftS.png', (TILE_SIZE, TILE_SIZE))
|
||||||
|
#forklift_image_full = load_image('forklift.png', (TILE_SIZE, TILE_SIZE))
|
||||||
|
freight_images_full = {
|
||||||
|
'clothes': load_image('clothes.png', (TILE_SIZE, TILE_SIZE)),
|
||||||
|
'fruit': load_image('fruit.png', (TILE_SIZE, TILE_SIZE)),
|
||||||
|
'nuclear_waste': load_image('nuclear_waste.png', (TILE_SIZE, TILE_SIZE)),
|
||||||
|
'car_parts': load_image('car_parts.png', (TILE_SIZE, TILE_SIZE)),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Initialize or reset game elements
|
||||||
|
def init_game():
|
||||||
|
freight_positions.clear()
|
||||||
|
load_images() # Ensure images are loaded after video mode set
|
||||||
|
reset_truck_bed_freight()
|
||||||
|
|
||||||
|
# Reset freight on the truck bed
|
||||||
|
def reset_truck_bed_freight():
|
||||||
|
types = list(freight_images_full.keys())
|
||||||
|
for x in range(12, 16):
|
||||||
|
freight_positions[(x, 0)] = random.choice(types)
|
||||||
|
|
||||||
|
# Drawing functions
|
||||||
|
def draw_board():
|
||||||
|
screen.fill((255, 255, 255))
|
||||||
|
for x in range(GRID_WIDTH):
|
||||||
|
for y in range(GRID_HEIGHT):
|
||||||
|
pygame.draw.rect(screen, (0, 0, 0), pygame.Rect(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE), 1)
|
||||||
|
|
||||||
|
def draw_truck_bed_and_racks():
|
||||||
|
for x in range(12, 16):
|
||||||
|
pygame.draw.rect(screen, (0, 0, 255), (x * TILE_SIZE, 0, TILE_SIZE, TILE_SIZE))
|
||||||
|
for y in range(5, 8):
|
||||||
|
for x in range(GRID_WIDTH):
|
||||||
|
pygame.draw.rect(screen, (165, 42, 42), (x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE))
|
||||||
|
|
||||||
|
|
||||||
|
def draw_forklift_and_freight():
|
||||||
|
x, y = forklift_pos
|
||||||
|
if carrying_freight:
|
||||||
|
# Draw smaller images when carrying freight
|
||||||
|
small_size = (TILE_SIZE // 2, TILE_SIZE // 2)
|
||||||
|
forklift_small = pygame.transform.scale(forklift_image_full, small_size)
|
||||||
|
freight_small = pygame.transform.scale(freight_images_full[carried_freight], small_size)
|
||||||
|
screen.blit(forklift_small, (x * TILE_SIZE, y * TILE_SIZE + TILE_SIZE // 2))
|
||||||
|
screen.blit(freight_small, (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE))
|
||||||
|
else:
|
||||||
|
screen.blit(forklift_image_full, (x * TILE_SIZE, y * TILE_SIZE))
|
||||||
|
|
||||||
|
def draw_freight():
|
||||||
|
for (x, y), freight_type in freight_positions.items():
|
||||||
|
screen.blit(freight_images_full[freight_type], (x * TILE_SIZE, y * TILE_SIZE))
|
||||||
|
|
||||||
|
# Game mechanics
|
||||||
|
def move_forklift():
|
||||||
|
global forklift_pos
|
||||||
|
if(rotation=='E'):
|
||||||
|
new_pos=[forklift_pos[0]+1,forklift_pos[1]]
|
||||||
|
elif(rotation=='W'):
|
||||||
|
new_pos=[forklift_pos[0]-1,forklift_pos[1]]
|
||||||
|
elif(rotation=='N'):
|
||||||
|
new_pos=[forklift_pos[0],forklift_pos[1]+1]
|
||||||
|
elif (rotation == 'S'):
|
||||||
|
new_pos = [forklift_pos[0], forklift_pos[1] - 1]
|
||||||
|
#new_pos = [forklift_pos[0] + dx, forklift_pos[1] + dy]
|
||||||
|
if 0 <= new_pos[0] < GRID_WIDTH and 0 <= new_pos[1] < GRID_HEIGHT:
|
||||||
|
forklift_pos = new_pos
|
||||||
|
def rotate_forklift(x):
|
||||||
|
global rotation
|
||||||
|
rot=['N','E','S','W']
|
||||||
|
rots=rot.index(rotation)
|
||||||
|
if x=='R':
|
||||||
|
if rots==0:
|
||||||
|
x=rot[3]
|
||||||
|
else:
|
||||||
|
x=rot[rots-1]
|
||||||
|
|
||||||
|
elif x=='L':
|
||||||
|
if rots==3:
|
||||||
|
x=rot[0]
|
||||||
|
else:
|
||||||
|
x=rot[rots+1]
|
||||||
|
rotation=x
|
||||||
|
def handle_freight():
|
||||||
|
global carrying_freight, carried_freight, freight_positions
|
||||||
|
pos_tuple = tuple(forklift_pos)
|
||||||
|
if carrying_freight:
|
||||||
|
if pos_tuple not in freight_positions:
|
||||||
|
freight_positions[pos_tuple] = carried_freight
|
||||||
|
carrying_freight = False
|
||||||
|
carried_freight = None
|
||||||
|
else:
|
||||||
|
if pos_tuple in freight_positions:
|
||||||
|
carried_freight = freight_positions.pop(pos_tuple)
|
||||||
|
carrying_freight = True
|
||||||
|
|
||||||
|
#searching for successors
|
||||||
|
def succ(current_node):
|
||||||
|
current_rotation=current_node.rotation
|
||||||
|
x=current_node.position[0]
|
||||||
|
y=current_node.position[1]
|
||||||
|
successors=[]
|
||||||
|
if(current_rotation=="N"):
|
||||||
|
if(y<7):
|
||||||
|
pos=[]
|
||||||
|
pos.append(x)
|
||||||
|
|
||||||
|
pos.append(y+1)
|
||||||
|
action='FW'
|
||||||
|
successor=Node(pos,current_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if(x>0):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation='W'
|
||||||
|
action='L'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if(x<15):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation='E'
|
||||||
|
action='R'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
|
||||||
|
|
||||||
|
elif (current_rotation == "S"):
|
||||||
|
if (y > 0):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y - 1)
|
||||||
|
action = 'FW'
|
||||||
|
successor = Node(pos, current_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if (x > 0):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation = 'E'
|
||||||
|
action='L'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if (x < 15):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation = 'W'
|
||||||
|
action = 'R'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
|
||||||
|
elif (current_rotation == "E"):
|
||||||
|
if (x <15):
|
||||||
|
pos = []
|
||||||
|
pos.append(x+1)
|
||||||
|
pos.append(y)
|
||||||
|
action = 'FW'
|
||||||
|
successor = Node(pos, current_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if (y <7):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation = 'N'
|
||||||
|
action='R'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if (y >0):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation = 'S'
|
||||||
|
action = 'L'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
|
||||||
|
elif (current_rotation == "W"):
|
||||||
|
if (x > 0):
|
||||||
|
pos = []
|
||||||
|
pos.append(x+1)
|
||||||
|
pos.append(y)
|
||||||
|
action = 'FW'
|
||||||
|
successor = Node(pos, current_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if (y > 0):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation = 'S'
|
||||||
|
action='R'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
if (y < 7):
|
||||||
|
pos = []
|
||||||
|
pos.append(x)
|
||||||
|
pos.append(y)
|
||||||
|
new_rotation = 'N'
|
||||||
|
action = 'L'
|
||||||
|
successor = Node(pos, new_rotation,action,current_node)
|
||||||
|
successors.append(successor)
|
||||||
|
|
||||||
|
return successors
|
||||||
|
|
||||||
|
#bfs
|
||||||
|
def bfs(isstate,final):
|
||||||
|
fringe=[]
|
||||||
|
fringe.append(isstate)
|
||||||
|
path=[]
|
||||||
|
explored=[]
|
||||||
|
while(True):
|
||||||
|
if(len(fringe)==0):
|
||||||
|
return False
|
||||||
|
node=fringe.pop(0)
|
||||||
|
if(node.position[0]==final.position[0] and node.position[1]==final.position[1]):
|
||||||
|
while(node.parent!=None):
|
||||||
|
path.append(node)
|
||||||
|
node=node.parent
|
||||||
|
return path
|
||||||
|
explored.append(node)
|
||||||
|
successors=succ(node)
|
||||||
|
for successor in successors:
|
||||||
|
if (successor not in fringe and successor not in explored):
|
||||||
|
fringe.append(successor)
|
||||||
|
|
||||||
|
# Main game loop
|
||||||
|
def game_loop():
|
||||||
|
init_game()
|
||||||
|
current=Node(forklift_pos,rotation,'start',None)
|
||||||
|
final=Node([10,6],'N','final',None)
|
||||||
|
path=bfs(current,final)
|
||||||
|
path.reverse()
|
||||||
|
for node in path:
|
||||||
|
print(node.action)
|
||||||
|
i=0
|
||||||
|
running = True
|
||||||
|
while running:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
running = False
|
||||||
|
elif event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_LEFT:
|
||||||
|
rotate_forklift('L')
|
||||||
|
load_images()
|
||||||
|
elif event.key == pygame.K_RIGHT:
|
||||||
|
rotate_forklift('R')
|
||||||
|
load_images()
|
||||||
|
elif event.key == pygame.K_UP:
|
||||||
|
move_forklift()
|
||||||
|
elif event.key == pygame.K_SPACE:
|
||||||
|
handle_freight()
|
||||||
|
elif event.key == pygame.K_r:
|
||||||
|
reset_truck_bed_freight()
|
||||||
|
|
||||||
|
draw_board()
|
||||||
|
draw_truck_bed_and_racks()
|
||||||
|
draw_freight()
|
||||||
|
draw_forklift_and_freight()
|
||||||
|
pygame.display.flip()
|
||||||
|
clock.tick(FPS)
|
||||||
|
if(i<len(path)):
|
||||||
|
nod=path[i]
|
||||||
|
if(nod.action=='FW'):
|
||||||
|
move_forklift()
|
||||||
|
elif(nod.action=='L'):
|
||||||
|
rotate_forklift('L')
|
||||||
|
load_images()
|
||||||
|
elif(nod.action=='R'):
|
||||||
|
rotate_forklift('R')
|
||||||
|
load_images()
|
||||||
|
i=i+1
|
||||||
|
pygame.time.wait(500)
|
||||||
|
|
||||||
|
pygame.quit()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
game_loop()
|