hi, i create a dungeon exploration game for my project, it is not done yet but i encounter some weird bug. There is not output (form print statement or the animation). I used python mode in here. Please provide help and help me trouble shoot the problem.
def setup():
size(2000, 1100)
global harrison_img
harrison_img = loadImage('Harrison_Jones.jpg')
global aluneth_img
aluneth_img = loadImage('Aluneth.jpg')
global miner_img
miner_img = loadImage('Cavern_Shinyfinder.jpg')
global darkness_img
darkness_img = loadImage('Darkness.jpg')
global dragon_img
dragon_img = loadImage('Hoarding_Dragon.jpg')
global kobold_img
kobold_img = loadImage('King_Togwaggale.jpg')
global kingsbane_img
kingsbane_img = loadImage('Kingsbane.jpg')
global recruits_img
recruits_img = loadImage('Level_Up.jpg')
global rhokdelar_img
rhokdelar_img = loadImage('Rhok\'delar.jpg')
global grizzly_img
grizzly_img = loadImage('Witchwood_Grizzly.jpg')
global armory_img
armory_img = loadImage('Armory.jpg')
global dungeon_img
dungeon_img = loadImage('Dungeon.jpg')
global mine_img
mine_img = loadImage('Mine.jpg')
global room_img
room_img = loadImage("Room.jpg")
global treasure_img
treasure_img = loadImage('Treasure_Room.jpg')
global arrow_img
arrow_img = loadImage('arrow.png')
global arrow_down_img
arrow_down_img = loadImage('arrow_down.png')
global arrow_left_img
arrow_left_img = loadImage('arrow_left.png')
global arrow_right_img
arrow_right_img = loadImage('arrow_right.png')
textSize(50)
from random import*
room_list = ['big trasure room', 'bigger treasure room', 'even bigger treasure room', 'dungeon', 'standard dungeon', 'regular dungeon', 'gold mine', 'diamond mine', 'emerald mine', 'armory 1', 'armory 2', 'armory 3', 'The Room of Darkness', 'The Room of Dragons', 'The Room of Beasts', 'Guarded passageway', 'Guarded corridor', 'Guarded hallway', 'Transportation Chamber', 'The Underground Library', 'The Graveyard of Adventurers']
win_condition = 0
player = [200, 2, 0, 0, 0]
gamemode = randint(1, 4)
if gamemode == 1:
win_condition = 4
if gamemode == 2:
win_condition = 25
if gamemode == 3:
win_condition = 15
toki = False
tess = False
darius = False
dragon = False
grizzly = False
darkness = False
aluneth = False
rhokdelar = False
kingsbane = False
#list, gold, emerald, diamond
def treasure(i, a, b, c, d, e, f):
j = randint(a, b)
if j <= 0:
i.append(0)
else:
i.append(randint(a, b))
j = randint(c,d)
if j <= 0:
i.append(0)
else:
i.append(randint(c, d))
j = randint(e,f)
if j <= 0:
i.append(0)
else:
i.append(randint(e, f))
treasure_list = [['big trasure room'], ['bigger treasure room'], ['even bigger treasure room'], ['dungeon'], ['standard dungeon'], ['regular dungeon'], ['gold mine'], ['diamond mine'], ['emerald mine'], ['armory 1'], ['armory 2'], ['armory 3'], ['The Room of Darkness'], ['The Room of Dragons'], ['The Room of Beasts']]
for i in range(3, 6):
treasure(treasure_list[i], 10, 100, 5, 40, -10, 3)
for i in range(1, 4):
treasure(treasure_list[i-1], 15*i, 120*i, 7*i, 70*i, 1*i, 10*i)
treasure(treasure_list[6], 250, 500, 0, 0, 0, 0)
treasure(treasure_list[8], 0, 0, 100, 250, 0, 0)
treasure(treasure_list[7], 0, 0, 0, 0, 12, 50)
for i in range(9, 12):
treasure(treasure_list[i], 10, 120, 5, 70, -10, 10)
for i in range(12, 15):
treasure(treasure_list[i], 30, 100, 25, 50, -5, 5)
if randint(1, 3) == 1:
treasure_list[randint(0, 14)].append('Tess\'s Cloak of Invisibility')
if randint(1, 3) == 1:
treasure_list[randint(0, 14)].append('Toki\'s Stopwatch')
if randint(1, 3) == 1:
treasure_list[randint(0, 14)].append('Darius\'s Cannon')
for i in range(3):
treasure_list[randint(0, 5)].append('lesser healing potion')
for i in range(2):
treasure_list[randint(0, 5)].append('healing potion')
treasure_list[randint(0, 5)].append('greater healing potion')
if gamemode == 1:
treasure_list[randint(0,14)].append('Wanderous Wand')
treasure_list[randint(0,14)].append('Tolin\'s Goblet')
treasure_list[randint(0,14)].append('Golden Kobald')
treasure_list[randint(0,14)].append('Zarog\'s Crown')
map = []
for i in range(21):
a = []
map.append(a)
def list_find(b, a):
for i in b:
if a == i:
return a
else:
return None
for i in range(21):
a = room_list[randint(1, len(room_list))-1]
map[i].insert(1, a)
for j in range (4):
map[i].append(None)
room_list.remove(a)
map.insert(2, ['entrance gate', None, 3, 7, 1])
map.insert(10, ['west hall', 5, 11, 15, None])
map.insert(14, ['east hall', 9, None, 19, 13])
map.insert(22, ['south hall', 17, 23, None, 21])
for i in range(25):
if i != 0 and i != 5 and i != 10 and i != 15 and i != 20:
map[i][4] = i - 1
if i != 4 and i != 9 and i != 14 and i != 19 and i != 24:
map[i][2] = i + 1
if i > 4:
map[i][1] = i - 5
if i < 20:
map[i][3] = i + 5
map_copy = []
for i in range(25):
map_copy.append(map[i])
map_copy.remove(map[2])
map_copy.remove(map[10])
map_copy.remove(map[14])
map_copy.remove(map[22])
a = 0
b = 4
counter = []
for i in range(25):
counter.append(i)
for x in range(12):
a = 0
b = 4
j = 0
while map[a][b] == None or a not in counter or (b == 1 and a-5 not in counter) or (b == 2 and a+1 not in counter) or (b==3 and a+5 not in counter) or (b==4 and a-1 not in counter)or (a==2 and b==3) or (a==7 and b==1)or(a==10 and b==2) or (a==11 and b==4) or (a==14 and b==4) or (a==13 and b==2) or (a==22 and b==1) or (a==17 and b==3):
a = choice(counter)
b = randint(1, 4)
j += 1
if j > 100:
break
if j > 100:
break
map[a][b] = None
if b == 1:
map[a-5][3] = None
counter.remove(a-5)
elif b == 2:
map[a+1][4] = None
counter.remove(a+1)
elif b == 3:
map[a+5][1] = None
counter.remove(a+5)
elif b == 4:
map[a-1][2] = None
counter.remove(a-1)
counter.remove(a)
print(counter)
print()
for i in treasure_list:
print(i)
def direction_to_num(q):
if q == 'w':
return 1
if q == 'd':
return 2
if q == 's':
return 3
if q == 'a':
return 4
else:
return None
def draw():
global player
global gamemode
global treasure_list
global win_condition
global aluneth
global rhokdelar
global kingsbane
global toki
global tess
global darius
global darkness
global grizzly
global dragon
enemy_list = [['big trasure room', None], ['bigger treasure room', None], ['even bigger treasure room', None], ['dungeon', [2, 10, 'kobalt', kobold_img]] , ['standard dungeon', [2, 10, 'kobalt', kobold_img]], ['regular dungeon', [2, 10, 'kobalt', kobold_img]], ['gold mine', [3, 5, 'miner', miner_img]], ['diamond mine', [3, 5, 'miner', miner_img]], ['emerald mine', [3, 5, 'miner', miner_img]], ['armory 1', [8, 10, 'Aluneth', aluneth_img]], ['armory 2', [8, 10, 'Rhok\'deklar', rhokdelar_img]], ['armory 3', [8, 10, 'Kingsbane', kingsbane_img]], ['The Room of Darkness', [4, 30, 'The Darkness', darkness_img]], ['The Room of Dragons', [4, 30, dragon_img]], ['The Room of Beasts', [4, 30, grizzly_img]], ['Guarded passageway', [6, 20, recruits_img]], ['Guarded corridor', [6, 20, recruits_img]], ['Guarded hallway', [6, 20, recruits_img]], ['Transportation Chamber', None], ['The Underground Library', None], ['The Graveyard of Adventurers', None], ['entrance gate', None], ['west hall', None], ['east hall', None], ['south hall', None]]
for i in range(len(enemy_list)):
if enemy_list[i][0] == map[player[1]][0] and enemy_list[i][1] != None:
print('You encounter', enemy_list[i][1][2])
enemy = enemy_list[i][1]
image(harrison_img, 0, 0)
image(enemy[3], 0, 0)
player_choice = -1
while enemy[1] >0 and player[0]>0:
player_choice = int(input('Choose your move...'))
if mousePressed:
if 800<mouseY<1000:
if 0<mouseX<250:
player_choice = 1
if 250<mouseX<500:
player_choice = 2
if 500<mouseX<750:
player_choice = 3
if 750<mouseX<1000 and tess == True and player[0] <= 80:
player_choice = 4
enemy_choice = randint(1, 3)
escape = -1
player_original = player[0]
enemy_original = enemy[1]
if player_choice == 4:
escape = randint[1, 2]
if escape == 1:
break
print('TESS\'S CLOAK OF INVISIBILITY ACTIVATE!!')
print(player_choice, enemy_choice)
if enemy_choice - player_choice == 1 or enemy_choice - player_choice == -2 and player_choice != 4:
enemy[1] -= 1
if aluneth == True and player_choice == 1:
enemy[1] -= 2
if rhokdelar == True and player_choice == 2:
enemy[1] -= 2
if kingsbane == True and player_choice == 3:
enemy[1] -= 2
if dragon == True and randint[1, 2] == 1:
print('DRAGON\'S FANG ACTIVATE!!')
enemy[1] -= 1
if darius == True and randint[1, 10] == 1:
enemy[1] -= enemy[1] - enemy_original
print('DARIUS\'S CANNON ACTIVATE!!')
print(enemy[2], 'loses', (enemy_original - enemy[1]), 'hp!')
if enemy[1] >= 0:
print(enemy[1], 'hp remains!')
else:
print('Victory!!!')
if player_choice - enemy_choice == 1 or player_choice - enemy_choice == -2 or player_choice == 4:
player[0] -= enemy[0]
if darkness == True and randint[1,5] == 1:
player[0] += enemy[0]
print('You loses', player_original - player[0], 'hp!')
if player[0] >= 0:
print(player[0], 'hp remains!')
elif toki == True:
player[0] == 100
print('TOKI\'S STOPWATCH ACTIVATE!!')
print('You have been brought back to life with 100 hp')
player[0] = 100
toki == False
else:
print('Defeated')
if grizzly == True and randint[1, 2] == 1:
player[0] += 10
print('GRIZZLY SOUL ACTIVATE!!')
print('regenerated 10 hp')
if player[0] <= 0:
win_condition = -1
break
else:
if gamemode != 3:
if enemy_list[i][0][1] != 'Guarded passageway' or 'Guarded hallway' or 'Guarded corridor':
enemy_list[i][1] = None
else:
enemy_list[i][1] = None
win_condition -= 1
for i in range(len(treasure_list)):
if treasure_list[i][0] == map[player[1]][0]:
if len(treasure_list) > 1:
print('You have found', treasure_list[i][1], 'gold')
print('You have found', treasure_list[i][2], 'emerald')
print('You have found', treasure_list[i][3], 'diamond')
for j in treasure_list[i]:
if j == 'lesser healing potion':
print('You have found', j)
player[0] += 20
if j == 'healing potion':
print('You have found', j)
player[0] += 40
if j == 'greater healing potion':
print('You have found', j)
player[0] += 60
if j == 'Tess\'s Cloak of Invisibility':
print('You have found', j)
tess = True
if j == 'Toki\'s Stopwatch':
print('You have found', j)
toki == True
if j == 'Darius\'s Cannon':
darius == True
print('You have found', j)
if j == 'Golden Kobald' or j == 'Zarog\'s Crown' or j == 'Tolin\'s Goblet' or j == 'Wanderous Wand':
print('You have found', j)
win_condition -= 1
if map[player[1]][0] == 'armory 1':
aluneth = True
print('You have found Aluneth')
if map[player[1]][0] == 'armory 2':
rhokdelar = True
print('You have found Rhok\'delar')
if map[player[1]][0] == 'armory 3':
kingsbane = True
print('You have found Kingsbane')
if map[player[1]][0] == 'The Room of Darkness':
darkness = True
print('You have found Darkness Candle')
if map[player[1]][0] == 'The Room of Dragons':
dragon = True
print('You have found Dragon Fang')
if map[player[1]][0] == 'The Room of Beasts':
grizzly = True
print('You have found Grizzly Soul')
for i in range(len(treasure_list)):
if treasure_list[i][0] == map[player[1]][0]:
treasure_list.remove(treasure_list[i])
break
if map[player[1]][0] == 'entrance gate' or map[player[1]][0] == 'west hall' or map[player[1]][0] == 'east hall' or map[player[1]][0] == 'south hall':
image(room_img, 0, 0)
if map[player[1]][0] == map[player[1]][0] == 'armory 1' or map[player[1]][0] == 'armory 2' or map[player[1]][0] == 'armory 3':
image(armory_img, 0, 0)
if map[player[1]][0] == 'room of darkness' or map[player[1]][0] == 'room of beast' or map[player[1]][0] == 'room of dragon':
image(room_img, 0, 0)
if map[player[1]][0] == 'dungeon' or map[player[1]][0] == 'standard dungeon' or map[player[1]][0] == 'regular dungeon':
image(dungeon_img, 0, 0)
if map[player[1]][0] == 'treasure room' or map[player[1]][0] == 'bigger treasure room' or map[player[1]][0] == 'even bigger treasure room':
image(treasure_img, 0, 0)
if map[player[1]][0] == 'gold mine' or map[player[1]][0] == 'emerald mine' or map[player[1]][0] == 'diamond mine':
image(mine_img, 0, 0)
if win_condition > 0:
if map[player[1]][1] != None:
textAlign(CENTER, CENTER)
text('{0}'.format(map[map[player[1]][1]][0]), 1000, 260)
image(arrow_img, 900, 30)
if map[player[1]][2] != None:
textAlign(RIGHT, CENTER)
text('{0}'.format(map[map[player[1]][2]][0]), 1740, 500)
image(arrow_left_img, 1770, 400)
if map[player[1]][3] != None:
textAlign(CENTER, CENTER)
text('{0}'.format(map[map[player[1]][3]][0]), 1000, 740)
image(arrow_down_img, 900, 770)
if map[player[1]][4] != None:
textAlign(LEFT, CENTER)
text('{0}'.format(map[map[player[1]][4]][0]), 260, 500)
image(arrow_right_img, 30, 400)
textAlign(CENTER, CENTER)
text('You are currently at {0}'.format(map[player[1]][0]), 1000, 1050)
if map[player[1]][1] != None:
print('The north way leads to the', map[map[player[1]][1]][0])
if map[player[1]][2] != None:
print('The east way leads to the', map[map[player[1]][2]][0])
if map[player[1]][3] != None:
print('The south way leads to the', map[map[player[1]][3]][0])
if map[player[1]][4] != None:
print('The west way leads to the', map[map[player[1]][4]][0])
determiner = False
while determiner == False:
if mousePressed:
if 900 < mouseX < 1100 and 260 < mouseY < 460:
player[1] = map[player[1]][1]
determiner = True
if 1770 < mouseX < 1970 and 400 < mouseY < 600:
player[1] = map[player[1]][2]
determiner = True
if 900 < mouseX < 1100 and 770 < mouseY < 970:
player[1] = map[player[1]][3]
determiner = True
if 30 < mouseX < 230 and 400 < mouseY < 600:
player[1] = map[player[1]][4]
determiner = True
elif win_condition == 0:
textAlign(CENTER)
text('You did it adventurer', 1000, 250)
textAlign(CENTER)
text('YOU WON !!!', 1000, 500)
textAlign(CENTER)
text('You collected {0} gold, {1} emerald, and {2} diamonds'.format(player[2], player[3], player[4]), 1000, 750)