Add project files.

tmaksimovs-patch-1
RVKG 2024-01-29 12:39:52 +02:00
parent 45b186be00
commit f4ed26977c
5 changed files with 138 additions and 0 deletions

23
Game_1.sln 100644
View File

@ -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

BIN
Game_1/Floor.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

80
Game_1/Game_1.py 100644
View File

@ -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()

View File

@ -0,0 +1,35 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>5a0a8f0a-4743-4282-a2fa-e1f09ffc6a22</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>Game_1.py</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<Name>Game_1</Name>
<RootNamespace>Game_1</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="Game_1.py" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
<!-- Uncomment the CoreCompile target to enable the Build command in
Visual Studio and specify your pre- and post-build commands in
the BeforeBuild and AfterBuild targets below. -->
<!--<Target Name="CoreCompile" />-->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
</Project>

BIN
Game_1/Player.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB