diff --git a/AI-Final-master/__pycache__/enemy.cpython-39.pyc b/AI-Final-master/__pycache__/enemy.cpython-39.pyc
new file mode 100644
index 0000000..f1bac84
Binary files /dev/null and b/AI-Final-master/__pycache__/enemy.cpython-39.pyc differ
diff --git a/AI-Final-master/__pycache__/game.cpython-36.pyc b/AI-Final-master/__pycache__/game.cpython-36.pyc
new file mode 100644
index 0000000..3bce706
Binary files /dev/null and b/AI-Final-master/__pycache__/game.cpython-36.pyc differ
diff --git a/AI-Final-master/__pycache__/game.cpython-39.pyc b/AI-Final-master/__pycache__/game.cpython-39.pyc
new file mode 100644
index 0000000..50ed1bd
Binary files /dev/null and b/AI-Final-master/__pycache__/game.cpython-39.pyc differ
diff --git a/AI-Final-master/__pycache__/player.cpython-36.pyc b/AI-Final-master/__pycache__/player.cpython-36.pyc
new file mode 100644
index 0000000..1ee2521
Binary files /dev/null and b/AI-Final-master/__pycache__/player.cpython-36.pyc differ
diff --git a/AI-Final-master/__pycache__/player.cpython-39.pyc b/AI-Final-master/__pycache__/player.cpython-39.pyc
new file mode 100644
index 0000000..3f52a3a
Binary files /dev/null and b/AI-Final-master/__pycache__/player.cpython-39.pyc differ
diff --git a/AI-Final-master/character PNGs/characters.png b/AI-Final-master/character PNGs/characters.png
new file mode 100644
index 0000000..dffa194
Binary files /dev/null and b/AI-Final-master/character PNGs/characters.png differ
diff --git a/AI-Final-master/character PNGs/goblin.png b/AI-Final-master/character PNGs/goblin.png
new file mode 100644
index 0000000..171640a
Binary files /dev/null and b/AI-Final-master/character PNGs/goblin.png differ
diff --git a/AI-Final-master/enemy.py b/AI-Final-master/enemy.py
new file mode 100644
index 0000000..9503b59
--- /dev/null
+++ b/AI-Final-master/enemy.py
@@ -0,0 +1,90 @@
+"""
+File for enemy functions (AI functionality for movement and attacks and things)
+"""
+
+import pygame
+from pygame.locals import *
+from pytmx.util_pygame import load_pygame
+
+
+
+class Enemy:
+
+
+
+
+ def __init__(self, x, y):
+ self.image = pygame.image.load("character PNGs\\goblin.png")
+ self.x = x
+ self.y = y
+ self.path = [self.x, self.y]
+ self.walkCount = 0
+ self.vel = 3
+ self.hitbox = (self.x + 17, self.y + 2, 31, 57) # NEW
+ self.health = 1000
+ self.visible = True
+
+ def draw(self,win):
+ self.move()
+ if self.visible:
+ if self.walkCount + 1 >= 33:
+ self.walkCount = 0
+
+ if self.vel > 0:
+ win.blit(self.walkRight[self.walkCount //3], (self.x, self.y))
+ self.walkCount += 1
+ else:
+ win.blit(self.walkLeft[self.walkCount //3], (self.x, self.y))
+ self.walkCount += 1
+
+
+ # Drawing the health bar of the enemy.
+ pygame.draw.rect(win, (255,0,0), (self.hitbox[0], self.hitbox[1] - 20, 50, 10))
+
+ # Substract from the health bar width each time enemy is hit
+ pygame.draw.rect(win, (0,255,0), (self.hitbox[0], self.hitbox[1] - 20, 50 - (5 * (10 - self.health)), 10))
+
+ # Creating a hitbox around the character.
+ self.hitbox = (self.x + 15, self.y + 10, 29, 52)
+
+ def hit(self):
+ if self.health > 0:
+ self.health -= 1
+ else:
+ self.visible = False
+ print('Enemy hit')
+
+ def move(self):
+ if self.vel > 0:
+ if self.x + self.vel < self.path[1]:
+ self.x += self.vel
+ else:
+ self.vel = self.vel * -1
+ self.walkCount = 0
+ else:
+ if self.x - self.vel > self.path[0]:
+ self.x += self.vel
+ else:
+ self.vel = self.vel * -1
+ self.walkCount = 0
+
+ # NEW METHOD
+ def hit(self): # This will display when the enemy is hit
+ print('hit')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI-Final-master/game.py b/AI-Final-master/game.py
new file mode 100644
index 0000000..3a8a14e
--- /dev/null
+++ b/AI-Final-master/game.py
@@ -0,0 +1,70 @@
+"""
+Contains info to initialize the game (pygame init, screen init, map info/drawing, etc.)
+"""
+import player
+import sys
+import pygame
+from pygame.locals import *
+from pytmx.util_pygame import load_pygame
+
+class Directions:
+ NORTH = "North"
+ SOUTH = 'South'
+ EAST = 'East'
+ WEST = 'West'
+ STOP = 'Stop'
+
+ LEFT = {NORTH: WEST,
+ SOUTH: EAST,
+ EAST: NORTH,
+ WEST: SOUTH,
+ STOP: STOP}
+
+ RIGHT = dict([(y, x) for x, y in list(LEFT.items())])
+
+ REVERSE = {NORTH: SOUTH,
+ SOUTH: NORTH,
+ EAST: WEST,
+ WEST: EAST,
+ STOP: STOP}
+
+class Game:
+ def __init__(self):
+ self.screen = pygame.display.set_mode((640, 640)) # set screen size
+ pygame.display.set_caption("Untitled Rogue-like Game") # set display caption
+ self.clock = pygame.time.Clock() # create clock
+ self.running = True # init running to true, change to false when exit button clicked
+ self.tmxdata = load_pygame("rooms\\basic_room.tmx") # Load map from tmx file
+ self.playerX = 320
+ self.playerY = 500
+
+ #game loop
+ def runGame(self):
+ print("run game")
+ while self.running:
+ #print("running")
+ self.screen.fill((255,255,255)) # init screen to white
+ keyPressed = pygame.key.get_pressed()
+ mousePressed = pygame.mouse.get_pressed()
+ mouseX, mouseY = pygame.mouse.get_pos()
+ self.getEvents()
+ self.drawMap()
+ #player.Player().draw()
+ pygame.display.update()
+
+
+ # handle all events in game
+ def getEvents(self):
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ #print("exit game")
+ self.running = False
+
+ def drawMap(self):
+ #print("draw map")
+ for layer in self.tmxdata:
+ for tiles in layer.tiles():
+ xPixel = tiles[0] * 16
+ yPixel = tiles[1] * 16
+ mapImg = tiles[2]
+ self.screen.blit(mapImg, (xPixel, yPixel))
\ No newline at end of file
diff --git a/AI-Final-master/game_test.py b/AI-Final-master/game_test.py
new file mode 100644
index 0000000..093bbde
--- /dev/null
+++ b/AI-Final-master/game_test.py
@@ -0,0 +1,172 @@
+"""
+This file is meant to be used to test various parts of the final game in static, mostly blank world.
+The world is created using Tiled and pyTMX.
+
+Features to test here include initial player movement, player attacking, enemy AI movement, and enemy attacking.
+"""
+import sys
+import random
+import pygame
+import math
+from enemy import Enemy
+from player import Player
+from game import Game
+from pygame.locals import *
+from pytmx.util_pygame import load_pygame
+
+
+width, height = 640, 640
+#init pygame
+pygame.init()
+#create screen (width, height)
+#Game().runGame() # UNCOMMENT THIS TO RUN WITH GAME CLASS INSTEAD -- CURRENTLY UNECESSARY
+screenSize = (width, height)
+screen = pygame.display.set_mode(screenSize)
+# Window title
+pygame.display.set_caption("Untitled Rogue-Like game")
+tmxdata = load_pygame("rooms\\basic_room.tmx") # Load map from tmx file
+fireBallList = [] # list of fire ball sprites
+
+fireBallTimer = 0.1
+# To set window icon:
+# icon = pygame.image.load("image.png")
+# pygame.display.set_icon(icon)
+clock = pygame.time.Clock()
+dt = clock.tick(60)/1000 # dt = time since last tick in milliseconds
+startTicks = pygame.time.get_ticks()
+
+class fireBall:
+ def __init__(self, playerX, playerY, mouseX, mouseY):
+ self.x = playerX
+ self.y = playerY
+ self.speed = 2
+ self.angle = math.atan2(mouseY-playerY, mouseX-playerX)
+ self.xVel = math.cos(self.angle) * self.speed
+ self.yVel = math.sin(self.angle) * self.speed
+ self.fireBallTimer = 0.1
+
+ def update(self, dt):
+ self.x += int(self.xVel)
+ self.y += int(self.yVel)
+
+ # fbTimer = self.fireBallTimer - dt
+ # if fbTimer <= 0:
+ # print("SHHOOOOTT HEERRRR")
+ # #wafbTimer = 0
+ pygame.draw.circle(screen, (0,0,0), (self.x, self.y), 10)
+ # fbTimer = 0.1
+
+
+
+"""
+Consider changing attack buttons to arrow keys instead of mouse
+"""
+def playerAttack(playerX, playerY, mouseX, mouseY, mousePressed):
+ if mousePressed:
+ fireBallList.append(fireBall(playerX, playerY, mouseX, mouseY))
+ for fb in fireBallList:
+ #pygame.time.wait(5)
+ #print("before update")
+ fb.update(dt)
+ #print("after update")
+ if fb.x < 20 or fb.y < 20 or fb.x > 610 or fb.y > 610: #delete orb if it leaves world bounds --
+ #need to make this so it deltes when it hits an enemy or a wall
+ fireBallList.pop(fireBallList.index(fb))
+
+"""
+Using this for now but there is also a drawMap function in the Game class from game.py
+"""
+# start draw_map()
+def draw_map():
+ #tmxdata = load_pygame("rooms\\basic_room.tmx") # Load map from tmx file
+ for layer in tmxdata:
+ for tiles in layer.tiles():
+ xPixelPos = tiles[0] * 16 #+ world_offset
+ yPixelPos = tiles[1] * 16 #+ world_offset
+ mapImg = tiles[2] #get img to draw from tmxdata
+ screen.blit(mapImg, (xPixelPos, yPixelPos)) #draw map to screen
+# end draw_map()
+
+def redraw_game_window():
+ win.blit(bg, (0, 0))
+ win.blit(text, (520, 10))
+ player.draw(win)
+ enemy.draw(win)
+ for fireball in fireballs
+ fireball.draw(win)
+ # Refresh the display and show the character
+ pygame.display.update()
+
+
+player = Player(250, 250)
+enemy = Enemy(450, 300)
+
+# Game loop
+running = True
+fireballCooldown = 0
+fireballs = []
+while running:
+ screen.fill((255,255,255)) # Screen starts white before doing anything else
+ keyPressed = pygame.key.get_pressed() # get key presses for movement
+ mousePressed = pygame.mouse.get_pressed()[0]
+ mouseX, mouseY = pygame.mouse.get_pos()
+
+ if fireballCooldown > 0:
+ fireballCooldown += 1
+ if fireballCooldown > 3:
+ fireballCooldown = 0
+
+ #event loop -- looks for events like key presses or quit
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ running = False
+
+
+ for fireball in fireballs:
+ if fireball.y - fireball.radius < enemy.hitbox[1] + enemy.hitbox[3] and fireball.y + fireball.radius > enemy.hitbox[1]:
+ if fireball.x + fireball.radius > enemy.hitbox[0] and fireball.x - fireball.radius < enemy.hitbox[0] + enemy.hitbox[2]:
+
+ enemy.hit()
+
+ fireballs.pop(fireballs.index(fireball))
+ if fireball.x < 750 and fireball.x > 0:
+ fireball.x += fireball.vel
+ else:
+ fireballs.pop(fireballs.index(fireball))
+
+
+
+ #player movement
+ playerXY = player.move(playerXpos, playerYpos, keyPressed, tmxdata)
+ playerXpos = playerXY[0]
+ playerYpos = playerXY[1]
+
+ draw_map() #draws the map to the screen
+ #draw player and update postion
+ player.draw((playerXpos, playerYpos), screen)
+
+
+
+ playerAttack(playerXpos, playerYpos, mouseX, mouseY, mousePressed)
+
+ redraw_game_window()
+
+
+
+pygame.quit()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AI-Final-master/player.py b/AI-Final-master/player.py
new file mode 100644
index 0000000..ba3c767
--- /dev/null
+++ b/AI-Final-master/player.py
@@ -0,0 +1,51 @@
+"""
+File for player functions (move, attack, etc.)
+"""
+
+import pygame
+from pygame.locals import *
+from pytmx.util_pygame import load_pygame
+
+class Player:
+ def __init__(self, x, y):
+ self.image = pygame.image.load("tile PNGs\\blueWizard.png")
+ self.x = x
+ self.y = y
+ self.speed = 10
+ def draw(self, XYpos, screen):
+ screen.blit(self.image, XYpos)
+
+ def getMapProperties(self, x, y):
+ xTile = x // 16
+ yTile = y // 16
+
+
+ wallProp = game.Game().tmxdata.get_tile_properties(xTile, yTile, 0)
+ stairProp = game.Game().tmxdata.get_tile_properties(xTile, yTile, 1)
+ #print("got wall props")
+ if wallProp is None and stairProp is None:
+ wallProp = {"solid":0, "stairs":0}
+ stairProp = {"solid":0, "stairs":0}
+ return (wallProp, stairProp)
+
+ def move(self, x, y, keyPressed, tmxdata):
+ if keyPressed[ord("a")]: # check what key was pressed
+ westTile = self.getMapProperties(x-5, y+11) #find the tile next to the player and get its properties
+ if westTile[0]['solid'] == 0: # if not solid keep moving, stop otherwise
+ x += -self.speed
+ if keyPressed[ord("d")]:
+ eastTile = self.getMapProperties(x+24, y+22)
+ if eastTile[0]['solid'] == 0:
+ x += self.speed
+ if keyPressed[ord("w")]:
+ northTile = self.getMapProperties(x, y)
+ if northTile[0]['solid'] == 0:
+ y += -self.speed
+ if keyPressed[ord("s")]:
+ southTile = self.getMapProperties(x-2, y+32)
+ if southTile[0]['solid'] == 0:
+ y += self.speed
+ return(x, y)
+
+
+ #def attack(self, dt):
\ No newline at end of file
diff --git a/AI-Final-master/report docs/Dungeon Crawler proposal.pdf b/AI-Final-master/report docs/Dungeon Crawler proposal.pdf
new file mode 100644
index 0000000..ae3a633
Binary files /dev/null and b/AI-Final-master/report docs/Dungeon Crawler proposal.pdf differ
diff --git a/AI-Final-master/report docs/Untitled Dungeon Crawler Game PPT.pdf b/AI-Final-master/report docs/Untitled Dungeon Crawler Game PPT.pdf
new file mode 100644
index 0000000..54796a2
Binary files /dev/null and b/AI-Final-master/report docs/Untitled Dungeon Crawler Game PPT.pdf differ
diff --git a/AI-Final-master/rewardArrs.py b/AI-Final-master/rewardArrs.py
new file mode 100644
index 0000000..e435b81
--- /dev/null
+++ b/AI-Final-master/rewardArrs.py
@@ -0,0 +1,26 @@
+"""
+file to hold 2D arrays that hold the reward data for the various maps
+These are disgusting to make so it might take a while to complete -- currently working on a way to automate this process
+"""
+
+class Rewards:
+ trainer0Arr = [[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100]
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,,85,90,95,90,85,80,75,-100],
+ [-100,35,40,45,50,55,60,65,70,75,80,85,90,95,100,95,90,85,80,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100],
+ [-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100]]
\ No newline at end of file
diff --git a/AI-Final-master/rooms/Dungeon_rooms.tsx b/AI-Final-master/rooms/Dungeon_rooms.tsx
new file mode 100644
index 0000000..38099f3
--- /dev/null
+++ b/AI-Final-master/rooms/Dungeon_rooms.tsx
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AI-Final-master/rooms/basic_room.tmx b/AI-Final-master/rooms/basic_room.tmx
new file mode 100644
index 0000000..20e99e2
--- /dev/null
+++ b/AI-Final-master/rooms/basic_room.tmx
@@ -0,0 +1,92 @@
+
+
diff --git a/AI-Final-master/rooms/finalMap.tmx b/AI-Final-master/rooms/finalMap.tmx
new file mode 100644
index 0000000..9da976f
--- /dev/null
+++ b/AI-Final-master/rooms/finalMap.tmx
@@ -0,0 +1,38 @@
+
+
diff --git a/AI-Final-master/rooms/trainer0.tmx b/AI-Final-master/rooms/trainer0.tmx
new file mode 100644
index 0000000..a0059cb
--- /dev/null
+++ b/AI-Final-master/rooms/trainer0.tmx
@@ -0,0 +1,28 @@
+
+
diff --git a/AI-Final-master/rooms/trainer1.tmx b/AI-Final-master/rooms/trainer1.tmx
new file mode 100644
index 0000000..3f4cd57
--- /dev/null
+++ b/AI-Final-master/rooms/trainer1.tmx
@@ -0,0 +1,28 @@
+
+
diff --git a/AI-Final-master/rooms/trainer2.tmx b/AI-Final-master/rooms/trainer2.tmx
new file mode 100644
index 0000000..8fd38ae
--- /dev/null
+++ b/AI-Final-master/rooms/trainer2.tmx
@@ -0,0 +1,28 @@
+
+
diff --git a/AI-Final-master/rooms/trainer3.tmx b/AI-Final-master/rooms/trainer3.tmx
new file mode 100644
index 0000000..ea35e9e
--- /dev/null
+++ b/AI-Final-master/rooms/trainer3.tmx
@@ -0,0 +1,28 @@
+
+
diff --git a/AI-Final-master/rooms/trainer4.tmx b/AI-Final-master/rooms/trainer4.tmx
new file mode 100644
index 0000000..918d212
--- /dev/null
+++ b/AI-Final-master/rooms/trainer4.tmx
@@ -0,0 +1,28 @@
+
+
diff --git a/AI-Final-master/rooms/trainer5.tmx b/AI-Final-master/rooms/trainer5.tmx
new file mode 100644
index 0000000..98d3bb7
--- /dev/null
+++ b/AI-Final-master/rooms/trainer5.tmx
@@ -0,0 +1,28 @@
+
+
diff --git a/AI-Final-master/rooms/untitled.tmx b/AI-Final-master/rooms/untitled.tmx
new file mode 100644
index 0000000..de4f32d
--- /dev/null
+++ b/AI-Final-master/rooms/untitled.tmx
@@ -0,0 +1,57 @@
+
+
diff --git a/AI-Final-master/tile PNGs/basictiles.png b/AI-Final-master/tile PNGs/basictiles.png
new file mode 100644
index 0000000..5061a68
Binary files /dev/null and b/AI-Final-master/tile PNGs/basictiles.png differ
diff --git a/AI-Final-master/tile PNGs/basictiles1.png b/AI-Final-master/tile PNGs/basictiles1.png
new file mode 100644
index 0000000..71d9469
Binary files /dev/null and b/AI-Final-master/tile PNGs/basictiles1.png differ
diff --git a/AI-Final-master/tile PNGs/basictiles2.png b/AI-Final-master/tile PNGs/basictiles2.png
new file mode 100644
index 0000000..f9fa6e2
Binary files /dev/null and b/AI-Final-master/tile PNGs/basictiles2.png differ
diff --git a/AI-Final-master/tile PNGs/blueWizard.png b/AI-Final-master/tile PNGs/blueWizard.png
new file mode 100644
index 0000000..92a9766
Binary files /dev/null and b/AI-Final-master/tile PNGs/blueWizard.png differ
diff --git a/AI-Final-master/tile PNGs/dungeon_tiles.png b/AI-Final-master/tile PNGs/dungeon_tiles.png
new file mode 100644
index 0000000..53df861
Binary files /dev/null and b/AI-Final-master/tile PNGs/dungeon_tiles.png differ
diff --git a/AI-Final-master/tile PNGs/floor.png b/AI-Final-master/tile PNGs/floor.png
new file mode 100644
index 0000000..319618b
Binary files /dev/null and b/AI-Final-master/tile PNGs/floor.png differ
diff --git a/AI-Final-master/tile PNGs/stairsUp.png b/AI-Final-master/tile PNGs/stairsUp.png
new file mode 100644
index 0000000..b4acb25
Binary files /dev/null and b/AI-Final-master/tile PNGs/stairsUp.png differ
diff --git a/AI-Final-master/tile PNGs/wallSideOne.png b/AI-Final-master/tile PNGs/wallSideOne.png
new file mode 100644
index 0000000..155bd34
Binary files /dev/null and b/AI-Final-master/tile PNGs/wallSideOne.png differ
diff --git a/AI-Final-master/tile PNGs/wallSideTwo.png b/AI-Final-master/tile PNGs/wallSideTwo.png
new file mode 100644
index 0000000..ebd1035
Binary files /dev/null and b/AI-Final-master/tile PNGs/wallSideTwo.png differ
diff --git a/AI-Final-master/tile PNGs/wallTopOne.png b/AI-Final-master/tile PNGs/wallTopOne.png
new file mode 100644
index 0000000..c3f3432
Binary files /dev/null and b/AI-Final-master/tile PNGs/wallTopOne.png differ
diff --git a/AI-Final-master/tile PNGs/wallTopTwo.png b/AI-Final-master/tile PNGs/wallTopTwo.png
new file mode 100644
index 0000000..5c791e0
Binary files /dev/null and b/AI-Final-master/tile PNGs/wallTopTwo.png differ
diff --git a/testing.py b/testing.py
new file mode 100644
index 0000000..7f5781b
--- /dev/null
+++ b/testing.py
@@ -0,0 +1,140 @@
+"""
+This file is meant to be used to test various parts of the final game in static, mostly blank world.
+The world is created using Tiled and pyTMX.
+
+Features to test here include initial player movement, player attacking, enemy AI movement, and enemy attacking.
+"""
+import sys
+import random
+import pygame
+from pygame.locals import *
+from pytmx.util_pygame import load_pygame
+
+#INITIALIZE GAME
+pygame.init()
+pygame.display.set_caption("Dungeon Crawler")
+win = pygame.display.set_mode((640,640))
+clock = pygame.time.Clock()
+wizard = pygame.image.load("tile PNGs\\blueWizard.png") # Load player sprite
+tmxdata = load_pygame("rooms\\basic_room.tmx") # Load map from tmx file
+
+
+class player(object):
+ #Initialization function
+ def __init__(self, x,y, width, height):
+ self.x = x
+ self.y = y
+ self.width = width
+ self.height = height
+ self.vel = 5
+ self.up = False
+ self.down = False
+ self.left = False
+ self.right = False
+ self.walkCount = 0
+
+
+ def draw(self, win):
+ if self.walkCount + 1 >= 27:
+ self.walkCount = 0
+ #ADD SPRITES BASED ON WHICH DIRECTION ITS FACING
+ if self.left:
+ win.blit(wizard[self.walkCount//3], (self.x, self.y))
+ self.walkCount += 1
+ elif self.right:
+ win.blit(wizard[self.walkCount//3], (self.x, self.y))
+ self.walkCount += 1
+ elif self.up:
+ win.blit(wizard[self.walkCount//3], (self.x, self.y))
+ self.walkCount += 1
+ elif self.down:
+ win.blit(wizard[self.walkCount//3], (self.x, self.y))
+ self.walkCount += 1
+
+
+def getLocProperties(tmxdata, xPos, yPos):
+ xTile = xPos // 16
+ yTile = yPos // 16
+ wallProp = tmxdata.get_tile_properties(xTile, yTile, 0)
+ stairProp = tmxdata.get_tile_properties(xTile, yTile, 1)
+
+ if wallProp is None: # set default properties if none are found
+ wallProp = {"solid":0, "stairs":0}
+ stairProp = {"solid":0, "stairs":0}
+ return (wallProp, stairProp)
+# end getLocProperties
+
+def draw_map():
+
+ """
+ #tmxdata = load_pygame("rooms\\basic_room.tmx") # Load map from tmx file
+ for layer in tmxdata:
+ for tiles in layer.tiles():
+ xPixelPos = tiles[0] * 16 #+ world_offset
+ yPixelPos = tiles[1] * 16 #+ world_offset
+ mapImg = tiles[2] #get img to draw from tmxdata
+ win.blit(mapImg, (xPixelPos, yPixelPos)) #draw map to screen
+ """
+ win.blit(bg, (0,0))
+ p1.draw(win)
+
+ pygame.display.update()
+# end draw_map()
+
+
+
+#MAIN LOOP
+p1 = player(320, 500, 64, 64)
+running = True
+
+while running:
+ win.fill((255,255,255)) # Screen starts white before doing anything else
+ keys = pygame.key.get_pressed()
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ running = False
+
+
+ if keys[pygame.K_LEFT] and p1.x > p1.vel:
+ p1.x -= p1.vel
+ p1.left = True
+ p1.right = False
+ elif keys[pygame.K_RIGHT] and p1.x < 500 - p1.width - p1.vel:
+ p1.x += p1.vel
+ p1.right = True
+ p1.left = False
+ else:
+ p1.right = False
+ p1.left = False
+ p1.walkCount = 0
+
+
+ """
+ if keys[ord("a")]: # check what key was pressed
+ p1.westTile = getLocProperties(tmxdata, xPos-2, yPos+11) #find the tile next to the player and get its properties
+ if p1.westTile[0]['solid'] == 0: # if not solid keep moving, stop otherwise
+ xPos += -1
+ if keys[ord("d")]:
+ p1.eastTile = getLocProperties(tmxdata, xPos+22, yPos+11)
+ if p1.eastTile[0]['solid'] == 0:
+ xPos += 1
+ if keys[ord("w")]:
+ p1.northTile = getLocProperties(tmxdata, xPos, yPos-2)
+ if p1.northTile[0]['solid'] == 0:
+ yPos += -1
+ if keys[ord("s")]:
+ p1.southTile = getLocProperties(tmxdata, xPos+2, yPos+22)
+ if p1.southTile[0]['solid'] == 0:
+ yPos += 1
+
+"""
+ draw_map()
+
+
+
+
+pygame.quit()
+
+
+
+