Add new certificates for brain and brainw
- Added brain.crt containing a new certificate. - Added brainw.crt containing a new certificate.
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
import random
|
||||
import math
|
||||
from Entities.entity import Entity
|
||||
|
||||
class Marine(Entity):
|
||||
|
||||
target_cell = (8,7)
|
||||
|
||||
movement = 0
|
||||
view = 3
|
||||
|
||||
|
||||
def update(self):
|
||||
self.centered_position = (self.iso_x, self.iso_y)
|
||||
self.cast_rays_to_distance(6)
|
||||
|
||||
self.move()
|
||||
super().update()
|
||||
|
||||
@@ -109,4 +113,25 @@ class Marine(Entity):
|
||||
self.target_cell = target_cell
|
||||
if not self.engine.cmd_sound_effects:
|
||||
self.graphics.play_sound(f"marine/tmayes0{random.randint(0, 3)}.wav")
|
||||
self.engine.cmd_sound_effects = True
|
||||
self.engine.cmd_sound_effects = True
|
||||
|
||||
def cast_rays_to_distance(self, distance):
|
||||
# Cast rays to check for visibility
|
||||
done_cells = {}
|
||||
for angle in range(0, 360, 20):
|
||||
for i in range(distance, 0, -1):
|
||||
ray_x = int(self.centered_position[0] + (distance -i) * int(self.engine.graphics.cell_size/3) * math.sin(math.radians(angle)))
|
||||
ray_y = int(self.centered_position[1] - (distance - i)* int(self.engine.graphics.cell_size/6) * math.cos(math.radians(angle)))
|
||||
|
||||
v_x, v_y = self.graphics.inv_iso_transform(ray_x, ray_y)
|
||||
if v_x>= 0 and v_x < len(self.engine.map[0]) and v_y >= 0 and v_y < len(self.engine.map):
|
||||
if (v_x, v_y) not in done_cells.keys():
|
||||
done_cells.update({(v_x, v_y): self.engine.map_shadow[v_y][v_x]})
|
||||
self.engine.map[v_y][v_x]["visited"] = True
|
||||
self.engine.map_shadow[v_y][v_x] = 0
|
||||
if i == 1:
|
||||
|
||||
self.engine.map_shadow[v_y][v_x] = max(done_cells.get((v_x, v_y), 0)-0.5, 0)
|
||||
print(done_cells.get((v_x, v_y), 0))
|
||||
#self.graphics.draw_line((self.centered_position[0], self.centered_position[1], ray_x, ray_y), color=(0, 255, 0, 255))
|
||||
continue
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ class Entity:
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.next_cell = (x, y)
|
||||
self.target_cell = (x, y)
|
||||
self.iso_x, self.iso_y = self.graphics.iso_transform(self.x, self.y)
|
||||
self.action = action
|
||||
self.direction = direction
|
||||
@@ -26,7 +27,7 @@ class Entity:
|
||||
# Draw target indicator if target is set
|
||||
|
||||
|
||||
occlusion = self.graphics.map_shadow[self.y][self.x]
|
||||
occlusion = self.graphics.engine.map_shadow[self.y][self.x]
|
||||
if occlusion >= 0.8:
|
||||
return
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 929 KiB |
@@ -0,0 +1,21 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDdjCCAl6gAwIBAgIUO+7fPRqW/ZlLcjJc7abg7zY0dMswDQYJKoZIhvcNAQEL
|
||||
BQAwNTEOMAwGA1UECwwFV2F6dWgxDjAMBgNVBAoMBVdhenVoMRMwEQYDVQQHDApD
|
||||
YWxpZm9ybmlhMB4XDTI1MDQxOTE0NTQwM1oXDTM1MDQxNzE0NTQwM1owXDELMAkG
|
||||
A1UEBhMCVVMxEzARBgNVBAcMCkNhbGlmb3JuaWExDjAMBgNVBAoMBVdhenVoMQ4w
|
||||
DAYDVQQLDAVXYXp1aDEYMBYGA1UEAwwPd2F6dWguZGFzaGJvYXJkMIIBIjANBgkq
|
||||
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvmIj4rPiA56NxFJDDjwMyE41wUzojw5X
|
||||
zfHOvvn22/G7I5pT7TKebFJcjMhLdj3oP2l3owYC/9SkwXD9S3nIkApLUMeg44LK
|
||||
LxuDdluneKa8hCm74zzZxP4D8lrSN4GBgCWB4D2UgOBEEBQXqD2bHp8Q/3JZHq44
|
||||
yRVEBYHRHNKNV8V+X/jwsRQX/AXxrZB5+88+E/q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@@ from Entities.Units.marine import Marine
|
||||
class GameEngine(UserControls):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.graphics = SDL2Wrapper(self)
|
||||
|
||||
# Load map from JSON file
|
||||
try:
|
||||
@@ -20,6 +19,8 @@ class GameEngine(UserControls):
|
||||
print("Exiting program.")
|
||||
sys.exit(0)
|
||||
|
||||
self.graphics = SDL2Wrapper(self)
|
||||
|
||||
self.frame_time = 0
|
||||
self.cursor_pos = (0, 0)
|
||||
|
||||
@@ -30,10 +31,10 @@ class GameEngine(UserControls):
|
||||
def run(self):
|
||||
running = True
|
||||
# Set a custom scale if needed
|
||||
self.graphics.set_scaling_factor(1.50) # 50% scale
|
||||
self.graphics.set_scaling_factor(1.0) # 50% scale
|
||||
|
||||
self.entities.append(Marine("knight", 0, 0, "idle", 1, 1, self))
|
||||
self.entities.append(Marine("knight", 5, 0, "idle", 1, 1, self))
|
||||
self.entities.append(Marine("knight", 5, 5, "idle", 1, 1, self))
|
||||
#5 more marines
|
||||
self.entities.append(Marine("knight", 0, 5, "idle", 1, 1, self))
|
||||
self.entities.append(Marine("knight", 5, 5, "idle", 1, 1, self))
|
||||
@@ -45,13 +46,11 @@ class GameEngine(UserControls):
|
||||
# Start the frame timer
|
||||
perf_counter = self.graphics.get_perf_counter()
|
||||
# Initialize the map shadow and entities positions
|
||||
self.map_shadow = [ [0 for _ in range(len(self.map[0]))] for _ in range(len(self.map)) ]
|
||||
self.map_shadow = [ [1 for _ in range(len(self.map[0]))] for _ in range(len(self.map)) ]
|
||||
self.entities_positions.clear()
|
||||
for entity in self.entities:
|
||||
self.entities_positions[entity.next_cell] = entity
|
||||
self.entities_positions[(entity.x, entity.y)] = entity
|
||||
# Create the map background texture with tiles
|
||||
self.graphics.create_background(self.map, "tiles", self.map_shadow)
|
||||
|
||||
# Handle events
|
||||
event = self.graphics.handle_events()
|
||||
@@ -70,21 +69,23 @@ class GameEngine(UserControls):
|
||||
self.select_units_in_area(event)
|
||||
elif event.startswith("MOUSEUP"):
|
||||
if event[-1] == "1":
|
||||
|
||||
self.select_entity_at_cursor()
|
||||
self.handle_events("keymap_game", event)
|
||||
|
||||
running = False if event == "QUIT" else True
|
||||
|
||||
self.graphics.clear_screen()
|
||||
self.graphics.render_background()
|
||||
self.cursor_pos = self.graphics.draw_cursor()
|
||||
|
||||
# Draw the selection rectangle if selecting
|
||||
if self.graphics.is_mouse_button_pressed(1):
|
||||
self.graphics.draw_selection_rectangle()
|
||||
for entity in self.entities:
|
||||
entity.update()
|
||||
# Create the map background texture with tiles
|
||||
self.graphics.create_background(self.map, "tiles", self.map_shadow)
|
||||
self.cursor_pos = self.graphics.draw_cursor()
|
||||
|
||||
self.graphics.render_background()
|
||||
self.graphics.render_sprites()
|
||||
self.graphics.draw_selection_rectangle()
|
||||
self.graphics.update_status(f"Frame time: {round(self.frame_time)}ms - FPS: {round(1000/self.frame_time if self.frame_time != 0 else 1)}")
|
||||
self.graphics.present_renderer()
|
||||
self.frame_time = self.graphics.get_frame_time(perf_counter)
|
||||
|
||||
@@ -20,6 +20,8 @@ class SDL2Wrapper(IsometricGeometry, SDL2Gui):
|
||||
sdlmixer.Mix_OpenAudio(44100, sdlmixer.MIX_DEFAULT_FORMAT, 2, 1024)
|
||||
sdlmixer.Mix_AllocateChannels(16) # Allocate channels for multiple sounds
|
||||
|
||||
self.height = len(engine.map)
|
||||
self.width = len(engine.map[0])
|
||||
self.view_size = (800, 600)
|
||||
self.target_size = (800, 600)
|
||||
self.base_cell_size = 132 # Original/base cell size
|
||||
@@ -152,14 +154,15 @@ class SDL2Wrapper(IsometricGeometry, SDL2Gui):
|
||||
sdl2.SDL_SetRenderTarget(self.renderer.sdlrenderer, self.tiles_texture)
|
||||
sdl2.SDL_SetRenderDrawColor(self.renderer.sdlrenderer, 0, 0, 0, 255) # Green background
|
||||
sdl2.SDL_RenderClear(self.renderer.sdlrenderer)
|
||||
self.height = len(map)
|
||||
self.width = len(map[0])
|
||||
self.map_shadow = map_shadow
|
||||
|
||||
tilesheet_texture = self.tile_managers[spritesheet_name].get_tilesheet_texture()
|
||||
|
||||
def get_shadow(x, y):
|
||||
return min(self.map_shadow[y][x], 1)
|
||||
shadow = min(self.map_shadow[y][x], 1)
|
||||
if shadow == 1 and self.engine.map[y][x].get('visited'):
|
||||
shadow = 0.8
|
||||
return shadow
|
||||
|
||||
def blit_tile(tile, x, y):
|
||||
tile_rect = self.tile_managers[spritesheet_name].get_tile_rect(tile)
|
||||
@@ -171,10 +174,6 @@ class SDL2Wrapper(IsometricGeometry, SDL2Gui):
|
||||
|
||||
# Adjusted vertical offset calculation for half-sized cells
|
||||
vertical_offset = (self.cell_size - tile_rect[3] * self.scaling_factor - self.ground_level_offset * self.scaling_factor)
|
||||
|
||||
print(f"Vertical offset: {vertical_offset}")
|
||||
|
||||
|
||||
# Adjusted horizontal offset calculation for half-sized cells
|
||||
horizontal_offset = (self.cell_size - tile_rect[2] * self.scaling_factor )
|
||||
|
||||
@@ -219,13 +218,15 @@ class SDL2Wrapper(IsometricGeometry, SDL2Gui):
|
||||
def draw_cursor(self):
|
||||
x, y = self.cursor
|
||||
c_x, c_y = self.inv_iso_transform(x, y)
|
||||
#print(f"Cursor: {c_x}, {c_y}")
|
||||
iso_x, iso_y = self.iso_transform(c_x, c_y)
|
||||
sdl2.SDL_SetRenderTarget(self.renderer.sdlrenderer, self.sprite_texture)
|
||||
|
||||
self.renderer.draw_line(points=[(iso_x, iso_y), (iso_x + self.cell_size//2, iso_y + self.cell_size//4)], color=(255
|
||||
, 0, 0, 255))
|
||||
self.renderer.draw_line(points=[(iso_x + self.cell_size//2, iso_y + self.cell_size//4), (iso_x, iso_y + self.cell_size//2)], color=(255, 0, 0, 255))
|
||||
self.renderer.draw_line(points=[(iso_x, iso_y + self.cell_size//2), (iso_x - self.cell_size//2, iso_y + self.cell_size//4)], color=(255, 0, 0, 255))
|
||||
self.renderer.draw_line(points=[(iso_x - self.cell_size//2, iso_y + self.cell_size//4), (iso_x, iso_y)], color=(255, 0, 0, 255))
|
||||
sdl2.SDL_SetRenderTarget(self.renderer.sdlrenderer, None)
|
||||
return c_x, c_y
|
||||
|
||||
def draw_square(self, iso_x, iso_y, color=(0, 255, 0, 255), margin=6):
|
||||
@@ -381,4 +382,9 @@ class SDL2Wrapper(IsometricGeometry, SDL2Gui):
|
||||
return False
|
||||
|
||||
def set_opacity(self, x, y, opacity):
|
||||
self.engine.map_shadow[y][x] = max(self.engine.map_shadow[y][x], opacity)
|
||||
self.engine.map_shadow[y][x] = max(self.engine.map_shadow[y][x], opacity)
|
||||
|
||||
def draw_line(self, points, color=(255, 0, 0, 255)):
|
||||
sdl2.SDL_SetRenderTarget(self.renderer.sdlrenderer, self.sprite_texture)
|
||||
self.renderer.draw_line(points=points, color=color)
|
||||
sdl2.SDL_SetRenderTarget(self.renderer.sdlrenderer, None)
|
||||
@@ -1,5 +0,0 @@
|
||||
# Core dependencies
|
||||
pysdl2
|
||||
pysdl2-dll
|
||||
pillow
|
||||
|
||||
|
||||
Reference in New Issue
Block a user