diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/chopper.py b/chopper.py new file mode 100644 index 0000000..7c279c2 --- /dev/null +++ b/chopper.py @@ -0,0 +1,16 @@ + +class Chopper: + + def __init__(self,xpos,ypos,state): + self.xpos = xpos + self.ypos = ypos + self.state = state + self.STATE_FRONT=0 + self.STATE_RIGHT=1 + self.STATE_LEFT = 2 + self.images = {} + + + def add_sprite(self,state,sprite): + self.images[state] = sprite + diff --git a/chopper_demo.py b/chopper_demo.py new file mode 100644 index 0000000..4c8057f --- /dev/null +++ b/chopper_demo.py @@ -0,0 +1,53 @@ +import pygame +from chopper import Chopper + +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)) + 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() + + self.chopper = Chopper(100,100,0) + self.chopper.add_sprite(self.chopper.STATE_FRONT, self.chopper_front) + self.chopper.add_sprite(self.chopper.STATE_RIGHT, self.chopper_side_right) + self.chopper.add_sprite(self.chopper.STATE_LEFT, self.chopper_moving_left) + + def mainloop(self): + running = True + self.screen.blit(self.chopper_front, (self.chopper_x, self.chopper_y)) +# self.screen.blit(self.chopper_side_right, (100, 100)) +# self.screen.blit(self.chopper_moving_left, (150, 150)) + pygame.display.flip() + while running: +# print (f'running={running}') + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running=False + if event.type == pygame.KEYDOWN: + match event.key: + case pygame.QUIT: + running = False + case pygame.K_RIGHT: + print('right') + self.screen.blit(self.chopper_side_right,(self.chopper_x,self.chopper_y)) + case pygame.K_LEFT: + print('left') + self.screen.blit(self.chopper_moving_left,(self.chopper_x,self.chopper_y)) + + case pygame.K_DOWN: + print('down') + self.screen.blit(self.chopper_front,(self.chopper_x,self.chopper_y)) + + pygame.display.flip() +if __name__ == '__main__': + fort = Fort() + fort.mainloop() + diff --git a/hello.py b/hello.py deleted file mode 100644 index 7d6200a..0000000 --- a/hello.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(): - print("Hello from fort!") - - -if __name__ == "__main__": - main() diff --git a/sprites/chopper_front.png b/sprites/chopper_front.png new file mode 100644 index 0000000..e2ece96 Binary files /dev/null and b/sprites/chopper_front.png differ diff --git a/sprites/chopper_moving_left.png b/sprites/chopper_moving_left.png new file mode 100644 index 0000000..7011442 Binary files /dev/null and b/sprites/chopper_moving_left.png differ diff --git a/sprites/chopper_side_right.png b/sprites/chopper_side_right.png new file mode 100644 index 0000000..fa0712d Binary files /dev/null and b/sprites/chopper_side_right.png differ diff --git a/xcf/chopper_front.xcf b/xcf/chopper_front.xcf new file mode 100644 index 0000000..cf01f40 Binary files /dev/null and b/xcf/chopper_front.xcf differ diff --git a/xcf/chopper_moving_left.xcf b/xcf/chopper_moving_left.xcf new file mode 100644 index 0000000..d366df4 Binary files /dev/null and b/xcf/chopper_moving_left.xcf differ diff --git a/xcf/chopper_side_right.xcf b/xcf/chopper_side_right.xcf new file mode 100644 index 0000000..2a57e27 Binary files /dev/null and b/xcf/chopper_side_right.xcf differ diff --git a/xcf/shifted.png b/xcf/shifted.png new file mode 100644 index 0000000..80eff66 Binary files /dev/null and b/xcf/shifted.png differ diff --git a/xcf/shifted.xcf b/xcf/shifted.xcf new file mode 100644 index 0000000..de23268 Binary files /dev/null and b/xcf/shifted.xcf differ