background images
movement of chopper
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user