First commit
This commit is contained in:
commit
5a40f4eb81
52
config.py
Normal file
52
config.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import pygame as pg
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
screen_height = 560
|
||||||
|
screen_width = 700
|
||||||
|
tile_size = 80
|
||||||
|
|
||||||
|
screen = pg.display.set_mode([screen_width, screen_height])
|
||||||
|
|
||||||
|
# agent
|
||||||
|
agent_img = pg.image.load('tractor.png').convert()
|
||||||
|
|
||||||
|
# background
|
||||||
|
road = 0
|
||||||
|
ground = 1
|
||||||
|
|
||||||
|
bg_textures = {
|
||||||
|
road: pg.image.load('road.png').convert(),
|
||||||
|
ground: pg.image.load('ground.png').convert()}
|
||||||
|
|
||||||
|
background = np.array([[1, 1, 1, 0, 1, 1, 1],
|
||||||
|
[1, 1, 1, 0, 1, 1, 1],
|
||||||
|
[1, 1, 1, 0, 1, 1, 1],
|
||||||
|
[0, 0, 0, 0, 0, 0, 0],
|
||||||
|
[1, 1, 1, 0, 1, 1, 1],
|
||||||
|
[1, 1, 1, 0, 1, 1, 1],
|
||||||
|
[1, 1, 1, 0, 1, 1, 1]])
|
||||||
|
|
||||||
|
# objects
|
||||||
|
rose = 2
|
||||||
|
tulip = 3
|
||||||
|
orchid = 4
|
||||||
|
sunflower = 5
|
||||||
|
barn = 6
|
||||||
|
disease = 7
|
||||||
|
|
||||||
|
ob_textures = {
|
||||||
|
0: pg.image.load('none.png').convert_alpha(),
|
||||||
|
rose: pg.image.load('rose.png').convert_alpha(),
|
||||||
|
tulip: pg.image.load('tulip.png').convert_alpha(),
|
||||||
|
orchid: pg.image.load('orchid.png').convert_alpha(),
|
||||||
|
sunflower: pg.image.load('sunflower.png').convert_alpha(),
|
||||||
|
barn: pg.image.load('barn.png').convert(),
|
||||||
|
disease: pg.image.load('disease.png').convert_alpha()}
|
||||||
|
|
||||||
|
objects = np.array([[2, 2, 2, 0, 3, 3, 3],
|
||||||
|
[2, 2, 2, 0, 3, 3, 3],
|
||||||
|
[2, 2, 2, 0, 3, 3, 3],
|
||||||
|
[0, 0, 0, 6, 0, 0, 0],
|
||||||
|
[4, 4, 4, 0, 5, 5, 5],
|
||||||
|
[4, 4, 4, 0, 5, 5, 5],
|
||||||
|
[4, 4, 4, 0, 5, 5, 5]])
|
BIN
disease.png
Normal file
BIN
disease.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
BIN
ground.png
Normal file
BIN
ground.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 243 B |
38
main.py
Normal file
38
main.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import pygame as pg
|
||||||
|
import sys
|
||||||
|
import numpy as np
|
||||||
|
from tile import Tile
|
||||||
|
from config import *
|
||||||
|
|
||||||
|
done = False
|
||||||
|
|
||||||
|
clock = pg.time.Clock()
|
||||||
|
pg.display.set_caption('Intelligent Tractor')
|
||||||
|
tiles = []
|
||||||
|
|
||||||
|
for y in range(0, 7):
|
||||||
|
for x in range(0, 7):
|
||||||
|
t = Tile(background[x][y], objects[x][y], x, y)
|
||||||
|
tiles.append(t)
|
||||||
|
|
||||||
|
|
||||||
|
def display_background():
|
||||||
|
for tile in tiles:
|
||||||
|
screen.blit(bg_textures[tile.ground], (tile.x * tile_size, tile.y * tile_size))
|
||||||
|
|
||||||
|
|
||||||
|
def display_objects():
|
||||||
|
for tile in tiles:
|
||||||
|
screen.blit(ob_textures[tile.object], (tile.x * tile_size, tile.y * tile_size))
|
||||||
|
pg.display.flip()
|
||||||
|
|
||||||
|
|
||||||
|
while not done:
|
||||||
|
for event in pg.event.get():
|
||||||
|
if event.type == pg.QUIT:
|
||||||
|
done = True
|
||||||
|
display_background()
|
||||||
|
display_objects()
|
||||||
|
clock.tick(60)
|
||||||
|
|
||||||
|
pg.quit()
|
BIN
orchid.png
Normal file
BIN
orchid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
sunflower.png
Normal file
BIN
sunflower.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
7
tile.py
Normal file
7
tile.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class Tile:
|
||||||
|
def __init__(self, a, b, x, y):
|
||||||
|
self.ground = a
|
||||||
|
self.object = b
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
self.h = 0
|
BIN
tractor.png
Normal file
BIN
tractor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
Loading…
Reference in New Issue
Block a user