diff --git a/Game_1.sln b/Game_1.sln new file mode 100644 index 0000000..70e102e --- /dev/null +++ b/Game_1.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34018.315 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Game_1", "Game_1\Game_1.pyproj", "{5A0A8F0A-4743-4282-A2FA-E1F09FFC6A22}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A0A8F0A-4743-4282-A2FA-E1F09FFC6A22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A0A8F0A-4743-4282-A2FA-E1F09FFC6A22}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3BAECF31-65AB-41B5-9E61-740FB272932B} + EndGlobalSection +EndGlobal diff --git a/Game_1/Floor.png b/Game_1/Floor.png new file mode 100644 index 0000000..b2b6e19 Binary files /dev/null and b/Game_1/Floor.png differ diff --git a/Game_1/Game_1.py b/Game_1/Game_1.py new file mode 100644 index 0000000..cd09632 --- /dev/null +++ b/Game_1/Game_1.py @@ -0,0 +1,80 @@ +import pygame + +pygame.init() + +screen = pygame.display.set_mode((1920, 1015)) +pygame.display.set_caption("Game_name") + +clock = pygame.time.Clock() +dt = 0 + +player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2) + +floor_image = pygame.transform.scale(pygame.image.load("Floor.png").convert_alpha(), (30, 30)) + +#class Player(pygame.sprite.Sprite): + #def __init__(self, size, pos, walls) + +player = pygame.transform.scale(pygame.image.load("Player.png").convert_alpha(), (25, 30)) + +running = True + +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + screen.fill("cyan") + for j in range(10,20): + for i in range(26,38): + screen.blit(floor_image, (30*i, 30*j)) + screen.blit(player, (player_pos.x, player_pos.y)) + + keys = pygame.key.get_pressed() + if keys[pygame.K_w]: + player_pos.y -= 200 * dt + if keys[pygame.K_s]: + player_pos.y += 200 * dt + if keys[pygame.K_a]: + player_pos.x -= 200 * dt + if keys[pygame.K_d]: + player_pos.x += 200 * dt + + + pygame.display.flip() + + dt = clock.tick(60)/1000 + + + + + + class Camera: + def __init__(self, player, size=(400, 300)): + self.player = player + self.center = pygame.display.get_surface().get_rect().center + self.size = size + self.player_size = self.player.rect.size + self.speed_x = 0 + self.speed_y = 0 + + def update(self, dt, sprites): + x_move = abs(self.player.rect.centerx - self.center[0]) > self.size[0] // 2 + y_move = abs(self.player.rect.centery - self.center[1]) > self.size[1] // 2 + if x_move or y_move: + for sprite in sprites: + if x_move: + self.speed_x = (self.player.rect.centerx - self.center[0]) * 2 * dt + sprite.rect.x -= self.speed_x + if y_move: + self.speed_y = (self.player.rect.centery - self.center[1]) * 2 * dt + sprite.rect.y -= self.speed_y + + + + + + + + +pygame.quit() \ No newline at end of file diff --git a/Game_1/Game_1.pyproj b/Game_1/Game_1.pyproj new file mode 100644 index 0000000..077ef49 --- /dev/null +++ b/Game_1/Game_1.pyproj @@ -0,0 +1,35 @@ + + + Debug + 2.0 + 5a0a8f0a-4743-4282-a2fa-e1f09ffc6a22 + . + Game_1.py + + + . + . + Game_1 + Game_1 + + + true + false + + + true + false + + + + + + + + + + + + \ No newline at end of file diff --git a/Game_1/Player.png b/Game_1/Player.png new file mode 100644 index 0000000..bcd7b75 Binary files /dev/null and b/Game_1/Player.png differ