ElementalMages_fullscreen.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. import os,sys,time
  2. import pygame
  3. pygame.init()
  4. from monster import *
  5. from tile import *
  6. from maP import *
  7. from world import *
  8. from sfx import *
  9. basic_path = os.path.dirname(os.path.realpath('main.py')) #just get the execution path for resources
  10. print(basic_path)
  11. data_path = basic_path+os.sep+'DATA'+os.sep
  12. print(data_path)
  13. class screen():
  14. def __init__(self):
  15. display_info = pygame.display.Info()
  16. self.scale_up = min(display_info.current_w, display_info.current_h)
  17. self.screen = pygame.display.set_mode((self.scale_up,self.scale_up),pygame.FULLSCREEN)
  18. def draw_title(self):
  19. s = pygame.Surface((64,64))
  20. s.blit(gl.glist['title'],(0,0))
  21. s = pygame.transform.scale(s,(screen.scale_up,screen.scale_up))
  22. screen.screen.blit(s,(0,0))
  23. pygame.display.flip()
  24. run = True
  25. while run:
  26. u = ui.get_ui(blocked=True)
  27. if u == 'e' or u == 'x':
  28. run = False
  29. def draw_gameover(self,victory=False):
  30. s = pygame.Surface((64,64))
  31. s.fill((20,12,28))
  32. if victory == False:
  33. sfx.play_sound('loose')
  34. dead_string = self.draw_string('YOU ARE DEAD')
  35. else:
  36. sfx.play_sound('win')
  37. dead_string = self.draw_string(' VICTORY')
  38. s.blit(dead_string,(3,6))
  39. score_string = self.draw_string('SCORE '+str(player.score))
  40. s.blit(score_string,(13,38))
  41. s = pygame.transform.scale(s,(screen.scale_up,screen.scale_up))
  42. screen.screen.blit(s,(0,0))
  43. pygame.display.flip()
  44. run = True
  45. while run:
  46. u = ui.get_ui(True)
  47. if u == 'e' or u == 'x':
  48. run = False
  49. exit(0)
  50. def draw_brake(self):
  51. run = True
  52. num = 0
  53. while run:
  54. bg = screen.render(simulation=True)
  55. bg.blit(gl.glist['unknown_mage'],(player.y*8,player.x*8))
  56. bg.blit(gl.glist['box2'],(8,11))
  57. resume = self.draw_string('RESUME')
  58. bg.blit(resume,(17,13))
  59. last_cp = self.draw_string('LAST CP')
  60. bg.blit(last_cp,(17,21))
  61. exit_s = self.draw_string('EXIT')
  62. bg.blit(exit_s,(17,29))
  63. bg.blit(gl.glist['marker'],(9,12+(num*8)))
  64. s = pygame.transform.scale(bg,(screen.scale_up,screen.scale_up))
  65. screen.screen.blit(s,(0,0))
  66. pygame.display.flip()
  67. u_input = ui.get_ui(False,True)
  68. if u_input == 'w':
  69. num -= 1
  70. sfx.play_sound('beep')
  71. if num < 0:
  72. num = 2
  73. if u_input == 's':
  74. num += 1
  75. sfx.play_sound('beep')
  76. if num > 2:
  77. num = 0
  78. if u_input == 'e':
  79. if num == 0:
  80. run = False
  81. elif num == 1:
  82. sfx.play_sound('tp')
  83. player.on_map = player.last_cp_map
  84. player.x = player.last_cp_x
  85. player.y = player.last_cp_y
  86. player.x_dest = player.x
  87. player.y_dest = player.y
  88. run = False
  89. else:
  90. exit(0)
  91. def draw_map(self,re_maP):
  92. s = pygame.Surface((64,64))
  93. for y in range(0,8):
  94. for x in range(0,8):
  95. s.blit(gl.glist[tile_list[re_maP.tiles[y][x]].graphic],(x*8,y*8))
  96. return s
  97. def draw_string(self,string):
  98. l = len(string)
  99. s = pygame.Surface((l*8,5))
  100. s.fill((255,0,255))
  101. for i in range(0,l):
  102. if string[i] != ' ':
  103. s.blit(gl.glist[string[i]],(5*i,0))
  104. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  105. s = s.convert_alpha()
  106. return s
  107. def draw_lp(self):
  108. s = pygame.Surface((22,4))
  109. s.blit(gl.glist['lp_bar_empty'],(0,0))
  110. help_s = pygame.Surface((max(player.lp*2,0),4))
  111. help_s.blit(gl.glist['lp_bar_full'],(0,0))
  112. s.blit(help_s,(1,0))
  113. return s
  114. def draw_monster(self,monster):
  115. s = pygame.Surface((8,8))
  116. s.fill((255,0,255))
  117. if monster.lp > 0:
  118. s.blit(gl.glist[monster.graphic],(0,0))
  119. #if monster.lp >= 3:
  120. # s.blit(gl.glist['mon_3_lp'],(0,0))
  121. #elif monster.lp == 2:
  122. # s.blit(gl.glist['mon_2_lp'],(0,0))
  123. #elif monster.lp == 1:
  124. # s.blit(gl.glist['mon_1_lp'],(0,0))
  125. if monster.lp < 1:
  126. s.blit(gl.glist['monster_dead'],(0,0))
  127. s.set_colorkey((255,0,255),pygame.RLEACCEL)
  128. s = s.convert_alpha()
  129. return s
  130. def render(self,blink='none',simulation=False):
  131. map_image = self.draw_map(world[player.on_map])
  132. for c in range(0,8):
  133. offset.set_offset(c)
  134. if player.x_dest > player.x:
  135. y_offset = offset.h_y_offset
  136. x_offset = offset.h_x_offset
  137. elif player.x_dest < player.x:
  138. y_offset = offset.h_y_offset
  139. x_offset = offset.h_x_offset*(-1)
  140. elif player.y_dest > player.y:
  141. y_offset = offset.v_y_offset
  142. x_offset = offset.v_x_offset
  143. elif player.y_dest < player.y:
  144. y_offset = offset.v_y_offset*(-1)
  145. x_offset = offset.v_x_offset
  146. else:
  147. x_offset = 0
  148. y_offset = 0
  149. s = pygame.Surface((64,64))
  150. s.blit(map_image,(0,0))
  151. for i in world[player.on_map].monsters:
  152. if i.x_dest > i.x:
  153. m_y_offset = offset.h_y_offset
  154. m_x_offset = offset.h_x_offset
  155. elif i.x_dest < i.x:
  156. m_y_offset = offset.h_y_offset
  157. m_x_offset = offset.h_x_offset*(-1)
  158. elif i.y_dest > i.y:
  159. m_y_offset = offset.v_y_offset
  160. m_x_offset = offset.v_x_offset
  161. elif i.y_dest < i.y:
  162. m_y_offset = offset.v_y_offset*(-1)
  163. m_x_offset = offset.v_x_offset
  164. else:
  165. m_x_offset = 0
  166. m_y_offset = 0
  167. s.blit(self.draw_monster(i),((i.y*8)+m_y_offset,(i.x*8)+m_x_offset))
  168. s.blit(gl.glist['player'][player.mage],((player.y*8)+y_offset,(player.x*8)+x_offset))
  169. if blink != 'none':
  170. alpha = (32,64,128,128,255,128,128,64,32)
  171. color = {'red' : (208,70,72,alpha[c]) , 'white' : (222,238,214,alpha[c]) , 'blue' : (133,149,161,alpha[c])}
  172. bs = pygame.Surface((64,64),pygame.SRCALPHA)
  173. bs.fill(color[blink])
  174. s.blit(bs,(0,0))
  175. s.blit(screen.draw_lp(),(0,0))
  176. s.blit(gl.glist['key_w'],(23,0))
  177. if len(str(player.keys)) == 2:
  178. key_string = str(player.keys)
  179. else:
  180. key_string = '0'+str(player.keys)
  181. s.blit(screen.draw_string(key_string),(29,0))
  182. sn = 4-len(str(player.score))
  183. zero_string = ''
  184. if sn > 0:
  185. for j in range(0,sn):
  186. zero_string += '0'
  187. score_string = zero_string + str(player.score)
  188. s.blit(screen.draw_string(score_string),(45,0))
  189. if simulation == True:
  190. return s
  191. s = pygame.transform.scale(s,(self.scale_up,self.scale_up))
  192. self.screen.blit(s,(0,0))
  193. pygame.display.flip()
  194. clock.tick(24)
  195. class offset():
  196. def __init__(self):
  197. self.h_x_offset = 0
  198. self.h_y_offset = 0
  199. self.v_x_offset = 0
  200. self.v_y_offset = 0
  201. def set_offset(self,frame):
  202. self.v_y_offset = frame
  203. self.h_x_offset = frame
  204. if frame % 4 == 0:
  205. if self.v_y_offset == 0:
  206. self.v_x_offset = -1
  207. self.h_y_offset = -1
  208. else:
  209. self.v_x_offset = 0
  210. self.h_y_offset = 0
  211. class gra_files():
  212. def __init__(self):
  213. self.glist = {}
  214. self.glist['player'] = []
  215. i_name = data_path + 'firemage.png'
  216. i = pygame.image.load(i_name)
  217. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  218. i = i.convert_alpha()
  219. self.glist['player'].append(i)
  220. i_name = data_path + 'watermage.png'
  221. i = pygame.image.load(i_name)
  222. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  223. i = i.convert_alpha()
  224. self.glist['player'].append(i)
  225. i_name = data_path + 'skymage.png'
  226. i = pygame.image.load(i_name)
  227. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  228. i = i.convert_alpha()
  229. self.glist['player'].append(i)
  230. i_name = data_path + 'earthmage.png'
  231. i = pygame.image.load(i_name)
  232. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  233. i = i.convert_alpha()
  234. self.glist['player'].append(i)
  235. #Alphabet
  236. al = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9','0','+','-')
  237. for j in al:
  238. i_name = data_path + j +'.png'
  239. i = pygame.image.load(i_name)
  240. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  241. i = i.convert_alpha()
  242. self.glist[j] = i
  243. #/Alphabet
  244. i_name = data_path + 'earth.png'
  245. i = pygame.image.load(i_name)
  246. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  247. i = i.convert_alpha()
  248. self.glist['earth'] = i
  249. i_name = data_path + 'fire.png'
  250. i = pygame.image.load(i_name)
  251. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  252. i = i.convert_alpha()
  253. self.glist['fire'] = i
  254. i_name = data_path + 'water.png'
  255. i = pygame.image.load(i_name)
  256. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  257. i = i.convert_alpha()
  258. self.glist['water'] = i
  259. i_name = data_path + 'air.png'
  260. i = pygame.image.load(i_name)
  261. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  262. i = i.convert_alpha()
  263. self.glist['air'] = i
  264. i_name = data_path + 'lp_bar_full.png'
  265. i = pygame.image.load(i_name)
  266. self.glist['lp_bar_full'] = i
  267. i_name = data_path + 'lp_bar_empty.png'
  268. i = pygame.image.load(i_name)
  269. self.glist['lp_bar_empty'] = i
  270. i_name = data_path + 'lp_bar_blink.png'
  271. i = pygame.image.load(i_name)
  272. self.glist['lp_bar_blink'] = i
  273. i_name = data_path + 'title.png'
  274. i = pygame.image.load(i_name)
  275. self.glist['title'] = i
  276. i_name = data_path + 'wall.png'
  277. i = pygame.image.load(i_name)
  278. self.glist['wall'] = i
  279. i_name = data_path + 'floor.png'
  280. i = pygame.image.load(i_name)
  281. self.glist['floor'] = i
  282. i_name = data_path + 'fence.png'
  283. i = pygame.image.load(i_name)
  284. self.glist['fence'] = i
  285. i_name = data_path + 'heart.png'
  286. i = pygame.image.load(i_name)
  287. self.glist['heart'] = i
  288. i_name = data_path + 'door.png'
  289. i = pygame.image.load(i_name)
  290. self.glist['door'] = i
  291. i_name = data_path + 'key.png'
  292. i = pygame.image.load(i_name)
  293. self.glist['key'] = i
  294. i_name = data_path + 'thorn.png'
  295. i = pygame.image.load(i_name)
  296. self.glist['thorn'] = i
  297. i_name = data_path + 'gem.png'
  298. i = pygame.image.load(i_name)
  299. self.glist['gem'] = i
  300. i_name = data_path + 'checkpoint_activ.png'
  301. i = pygame.image.load(i_name)
  302. self.glist['checkpoint_activ'] = i
  303. i_name = data_path + 'checkpoint_passiv.png'
  304. i = pygame.image.load(i_name)
  305. self.glist['checkpoint_passiv'] = i
  306. i_name = data_path + 'amulett.png'
  307. i = pygame.image.load(i_name)
  308. self.glist['amulett'] = i
  309. i_name = data_path + 'teleport.png'
  310. i = pygame.image.load(i_name)
  311. self.glist['teleport'] = i
  312. i_name = data_path + 'unknown_mage.png'
  313. i = pygame.image.load(i_name)
  314. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  315. i = i.convert_alpha()
  316. self.glist['unknown_mage'] = i
  317. i_name = data_path + 'box1.png'
  318. i = pygame.image.load(i_name)
  319. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  320. i = i.convert_alpha()
  321. self.glist['box1'] = i
  322. i_name = data_path + 'box2.png'
  323. i = pygame.image.load(i_name)
  324. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  325. i = i.convert_alpha()
  326. self.glist['box2'] = i
  327. i_name = data_path + 'marker.png'
  328. i = pygame.image.load(i_name)
  329. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  330. i = i.convert_alpha()
  331. self.glist['marker'] = i
  332. i_name = data_path + 'key_w.png'
  333. i = pygame.image.load(i_name)
  334. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  335. i = i.convert_alpha()
  336. self.glist['key_w'] = i
  337. i_name = data_path + 'mon_3_lp.png'
  338. i = pygame.image.load(i_name)
  339. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  340. i = i.convert_alpha()
  341. self.glist['mon_3_lp'] = i
  342. i_name = data_path + 'mon_2_lp.png'
  343. i = pygame.image.load(i_name)
  344. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  345. i = i.convert_alpha()
  346. self.glist['mon_2_lp'] = i
  347. i_name = data_path + 'mon_1_lp.png'
  348. i = pygame.image.load(i_name)
  349. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  350. i = i.convert_alpha()
  351. self.glist['mon_1_lp'] = i
  352. i_name = data_path + 'monster_dead.png'
  353. i = pygame.image.load(i_name)
  354. i.set_colorkey((255,0,255),pygame.RLEACCEL)
  355. i = i.convert_alpha()
  356. self.glist['monster_dead'] = i
  357. class player():
  358. def __init__(self):
  359. self.x = 4
  360. self.y = 4
  361. self.x_dest = self.x
  362. self.y_dest = self.y
  363. self.on_map = 'map1'
  364. self.last_cp_map = self.on_map
  365. self.last_cp_x = self.x
  366. self.last_cp_y = self.y
  367. self.mage = 0
  368. self.lp_max = 10
  369. self.lp = self.lp_max
  370. self.keys = 0
  371. self.score = 0
  372. self.move_blocked = False
  373. def check_wall_col(self,te_maP,x,y):
  374. global blink
  375. if x != player.x:
  376. x_change = True
  377. else:
  378. x_change = False
  379. if x_change == True and player.y_dest != player.y:
  380. player.y_dest = player.y
  381. elif x_change == False and player.x_dest != player.x:
  382. player.x_dest = player.x
  383. if self.move_blocked == True:
  384. return False
  385. if min(x,y) > -1 and max(x,y) < 8:
  386. for i in range(0,len(te_maP.monsters)):
  387. if x == te_maP.monsters[i].x and y == te_maP.monsters[i].y and te_maP.monsters[i].move_blocked == False:
  388. blink = te_maP.monsters[i].fight(self,te_maP)
  389. elif x == te_maP.monsters[i].x and y == te_maP.monsters[i].y:
  390. return False
  391. if world[self.on_map].tiles[x][y] == 'A':
  392. screen.draw_gameover(True)
  393. if world[self.on_map].tiles[x][y] == 't':
  394. sfx.play_sound('tp')
  395. if tile_list[te_maP.tiles[x][y]].special == 'cp_passiv':
  396. world[self.on_map].tiles[x][y] = 'C'
  397. world[self.last_cp_map].tiles[self.last_cp_x][self.last_cp_y] = 'c'
  398. self.last_cp_map = player.on_map
  399. self.last_cp_x = x
  400. self.last_cp_y = y
  401. sfx.play_sound('activate')
  402. blink = 'white'
  403. if tile_list[te_maP.tiles[x][y]].hurt:
  404. self.lp -= 1
  405. sfx.play_sound('hit')
  406. blink = 'red'
  407. if tile_list[te_maP.tiles[x][y]].special == 'key':
  408. world[self.on_map].tiles[x][y] = '.'
  409. self.keys += 1
  410. sfx.play_sound('got')
  411. blink = 'white'
  412. if tile_list[te_maP.tiles[x][y]].special == 'heart':
  413. world[self.on_map].tiles[x][y] = '.'
  414. self.lp = self.lp_max
  415. sfx.play_sound('heal')
  416. blink = 'white'
  417. if tile_list[te_maP.tiles[x][y]].special == 'gem':
  418. world[self.on_map].tiles[x][y] = '.'
  419. self.score += 10
  420. sfx.play_sound('got')
  421. blink = 'blue'
  422. if tile_list[te_maP.tiles[x][y]].special == 'door' and self.keys > 0:
  423. world[self.on_map].tiles[x][y] = '.'
  424. self.keys -= 1
  425. sfx.play_sound('door')
  426. return False
  427. if tile_list[te_maP.tiles[x][y]].move == True:
  428. if pygame.mixer.get_busy() == False:
  429. sfx.play_sound('step')
  430. return tile_list[te_maP.tiles[x][y]].move
  431. else:
  432. return False
  433. def check_tp(self,te_maP):
  434. for i in te_maP.tp:
  435. if self.x == i[0] and self.y == i[1]:
  436. self.on_map = i[2]
  437. self.x = i[3]
  438. self.y = i[4]
  439. self.x_dest = self.x
  440. self.y_dest = self.y
  441. return True
  442. return False
  443. def choose_mage(self):
  444. run = True
  445. num = 0
  446. while run:
  447. bg = screen.render(simulation=True)
  448. bg.blit(gl.glist['unknown_mage'],(player.y*8,player.x*8))
  449. bg.blit(gl.glist['box1'],(23,13))
  450. for i in range(0,4):
  451. bg.blit(gl.glist['player'][i],(33,15+(i*9)))
  452. bg.blit(gl.glist['marker'],(25,15+(num*9)))
  453. s = pygame.transform.scale(bg,(screen.scale_up,screen.scale_up))
  454. screen.screen.blit(s,(0,0))
  455. pygame.display.flip()
  456. u_input = ui.get_ui(False,True)
  457. if u_input == 'w':
  458. num -= 1
  459. sfx.play_sound('beep')
  460. if num < 0:
  461. num = 3
  462. elif u_input == 's':
  463. num += 1
  464. sfx.play_sound('beep')
  465. if num > 3:
  466. num = 0
  467. elif u_input == 'e':
  468. return num
  469. elif u_input == 'x':
  470. run = False
  471. return self.mage
  472. class ui():
  473. def __init__(self):
  474. self.vcon ={'w':False,'s':False,'a':False,'d':False,'e':False,'x':False}
  475. self.num_blocked = 0
  476. def get_ui(self,blocked,one_press=False):
  477. if one_press == True:
  478. self.vcon ={'w':False,'s':False,'a':False,'d':False,'e':False,'x':False}
  479. g = None
  480. if blocked == True:
  481. self.num_blocked += 1
  482. if self.num_blocked > 2:
  483. blocked = False
  484. else:
  485. self.num_blocked = 0
  486. for event in pygame.event.get():
  487. if event.type == pygame.KEYDOWN:
  488. if (event.key == pygame.K_w or event.key == pygame.K_UP) and blocked == False:
  489. self.vcon['w'] = True
  490. elif (event.key == pygame.K_s or event.key == pygame.K_DOWN) and blocked == False:
  491. self.vcon['s'] = True
  492. elif (event.key == pygame.K_a or event.key == pygame.K_LEFT) and blocked == False:
  493. self.vcon['a'] = True
  494. elif (event.key == pygame.K_d or event.key == pygame.K_RIGHT) and blocked == False:
  495. self.vcon['d'] = True
  496. elif event.key == pygame.K_e or event.key == pygame.K_SPACE:
  497. self.vcon['e'] = True
  498. if event.key == pygame.K_x or event.key == pygame.K_ESCAPE:
  499. self.vcon['x'] = True
  500. elif event.type == pygame.KEYUP and one_press == False:
  501. if (event.key == pygame.K_w or event.key == pygame.K_UP):
  502. self.vcon['w'] = False
  503. elif (event.key == pygame.K_s or event.key == pygame.K_DOWN):
  504. self.vcon['s'] = False
  505. elif (event.key == pygame.K_a or event.key == pygame.K_LEFT):
  506. self.vcon['a'] = False
  507. elif (event.key == pygame.K_d or event.key == pygame.K_RIGHT):
  508. self.vcon['d'] = False
  509. elif event.key == pygame.K_e or event.key == pygame.K_SPACE:
  510. self.vcon['e'] = False
  511. if event.key == pygame.K_x or event.key == pygame.K_ESCAPE:
  512. self.vcon['x'] = False
  513. if self.vcon['w'] == True:
  514. g = 'w'
  515. elif self.vcon['s'] == True:
  516. g = 's'
  517. elif self.vcon['a'] == True:
  518. g = 'a'
  519. elif self.vcon['d'] == True:
  520. g = 'd'
  521. elif self.vcon['e'] == True:
  522. g = 'e'
  523. if self.vcon['x'] == True:
  524. g = 'x'
  525. return g
  526. screen = screen()
  527. gl = gra_files()
  528. ui = ui()
  529. sfx = sfx(data_path)
  530. offset = offset()
  531. player = player()
  532. clock = pygame.time.Clock()
  533. screen.draw_title()
  534. blink = 'none'
  535. run = True
  536. loop_count = 0
  537. while run:
  538. player.check_tp(world[player.on_map])
  539. ####test
  540. screen.render(blink)
  541. ####/test
  542. if player.lp <= 0:
  543. screen.draw_gameover()
  544. blink = 'none'
  545. user_input = ui.get_ui(player.move_blocked)
  546. player.move_blocked = False
  547. player.x = player.x_dest
  548. player.y = player.y_dest
  549. if user_input == 'x':
  550. screen.draw_brake()
  551. if user_input == 'w':
  552. if player.check_wall_col(world[player.on_map],player.x-1,player.y):
  553. player.x_dest -=1
  554. if user_input == 's':
  555. if player.check_wall_col(world[player.on_map],player.x+1,player.y):
  556. player.x_dest +=1
  557. if user_input == 'a':
  558. if player.check_wall_col(world[player.on_map],player.x,player.y-1):
  559. player.y_dest -=1
  560. if user_input == 'd':
  561. if player.check_wall_col(world[player.on_map],player.x,player.y+1):
  562. player.y_dest +=1
  563. if user_input == 'e' and world[player.on_map].tiles[player.x][player.y] == 'C':
  564. player.mage = player.choose_mage()
  565. ml = []
  566. for k in range(0,len(world[player.on_map].monsters)):
  567. if world[player.on_map].monsters[k].lp > 0:
  568. ml.append(world[player.on_map].monsters[k])
  569. world[player.on_map].monsters = ml
  570. for q in range(0,len(world[player.on_map].monsters)):
  571. if world[player.on_map].monsters[q].move_blocked == False:
  572. b_test = world[player.on_map].monsters[q].AI_move(player,world[player.on_map])
  573. else:
  574. b_test = None
  575. if b_test == 'red' or b_test == 'blue' or b_test == 'white':
  576. blink = b_test
  577. world[player.on_map].monsters[q].move_blocked = False