Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
import pygame


class AnimationEngine:

def __init__(self):

None

def update(self,**kwargs):
def update(self, **kwargs):

objects = kwargs['GameObject']

match objects.animator.which_sheet:

case 1:
self.set_current_sprite(objects,objects.generic_sprite_1)
self.set_current_sprite(objects, objects.generic_sprite_1)
case 2:
self.set_current_sprite(objects,objects.generic_sprite_2)
self.set_current_sprite(objects, objects.generic_sprite_2)
case 3:
self.set_current_sprite(objects,objects.generic_sprite_3)
self.set_current_sprite(objects, objects.generic_sprite_3)
case 4:
self.set_current_sprite(objects,objects.generic_sprite_4)
self.set_current_sprite(objects, objects.generic_sprite_4)


def set_current_sprite(self,objects,generic_sprite):
def set_current_sprite(self, objects, generic_sprite):
try:

if len(generic_sprite.sprite_sheet) > 0:

objects.animator.determine_frame_count()

if objects.animator.direction_x == -1:
objects.current_sprite.image = pygame.transform.flip(generic_sprite.sprite_sheet[objects.animator.frame_index],True,False)
objects.current_sprite.image = pygame.transform.flip(
generic_sprite.sprite_sheet[objects.animator.frame_index], True, False)
else:
objects.current_sprite.image = generic_sprite.sprite_sheet[objects.animator.frame_index]
elif generic_sprite.image is not None:
if objects.animator.direction_x == -1:
objects.current_sprite.image = pygame.transform.flip(generic_sprite.image,True,False)
objects.current_sprite.image = pygame.transform.flip(generic_sprite.image, True, False)
else:
objects.current_sprite.image = generic_sprite.image

except Exception as Error:
print(objects.animator.which_sheet)


File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,40 @@ def __init__(self):

def update(self, **kwargs):
current_object = kwargs['CurrentObject']
render_buffer = kwargs['RenderBuffer']
e_graphics = kwargs['GraphicsEngine']
current_object.collider.reset()
for other in render_buffer:
if (current_object != other
and not isinstance(other, scene_object.SceneObject)
and not isinstance(current_object, scene_object.SceneObject)) \
and not current_object.collider.all_off:
collision_buffer = None

if current_object.current_sprite.rect.colliderect(other.current_sprite.rect) \
and not other.collider.pass_through:
collision_buffer = self.get_collision_buffer(current_object, e_graphics)

if not current_object.collider.up_off:
self.detect_up_collisions(current_object, other)
if collision_buffer is not None:
for other in collision_buffer:
self.detect_collisions(current_object, other)

if not current_object.collider.right_off:
self.detect_right_collisions(current_object, other)
def detect_collisions(self, current_object, other):
if (current_object != other
and not isinstance(other, scene_object.SceneObject)
and not isinstance(current_object, scene_object.SceneObject)) \
and not current_object.collider.all_off:

if not current_object.collider.down_off:
self.detect_down_collisions(current_object, other)
if current_object.current_sprite.rect.colliderect(other.current_sprite.rect) \
and not other.collider.pass_through:

if not current_object.collider.left_off:
self.detect_left_collisions(current_object, other)
if not current_object.collider.up_off:
self.detect_up_collisions(current_object, other)

if not current_object.collider.right_off:
self.detect_right_collisions(current_object, other)

if not current_object.collider.down_off:
self.detect_down_collisions(current_object, other)

if not current_object.collider.left_off:
self.detect_left_collisions(current_object, other)
def get_collision_buffer(self, current_object, e_graphics):
for i in range(e_graphics.resolution):
if i * e_graphics.spacing - e_graphics.padding <= current_object.physics.position.x < (i + 1) * e_graphics.spacing + e_graphics.padding:
return e_graphics.collision_buffer[i * e_graphics.spacing]
def detect_up_collisions(self, current_object, other):
if current_object.current_sprite.rect.top < other.current_sprite.rect.bottom \
and current_object.current_sprite.rect.bottom > other.current_sprite.rect.bottom \
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ def __init__(self):
self.button_objects = None
self.draw_colliders = True

# collision buffer
self.resolution = 4
self.padding = 64
self.spacing = self.screen_width / self.resolution
self.collision_buffer = {}
for i in range(self.resolution):
self.collision_buffer[i * self.spacing] = list()


self.scene_objects = list()
self.enemy_objects = list()
self.player_objects = list()
Expand All @@ -47,14 +56,14 @@ def update(self, **kwargs):
events = kwargs['Events']
self.screen.fill((92, 148, 252))

if self.clear_render_buffer:
self.render_buffer.clear()
self.item_objects.clear()
self.enemy_objects.clear()
self.environment_objects.clear()
self.player_objects.clear()
self.scene_objects.clear()
self.clear_render_buffer = False
# empty our buffers
self.clear_collision_buffer()
self.render_buffer.clear()
self.item_objects.clear()
self.enemy_objects.clear()
self.environment_objects.clear()
self.player_objects.clear()
self.scene_objects.clear()

for key, value in kwargs.items():
if 'ObjectsList' in key:
Expand Down Expand Up @@ -91,32 +100,43 @@ def update(self, **kwargs):
e_level_editor.c_object.f_object_component.update(self.screen, events)
pygame.display.flip()

def clear_collision_buffer(self):
for i in range(self.resolution):
self.collision_buffer[i * self.spacing].clear()

def load_collision_buffer(self, objects):

for i in range(self.resolution):
if i * self.spacing - self.padding <= objects.physics.position.x <= (i + 1) * self.spacing + self.padding:
self.collision_buffer[i * self.spacing].append(objects)
break

def load_render_buffer(self, l_objects):

for objects in l_objects:
image = objects.current_sprite.image
if image is not None:
if (
-image.get_width() - self.cushion < objects.physics.position.x < self.screen_width * 0.8 + image.get_width() + self.cushion
or - image.get_width() - self.cushion < objects.physics.initial_position.x < self.screen_width * 0.8 + image.get_width() + self.cushion) \
((-image.get_width() - self.cushion < objects.physics.position.x < self.screen_width * 0.8 + image.get_width() + self.cushion) and objects.physics.pause)
or ((- image.get_width() - self.cushion < objects.physics.initial_position.x < self.screen_width * 0.8 + image.get_width() + self.cushion) ) and not objects.physics.pause) \
and -image.get_height() < objects.physics.position.y < self.screen_height + image.get_height():

if not objects.current_sprite.is_rendered:
objects.current_sprite.is_rendered = True
if isinstance(objects, enemy_object.EnemyObject):
self.enemy_objects.append(objects)
elif isinstance(objects, environment_object.EnvironmentObject):
self.environment_objects.append(objects)
elif isinstance(objects, player_object.PlayerObject):
self.player_objects.append(objects)
elif isinstance(objects, item_object.ItemObject):
self.item_objects.append(objects)
elif isinstance(objects, scene_object.SceneObject):
self.scene_objects.append(objects)

if isinstance(objects, enemy_object.EnemyObject):
self.enemy_objects.append(objects)
elif isinstance(objects, environment_object.EnvironmentObject):
self.environment_objects.append(objects)
elif isinstance(objects, player_object.PlayerObject):
self.player_objects.append(objects)
elif isinstance(objects, item_object.ItemObject):
self.item_objects.append(objects)
elif isinstance(objects, scene_object.SceneObject):
self.scene_objects.append(objects)
self.render_buffer.append(objects)

self.load_collision_buffer(objects)

self.render_buffer.append(objects)
elif objects.current_sprite.is_rendered and objects.destroy:
if objects.destroy:

if isinstance(objects, enemy_object.EnemyObject):
self.enemy_objects.remove(objects)
Expand All @@ -131,22 +151,7 @@ def load_render_buffer(self, l_objects):

self.render_buffer.remove(objects)
l_objects.remove(objects)
else:

objects.current_sprite.is_rendered = False
if objects in self.render_buffer:
self.render_buffer.remove(objects)

if isinstance(objects, enemy_object.EnemyObject):
self.enemy_objects.remove(objects)
elif isinstance(objects, environment_object.EnvironmentObject):
self.environment_objects.remove(objects)
elif isinstance(objects, player_object.PlayerObject):
self.player_objects.remove(objects)
elif isinstance(objects, item_object.ItemObject):
self.item_objects.remove(objects)
elif isinstance(objects, scene_object.SceneObject):
self.scene_objects.remove(objects)

def draw_objects(self):

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added Engine/__init__.py
Empty file.
6 changes: 5 additions & 1 deletion FuzzyProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import json
import subprocess

global selected_project_directory
selected_project_directory = "" # Variable to store the selected project directory
global selected_directory
selected_directory = ""


def open_directory_dialog():
global selected_directory

Expand Down Expand Up @@ -53,6 +54,7 @@ def open_project():


def create_fzy_file():
global selected_directory
new_fzy_file = os.path.join(selected_directory, "new_project.fzy")
# Ask the user for the project name
project_name = simpledialog.askstring("Project Name", "Enter the project name:")
Expand All @@ -69,6 +71,8 @@ def create_fzy_file():


def update_listbox(directory):
global selected_directory
selected_directory = directory
# Clear the existing items in the Listbox
listbox.delete(0, tk.END)

Expand Down
File renamed without changes.
Loading