Fix Python3 compatibility
Closes: #958463, #1028598
Thanks: Ionen Wolkens for the patch
Reiner Herrmann
1 year, 3 months ago
42 | 42 | |
43 | 43 | # Direction references |
44 | 44 | dirs = ((0,-1),(1,0),(0,1),(-1,0)) |
45 | @@ -125,9 +125,9 @@ | |
45 | @@ -125,16 +125,16 @@ | |
46 | 46 | fullname = os.path.join('graphics', name) |
47 | 47 | try: |
48 | 48 | image = pygame.image.load(fullname) |
55 | 55 | |
56 | 56 | if size is not None: |
57 | 57 | image = pygame.transform.scale( image, size) |
58 | image = image.convert() | |
59 | ||
60 | if colorkey is not None: | |
61 | - if colorkey is -1: | |
62 | + if colorkey == -1: | |
63 | colorkey = image.get_at((0,0)) | |
64 | image.set_colorkey(colorkey, RLEACCEL) | |
65 | return image | |
58 | 66 | @@ -147,8 +147,8 @@ |
59 | 67 | fullname = os.path.join('sounds', name) |
60 | 68 | try: |
486 | 494 | tile_xr = pos[0] - self.pos[0] - tile_x * tile_size |
487 | 495 | tile_yr = pos[1] - self.pos[1] - tile_y * tile_size |
488 | 496 | if tile_x >= 0 and tile_x < horiz_tiles and \ |
497 | @@ -1397,10 +1397,10 @@ | |
498 | ||
499 | # Handle Input Events | |
500 | for event in pygame.event.get(): | |
501 | - if event.type is QUIT: | |
502 | + if event.type == QUIT: | |
503 | return -4 | |
504 | - elif event.type is KEYDOWN: | |
505 | - if event.key is K_ESCAPE: return -3 | |
506 | + elif event.type == KEYDOWN: | |
507 | + if event.key == K_ESCAPE: return -3 | |
508 | elif event.key == ord('n'): return 2 | |
509 | elif event.key == ord('b'): return 3 | |
510 | elif event.key == ord(' ') or \ | |
511 | @@ -1421,7 +1421,7 @@ | |
512 | elif event.key == K_F4: | |
513 | toggle_sound() | |
514 | ||
515 | - elif event.type is MOUSEBUTTONDOWN: | |
516 | + elif event.type == MOUSEBUTTONDOWN: | |
517 | if self.paused: | |
518 | self.paused = 0 | |
519 | popdown( pause_popup) | |
489 | 520 | @@ -1491,16 +1491,16 @@ |
490 | 521 | except: |
491 | 522 | try: |
565 | 596 | |
566 | 597 | rc = self.board_dialog( message, 1, 1) |
567 | 598 | self.level += 1 |
599 | @@ -1715,9 +1715,9 @@ | |
600 | while 1: | |
601 | pygame.time.wait(20) | |
602 | for event in pygame.event.get(): | |
603 | - if event.type is QUIT: | |
604 | + if event.type == QUIT: | |
605 | return -2 | |
606 | - elif event.type is KEYDOWN: | |
607 | + elif event.type == KEYDOWN: | |
608 | if event.key == K_ESCAPE: return -1 | |
609 | if event.key == ord('b'): | |
610 | if self.level > 0: self.level -= 1 | |
611 | @@ -1746,7 +1746,7 @@ | |
612 | event.key == K_RCTRL: | |
613 | continue | |
614 | return 1 | |
615 | - elif event.type is MOUSEBUTTONDOWN: | |
616 | + elif event.type == MOUSEBUTTONDOWN: | |
617 | return 1 | |
618 | ||
619 | def translate_key( key, shift_state): | |
568 | 620 | @@ -1776,7 +1776,7 @@ |
569 | 621 | return key |
570 | 622 | |
574 | 626 | cursor_pos = [cursor_box[0], cursor_box[1], cursor_width, cursor_box[3]] |
575 | 627 | name = "" |
576 | 628 | |
629 | @@ -1801,14 +1801,14 @@ | |
630 | ||
631 | pygame.time.wait(20) | |
632 | for event in pygame.event.get(): | |
633 | - if event.type is QUIT: | |
634 | + if event.type == QUIT: | |
635 | return None | |
636 | - elif event.type is KEYUP: | |
637 | + elif event.type == KEYUP: | |
638 | if event.key == K_LSHIFT: | |
639 | shift_state &= ~KMOD_LSHIFT | |
640 | elif event.key == K_RSHIFT: | |
641 | shift_state &= ~KMOD_RSHIFT | |
642 | - elif event.type is KEYDOWN: | |
643 | + elif event.type == KEYDOWN: | |
644 | if event.key == K_LSHIFT: | |
645 | shift_state |= KMOD_LSHIFT | |
646 | elif event.key == K_RSHIFT: | |
577 | 647 | @@ -1835,7 +1835,7 @@ |
578 | 648 | "Sound Effects:", "Quit Game") |
579 | 649 | start_level = 1 |
583 | 653 | menu_font_height = 32 |
584 | 654 | menu_color = (255,255,255) |
585 | 655 | menu_cursor_color = (60,60,60) |
656 | @@ -2014,12 +2014,12 @@ | |
657 | ||
658 | pygame.time.wait(20) | |
659 | for event in pygame.event.get(): | |
660 | - if event.type is QUIT: | |
661 | + if event.type == QUIT: | |
662 | if self.curpage == 1: | |
663 | self.go_to_main_menu() | |
664 | continue | |
665 | return -2 | |
666 | - elif event.type is KEYDOWN: | |
667 | + elif event.type == KEYDOWN: | |
668 | if event.key == K_F2: | |
669 | play_sound( menu_select) | |
670 | if not toggle_fullscreen(): return -3 | |
671 | @@ -2060,7 +2060,7 @@ | |
672 | self.inc_level() | |
673 | self.draw_menu() | |
674 | continue | |
675 | - elif event.type is MOUSEBUTTONDOWN: | |
676 | + elif event.type == MOUSEBUTTONDOWN: | |
677 | if self.curpage == 1: | |
678 | self.go_to_main_menu() | |
679 | continue | |
586 | 680 | @@ -2072,7 +2072,7 @@ |
587 | 681 | if pos[0] < self.menu_pos[0]: continue |
588 | 682 | if pos[0] >= self.menu_pos[0] + self.menu_width: continue |