Well I have been working on this game for my "AI" for a few hours and it is just a list-text based game, for some reason tho, the lists are not like I would say they should.
import random
sizeX = 3
sizeY = 4
won = 0
coordX = random.randint(0, 2)
coordY = random.randint(0, 3)
displayLayer = []
def move():
global coordX, coordY, won
print("Where do u wanna move [W, A, S, D]")
userInput = input()
if userInput == 'w' or 'W':
if coordY == 0:
won = 1
else:
coordY = coordY + 1
if userInput == 'a' or 'A':
if coordX == 0:
pass
else:
coordX = coordX - 1
if userInput == 's' or 'S':
if coordY == sizeY - 1:
pass
else:
coordY = coordY - 1
if userInput == 'd' or 'D':
if coordX == sizeX - 1:
pass
else:
coordX = coordX + 1
def updateVisuals(y):
global coordX, coordY
if y == coordY + 1:
for i in range(coordX):
displayLayer.append(0)
displayLayer.append(1)
for i in range(sizeX - coordX - 1):
displayLayer.append(0)
else:
for i in range(sizeX):
displayLayer.append(0)
def showLists():
for i in range(sizeY):
displayLayer.clear()
updateVisuals(i)
print(displayLayer)
showLists()
move()
showLists()
sometimes the "player" (1) is just out of "map" and it doesn't move, sometimes I do 'd' and I move up, I would love help...
Aucun commentaire:
Enregistrer un commentaire