diff --git a/background/fort_01.png b/background/fort_01.png new file mode 100644 index 0000000..f004b09 Binary files /dev/null and b/background/fort_01.png differ diff --git a/background/fort_02.png b/background/fort_02.png new file mode 100644 index 0000000..df6d475 Binary files /dev/null and b/background/fort_02.png differ diff --git a/background/fort_03.png b/background/fort_03.png new file mode 100644 index 0000000..d9a24b2 Binary files /dev/null and b/background/fort_03.png differ diff --git a/background/fort_04.png b/background/fort_04.png new file mode 100644 index 0000000..6ae14b6 Binary files /dev/null and b/background/fort_04.png differ diff --git a/background/fort_05.png b/background/fort_05.png new file mode 100644 index 0000000..270d059 Binary files /dev/null and b/background/fort_05.png differ diff --git a/background/fort_06.png b/background/fort_06.png new file mode 100644 index 0000000..44895a7 Binary files /dev/null and b/background/fort_06.png differ diff --git a/background/fort_07.png b/background/fort_07.png new file mode 100644 index 0000000..264745f Binary files /dev/null and b/background/fort_07.png differ diff --git a/background/fort_08.png b/background/fort_08.png new file mode 100644 index 0000000..1a66c62 Binary files /dev/null and b/background/fort_08.png differ diff --git a/background/fort_09.png b/background/fort_09.png new file mode 100644 index 0000000..283d7b0 Binary files /dev/null and b/background/fort_09.png differ diff --git a/background/fort_10.png b/background/fort_10.png new file mode 100644 index 0000000..1a31bdf Binary files /dev/null and b/background/fort_10.png differ diff --git a/background/fort_11.png b/background/fort_11.png new file mode 100644 index 0000000..9f55356 Binary files /dev/null and b/background/fort_11.png differ diff --git a/background/fort_12.png b/background/fort_12.png new file mode 100644 index 0000000..498aec7 Binary files /dev/null and b/background/fort_12.png differ diff --git a/background/fort_13.png b/background/fort_13.png new file mode 100644 index 0000000..9b5daae Binary files /dev/null and b/background/fort_13.png differ diff --git a/background/fort_14.png b/background/fort_14.png new file mode 100644 index 0000000..4a84aa9 Binary files /dev/null and b/background/fort_14.png differ diff --git a/background/fort_15.png b/background/fort_15.png new file mode 100644 index 0000000..93ac1a9 Binary files /dev/null and b/background/fort_15.png differ diff --git a/background/fort_16.png b/background/fort_16.png new file mode 100644 index 0000000..1215450 Binary files /dev/null and b/background/fort_16.png differ diff --git a/background/fort_17.png b/background/fort_17.png new file mode 100644 index 0000000..3256059 Binary files /dev/null and b/background/fort_17.png differ diff --git a/background/fort_18.png b/background/fort_18.png new file mode 100644 index 0000000..9ab2e3c Binary files /dev/null and b/background/fort_18.png differ diff --git a/background/fort_19.png b/background/fort_19.png new file mode 100644 index 0000000..2875a5a Binary files /dev/null and b/background/fort_19.png differ diff --git a/background/fort_20.png b/background/fort_20.png new file mode 100644 index 0000000..4c7bd09 Binary files /dev/null and b/background/fort_20.png differ diff --git a/background/fort_21.png b/background/fort_21.png new file mode 100644 index 0000000..d17e210 Binary files /dev/null and b/background/fort_21.png differ diff --git a/background/fort_22.png b/background/fort_22.png new file mode 100644 index 0000000..e05299a Binary files /dev/null and b/background/fort_22.png differ diff --git a/background/fort_23.png b/background/fort_23.png new file mode 100644 index 0000000..0f0a52c Binary files /dev/null and b/background/fort_23.png differ diff --git a/background/fort_24.png b/background/fort_24.png new file mode 100644 index 0000000..0403c44 Binary files /dev/null and b/background/fort_24.png differ diff --git a/background/fort_25.png b/background/fort_25.png new file mode 100644 index 0000000..f088bfe Binary files /dev/null and b/background/fort_25.png differ diff --git a/background/fort_26.png b/background/fort_26.png new file mode 100644 index 0000000..e732f4f Binary files /dev/null and b/background/fort_26.png differ diff --git a/background/fort_27.png b/background/fort_27.png new file mode 100644 index 0000000..88db29d Binary files /dev/null and b/background/fort_27.png differ diff --git a/background/fort_28.png b/background/fort_28.png new file mode 100644 index 0000000..a6f0a82 Binary files /dev/null and b/background/fort_28.png differ diff --git a/background/fort_29.png b/background/fort_29.png new file mode 100644 index 0000000..55a3e61 Binary files /dev/null and b/background/fort_29.png differ diff --git a/background/fort_30.png b/background/fort_30.png new file mode 100644 index 0000000..3e314cf Binary files /dev/null and b/background/fort_30.png differ diff --git a/background/fort_31.png b/background/fort_31.png new file mode 100644 index 0000000..a811913 Binary files /dev/null and b/background/fort_31.png differ diff --git a/background/fort_32.png b/background/fort_32.png new file mode 100644 index 0000000..2ce2cb3 Binary files /dev/null and b/background/fort_32.png differ diff --git a/background/fort_33.png b/background/fort_33.png new file mode 100644 index 0000000..a6b1e8b Binary files /dev/null and b/background/fort_33.png differ diff --git a/background/fort_34.png b/background/fort_34.png new file mode 100644 index 0000000..97abf8b Binary files /dev/null and b/background/fort_34.png differ diff --git a/background/fort_35.png b/background/fort_35.png new file mode 100644 index 0000000..5001501 Binary files /dev/null and b/background/fort_35.png differ diff --git a/background/fort_36.png b/background/fort_36.png new file mode 100644 index 0000000..5a9907a Binary files /dev/null and b/background/fort_36.png differ diff --git a/background/fort_37.png b/background/fort_37.png new file mode 100644 index 0000000..a68e0b5 Binary files /dev/null and b/background/fort_37.png differ diff --git a/background/fort_38.png b/background/fort_38.png new file mode 100644 index 0000000..a1592ac Binary files /dev/null and b/background/fort_38.png differ diff --git a/background/fort_39.png b/background/fort_39.png new file mode 100644 index 0000000..ae46925 Binary files /dev/null and b/background/fort_39.png differ diff --git a/background/fort_40.png b/background/fort_40.png new file mode 100644 index 0000000..01da389 Binary files /dev/null and b/background/fort_40.png differ diff --git a/background/fort_41.png b/background/fort_41.png new file mode 100644 index 0000000..d1efc30 Binary files /dev/null and b/background/fort_41.png differ diff --git a/background/fort_42.png b/background/fort_42.png new file mode 100644 index 0000000..e4054b2 Binary files /dev/null and b/background/fort_42.png differ diff --git a/background/fort_43.png b/background/fort_43.png new file mode 100644 index 0000000..821ca6a Binary files /dev/null and b/background/fort_43.png differ diff --git a/background/fort_44.png b/background/fort_44.png new file mode 100644 index 0000000..94b6e1a Binary files /dev/null and b/background/fort_44.png differ diff --git a/background/fort_45.png b/background/fort_45.png new file mode 100644 index 0000000..a52e71c Binary files /dev/null and b/background/fort_45.png differ diff --git a/background/fort_46.png b/background/fort_46.png new file mode 100644 index 0000000..b40418d Binary files /dev/null and b/background/fort_46.png differ diff --git a/background/fort_47.png b/background/fort_47.png new file mode 100644 index 0000000..4cb6bb1 Binary files /dev/null and b/background/fort_47.png differ diff --git a/background/fort_48.png b/background/fort_48.png new file mode 100644 index 0000000..3a005ea Binary files /dev/null and b/background/fort_48.png differ diff --git a/background/fort_49.png b/background/fort_49.png new file mode 100644 index 0000000..39ef590 Binary files /dev/null and b/background/fort_49.png differ diff --git a/background/fort_50.png b/background/fort_50.png new file mode 100644 index 0000000..7f4da50 Binary files /dev/null and b/background/fort_50.png differ diff --git a/background/fort_51.png b/background/fort_51.png new file mode 100644 index 0000000..2b9bbed Binary files /dev/null and b/background/fort_51.png differ diff --git a/background/fort_52.png b/background/fort_52.png new file mode 100644 index 0000000..4254148 Binary files /dev/null and b/background/fort_52.png differ diff --git a/background/fort_53.png b/background/fort_53.png new file mode 100644 index 0000000..b56c364 Binary files /dev/null and b/background/fort_53.png differ diff --git a/background/fort_54.png b/background/fort_54.png new file mode 100644 index 0000000..3609b5d Binary files /dev/null and b/background/fort_54.png differ diff --git a/background/fort_55.png b/background/fort_55.png new file mode 100644 index 0000000..e6db01f Binary files /dev/null and b/background/fort_55.png differ diff --git a/background/fort_56.png b/background/fort_56.png new file mode 100644 index 0000000..42834ad Binary files /dev/null and b/background/fort_56.png differ diff --git a/background/fort_57.png b/background/fort_57.png new file mode 100644 index 0000000..8ab0739 Binary files /dev/null and b/background/fort_57.png differ diff --git a/background/fort_58.png b/background/fort_58.png new file mode 100644 index 0000000..213d966 Binary files /dev/null and b/background/fort_58.png differ diff --git a/background/fort_59.png b/background/fort_59.png new file mode 100644 index 0000000..54ba482 Binary files /dev/null and b/background/fort_59.png differ diff --git a/background/fort_60.png b/background/fort_60.png new file mode 100644 index 0000000..77c8c37 Binary files /dev/null and b/background/fort_60.png differ diff --git a/chopper.py b/chopper.py index 7c279c2..4777d38 100644 --- a/chopper.py +++ b/chopper.py @@ -8,9 +8,37 @@ class Chopper: self.STATE_FRONT=0 self.STATE_RIGHT=1 self.STATE_LEFT = 2 + + # directions of movement + self.UP = 0 + self.DOWN = 1 + self.LEFT = 2 + self.RIGHT = 3 + self.images = {} def add_sprite(self,state,sprite): self.images[state] = sprite + def move(self,direction): + match direction: + case self.UP: + self.state = self.STATE_FRONT + if self.ypos > 2: + self.ypos -= 2 + case self.DOWN: + self.state = self.STATE_FRONT + self.ypos +=2 + case self.LEFT: + self.state = self.STATE_LEFT + if self.xpos > 2: + self.xpos -=2 + case self.RIGHT: + self.state = self.STATE_RIGHT + self.xpos += 2 + + def current_image(self): + return self.images[self.state] + + diff --git a/chopper_demo.py b/chopper_demo.py index 4c8057f..672a22b 100644 --- a/chopper_demo.py +++ b/chopper_demo.py @@ -7,10 +7,9 @@ class Fort: def __init__(self): print('init()') pygame.init() - pygame.display.set_mode((640, 480)) - self.chopper_x = 100 - self.chopper_y = 100 - self.screen = pygame.display.set_mode((800, 600)) + pygame.display.set_mode((384, 240)) + self.background =pygame.image.load('background/fort_02.png') + self.screen = pygame.display.set_mode((384, 240)) self.chopper_front = pygame.image.load("sprites/chopper_front.png").convert() self.chopper_side_right = pygame.image.load("sprites/chopper_side_right.png").convert() self.chopper_moving_left = pygame.image.load("sprites/chopper_moving_left.png").convert() @@ -22,7 +21,8 @@ class Fort: def mainloop(self): running = True - self.screen.blit(self.chopper_front, (self.chopper_x, self.chopper_y)) + self.screen.blit(self.background,(0,0)) + self.screen.blit(self.chopper_front, (self.chopper.xpos, self.chopper.ypos)) # self.screen.blit(self.chopper_side_right, (100, 100)) # self.screen.blit(self.chopper_moving_left, (150, 150)) pygame.display.flip() @@ -36,16 +36,15 @@ class Fort: case pygame.QUIT: running = False case pygame.K_RIGHT: - print('right') - self.screen.blit(self.chopper_side_right,(self.chopper_x,self.chopper_y)) + self.chopper.move(self.chopper.RIGHT) case pygame.K_LEFT: - print('left') - self.screen.blit(self.chopper_moving_left,(self.chopper_x,self.chopper_y)) - + self.chopper.move(self.chopper.LEFT) + case pygame.K_UP: + self.chopper.move(self.chopper.UP) case pygame.K_DOWN: - print('down') - self.screen.blit(self.chopper_front,(self.chopper_x,self.chopper_y)) + self.chopper.move(self.chopper.DOWN) + self.screen.blit(self.chopper.current_image(),(self.chopper.xpos,self.chopper.ypos)) pygame.display.flip() if __name__ == '__main__': fort = Fort()