Compare commits

...

121 Commits

Author SHA1 Message Date
Timofejs Maksimovs bda3c715d7 Upload files to "Sprites" 2024-03-04 07:56:07 +00:00
Timofejs Maksimovs ebeef03971 Update menu copy 2.py 2024-03-04 07:55:42 +00:00
Gerhards Kristians Tillers 13e6d6777b Update Game_V2.py 2024-03-04 07:30:53 +00:00
Timofejs Maksimovs 54404cac31 Upload files to "resources/Game/resources" 2024-03-04 07:18:02 +00:00
Romāns Šaduncs bae5f86774 Update Game_V2.py 2024-03-04 07:16:46 +00:00
Gerhards Kristians Tillers cb9ed69a60 Update Game_V2.py 2024-03-04 07:05:03 +00:00
Gerhards Kristians Tillers a493b07760 Upload files to "Sounds" 2024-03-04 07:03:49 +00:00
Timofejs Maksimovs 94ce10056a Delete overlay.png 2024-03-03 21:20:43 +00:00
Timofejs Maksimovs 5d2b7766ff Upload files to "/" 2024-03-03 21:20:30 +00:00
Timofejs Maksimovs 0f227065c4 Upload files to "resources/Free Dungeon - Fantasy Dreamland/48x48" 2024-03-03 21:20:00 +00:00
Timofejs Maksimovs d825aec837 Upload files to "resources/Game" 2024-03-03 21:18:57 +00:00
Timofejs Maksimovs e58c81cd91 Upload files to "resources" 2024-03-03 21:18:31 +00:00
Timofejs Maksimovs d00e901688 Upload files to "/" 2024-03-03 21:17:52 +00:00
Timofejs Maksimovs 98909e7240 Delete map_0.py 2024-03-03 21:17:33 +00:00
Timofejs Maksimovs f91d169fbb Delete level1.tmx 2024-03-03 21:17:24 +00:00
Timofejs Maksimovs 27d898611a Delete FD_Dungeon_Free.tsx 2024-03-03 21:17:15 +00:00
Timofejs Maksimovs daa5e13260 Delete FD_Dungeon_Free.png 2024-03-03 21:17:08 +00:00
Timofejs Maksimovs dbe233dfcc Delete Collisions.csv 2024-03-03 21:17:02 +00:00
Timofejs Maksimovs c000338518 Delete trash/data.json 2024-03-03 21:16:51 +00:00
Timofejs Maksimovs 3363f39d2d Delete resources 2024-03-03 21:15:56 +00:00
Timofejs Maksimovs 501342da02 Delete start.ldtk 2024-03-03 21:15:50 +00:00
Timofejs Maksimovs 758d52c80e Delete try.py 2024-03-03 21:15:42 +00:00
Timofejs Maksimovs dff7e6a903 Delete world0_code.py 2024-03-03 21:15:35 +00:00
Timofejs Maksimovs 14895b9a00 Delete tiles.png 2024-03-03 21:15:08 +00:00
Timofejs Maksimovs ac4952a79d Add resources 2024-03-03 21:11:52 +00:00
Gerhards Kristians Tillers c8515d3312 Delete Movement.py 2024-03-03 20:36:48 +00:00
Gerhards Kristians Tillers d3da2b8c2b Delete Movement+shooting.py 2024-03-03 20:36:38 +00:00
Gerhards Kristians Tillers ed4aba668e Delete explosion.wav 2024-03-03 20:36:24 +00:00
Gerhards Kristians Tillers d1f6d0a52d Delete minigun_shooting.wav 2024-03-03 20:36:16 +00:00
Gerhards Kristians Tillers c0fa26e80a Delete sshooting.py 2024-03-03 20:36:09 +00:00
Gerhards Kristians Tillers 0d1331adf5 Delete minigun_stop.wav 2024-03-03 20:35:56 +00:00
Gerhards Kristians Tillers 17f9409190 Delete Movement_version_3.py 2024-03-03 20:35:37 +00:00
Gerhards Kristians Tillers b694c95d28 Delete Game_1.sln 2024-03-03 20:35:18 +00:00
Gerhards Kristians Tillers efea158dbb Upload files to "Sounds" 2024-03-03 20:34:35 +00:00
Gerhards Kristians Tillers 0a89e951ec Upload files to "assets" 2024-03-03 20:33:56 +00:00
Gerhards Kristians Tillers 831e7ba96b Upload files to "assets" 2024-03-03 20:33:14 +00:00
Gerhards Kristians Tillers 89244e6fa7 Delete Game_1/Game_1.pyproj 2024-03-03 20:31:57 +00:00
Gerhards Kristians Tillers 9da2f79ac5 Delete Game_1/Main.py 2024-03-03 20:31:47 +00:00
Gerhards Kristians Tillers 2268027236 Upload files to "Sprites" 2024-03-03 20:30:58 +00:00
Gerhards Kristians Tillers c39efd2649 Update menu copy 2.py 2024-03-03 20:20:34 +00:00
Gerhards Kristians Tillers 5b4e2f5f2c Update Game_V2.py 2024-03-03 20:20:00 +00:00
Gerhards Kristians Tillers b97bc194b4 Update menu copy 2.py 2024-03-03 20:18:56 +00:00
Timofejs Maksimovs 38f4e36c79 Upload files to "/" 2024-03-03 14:48:42 +00:00
Timofejs Maksimovs f5a7a5656f Upload files to "/" 2024-03-03 14:48:40 +00:00
Timofejs Maksimovs 870658a6b8 Upload files to "/" 2024-03-03 14:38:53 +00:00
Timofejs Maksimovs fa969b92b1 map addition
Browsing map textures, character is yet static
2024-03-03 14:36:47 +00:00
Gerhards Kristians Tillers 3c49c43ba2 Delete Sounds 2024-03-03 14:11:54 +00:00
Gerhards Kristians Tillers 1646899a25 Upload files to "/" 2024-03-03 14:10:22 +00:00
Gerhards Kristians Tillers 811608d8b4 Upload files to "Sprites" 2024-03-03 14:03:58 +00:00
Gerhards Kristians Tillers a16013e8a4 Add Sounds 2024-03-03 14:01:33 +00:00
Gerhards Kristians Tillers 6322cb5b5c Update Game_V2.py 2024-03-03 14:00:13 +00:00
Gerhards Kristians Tillers a43c590d7b Update Game_V2.py 2024-03-03 10:53:31 +00:00
Gerhards Kristians Tillers 7b0dae6f96 Update Game_V2.py 2024-03-03 10:07:51 +00:00
Gerhards Kristians Tillers 0b11590e52 Update menu copy 2.py 2024-03-03 10:07:11 +00:00
Gerhards Kristians Tillers c6537320dc Upload files to "/" 2024-03-03 09:45:29 +00:00
Gerhards Kristians Tillers 5dcfcb05bd Delete Game_V2.py 2024-03-03 09:45:19 +00:00
Romāns Šaduncs eebc489d4f Обновить menu copy 2.py 2024-03-02 21:39:07 +00:00
Romāns Šaduncs 2bafedc81f Загрузить файлы в «assets» 2024-03-02 21:38:03 +00:00
Romāns Šaduncs bccca5ebba Загрузить файлы в «/» 2024-03-02 21:34:09 +00:00
Romāns Šaduncs 610498b140 Удалить Quit Rect.png 2024-03-02 21:32:56 +00:00
Romāns Šaduncs 435364bc89 Удалить Play Rect.png 2024-03-02 21:32:49 +00:00
Romāns Šaduncs 23c1a58dc4 Удалить Options Rect.png 2024-03-02 21:32:41 +00:00
Romāns Šaduncs b4465a0a17 Удалить Background.png 2024-03-02 21:32:33 +00:00
Romāns Šaduncs 6d909da094 Удалить font.ttf 2024-03-02 21:32:25 +00:00
Romāns Šaduncs a5feb09f00 Загрузить файлы в «/» 2024-03-02 21:32:07 +00:00
Romāns Šaduncs 7e45ab8275 Загрузить файлы в «assets» 2024-03-02 21:31:40 +00:00
Romāns Šaduncs 92fa566a2b Добавить assets/file 2024-03-02 21:31:17 +00:00
Romāns Šaduncs fa62e98963 Удалить assets 2024-03-02 21:30:49 +00:00
Romāns Šaduncs df215357ec Добавить assets 2024-03-02 21:30:30 +00:00
Romāns Šaduncs 7fd8011c2d assets 2024-03-02 21:26:11 +00:00
Romāns Šaduncs 78d5559bf5 Удалить font.ttf 2024-03-02 21:24:08 +00:00
Romāns Šaduncs 564bfae339 Удалить Background.png 2024-03-02 21:23:57 +00:00
Romāns Šaduncs 01f5dec622 Удалить Quit Rect.png 2024-03-02 21:23:45 +00:00
Romāns Šaduncs 7d54a8f005 Удалить Play Rect.png 2024-03-02 21:23:35 +00:00
Romāns Šaduncs ecb81cd321 Удалить Options Rect.png 2024-03-02 21:23:25 +00:00
Romāns Šaduncs 4567532519 Загрузить файлы в «/» 2024-03-02 21:19:15 +00:00
Gerhards Kristians Tillers 30931c4f91 Upload files to "Sprites" 2024-03-02 20:31:56 +00:00
Gerhards Kristians Tillers 091d30189d Delete Sprites/crosshair.png 2024-03-02 20:31:42 +00:00
Gerhards Kristians Tillers d58b98bd48 Delete Sprites/bullet.png 2024-03-02 20:31:26 +00:00
Gerhards Kristians Tillers 76823fc366 Delete Sprites/Orc_death_right.png 2024-03-02 20:31:16 +00:00
Gerhards Kristians Tillers 4c004e2b83 Delete Sprites/Orc_death_left.png 2024-03-02 20:31:09 +00:00
Gerhards Kristians Tillers 6710e760ae Upload files to "/" 2024-03-02 20:30:53 +00:00
Gerhards Kristians Tillers 7c8a4d9609 Upload files to "Sprites" 2024-02-26 10:27:02 +00:00
Gerhards Kristians Tillers a00dd3913a Upload files to "/" 2024-02-26 10:20:15 +00:00
Gerhards Kristians Tillers fb4a822086 Delete Movement_version_2.py 2024-02-26 10:18:11 +00:00
Gerhards Kristians Tillers d1a65d2c7e Upload files to "Sprites/Running" 2024-02-26 10:01:55 +00:00
Gerhards Kristians Tillers 37e9b3351f Upload files to "Sprites/Idle" 2024-02-26 09:57:41 +00:00
Gerhards Kristians Tillers fe7d23fb6b Upload files to "Sprites" 2024-02-26 09:56:52 +00:00
Gerhards Kristians Tillers 1a2c4e5803 Upload files to "Sprites" 2024-02-26 08:07:34 +00:00
Gerhards Kristians Tillers 84551d8cfc Upload files to "/" 2024-02-25 19:11:53 +00:00
ValerijSS aab706f9df Directory structure and optimisation. 2024-02-20 15:03:54 +02:00
Timofejs Maksimovs 801233d23a Upload files to "/" 2024-02-19 10:40:09 +00:00
Romāns Šaduncs 7da0c4bbe0 Загрузить файлы в «/» 2024-02-19 10:35:34 +00:00
Gerhards Kristians Tillers a7cff110df Upload files to "/" 2024-02-19 10:30:19 +00:00
Gerhards Kristians Tillers b594815da1 Delete Movement.py 2024-02-19 10:30:08 +00:00
Gerhards Kristians Tillers b2dc9c74c6 Upload files to "/" 2024-02-19 09:15:53 +00:00
Gerhards Kristians Tillers 6fb65432b4 Delete Movement.py 2024-02-19 09:15:32 +00:00
Gerhards Kristians Tillers eaf27c9e68 Upload files to "/" 2024-02-19 09:06:39 +00:00
Gerhards Kristians Tillers bb63943b0a Delete Movement.py 2024-02-19 09:06:04 +00:00
Gerhards Kristians Tillers 31ad65c3d7 Upload files to "Game_1" 2024-02-19 09:05:48 +00:00
Gerhards Kristians Tillers 1b4b076fec Upload files to "Game_1" 2024-02-19 09:05:32 +00:00
Gerhards Kristians Tillers 3fcb1a19cb Upload files to "Game_1" 2024-02-19 09:05:17 +00:00
Gerhards Kristians Tillers 46ea42cb5c Delete Game_1/Player_run_right_6.png 2024-02-19 09:04:53 +00:00
Gerhards Kristians Tillers b86f731c00 Delete Game_1/Player_run_right_5.png 2024-02-19 09:04:47 +00:00
Gerhards Kristians Tillers b162190c5d Delete Game_1/Player_run_right_4.png 2024-02-19 09:04:43 +00:00
Gerhards Kristians Tillers b0122a20cd Delete Game_1/Player_run_right_3.png 2024-02-19 09:04:39 +00:00
Gerhards Kristians Tillers e2bec74624 Delete Game_1/Player_run_right_2.png 2024-02-19 09:04:33 +00:00
Gerhards Kristians Tillers 9eaf7c5d4f Delete Game_1/Player_run_right_1.png 2024-02-19 09:04:28 +00:00
Gerhards Kristians Tillers a2dda344cd Upload files to "/" 2024-02-19 07:14:58 +00:00
Romāns Šaduncs e7026a39bf Загрузить файлы в «/»
Lai kods stradātu vēl japievieno modeļus "player.png", "enemy.png", "bullet.png"
2024-02-12 10:49:31 +00:00
Gerhards Kristians Tillers 6b2a8fa21f Upload files to "Game_1" 2024-02-12 10:47:06 +00:00
Gerhards Kristians Tillers e7d561c587 Upload files to "Game_1" 2024-02-12 10:46:03 +00:00
Gerhards Kristians Tillers 92ca2a9d6c Upload files to "Game_1" 2024-02-12 10:45:40 +00:00
Gerhards Kristians Tillers e43711e1f4 Delete Game_1/Game_1.pyproj 2024-02-12 10:44:54 +00:00
Gerhards Kristians Tillers 5869606ad2 Delete Game_1/Roguelite!.py 2024-02-12 10:44:49 +00:00
Gerhards Kristians Tillers 893e90c6e5 Delete Game_1/lvl.txt 2024-02-12 10:44:43 +00:00
Gerhards Kristians Tillers 442259637b Delete Game_1/main.py 2024-02-12 10:44:38 +00:00
Gerhards Kristians Tillers 0dbc671cd4 Delete G 2024-02-12 10:43:46 +00:00
Gerhards Kristians Tillers fd5c944391 Add G 2024-02-12 10:43:14 +00:00
Timofejs Maksimovs 81327d3d9c Upload files to "/" 2024-02-12 09:12:29 +00:00
Timofejs Maksimovs 9292b1a39b Upload files to "/" 2024-02-12 09:12:01 +00:00
62 changed files with 914 additions and 1246 deletions

View File

@ -1,23 +0,0 @@

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,35 +0,0 @@
<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>

View File

@ -1,125 +0,0 @@
import pygame
pygame.init()
class Wall(pygame.sprite.Sprite):
def __init__(self, size, pos) -> None:
super().__init__()
self.image = pygame.surface.Surface(size)
self.image.fill("red")
self.rect = self.image.get_rect(center=pos)
def create_floor(file_name):
floor = []
with open (file_name) as f:
lines = f.readlines()
for i, line in enumerate(lines[::2]):
if floor == "#":
floor.append(Floor((30,30), (30 + 30*i)))
def create_walls(file_name):
walls = []
with open(file_name) as f:
lines = f.readlines()
for i, line in enumerate(lines[::2]):
for j, floor in enumerate(line[1::2]):
if floor == "|":
walls.append(Wall((5, 30), (15 + 30*j, 30*i)))
for i, line in enumerate(lines[1::2]):
for j, floor in enumerate(line[::2]):
if floor == "-":
walls.append(Wall((30, 5), (30*j, 15 + 30*i)))
return walls
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
wall_list = create_walls("lvl.txt")
for wall in wall_list:
print(f'{wall.rect.size})x = {wall.rect.x}; y = {wall.rect.y}')
walls = pygame.sprite.Group(*wall_list)
floor_list = create_floor("lvl.txt")
for floor in floor_list:
print(f'{floor.rect.size})x = {floor.rect.x}; y = {floor.rect.y}')
floor = pygame.sprite.Group(*floor_list)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill("cyan")
for y in range(10,20):
for x in range(26,38):
screen.blit(floor_image, (30*x, 30*y))
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
walls.draw(screen)
pygame.display.flip()
dt = clock.tick(60)/1000
floor.draw(screen)
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

@ -1,15 +0,0 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
- - - - - -
# # # # # # # # # # # # # # # # # # # #|# # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #|# # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #|# # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #|# # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #|# # # # # # # # # # # # # # #

View File

@ -1,126 +0,0 @@
import pygame
pygame.init()
class Wall(pygame.sprite.Sprite):
def __init__(self, size, pos) -> None:
super().__init__()
self.image = pygame.surface.Surface(size)
self.image.fill("red")
self.rect = self.image.get_rect(center=pos)
def create_floor(file_name):
floor = []
with open (file_name) as f:
lines = f.readlines()
for i, line in enumerate(lines[::2]):
if floor == "#":
floor.append(Floor((30,30), (30 + 30*i)))
return floor
def create_walls(file_name):
walls = []
with open(file_name) as f:
lines = f.readlines()
for i, line in enumerate(lines[::2]):
for j, floor in enumerate(line[1::2]):
if floor == "|":
walls.append(Wall((5, 30), (15 + 30*j, 30*i)))
for i, line in enumerate(lines[1::2]):
for j, floor in enumerate(line[::2]):
if floor == "-":
walls.append(Wall((30, 5), (30*j, 15 + 30*i)))
return walls
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
wall_list = create_walls("lvl.txt")
for wall in wall_list:
print(f'{wall.rect.size})x = {wall.rect.x}; y = {wall.rect.y}')
walls = pygame.sprite.Group(*wall_list)
floor_list = create_floor("lvl.txt")
for floor in floor_list:
print(f'{floor.rect.size})x = {floor.rect.x}; y = {floor.rect.y}')
floor = pygame.sprite.Group(*floor_list)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill("cyan")
for y in range(10,20):
for x in range(26,38):
screen.blit(floor_image, (30*x, 30*y))
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
walls.draw(screen)
pygame.display.flip()
dt = clock.tick(60)/1000
floor.draw(screen)
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()

428
Game_V2.py 100644
View File

@ -0,0 +1,428 @@
import pygame
from random import randint
import math
import sys
SCREEN_X = 1280
SCREEN_Y = 720
# pygame setup
pygame.init()
pygame.display.set_caption("Rouglite")
screen = pygame.display.set_mode((SCREEN_X, SCREEN_Y))
clock = pygame.time.Clock()
running = True
class Player(pygame.sprite.Sprite):
def __init__(self, pos, group):
super().__init__(group)
self.idle_image = self.image = pygame.image.load("Sprites/Idle/Player_right.png").convert_alpha()
self.rect = self.image.get_rect(center = pos)
self.direction = pygame.math.Vector2()
self.speed = 2.25
self.time = 0
self.time_2 = 0
self.SCORE = 0
#health
self.current_health = 1000 #health
self.maximum_health = 1000
self.health_bar_lenght = 500
self.health_ratio = self.maximum_health / self.health_bar_lenght
self.target_health = 1000
self.health_change_speed = 5
# Shooting
self.can_shoot = True
self.shoot_cooldown_time = 100 # Milliseconds
self.shoot_cooldown = 0
# animations
self.image_direction = 1
self.animation_timer = 0
self.current_sprite = 0
self.running_sprites = []
for i in range(6):
self.running_sprites.append(pygame.image.load("Sprites/Running/Player_run_right_"+str(i+1)+".png").convert_alpha())
def get_damage(self, amount):
if self.target_health > 0:
self.target_health -= amount
if self.target_health <= 0:
self.target_health = 0
def get_health(self, amnount):
if self.target_health < self.maximum_health:
self.target_health += amnount
pygame.mixer.Sound("Sounds/health_plus.mp3")
if self.target_health >= self.maximum_health:
self.target_health = self.maximum_health
def ahealth_bar(self):
self.current_health += (self.target_health-self.current_health)/10
transition_colour = (0, 255, 0)
health_bar_width = self.current_health/self.health_ratio
transition_bar_width = self.target_health/self.health_ratio
if self.current_health > self.target_health:
health_bar_width = self.target_health/self.health_ratio
transition_bar_width = self.current_health/self.health_ratio
transition_colour = (255, 255, 0)
health_bar_rect = pygame.Rect(10,45,health_bar_width,25)
transition_bar_rect = pygame.Rect(10,45,transition_bar_width,25)
pygame.draw.rect(screen, transition_colour, transition_bar_rect)
pygame.draw.rect(screen,(255,0,0),health_bar_rect)
pygame.draw.rect(screen,(255,255,255), (10,45,self.health_bar_lenght,25),4)
def input(self):
keys = pygame.key.get_pressed()
speed_multiplier_x = 0
speed_multiplier_y = 0
if self.direction.x > 0:
self.image_direction = 1
elif self.direction.x < 0:
self.image_direction = -1
if keys[pygame.K_w]:
speed_multiplier_y = -1
elif keys[pygame.K_s]:
speed_multiplier_y = 1
# Check if A and D keys are pressed
if keys[pygame.K_a]:
speed_multiplier_x = -1
elif keys[pygame.K_d]:
speed_multiplier_x = 1
# Calculate movement direction based on keys pressed
self.direction.x = speed_multiplier_x
self.direction.y = speed_multiplier_y
self.direction.y = (keys[pygame.K_s]) - (keys[pygame.K_w])
self.direction.x = (keys[pygame.K_d]) - (keys[pygame.K_a])
if self.direction.x != 0 and self.direction.y != 0:
self.direction.normalize_ip()
self.direction.x *= self.speed
self.direction.y *= self.speed
if pygame.mouse.get_pressed()[0] and self.can_shoot:
direction = -(pygame.math.Vector2(self.rect.topleft) - pygame.mouse.get_pos() - camera_group.offset)
direction = pygame.math.Vector2.normalize(direction)
new_projectile = Projectile(self.rect.center, direction, camera_group)
self.can_shoot = False
self.shoot_cooldown = pygame.time.get_ticks()
self.shoot = True
def update(self):
self.input()
self.ahealth_bar()
self.rect.center += self.direction * self.speed
now = pygame.time.get_ticks()
if now - self.shoot_cooldown > self.shoot_cooldown_time:
self.can_shoot = True
if now - self.animation_timer > 50:
if pygame.Vector2.length(self.direction) == 0:
self.image = self.idle_image
self.current_sprite = 0
else:
self.animation_timer = pygame.time.get_ticks()
self.current_sprite += 1
if self.current_sprite > len(self.running_sprites)-1:
self.current_sprite = 0
self.image = self.running_sprites[self.current_sprite]
class Arm(pygame.sprite.Sprite):
def __init__(self, pos, group):
super().__init__(group)
self.base_image = pygame.image.load("Sprites/minigun.png").convert_alpha()
self.base_image = pygame.transform.scale(self.base_image, (40, 15))
self.image_direction = 1
self.direction = pygame.Vector2(0, 0)
self.speed = 10
angle = math.degrees(math.atan2(-self.direction.y, self.direction.x))
self.image = pygame.transform.rotate(self.base_image, angle)
self.rect = self.image.get_rect(center = pos)
def update(self):
self.rect.center = player.rect.center
self.direction = -(pygame.math.Vector2(self.rect.topleft) - pygame.mouse.get_pos() - camera_group.offset)
self.direction = pygame.math.Vector2.normalize(self.direction)
angle = math.degrees(math.atan2(-self.direction.y, self.direction.x))
if(abs(angle)<90):
self.image_direction = 1
else:
self.image_direction = -1
self.rect.center -= pygame.Vector2(math.sin(math.radians(angle-90))*20, math.cos(math.radians(angle-90))*20)
if(abs(angle)>90):
angle = math.degrees(math.atan2(self.direction.y, self.direction.x))+180
self.image = pygame.transform.rotate(self.base_image, angle)
class Projectile(pygame.sprite.Sprite):
def __init__(self, pos, direction, group):
super().__init__(group)
self.image = pygame.image.load("Sprites/bullet.png").convert_alpha()
self.image_direction = 1
self.direction = direction
self.speed = 15
angle = math.degrees(math.atan2(-self.direction.y, self.direction.x))
self.image = pygame.transform.rotate(self.image, angle)
self.rect = self.image.get_rect(center = pos)
self.rect.center += self.direction * 50
self.life_timer = 10000 # Milliseconds
self.spawned_time = pygame.time.get_ticks()
def collision(self):
for enemy in enemies:
distance = pygame.math.Vector2.length(pygame.math.Vector2(enemy.rect.center) - self.rect.center)
if distance < 20:
enemy.damage(1)
self.kill()
break
for enemy in enemies2:
distance = pygame.math.Vector2.length(pygame.math.Vector2(enemy.rect.center) - self.rect.center)
if distance < 20:
enemy.damage(1)
self.kill()
break
def update(self):
self.rect.center += self.direction * self.speed
self.collision()
now = pygame.time.get_ticks()
if now - self.spawned_time > self.life_timer:
self.kill()
class Enemy(pygame.sprite.Sprite):
def __init__(self, pos, group, scale):
super().__init__(group)
self.original_image = pygame.image.load("Sprites/bomb.png").convert_alpha()
self.image = pygame.transform.scale(self.original_image, (int(self.original_image.get_width() * scale), int(self.original_image.get_height() * scale)))
self.phase_2 = pygame.image.load("Sprites/bomb_phase2.png").convert_alpha()
self.phase_2 = pygame.transform.scale(self.phase_2, (int(self.phase_2.get_width() * scale), int(self.phase_2.get_height() * scale)))
self.rect = self.image.get_rect(center=pos)
self.pos = self.rect.center
self.direction = pygame.math.Vector2()
self.speed = 2
self.health = 3
self.death = pygame.mixer.Sound("Sounds/explosion.wav")
self.image_direction = 1
def damage(self, damage):
self.health -= 1
if self.health == 1:
self.image = self.phase_2
if self.health <= 0:
enemies.remove(self)
self.kill()
self.death.play()
player.SCORE += 1
def update(self):
self.direction = pygame.math.Vector2(player.rect.center) - self.rect.center
if pygame.math.Vector2.length(self.direction) < 20:
if self.image == self.phase_2:
player.get_damage(100)
self.kill()
enemies.remove(self)
player.time = 0
self.death.play()
else:
player.get_damage(200)
self.kill()
enemies.remove(self)
player.time = 0
self.death.play()
self.pos += self.direction.normalize() * self.speed
self.rect.center = (round(self.pos.x), round(self.pos.y))
class Enemy_2(pygame.sprite.Sprite):
def __init__(self, pos, group, scale):
super().__init__(group)
self.original_image = pygame.image.load("Sprites/atom_bomb.png").convert_alpha()
self.image = pygame.transform.scale(self.original_image, (int(self.original_image.get_width() * scale), int(self.original_image.get_height() * scale)))
self.rect = self.image.get_rect(center = pos)
self.pos = self.rect.center
self.direction = pygame.math.Vector2()
self.speed = 1
self.health = 10
self.image_direction = 1
self.death = pygame.mixer.Sound("Sounds/explosion_atomic.wav")
def damage(self, damage):
self.health -= 1
if self.health <= 0:
enemies2.remove(self)
self.kill()
self.death.play()
player.SCORE += 3
def update(self):
self.direction = pygame.math.Vector2(player.rect.center) - self.rect.center
if pygame.math.Vector2.length(self.direction) < 20:
player.get_damage(500)
self.kill()
enemies2.remove(self)
player.time = 0
self.death.play()
self.pos += self.direction.normalize() * self.speed
self.rect.center = (round(self.pos.x), round(self.pos.y))
class CameraGroup(pygame.sprite.Group):
def __init__(self):
super().__init__()
self.display_surface = pygame.display.get_surface()
self.offset = pygame.math.Vector2(300, 100)
self.half_w = self.display_surface.get_size()[0] // 2
self.half_h = self.display_surface.get_size()[1] // 2
def center_target_camera(self, target):
self.offset.x = target.rect.centerx - self.half_w
self.offset.y = target.rect.centery - self.half_h
def custom_draw(self, player):
self.center_target_camera(player)
for sprite in sorted(self.sprites(), key=lambda sprite: sprite.rect.centery):
offset_pos = sprite.rect.topleft - self.offset
if sprite.image_direction == -1:
self.display_surface.blit(pygame.transform.flip(sprite.image, True, False), offset_pos)
else:
self.display_surface.blit(sprite.image, offset_pos)
def spawn_enemy():
if len(enemies) < 5 + (player.time_2):
random_x = randint(-1000, 1000)
random_y = randint(-1000, 1000)
enemies.append(Enemy((player.rect.centerx + random_x, player.rect.centery + random_y), camera_group, 0.05))
def spawn_enemy2():
if len(enemies2) < 2 + int(player.time_2):
random_x = randint(-1000, 1000)
random_y = randint(-1000, 1000)
enemies2.append(Enemy_2((player.rect.centerx + random_x, player.rect.centery + random_y), camera_group, 0.5))
spawn_enemy_event = pygame.USEREVENT + 1
smallfont = pygame.font.Font("assets/font.ttf", 25)
def score(score):
text = smallfont.render("Score: " + str(score), True, "black")
screen.blit(text, [10,15])
#Setup
camera_group = CameraGroup()
enemies = []
enemies2 = []
player = Player((500, 500), camera_group)
Arm((0, 0), camera_group)
pygame.time.set_timer(spawn_enemy_event, 100)
crosshair_img = pygame.transform.scale(pygame.image.load('Sprites/crosshair.png'), (30, 30))
cursor = pygame.cursors.Cursor((0, 0), crosshair_img)
pygame.mouse.set_cursor(cursor)
pygame.mouse.set_visible(True | False)
# Add a variable to track player's life status
player_alive = True
# Main game loop
while running:
for e in pygame.event.get():
if e.type == pygame.QUIT:
running = False
pygame.quit()
if e.type == spawn_enemy_event:
spawn_enemy()
if e.type == spawn_enemy_event:
spawn_enemy2()
if player.time > 3:
if player.current_health < 999 and player.target_health > 0:
player.get_health(100)
player.time -= 1
else:
pass
# Check if the player's health reaches zero
if player.target_health <= 0:
player_alive = False
if not player_alive: # Display death screen
screen.fill((0, 0, 0)) # Fill screen with black color
death_font = pygame.font.Font(None, 50)
death_text = smallfont.render("You Died! Your score was " + str(player.SCORE), True, (255, 255, 255))
screen.blit(death_text, (SCREEN_X // 2 - death_text.get_width() // 2, SCREEN_Y // 2 - death_text.get_height() // 2))
restart_text = smallfont.render("Press SPACE to restart", True, (255, 255, 255))
screen.blit(restart_text, (SCREEN_X // 2 - restart_text.get_width() // 2, SCREEN_Y // 2 + 50))
quit_text = smallfont.render("Press Q to quit", True, (255, 255, 255))
screen.blit(quit_text, (SCREEN_X // 2 - quit_text.get_width() // 2, SCREEN_Y // 2 + 100))
pygame.display.flip()
# Check for restart or quit input
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
# Reset player's health, score, and other relevant variables
player_alive = True
player.current_health = player.maximum_health
player.target_health = player.maximum_health
player.SCORE = 0
if keys[pygame.K_q]:
pygame.quit()
sys.exit()
else: # If player is alive, continue the game
screen.fill("cyan")
score(player.SCORE)
camera_group.update()
camera_group.custom_draw(player)
pygame.display.flip()
clock.tick(60)
player.time += 0.016
player.time_2 += 0.005

View File

@ -1 +1,4 @@
# Game_1
IMPORTANT: dont forget to download pytmx
pip install pytmx (in cmd)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
Sprites/Map/_bg.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
Sprites/bomb.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

BIN
Sprites/bullet.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
Sprites/loading.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
Sprites/minigun.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

BIN
assets/Pixel 7.mp3 100644

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

BIN
assets/file 100644

Binary file not shown.

BIN
assets/font.ttf 100644

Binary file not shown.

29
button.py 100644
View File

@ -0,0 +1,29 @@
class Button():
def __init__(self, image, pos, text_input, font, base_color, hovering_color):
self.image = image
self.x_pos = pos[0]
self.y_pos = pos[1]
self.font = font
self.base_color, self.hovering_color = base_color, hovering_color
self.text_input = text_input
self.text = self.font.render(self.text_input, True, self.base_color)
if self.image is None:
self.image = self.text
self.rect = self.image.get_rect(center=(self.x_pos, self.y_pos))
self.text_rect = self.text.get_rect(center=(self.x_pos, self.y_pos))
def update(self, screen):
if self.image is not None:
screen.blit(self.image, self.rect)
screen.blit(self.text, self.text_rect)
def checkForInput(self, position):
if position[0] in range(self.rect.left, self.rect.right) and position[1] in range(self.rect.top, self.rect.bottom):
return True
return False
def changeColor(self, position):
if position[0] in range(self.rect.left, self.rect.right) and position[1] in range(self.rect.top, self.rect.bottom):
self.text = self.font.render(self.text_input, True, self.hovering_color)
else:
self.text = self.font.render(self.text_input, True, self.base_color)

279
map+coll+cam.py 100644
View File

@ -0,0 +1,279 @@
import pygame
import pytmx
import math
# Constants
BACKGROUND = (20, 20, 20)
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
MAP_COLLISION_LAYER = 1
# Pygame setup
pygame.init()
pygame.display.set_caption("Survive the vawe")
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
clock = pygame.time.Clock()
running = True
class Player(pygame.sprite.Sprite):
def __init__(self, pos):
super().__init__()
# Load the idle image
self.idle_image = pygame.image.load("Sprites/Idle/Player_right.png").convert_alpha()
self.image = self.idle_image
self.rect = self.image.get_rect(topleft=pos) # Adjust rect to match the image size
self.direction = pygame.math.Vector2()
self.speed = 1.6
self.time = 0
# Health
self.current_health = 1000
self.maximum_health = 1000
self.health_bar_length = 500
self.health_ratio = self.maximum_health / self.health_bar_length
self.target_health = 1000
self.health_change_speed = 5
# Shooting
self.can_shoot = True
self.shoot_cooldown_time = 100 # Milliseconds
self.shoot_cooldown = 0
# Animations
self.image_direction = 1
self.animation_timer = 0
self.current_sprite = 0
self.running_sprites = []
for i in range(6):
sprite = pygame.image.load(f"Sprites/Running/Player_run_right_{i + 1}.png").convert_alpha()
self.running_sprites.append(sprite)
def get_damage(self, amount):
if self.target_health > 0:
self.target_health -= amount
if self.target_health <= 0:
self.target_health = 0
def get_health(self, amount):
if self.target_health < self.maximum_health:
self.target_health += amount
if self.target_health >= self.maximum_health:
self.target_health = self.maximum_health
def health_bar(self):
self.current_health += (self.target_health - self.current_health) / 10
# Define smaller health bar dimensions
health_bar_width = self.current_health / self.health_ratio
health_bar_height = 10 # Set the height of the health bar
# Adjust the position of the health bar
health_bar_x = 10
health_bar_y = 10
if self.current_health > self.target_health:
health_bar_width = self.target_health / self.health_ratio
# Draw the health bar with adjusted dimensions and position
health_bar_rect = pygame.Rect(health_bar_x, health_bar_y, health_bar_width, health_bar_height)
pygame.draw.rect(screen, (255, 0, 0), health_bar_rect) # Draw health bar in red
def input(self):
keys = pygame.key.get_pressed()
speed_multiplier_x = 0
speed_multiplier_y = 0
if keys[pygame.K_w]:
speed_multiplier_y = -1
elif keys[pygame.K_s]:
speed_multiplier_y = 1
if keys[pygame.K_a]:
speed_multiplier_x = -1
elif keys[pygame.K_d]:
speed_multiplier_x = 1
self.direction.y = (keys[pygame.K_s]) - (keys[pygame.K_w])
self.direction.x = (keys[pygame.K_d]) - (keys[pygame.K_a])
if self.direction.x != 0 and self.direction.y != 0:
self.direction.normalize_ip()
self.direction.x *= self.speed
self.direction.y *= self.speed
if pygame.mouse.get_pressed()[0] and self.can_shoot:
direction = -(pygame.math.Vector2(self.rect.topleft) - pygame.mouse.get_pos())
direction = pygame.math.Vector2.normalize(direction)
new_projectile = Projectile(self.rect.center, direction)
self.can_shoot = False
self.shoot_cooldown = pygame.time.get_ticks()
def update(self, level):
self.input()
self.health_bar()
self.rect.center += self.direction * self.speed
# Move the screen if the player reaches the screen bounds
if self.rect.right >= SCREEN_WIDTH - 200:
difference = self.rect.right - (SCREEN_WIDTH - 200)
self.rect.right = SCREEN_WIDTH - 200
level.shift_level(-difference, 0)
if self.rect.left <= 200:
difference = 200 - self.rect.left
self.rect.left = 200
level.shift_level(difference, 0)
if self.rect.top <= 200:
difference = 200 - self.rect.top
self.rect.top = 200
level.shift_level(0, difference)
if self.rect.bottom >= SCREEN_HEIGHT - 200:
difference = self.rect.bottom - (SCREEN_HEIGHT - 200)
self.rect.bottom = SCREEN_HEIGHT - 200
level.shift_level(0, -difference)
self.check_collision(level)
now = pygame.time.get_ticks()
if now - self.shoot_cooldown > self.shoot_cooldown_time:
self.can_shoot = True
if now - self.animation_timer > 50:
if pygame.Vector2.length(self.direction) == 0:
self.image = self.idle_image
self.current_sprite = 0
else:
self.animation_timer = pygame.time.get_ticks()
self.current_sprite += 1
if self.current_sprite > len(self.running_sprites) - 1:
self.current_sprite = 0
self.image = self.running_sprites[self.current_sprite]
if self.direction.x < 0: # If moving left, flip the image
self.image = pygame.transform.flip(self.image, True, False)
def check_collision(self, level):
for layer in level.layers:
if layer.index == MAP_COLLISION_LAYER:
for tile in layer.tiles:
if self.rect.colliderect(tile.rect):
self.rect.center -= self.direction * self.speed
return
class Projectile(pygame.sprite.Sprite):
def __init__(self, pos, direction):
super().__init__()
self.image = pygame.image.load("Sprites/bullet.png").convert_alpha()
self.image_direction = 1
self.direction = direction
self.speed = 15
angle = math.degrees(math.atan2(-self.direction.y, self.direction.x))
self.image = pygame.transform.rotate(self.image, angle)
self.rect = self.image.get_rect(center=pos)
self.rect.center += self.direction * 50
self.life_timer = 10000 # Milliseconds
self.spawned_time = pygame.time.get_ticks()
def collision(self):
pass # Removed the collision logic for simplicity
def update(self):
self.rect.center += self.direction * self.speed
self.collision()
now = pygame.time.get_ticks()
if now - self.spawned_time > self.life_timer:
self.kill()
class Game:
def __init__(self):
self.currentLevelNumber = 0
self.levels = []
self.levels.append(Level(fileName="resources/level1.tmx"))
self.currentLevel = self.levels[self.currentLevelNumber]
def draw(self):
screen.fill(BACKGROUND)
self.currentLevel.draw()
player_group.draw(screen) # Draw player sprite
pygame.display.flip()
class Level:
def __init__(self, fileName):
self.mapObject = pytmx.load_pygame(fileName)
self.layers = []
for layer in range(len(self.mapObject.layers)):
self.layers.append(Layer(index=layer, mapObject=self.mapObject))
def draw(self):
for layer in self.layers:
layer.draw()
def shift_level(self, x_amount, y_amount):
for layer in self.layers:
for tile in layer.tiles:
tile.rect.x += x_amount
tile.rect.y += y_amount
class Layer:
def __init__(self, index, mapObject):
self.index = index
self.tiles = pygame.sprite.Group()
self.mapObject = mapObject
for x in range(self.mapObject.width):
for y in range(self.mapObject.height):
img = self.mapObject.get_tile_image(x, y, self.index)
if img:
self.tiles.add(Tile(image=img, x=(x * self.mapObject.tilewidth), y=(y * self.mapObject.tileheight)))
def draw(self):
for tile in self.tiles:
screen.blit(tile.image, tile.rect)
class Tile(pygame.sprite.Sprite):
def __init__(self, image, x, y):
pygame.sprite.Sprite.__init__(self)
self.image = image
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
# Main game setup
game = Game()
player = Player((100, 200)) # Update player spawn coordinates
player_group = pygame.sprite.Group() # Create a sprite group for the player
player_group.add(player) # Add the player sprite to the group
# Main game loop
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
player.get_health(200)
elif event.key == pygame.K_DOWN:
player.get_damage(200)
game.draw()
player.update(game.currentLevel)
pygame.display.flip()
clock.tick(60)

148
menu copy 2.py 100644
View File

@ -0,0 +1,148 @@
import pygame
import sys
from button import Button # Assuming you have a Button class defined in a separate file
from random import randint
import math
pygame.init()
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
SCREEN = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Rouglite")
# Loading images and music
BG = pygame.image.load("assets/Background.png")
LD = pygame.transform.scale(pygame.image.load("Sprites/loading.png").convert(), (SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.mixer.music.load('assets/Pixel 7.mp3')
# Define fonts
def get_font(size): # Returns Press-Start-2P in the desired size
return pygame.font.Font("assets/font.ttf", size)
def show_loading_screen():
start_time = pygame.time.get_ticks()
loading_image_rect = LD.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2))
pygame.mouse.set_visible(False) # Hide the cursor
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
SCREEN.fill((0, 0, 0))
SCREEN.blit(LD, loading_image_rect) # Display the loading image
pygame.display.update()
if pygame.time.get_ticks() - start_time >= 5000:
pygame.mouse.set_visible(True) # Show the cursor
return
# Display loading screen for 5 seconds before showing main menu
show_loading_screen()
def play():
while True:
pygame.time.delay(500)
import Game_V2
# Game_V2 vietāpievienojiet failu ar pabeigto spēli
def options():
volume = 1 # Initial volume
slider_height = 20 # Slider height
while True:
SCREEN.blit(BG, (0, 0))
OPTIONS_MOUSE_POS = pygame.mouse.get_pos()
OPTIONS_TEXT = get_font(45).render("Change Volume", True, "white")
OPTIONS_RECT = OPTIONS_TEXT.get_rect(center=(640, 260))
SCREEN.blit(OPTIONS_TEXT, OPTIONS_RECT)
# Volume slider
pygame.draw.rect(SCREEN, "gray", (500, 330, 200, slider_height)) # Slider background
# Calculate slider width based on volume level
slider_width = int(volume * 200)
slider_color = (62, 74, 49) # Green color
if volume < 1:
slider_color = (0, 255 * (1 - volume), 0) # Decrease green component based on volume level
pygame.draw.rect(SCREEN, slider_color, (500, 330, slider_width, slider_height)) # Actual slider
# Draw "+" and "-" symbols
plus_text = get_font(30).render("+", True, "#5c3938")
minus_text = get_font(30).render("-", True, "#5c3938")
plus_rect = plus_text.get_rect(center=(715, 330 + slider_height // 2))
minus_rect = minus_text.get_rect(center=(485, 330 + slider_height // 2))
SCREEN.blit(plus_text, plus_rect)
SCREEN.blit(minus_text, minus_rect)
# BACK button
OPTIONS_BACK = Button(image=None, pos=(640, 460),
text_input="BACK", font=get_font(75), base_color="#5c3938", hovering_color="White")
OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS)
OPTIONS_BACK.update(SCREEN)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if OPTIONS_BACK.checkForInput(OPTIONS_MOUSE_POS):
main_menu()
# Check if mouse click is on minus symbol
if minus_rect.collidepoint(event.pos):
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume) # Set the volume of the music
# Check if mouse click is on plus symbol
if plus_rect.collidepoint(event.pos):
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume) # Set the volume of the music
pygame.display.update()
def main_menu():
while True:
SCREEN.blit(BG, (0, 0))
MENU_MOUSE_POS = pygame.mouse.get_pos()
MENU_TEXT = get_font(100).render("Roguelite", True, "white")
MENU_RECT = MENU_TEXT.get_rect(center=(640, 100))
PLAY_BUTTON = Button(image=pygame.image.load("assets/Play Rect.png"), pos=(640, 250),
text_input="PLAY", font=get_font(75), base_color="#5c3938", hovering_color="White")
OPTIONS_BUTTON = Button(image=pygame.image.load("assets/Options Rect.png"), pos=(640, 400),
text_input="OPTIONS", font=get_font(75), base_color="#5c3938", hovering_color="White")
QUIT_BUTTON = Button(image=pygame.image.load("assets/Quit Rect.png"), pos=(640, 550),
text_input="QUIT", font=get_font(75), base_color="#5c3938", hovering_color="White")
SCREEN.blit(MENU_TEXT, MENU_RECT)
for button in [PLAY_BUTTON, OPTIONS_BUTTON, QUIT_BUTTON]:
button.changeColor(MENU_MOUSE_POS)
button.update(SCREEN)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS):
play()
if OPTIONS_BUTTON.checkForInput(MENU_MOUSE_POS):
options()
if QUIT_BUTTON.checkForInput(MENU_MOUSE_POS):
pygame.quit()
sys.exit()
pygame.display.update()
main_menu()

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="48x48" tilewidth="48" tileheight="48" tilecount="768" columns="32">
<image source="../../resources/Free Dungeon - Fantasy Dreamland/48x48/FD_Dungeon_Free.png" width="1536" height="1152"/>
</tileset>

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="48x48" tilewidth="48" tileheight="48" tilecount="768" columns="32">
<image source="../../Free Dungeon - Fantasy Dreamland/48x48/FD_Dungeon_Free.png" width="1536" height="1152"/>
</tileset>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="48x48" tilewidth="48" tileheight="48" tilecount="768" columns="32">
<image source="../../Free Dungeon - Fantasy Dreamland/48x48/FD_Dungeon_Free.png" width="1536" height="1152"/>
</tileset>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="40" height="22" tilewidth="48" tileheight="48" infinite="0" nextlayerid="3" nextobjectid="1">
<tileset firstgid="1" source="Game/resources/48x48.tsx"/>
<layer id="1" name="background" width="40" height="22">
<data encoding="base64" compression="zlib">
eJzNlFtuwjAURCMoaUJSwhp4JOXVsAZegYXz2T3VkWakqWtHLkVqKh1d20T4MPem9yiK7j0l6oFDqN/M8ALmhpPj+VdDYogNKfbtegQSVNddpWFleAelnOm5z+9oGIJ2vXDcQRd6JUA9E4/fEve3tYJTiXUp+y6/ObwG2B+xZlZ2TjHOU1nz8xhU4rAUKvEtA/IboLcnOB7gx75rT0fR9/6qVwr4W2LLp5RK15Xg81ugtzM4Hhw94v3a51TypKdv3unE/nKtc+jzO4Ah/I6O79eeMkN7Drv8dBa15yvJ1+f3H9h5Vj3zY5b2e9snvza3S4Df1DAxZCDHvgATYWx4w3mOfY6zCWoW6NfO3DXAjz5j8ZiCsTgUuJ+OdMrl8+kv/M6B+WWSlzrZeRXRz1wzy5/Ph/i1brcAP8KePTpPGX4fM+7K8gxu8DwH+LVumz/4af451oXHizDDJsBvDx71c/XPvreBzw1+VxDi9wGe5cd8XOd0bCL3O6x+NVgbtoad1DVqDfct1iF+nC2f96XjGfXb4e4NqHGmfnyGM1CjduWt9+ta34urJ2f120tGWpnjBpX5buFVW9X2a+Ruzhn7ytlktf/PqN/nkwidy5DvaP++AFtaqow=
</data>
</layer>
<layer id="2" name="collision" width="40" height="22">
<data encoding="base64" compression="zlib">
eJzNVjtOQzEQtN0BIQW0OQKhgDYH4RSIDiQq6KFDIFFBxycpQdSk4SMuQAkNv1yAhl3xTDb7Zu2YFDDSKImza4/H649zzp0QZ/0oT6ntzA2BYhB13qS5jBti29f5Tu0fFQdGjJUnUZJ7B/S9EFdDnQ0xtyaxH0bzduj3LvFStPVVXsxdJ15VMXseiHDf/78Z/iEsiHktgj67pKUX0nkxd9/QFBE1W/79F5T49xdA/rG+61Cvr3Nit2IP5M1R/DxYX5kn8626i1jx2D9e3yca57kai+t9LYzGPoC8JYpZVvr6wRiDxn71aZ0bxv6dovZpwBmfj8nlpXRqHBj+jXt+lhKdtVKn1BhrAs3NOp8nJVorCVkzyLefuRC3qG62iReZPscF96PvEY2B+J7Sx/4dkbZjsBcnQbxHrHu1KdYyd/+mfNP/jesxWmtZ621fj03tX1SvJUR7MuK++pS1rtEy9m+ErNdc7eTyNaI+rvVH4/zp+GGcBHvOay/rQb9BEDX0GSn9jPNl/z4Nfbxm1vly63A9pJjSypB+6rcaQsM4M9nzTrB9R2gFrFX2L/XpuSGk3qcMy3cNNA+0/1L1iLBp7I/S91VqHrk3RQqHhr6Su7/kbfCbfvX++AI6lJGU
</data>
</layer>
</map>

BIN
resources/tiles.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

File diff suppressed because one or more lines are too long