diff --git a/.gitignore b/.gitignore index 65d7f6f..8095ad1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ .idea +*/.idea test.py *__pycache__* TODO.md *pong_reloaded_remastered* .DS_Store -../docs/_build/ -../docs/_static/ -../docs/_templates \ No newline at end of file +dist \ No newline at end of file diff --git a/LISCENCE b/LISCENCE new file mode 100644 index 0000000..335ea9d --- /dev/null +++ b/LISCENCE @@ -0,0 +1,19 @@ +Copyright (c) 2018 The Python Packaging Authority + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/docs/base/events.html b/docs/base/events.html index ec5ddb4..97f9177 100644 --- a/docs/base/events.html +++ b/docs/base/events.html @@ -29,8 +29,6 @@
game_qu.base.events
from game_qu.base.history_keeper import HistoryKeeper
from game_qu.base.id_creator import id_creator
from game_qu.base.timed_event import TimedEvent
-from game_qu.base.count_event import CountEvent
-
class Event:
"""Used to store an event from the current cycle and past cycles (event being anything that is a bool)"""
diff --git a/docs/base/game_movement.html b/docs/base/game_movement.html
index 78a6894..919e5f0 100644
--- a/docs/base/game_movement.html
+++ b/docs/base/game_movement.html
@@ -26,9 +26,7 @@ Module game_qu.base.game_movement
Expand source code
-import pygame.key
-
-from game_qu.base.important_variables import SCREEN_HEIGHT, SCREEN_LENGTH
+from game_qu.base.important_variables import SCREEN_HEIGHT, SCREEN_LENGTH
from game_qu.base.utility_functions import key_is_pressed
from game_qu.base.velocity_calculator import VelocityCalculator
diff --git a/docs/base/important_variables.html b/docs/base/important_variables.html
index d6a98c4..c5aef00 100644
--- a/docs/base/important_variables.html
+++ b/docs/base/important_variables.html
@@ -38,7 +38,6 @@ Module game_qu.base.important_variables
from game_qu.base.keyboard import Keyboard
from game_qu.gui_components.window import Window
from game_qu.library_abstraction import keys
-from game_qu.base.colors import *
keyboard = Keyboard()
game_window = Window(SCREEN_LENGTH, SCREEN_HEIGHT, BACKGROUND_COLOR, "Game Basics")
diff --git a/docs/base/keyboard.html b/docs/base/keyboard.html
index 17fa00c..1c0178f 100644
--- a/docs/base/keyboard.html
+++ b/docs/base/keyboard.html
@@ -26,7 +26,8 @@ Module game_qu.base.keyboard
Expand source code
-from game_qu.base.events import Event, TimedEvent
+from game_qu.base.events import Event
+from game_qu.base.timed_event import TimedEvent
from game_qu.library_abstraction import keys
from game_qu.library_abstraction import utility_functions
from game_qu.library_abstraction import variables
diff --git a/docs/base/quadratic_equations.html b/docs/base/quadratic_equations.html
index 670d196..b46b523 100644
--- a/docs/base/quadratic_equations.html
+++ b/docs/base/quadratic_equations.html
@@ -26,13 +26,7 @@ Module game_qu.base.quadratic_equations
Expand source code
-import math
-
-from game_qu.base.important_variables import SCREEN_HEIGHT
-from game_qu.base.utility_functions import get_kwarg_item, solve_quadratic
-from game_qu.base.velocity_calculator import VelocityCalculator
-from game_qu.math.function import Function
-from game_qu.math.physics_function import PhysicsFunction
+from game_qu.math.physics_function import PhysicsFunction
from game_qu.math.quadratic_function import QuadraticFunction
from game_qu.paths.physics_followable_path import PhysicsFollowablePath
diff --git a/docs/getting_started/index.html b/docs/getting_started/index.html
index 65daae0..441b03e 100644
--- a/docs/getting_started/index.html
+++ b/docs/getting_started/index.html
@@ -32,7 +32,7 @@ Sub-modules
This game engine is compartmentalized. There is almost total freedom for making games with this engine.
Components like collision detection, …
-game_qu.getting_started.pong (example game)
+game_qu.getting_started.pong (example game)
This is an example of a simple game of pong made using the game engine. Click the see 'Expand Source Code' button below
to see the code.
@@ -60,7 +60,7 @@ Index
Sub-modules
diff --git a/docs/gui_components/button.html b/docs/gui_components/button.html
index a3d65af..e9c20b1 100644
--- a/docs/gui_components/button.html
+++ b/docs/gui_components/button.html
@@ -27,7 +27,7 @@ Module game_qu.gui_components.button
Expand source code
from game_qu.gui_components.text_box import TextBox
-from game_qu.base.events import TimedEvent
+from game_qu.base.timed_event import TimedEvent
class Button(TextBox):
diff --git a/docs/gui_components/component.html b/docs/gui_components/component.html
index 2429d6f..bfda9f4 100644
--- a/docs/gui_components/component.html
+++ b/docs/gui_components/component.html
@@ -57,6 +57,8 @@ Module game_qu.gui_components.component
def __init__(self, path_to_image=""):
"""Initializes the object and loads an image if the path_to_image is not empty"""
+ super().__init__(self.left_edge, self.top_edge, self.length, self.height)
+
self.path_to_image = path_to_image
if path_to_image != "":
@@ -117,7 +119,7 @@ Module game_qu.gui_components.component
"""Sets the functions that are called when the mouse enters and exits the component"""
self.set_mouse_enter_function(mouse_enter_function)
- self.mouse_exit_function(mouse_exit_function)
+ self.set_mouse_exit_function(mouse_exit_function)
def set_mouse_enter_function(self, mouse_enter_function):
"""Sets the action that happens when a mouse enters this object"""
@@ -182,6 +184,8 @@ Classes
def __init__(self, path_to_image=""):
"""Initializes the object and loads an image if the path_to_image is not empty"""
+ super().__init__(self.left_edge, self.top_edge, self.length, self.height)
+
self.path_to_image = path_to_image
if path_to_image != "":
@@ -242,7 +246,7 @@ Classes
"""Sets the functions that are called when the mouse enters and exits the component"""
self.set_mouse_enter_function(mouse_enter_function)
- self.mouse_exit_function(mouse_exit_function)
+ self.set_mouse_exit_function(mouse_exit_function)
def set_mouse_enter_function(self, mouse_enter_function):
"""Sets the action that happens when a mouse enters this object"""
@@ -269,8 +273,13 @@ Ancestors
Subclasses
+ self.set_mouse_exit_function(mouse_exit_function)
diff --git a/docs/gui_components/dimensions.html b/docs/gui_components/dimensions.html
index 54ac274..7a37cb9 100644
--- a/docs/gui_components/dimensions.html
+++ b/docs/gui_components/dimensions.html
@@ -217,6 +217,7 @@ Classes
Subclasses
Class variables
diff --git a/docs/gui_components/hud.html b/docs/gui_components/hud.html
index 36a734a..ea2cea8 100644
--- a/docs/gui_components/hud.html
+++ b/docs/gui_components/hud.html
@@ -61,6 +61,8 @@ Module game_qu.gui_components.hud
Returns:
None
"""
+
+ super().__init__("")
self.player_points_fields = []
self.rows = rows
@@ -176,6 +178,8 @@ Returns
Returns:
None
"""
+
+ super().__init__("")
self.player_points_fields = []
self.rows = rows
diff --git a/docs/gui_components/intermediate_screen.html b/docs/gui_components/intermediate_screen.html
index 9b379e3..89f437f 100644
--- a/docs/gui_components/intermediate_screen.html
+++ b/docs/gui_components/intermediate_screen.html
@@ -29,7 +29,7 @@ Module game_qu.gui_components.intermediate_screen
from game_qu.base.colors import white
from game_qu.base.utility_functions import get_index_of_range, get_ranges
from game_qu.gui_components.dimensions import Dimensions
-from game_qu.base.events import TimedEvent
+from game_qu.base.timed_event import TimedEvent
from game_qu.base.important_variables import BACKGROUND_COLOR, SCREEN_LENGTH, SCREEN_HEIGHT
from game_qu.gui_components.screen import Screen
from game_qu.gui_components.text_box import TextBox
diff --git a/docs/gui_components/screen.html b/docs/gui_components/screen.html
index d582e7a..095c86d 100644
--- a/docs/gui_components/screen.html
+++ b/docs/gui_components/screen.html
@@ -50,6 +50,8 @@ Module game_qu.gui_components.screen
""" Initializes the object and also loads the image which is at the path 'path_to_background_image.' No image will
be loaded if path_to_background_image is ''"""
+ super().__init__("")
+
self.path_to_background_image = path_to_background_image
self.background_color = background_color
@@ -139,6 +141,8 @@ Classes
""" Initializes the object and also loads the image which is at the path 'path_to_background_image.' No image will
be loaded if path_to_background_image is ''"""
+ super().__init__("")
+
self.path_to_background_image = path_to_background_image
self.background_color = background_color
@@ -197,10 +201,16 @@ Ancestors
Subclasses
+- Game1Screen
+- Game2Screen
+- MainScreen
+- MainScreen
+- IntermediateScreen
+- NavigationScreen
- Game1Screen
- Game2Screen
- MainScreen
-- MainScreen
+- MainScreen
- IntermediateScreen
- NavigationScreen
diff --git a/docs/gui_components/text_box.html b/docs/gui_components/text_box.html
index ba96b2a..50f9100 100644
--- a/docs/gui_components/text_box.html
+++ b/docs/gui_components/text_box.html
@@ -27,10 +27,10 @@ Module game_qu.gui_components.text_box
Expand source code
from game_qu.gui_components.dimensions import Dimensions
-from game_qu.base.important_variables import game_window
from game_qu.gui_components.component import Component
from game_qu.base.utility_functions import *
+
class TextBox(Component):
"""A box that contains text. The background color, text color, text, font_size, and the text being centered can all be set"""
@@ -214,6 +214,7 @@ Ancestors
Subclasses
Class variables
diff --git a/docs/math/function.html b/docs/math/function.html
index c1be792..55670ea 100644
--- a/docs/math/function.html
+++ b/docs/math/function.html
@@ -133,6 +133,11 @@ Ancestors
Subclasses
+- BoundedFunction
+- LinearInterpolation
+- PiecewiseFunction
+- Polynomial
+- QuadraticFunction
- BoundedFunction
- LinearInterpolation
- PiecewiseFunction
diff --git a/docs/math/linear_interpolation.html b/docs/math/linear_interpolation.html
index edad832..7be1005 100644
--- a/docs/math/linear_interpolation.html
+++ b/docs/math/linear_interpolation.html
@@ -234,6 +234,7 @@ Ancestors
Subclasses
Class variables
diff --git a/docs/math/physics_function.html b/docs/math/physics_function.html
index e405700..ee30b09 100644
--- a/docs/math/physics_function.html
+++ b/docs/math/physics_function.html
@@ -222,8 +222,10 @@ Module game_qu.math.physics_function
Returns:
float: the displacement of the object from start_time -> end_time only based upon velocity (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_velocity_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = self.initial_velocity * end_time
+ last_distance = self.initial_velocity * start_time
+
+ return current_distance - last_distance
def get_indefinite_integral_of_acceleration_equation(self):
"""
@@ -237,8 +239,10 @@ Module game_qu.math.physics_function
Returns:
float: the displacement of the object from start_time -> end_time only based upon acceleration (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_acceleration_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = 1 / 2 * self.acceleration * pow(end_time, 2)
+ last_distance = 1 / 2 * self.acceleration * pow(start_time, 2)
+
+ return current_distance - last_distance
def __str__(self):
return f"[{self.acceleration},{self.initial_velocity},{self.initial_distance},]"
@@ -455,8 +459,10 @@ Classes
Returns:
float: the displacement of the object from start_time -> end_time only based upon velocity (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_velocity_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = self.initial_velocity * end_time
+ last_distance = self.initial_velocity * start_time
+
+ return current_distance - last_distance
def get_indefinite_integral_of_acceleration_equation(self):
"""
@@ -470,8 +476,10 @@ Classes
Returns:
float: the displacement of the object from start_time -> end_time only based upon acceleration (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_acceleration_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = 1 / 2 * self.acceleration * pow(end_time, 2)
+ last_distance = 1 / 2 * self.acceleration * pow(start_time, 2)
+
+ return current_distance - last_distance
def __str__(self):
return f"[{self.acceleration},{self.initial_velocity},{self.initial_distance},]"
@@ -482,6 +490,8 @@ Classes
Subclasses
@@ -567,8 +577,10 @@ Methods
Returns:
float: the displacement of the object from start_time -> end_time only based upon acceleration (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_acceleration_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = 1 / 2 * self.acceleration * pow(end_time, 2)
+ last_distance = 1 / 2 * self.acceleration * pow(start_time, 2)
+
+ return current_distance - last_distance
@@ -589,8 +601,10 @@ Methods
Returns:
float: the displacement of the object from start_time -> end_time only based upon velocity (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_velocity_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = self.initial_velocity * end_time
+ last_distance = self.initial_velocity * start_time
+
+ return current_distance - last_distance
diff --git a/docs/math/polynomial.html b/docs/math/polynomial.html
index bf6c350..4ae3981 100644
--- a/docs/math/polynomial.html
+++ b/docs/math/polynomial.html
@@ -348,6 +348,7 @@ Ancestors
Subclasses
Class variables
diff --git a/docs/math/quadratic_function.html b/docs/math/quadratic_function.html
index e1fac33..7112ae1 100644
--- a/docs/math/quadratic_function.html
+++ b/docs/math/quadratic_function.html
@@ -341,6 +341,7 @@ Ancestors
Subclasses
Class variables
diff --git a/docs/paths/action_followable_path.html b/docs/paths/action_followable_path.html
index e8e2b8e..4a9a72e 100644
--- a/docs/paths/action_followable_path.html
+++ b/docs/paths/action_followable_path.html
@@ -215,6 +215,7 @@ Ancestors
Subclasses
Class variables
diff --git a/docs/paths/followable_path.html b/docs/paths/followable_path.html
index 1374015..95a3935 100644
--- a/docs/paths/followable_path.html
+++ b/docs/paths/followable_path.html
@@ -300,6 +300,9 @@ Ancestors
Subclasses
+- PhysicsFollowablePath
+- PiecewiseFollowablePath
+- VelocityFollowablePath
- PhysicsFollowablePath
- PiecewiseFollowablePath
- VelocityFollowablePath
diff --git a/docs/paths/physics_followable_path.html b/docs/paths/physics_followable_path.html
index b1c1a71..b5b1fd4 100644
--- a/docs/paths/physics_followable_path.html
+++ b/docs/paths/physics_followable_path.html
@@ -41,7 +41,7 @@ Module game_qu.paths.physics_followable_path
is_started = False
attribute_modifying = None
height_of_path = 0
- time = 0
+ time_to_vertex = 0
max_time = 0
last_time = 0
has_max_time = False
@@ -49,7 +49,6 @@ Module game_qu.paths.physics_followable_path
last_delta_time = 0
is_using_everything_this_cycle = False
- # def __init__(self, game_object=None, attribute_modifying="", height_of_path=0, initial_distance=0, time=.5):
def __init__(self, **kwargs):
""" Initializes the object
@@ -65,11 +64,11 @@ Module game_qu.paths.physics_followable_path
"""
FollowablePath.__init__(self, **kwargs)
- self.time, self.height_of_path = get_kwarg_item(kwargs, "time", .5), get_kwarg_item(kwargs, "height_of_path", 0)
+ self.time_to_vertex, self.height_of_path = get_kwarg_item(kwargs, "time", .5), get_kwarg_item(kwargs, "height_of_path", 0)
self.initial_distance = get_kwarg_item(kwargs, "initial_distance", 0)
# Adding the initial_distance, so it that is the height of the parabola
- self.set_all_variables(self.height_of_path + self.initial_distance, self.time, self.initial_distance)
+ self.set_all_variables(self.height_of_path + self.initial_distance, self.time_to_vertex, self.initial_distance)
def run(self, is_reset_event, is_start_event, is_using_everything=False, is_changing_coordinates=True):
""" Runs the code for the game_object following the physics path
@@ -86,13 +85,19 @@ Module game_qu.paths.physics_followable_path
self.is_using_everything_this_cycle = is_using_everything
# Calling the super method, but being explicit about which one I am looking for
- PhysicsFollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+ FollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+
+ can_change_attribute = self.is_started and self.game_object is not None
+ should_change_attribute = can_change_attribute and is_changing_coordinates
+
+ if is_using_everything and should_change_attribute:
+ self.game_object.__dict__[self.attribute_modifying] = self.get_distance(self.current_time)
def set_initial_distance(self, initial_distance):
"""Sets the initial distance, so the height of the parabola is equal to the vertex"""
self.initial_distance = initial_distance
- self.set_all_variables(self.initial_distance + self.height_of_path, self.time, self.initial_distance)
+ self.set_all_variables(self.initial_distance + self.height_of_path, self.time_to_vertex, self.initial_distance)
def get_velocity_displacement(self):
"""
@@ -135,7 +140,7 @@ Module game_qu.paths.physics_followable_path
object: the value of the attribute this path is modifying at 'time'"""
if self.is_using_everything_this_cycle:
- self.get_distance(time)
+ return self.get_distance(time)
else:
return self.get_displacement_due_to_velocity(0, time)
@@ -146,7 +151,7 @@ Module game_qu.paths.physics_followable_path
object: the delta value of the attribute within the domain [start_time, end_time]"""
if self.is_using_everything_this_cycle:
- self.get_distance(end_time)
+ return 0
else:
return self.get_displacement_due_to_velocity(start_time, end_time)
@@ -197,7 +202,7 @@ Returns
is_started = False
attribute_modifying = None
height_of_path = 0
- time = 0
+ time_to_vertex = 0
max_time = 0
last_time = 0
has_max_time = False
@@ -205,7 +210,6 @@ Returns
last_delta_time = 0
is_using_everything_this_cycle = False
- # def __init__(self, game_object=None, attribute_modifying="", height_of_path=0, initial_distance=0, time=.5):
def __init__(self, **kwargs):
""" Initializes the object
@@ -221,11 +225,11 @@ Returns
"""
FollowablePath.__init__(self, **kwargs)
- self.time, self.height_of_path = get_kwarg_item(kwargs, "time", .5), get_kwarg_item(kwargs, "height_of_path", 0)
+ self.time_to_vertex, self.height_of_path = get_kwarg_item(kwargs, "time", .5), get_kwarg_item(kwargs, "height_of_path", 0)
self.initial_distance = get_kwarg_item(kwargs, "initial_distance", 0)
# Adding the initial_distance, so it that is the height of the parabola
- self.set_all_variables(self.height_of_path + self.initial_distance, self.time, self.initial_distance)
+ self.set_all_variables(self.height_of_path + self.initial_distance, self.time_to_vertex, self.initial_distance)
def run(self, is_reset_event, is_start_event, is_using_everything=False, is_changing_coordinates=True):
""" Runs the code for the game_object following the physics path
@@ -242,13 +246,19 @@ Returns
self.is_using_everything_this_cycle = is_using_everything
# Calling the super method, but being explicit about which one I am looking for
- PhysicsFollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+ FollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+
+ can_change_attribute = self.is_started and self.game_object is not None
+ should_change_attribute = can_change_attribute and is_changing_coordinates
+
+ if is_using_everything and should_change_attribute:
+ self.game_object.__dict__[self.attribute_modifying] = self.get_distance(self.current_time)
def set_initial_distance(self, initial_distance):
"""Sets the initial distance, so the height of the parabola is equal to the vertex"""
self.initial_distance = initial_distance
- self.set_all_variables(self.initial_distance + self.height_of_path, self.time, self.initial_distance)
+ self.set_all_variables(self.initial_distance + self.height_of_path, self.time_to_vertex, self.initial_distance)
def get_velocity_displacement(self):
"""
@@ -291,7 +301,7 @@ Returns
object: the value of the attribute this path is modifying at 'time'"""
if self.is_using_everything_this_cycle:
- self.get_distance(time)
+ return self.get_distance(time)
else:
return self.get_displacement_due_to_velocity(0, time)
@@ -302,7 +312,7 @@ Returns
object: the delta value of the attribute within the domain [start_time, end_time]"""
if self.is_using_everything_this_cycle:
- self.get_distance(end_time)
+ return 0
else:
return self.get_displacement_due_to_velocity(start_time, end_time)
@@ -315,6 +325,7 @@ Ancestors
Subclasses
Class variables
@@ -363,7 +374,7 @@ Class variables
-var time
+var time_to_vertex
@@ -510,7 +521,13 @@ Returns
self.is_using_everything_this_cycle = is_using_everything
# Calling the super method, but being explicit about which one I am looking for
- PhysicsFollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+ FollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+
+ can_change_attribute = self.is_started and self.game_object is not None
+ should_change_attribute = can_change_attribute and is_changing_coordinates
+
+ if is_using_everything and should_change_attribute:
+ self.game_object.__dict__[self.attribute_modifying] = self.get_distance(self.current_time)
@@ -526,7 +543,7 @@ Returns
"""Sets the initial distance, so the height of the parabola is equal to the vertex"""
self.initial_distance = initial_distance
- self.set_all_variables(self.initial_distance + self.height_of_path, self.time, self.initial_distance)
+ self.set_all_variables(self.initial_distance + self.height_of_path, self.time_to_vertex, self.initial_distance)
@@ -605,7 +622,7 @@ max_time
run
set_initial_distance
-time
+time_to_vertex
diff --git a/docs/paths/velocity_followable_path.html b/docs/paths/velocity_followable_path.html
index f7578ec..9e19ea9 100644
--- a/docs/paths/velocity_followable_path.html
+++ b/docs/paths/velocity_followable_path.html
@@ -39,13 +39,9 @@ Module game_qu.paths.velocity_followable_path
Module game_qu.paths.velocity_followable_path
Module game_qu.paths.velocity_followable_path
Module game_qu.paths.velocity_followable_path
Module game_qu.paths.velocity_followable_path
Module game_qu.paths.velocity_followable_path
+ return string
+
+ @property
+ def last_end_time(self):
+ return self.max_time
+
+ @last_end_time.setter
+ def last_end_time(self, value):
+ self.max_time = value
+
+ @property
+ def total_time(self):
+ return self.current_time
+
+ @total_time.setter
+ def total_time(self, value):
+ self.current_time = value
+
+ @property
+ def previous_time(self):
+ return self.last_time
+
+ @previous_time.setter
+ def previous_time(self, value):
+ self.last_time = value
+
+ @property
+ def is_unending(self):
+ return self.has_max_time
+
+ @is_unending.setter
+ def is_unending(self, value):
+ self.has_max_time = value
var is_unending
var last_point
var last_end_time
var left_edge_lines
var last_point
var times
var left_edge_lines
var top_edge_lines
var previous_time
var velocity
var times
var is_unending
@property
+def is_unending(self):
+ return self.has_max_time
+var top_edge_lines
var last_end_time
@property
+def last_end_time(self):
+ return self.max_time
+var total_time
var previous_time
@property
+def previous_time(self):
+ return self.last_time
+var velocity
var total_time
@property
+def total_time(self):
+ return self.current_time
+def add_time_point(self, point, end_time):
"""Adds the point to the path using the end_time as the x_coordinate for the x and y coordinate lines"""
- left_edge_line = LineSegment(Point(self.last_end_time, self.last_point.x_coordinate),
+ left_edge_line = LineSegment(Point(self.max_time, self.last_point.x_coordinate),
Point(end_time, point.x_coordinate))
- top_edge_line = LineSegment(Point(self.last_end_time, self.last_point.y_coordinate),
+ top_edge_line = LineSegment(Point(self.max_time, self.last_point.y_coordinate),
Point(end_time, point.y_coordinate))
self.left_edge_lines.append(left_edge_line)
self.top_edge_lines.append(top_edge_line)
- self.last_end_time = end_time
+ self.max_time = end_time
# The height for the path_line doesn't matter
self.last_point = point
@@ -488,7 +579,7 @@
@@ -559,7 +650,7 @@ Methods
def set_time(self, time):
"""Sets the time to the provided 'time'- if it is greater than the max time it is reduced to a smaller time"""
- self.total_time = time % self.max_time
+ self.current_time = time % self.max_time
@@ -575,14 +666,14 @@ Methods
"""Updates the time variables for this object by the time the last game tick took"""
# The time should only be increased if it was not called that cycle
- if self.previous_time != VelocityCalculator.time:
- self.total_time += VelocityCalculator.time
- self.previous_time = VelocityCalculator.time
+ if self.last_time != VelocityCalculator.time:
+ self.current_time += VelocityCalculator.time
+ self.last_time = VelocityCalculator.time
- max_time = self.last_end_time
+ max_time = self.max_time
- if self.total_time > max_time and self.is_unending:
- self.total_time %= max_time
+ if self.current_time > max_time and self.has_max_time:
+ self.current_time %= max_time
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..5e40864
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,21 @@
+[project]
+name = "game_qu"
+version = "2.1.4"
+authors = [
+ { name="Micah Ribbens", email="mdribbens22@outlook.com" },
+]
+description = ""
+readme = "README.md"
+requires-python = ">=3.7"
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = "https://github.com/codingspartan9/Game-Qu"
+
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
\ No newline at end of file
diff --git a/game_qu/__init__.py b/src/__init__.py
similarity index 100%
rename from game_qu/__init__.py
rename to src/__init__.py
diff --git a/game_qu/getting_started/__init__.py b/src/game_qu/__init__.py
similarity index 100%
rename from game_qu/getting_started/__init__.py
rename to src/game_qu/__init__.py
diff --git a/game_qu/base/__init__.py b/src/game_qu/base/__init__.py
similarity index 100%
rename from game_qu/base/__init__.py
rename to src/game_qu/base/__init__.py
diff --git a/game_qu/base/colors.py b/src/game_qu/base/colors.py
similarity index 100%
rename from game_qu/base/colors.py
rename to src/game_qu/base/colors.py
diff --git a/game_qu/base/count_event.py b/src/game_qu/base/count_event.py
similarity index 100%
rename from game_qu/base/count_event.py
rename to src/game_qu/base/count_event.py
diff --git a/game_qu/base/engines.py b/src/game_qu/base/engines.py
similarity index 100%
rename from game_qu/base/engines.py
rename to src/game_qu/base/engines.py
diff --git a/game_qu/base/events.py b/src/game_qu/base/events.py
similarity index 98%
rename from game_qu/base/events.py
rename to src/game_qu/base/events.py
index 2e177d3..5a3e872 100644
--- a/game_qu/base/events.py
+++ b/src/game_qu/base/events.py
@@ -1,8 +1,6 @@
from game_qu.base.history_keeper import HistoryKeeper
from game_qu.base.id_creator import id_creator
from game_qu.base.timed_event import TimedEvent
-from game_qu.base.count_event import CountEvent
-
class Event:
"""Used to store an event from the current cycle and past cycles (event being anything that is a bool)"""
diff --git a/game_qu/base/file_reader.py b/src/game_qu/base/file_reader.py
similarity index 100%
rename from game_qu/base/file_reader.py
rename to src/game_qu/base/file_reader.py
diff --git a/game_qu/base/fraction.py b/src/game_qu/base/fraction.py
similarity index 100%
rename from game_qu/base/fraction.py
rename to src/game_qu/base/fraction.py
diff --git a/game_qu/base/game_movement.py b/src/game_qu/base/game_movement.py
similarity index 99%
rename from game_qu/base/game_movement.py
rename to src/game_qu/base/game_movement.py
index 9101400..40c8761 100644
--- a/game_qu/base/game_movement.py
+++ b/src/game_qu/base/game_movement.py
@@ -1,5 +1,3 @@
-import pygame.key
-
from game_qu.base.important_variables import SCREEN_HEIGHT, SCREEN_LENGTH
from game_qu.base.utility_functions import key_is_pressed
from game_qu.base.velocity_calculator import VelocityCalculator
diff --git a/game_qu/base/game_runner_function.py b/src/game_qu/base/game_runner_function.py
similarity index 100%
rename from game_qu/base/game_runner_function.py
rename to src/game_qu/base/game_runner_function.py
diff --git a/game_qu/base/history_keeper.py b/src/game_qu/base/history_keeper.py
similarity index 100%
rename from game_qu/base/history_keeper.py
rename to src/game_qu/base/history_keeper.py
diff --git a/game_qu/base/id_creator.py b/src/game_qu/base/id_creator.py
similarity index 100%
rename from game_qu/base/id_creator.py
rename to src/game_qu/base/id_creator.py
diff --git a/game_qu/base/important_constants.py b/src/game_qu/base/important_constants.py
similarity index 100%
rename from game_qu/base/important_constants.py
rename to src/game_qu/base/important_constants.py
diff --git a/game_qu/base/important_variables.py b/src/game_qu/base/important_variables.py
similarity index 98%
rename from game_qu/base/important_variables.py
rename to src/game_qu/base/important_variables.py
index 21f6f38..76551da 100644
--- a/game_qu/base/important_variables.py
+++ b/src/game_qu/base/important_variables.py
@@ -9,7 +9,6 @@
from game_qu.base.keyboard import Keyboard
from game_qu.gui_components.window import Window
from game_qu.library_abstraction import keys
-from game_qu.base.colors import *
keyboard = Keyboard()
game_window = Window(SCREEN_LENGTH, SCREEN_HEIGHT, BACKGROUND_COLOR, "Game Basics")
diff --git a/game_qu/base/keyboard.py b/src/game_qu/base/keyboard.py
similarity index 97%
rename from game_qu/base/keyboard.py
rename to src/game_qu/base/keyboard.py
index 1c1ad35..f2f7423 100644
--- a/game_qu/base/keyboard.py
+++ b/src/game_qu/base/keyboard.py
@@ -1,4 +1,5 @@
-from game_qu.base.events import Event, TimedEvent
+from game_qu.base.events import Event
+from game_qu.base.timed_event import TimedEvent
from game_qu.library_abstraction import keys
from game_qu.library_abstraction import utility_functions
from game_qu.library_abstraction import variables
diff --git a/game_qu/base/library_changer.py b/src/game_qu/base/library_changer.py
similarity index 100%
rename from game_qu/base/library_changer.py
rename to src/game_qu/base/library_changer.py
diff --git a/game_qu/base/library_independant_utility_functions.py b/src/game_qu/base/library_independant_utility_functions.py
similarity index 100%
rename from game_qu/base/library_independant_utility_functions.py
rename to src/game_qu/base/library_independant_utility_functions.py
diff --git a/game_qu/base/lines.py b/src/game_qu/base/lines.py
similarity index 61%
rename from game_qu/base/lines.py
rename to src/game_qu/base/lines.py
index 2e24bb7..3fb8606 100644
--- a/game_qu/base/lines.py
+++ b/src/game_qu/base/lines.py
@@ -1,3 +1,3 @@
from game_qu.math.function import Function
from game_qu.math.point import Point
-from game_qu.math.line_segment import LineSegment
+from game_qu.math.line_segment import LineSegment
\ No newline at end of file
diff --git a/game_qu/base/paths.py b/src/game_qu/base/paths.py
similarity index 100%
rename from game_qu/base/paths.py
rename to src/game_qu/base/paths.py
diff --git a/game_qu/base/quadratic_equations.py b/src/game_qu/base/quadratic_equations.py
similarity index 73%
rename from game_qu/base/quadratic_equations.py
rename to src/game_qu/base/quadratic_equations.py
index 617e62c..7438f7a 100644
--- a/game_qu/base/quadratic_equations.py
+++ b/src/game_qu/base/quadratic_equations.py
@@ -1,9 +1,3 @@
-import math
-
-from game_qu.base.important_variables import SCREEN_HEIGHT
-from game_qu.base.utility_functions import get_kwarg_item, solve_quadratic
-from game_qu.base.velocity_calculator import VelocityCalculator
-from game_qu.math.function import Function
from game_qu.math.physics_function import PhysicsFunction
from game_qu.math.quadratic_function import QuadraticFunction
from game_qu.paths.physics_followable_path import PhysicsFollowablePath
diff --git a/game_qu/base/range.py b/src/game_qu/base/range.py
similarity index 100%
rename from game_qu/base/range.py
rename to src/game_qu/base/range.py
diff --git a/game_qu/base/timed_event.py b/src/game_qu/base/timed_event.py
similarity index 100%
rename from game_qu/base/timed_event.py
rename to src/game_qu/base/timed_event.py
diff --git a/game_qu/base/unique_ids_list.py b/src/game_qu/base/unique_ids_list.py
similarity index 100%
rename from game_qu/base/unique_ids_list.py
rename to src/game_qu/base/unique_ids_list.py
diff --git a/game_qu/base/utility_functions.py b/src/game_qu/base/utility_functions.py
similarity index 100%
rename from game_qu/base/utility_functions.py
rename to src/game_qu/base/utility_functions.py
diff --git a/game_qu/base/velocity_calculator.py b/src/game_qu/base/velocity_calculator.py
similarity index 100%
rename from game_qu/base/velocity_calculator.py
rename to src/game_qu/base/velocity_calculator.py
diff --git a/src/game_qu/getting_started/__init__.py b/src/game_qu/getting_started/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/game_qu/getting_started/getting_started.py b/src/game_qu/getting_started/getting_started.py
similarity index 100%
rename from game_qu/getting_started/getting_started.py
rename to src/game_qu/getting_started/getting_started.py
diff --git a/game_qu/getting_started/pong (example game).py b/src/game_qu/getting_started/pong (example game).py
similarity index 100%
rename from game_qu/getting_started/pong (example game).py
rename to src/game_qu/getting_started/pong (example game).py
diff --git a/game_qu/gui_components/__init__.py b/src/game_qu/gui_components/__init__.py
similarity index 100%
rename from game_qu/gui_components/__init__.py
rename to src/game_qu/gui_components/__init__.py
diff --git a/game_qu/gui_components/button.py b/src/game_qu/gui_components/button.py
similarity index 98%
rename from game_qu/gui_components/button.py
rename to src/game_qu/gui_components/button.py
index ab048f1..0d4ead0 100644
--- a/game_qu/gui_components/button.py
+++ b/src/game_qu/gui_components/button.py
@@ -1,5 +1,5 @@
from game_qu.gui_components.text_box import TextBox
-from game_qu.base.events import TimedEvent
+from game_qu.base.timed_event import TimedEvent
class Button(TextBox):
diff --git a/game_qu/gui_components/component.py b/src/game_qu/gui_components/component.py
similarity index 97%
rename from game_qu/gui_components/component.py
rename to src/game_qu/gui_components/component.py
index 98d79f3..c58b28e 100644
--- a/game_qu/gui_components/component.py
+++ b/src/game_qu/gui_components/component.py
@@ -29,6 +29,8 @@ class Component(Dimensions):
def __init__(self, path_to_image=""):
"""Initializes the object and loads an image if the path_to_image is not empty"""
+ super().__init__(self.left_edge, self.top_edge, self.length, self.height)
+
self.path_to_image = path_to_image
if path_to_image != "":
@@ -89,7 +91,7 @@ def set_mouse_functions(self, mouse_enter_function, mouse_exit_function):
"""Sets the functions that are called when the mouse enters and exits the component"""
self.set_mouse_enter_function(mouse_enter_function)
- self.mouse_exit_function(mouse_exit_function)
+ self.set_mouse_exit_function(mouse_exit_function)
def set_mouse_enter_function(self, mouse_enter_function):
"""Sets the action that happens when a mouse enters this object"""
diff --git a/game_qu/gui_components/dimensions.py b/src/game_qu/gui_components/dimensions.py
similarity index 100%
rename from game_qu/gui_components/dimensions.py
rename to src/game_qu/gui_components/dimensions.py
diff --git a/game_qu/gui_components/grid.py b/src/game_qu/gui_components/grid.py
similarity index 100%
rename from game_qu/gui_components/grid.py
rename to src/game_qu/gui_components/grid.py
diff --git a/game_qu/gui_components/hud.py b/src/game_qu/gui_components/hud.py
similarity index 98%
rename from game_qu/gui_components/hud.py
rename to src/game_qu/gui_components/hud.py
index 353dd47..9cd2be9 100644
--- a/game_qu/gui_components/hud.py
+++ b/src/game_qu/gui_components/hud.py
@@ -33,6 +33,8 @@ def __init__(self, number_of_points_fields, other_fields, length, height, rows=1
Returns:
None
"""
+
+ super().__init__("")
self.player_points_fields = []
self.rows = rows
diff --git a/game_qu/gui_components/intermediate_screen.py b/src/game_qu/gui_components/intermediate_screen.py
similarity index 98%
rename from game_qu/gui_components/intermediate_screen.py
rename to src/game_qu/gui_components/intermediate_screen.py
index fa9b004..d9750b7 100644
--- a/game_qu/gui_components/intermediate_screen.py
+++ b/src/game_qu/gui_components/intermediate_screen.py
@@ -1,7 +1,7 @@
from game_qu.base.colors import white
from game_qu.base.utility_functions import get_index_of_range, get_ranges
from game_qu.gui_components.dimensions import Dimensions
-from game_qu.base.events import TimedEvent
+from game_qu.base.timed_event import TimedEvent
from game_qu.base.important_variables import BACKGROUND_COLOR, SCREEN_LENGTH, SCREEN_HEIGHT
from game_qu.gui_components.screen import Screen
from game_qu.gui_components.text_box import TextBox
diff --git a/game_qu/gui_components/navigation_screen.py b/src/game_qu/gui_components/navigation_screen.py
similarity index 100%
rename from game_qu/gui_components/navigation_screen.py
rename to src/game_qu/gui_components/navigation_screen.py
diff --git a/game_qu/gui_components/screen.py b/src/game_qu/gui_components/screen.py
similarity index 98%
rename from game_qu/gui_components/screen.py
rename to src/game_qu/gui_components/screen.py
index b97bdb4..a996307 100644
--- a/game_qu/gui_components/screen.py
+++ b/src/game_qu/gui_components/screen.py
@@ -22,6 +22,8 @@ def __init__(self, path_to_background_image="", background_color=light_gray):
""" Initializes the object and also loads the image which is at the path 'path_to_background_image.' No image will
be loaded if path_to_background_image is ''"""
+ super().__init__("")
+
self.path_to_background_image = path_to_background_image
self.background_color = background_color
diff --git a/game_qu/gui_components/text_box.py b/src/game_qu/gui_components/text_box.py
similarity index 97%
rename from game_qu/gui_components/text_box.py
rename to src/game_qu/gui_components/text_box.py
index 6a6ae59..fd44b38 100644
--- a/game_qu/gui_components/text_box.py
+++ b/src/game_qu/gui_components/text_box.py
@@ -1,8 +1,8 @@
from game_qu.gui_components.dimensions import Dimensions
-from game_qu.base.important_variables import game_window
from game_qu.gui_components.component import Component
from game_qu.base.utility_functions import *
+
class TextBox(Component):
"""A box that contains text. The background color, text color, text, font_size, and the text being centered can all be set"""
diff --git a/game_qu/gui_components/window.py b/src/game_qu/gui_components/window.py
similarity index 100%
rename from game_qu/gui_components/window.py
rename to src/game_qu/gui_components/window.py
diff --git a/game_qu/library_abstraction.py b/src/game_qu/library_abstraction.py
similarity index 100%
rename from game_qu/library_abstraction.py
rename to src/game_qu/library_abstraction.py
diff --git a/game_qu/math/__init__.py b/src/game_qu/math/__init__.py
similarity index 100%
rename from game_qu/math/__init__.py
rename to src/game_qu/math/__init__.py
diff --git a/game_qu/math/bounded_function.py b/src/game_qu/math/bounded_function.py
similarity index 100%
rename from game_qu/math/bounded_function.py
rename to src/game_qu/math/bounded_function.py
diff --git a/game_qu/math/derivative.py b/src/game_qu/math/derivative.py
similarity index 100%
rename from game_qu/math/derivative.py
rename to src/game_qu/math/derivative.py
diff --git a/game_qu/math/function.py b/src/game_qu/math/function.py
similarity index 100%
rename from game_qu/math/function.py
rename to src/game_qu/math/function.py
diff --git a/game_qu/math/indefinite_integral.py b/src/game_qu/math/indefinite_integral.py
similarity index 100%
rename from game_qu/math/indefinite_integral.py
rename to src/game_qu/math/indefinite_integral.py
diff --git a/game_qu/math/line_segment.py b/src/game_qu/math/line_segment.py
similarity index 100%
rename from game_qu/math/line_segment.py
rename to src/game_qu/math/line_segment.py
diff --git a/game_qu/math/linear_interpolation.py b/src/game_qu/math/linear_interpolation.py
similarity index 100%
rename from game_qu/math/linear_interpolation.py
rename to src/game_qu/math/linear_interpolation.py
diff --git a/game_qu/math/matrix.py b/src/game_qu/math/matrix.py
similarity index 100%
rename from game_qu/math/matrix.py
rename to src/game_qu/math/matrix.py
diff --git a/game_qu/math/physics_function.py b/src/game_qu/math/physics_function.py
similarity index 96%
rename from game_qu/math/physics_function.py
rename to src/game_qu/math/physics_function.py
index 8eab64a..c93cf3e 100644
--- a/game_qu/math/physics_function.py
+++ b/src/game_qu/math/physics_function.py
@@ -194,8 +194,10 @@ def get_displacement_due_to_velocity(self, start_time, end_time):
Returns:
float: the displacement of the object from start_time -> end_time only based upon velocity (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_velocity_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = self.initial_velocity * end_time
+ last_distance = self.initial_velocity * start_time
+
+ return current_distance - last_distance
def get_indefinite_integral_of_acceleration_equation(self):
"""
@@ -209,8 +211,10 @@ def get_displacement_due_to_acceleration(self, start_time, end_time):
Returns:
float: the displacement of the object from start_time -> end_time only based upon acceleration (the integral from start_time to end_time)"""
- indefinite_integral = self.get_indefinite_integral_of_acceleration_equation()
- return indefinite_integral.get(end_time) - indefinite_integral.get(start_time)
+ current_distance = 1 / 2 * self.acceleration * pow(end_time, 2)
+ last_distance = 1 / 2 * self.acceleration * pow(start_time, 2)
+
+ return current_distance - last_distance
def __str__(self):
return f"[{self.acceleration},{self.initial_velocity},{self.initial_distance},]"
diff --git a/game_qu/math/piecewise_function.py b/src/game_qu/math/piecewise_function.py
similarity index 100%
rename from game_qu/math/piecewise_function.py
rename to src/game_qu/math/piecewise_function.py
diff --git a/game_qu/math/point.py b/src/game_qu/math/point.py
similarity index 100%
rename from game_qu/math/point.py
rename to src/game_qu/math/point.py
diff --git a/game_qu/math/polynomial.py b/src/game_qu/math/polynomial.py
similarity index 100%
rename from game_qu/math/polynomial.py
rename to src/game_qu/math/polynomial.py
diff --git a/game_qu/math/quadratic_function.py b/src/game_qu/math/quadratic_function.py
similarity index 100%
rename from game_qu/math/quadratic_function.py
rename to src/game_qu/math/quadratic_function.py
diff --git a/game_qu/math/range.py b/src/game_qu/math/range.py
similarity index 100%
rename from game_qu/math/range.py
rename to src/game_qu/math/range.py
diff --git a/game_qu/math/vector_2d.py b/src/game_qu/math/vector_2d.py
similarity index 100%
rename from game_qu/math/vector_2d.py
rename to src/game_qu/math/vector_2d.py
diff --git a/game_qu/paths/__init__.py b/src/game_qu/paths/__init__.py
similarity index 100%
rename from game_qu/paths/__init__.py
rename to src/game_qu/paths/__init__.py
diff --git a/game_qu/paths/action_followable_path.py b/src/game_qu/paths/action_followable_path.py
similarity index 100%
rename from game_qu/paths/action_followable_path.py
rename to src/game_qu/paths/action_followable_path.py
diff --git a/game_qu/paths/followable_path.py b/src/game_qu/paths/followable_path.py
similarity index 100%
rename from game_qu/paths/followable_path.py
rename to src/game_qu/paths/followable_path.py
diff --git a/game_qu/paths/physics_followable_path.py b/src/game_qu/paths/physics_followable_path.py
similarity index 85%
rename from game_qu/paths/physics_followable_path.py
rename to src/game_qu/paths/physics_followable_path.py
index 8ee93a4..68dc707 100644
--- a/game_qu/paths/physics_followable_path.py
+++ b/src/game_qu/paths/physics_followable_path.py
@@ -13,7 +13,7 @@ class PhysicsFollowablePath(FollowablePath, PhysicsFunction):
is_started = False
attribute_modifying = None
height_of_path = 0
- time = 0
+ time_to_vertex = 0
max_time = 0
last_time = 0
has_max_time = False
@@ -21,7 +21,6 @@ class PhysicsFollowablePath(FollowablePath, PhysicsFunction):
last_delta_time = 0
is_using_everything_this_cycle = False
- # def __init__(self, game_object=None, attribute_modifying="", height_of_path=0, initial_distance=0, time=.5):
def __init__(self, **kwargs):
""" Initializes the object
@@ -37,11 +36,11 @@ def __init__(self, **kwargs):
"""
FollowablePath.__init__(self, **kwargs)
- self.time, self.height_of_path = get_kwarg_item(kwargs, "time", .5), get_kwarg_item(kwargs, "height_of_path", 0)
+ self.time_to_vertex, self.height_of_path = get_kwarg_item(kwargs, "time", .5), get_kwarg_item(kwargs, "height_of_path", 0)
self.initial_distance = get_kwarg_item(kwargs, "initial_distance", 0)
# Adding the initial_distance, so it that is the height of the parabola
- self.set_all_variables(self.height_of_path + self.initial_distance, self.time, self.initial_distance)
+ self.set_all_variables(self.height_of_path + self.initial_distance, self.time_to_vertex, self.initial_distance)
def run(self, is_reset_event, is_start_event, is_using_everything=False, is_changing_coordinates=True):
""" Runs the code for the game_object following the physics path
@@ -58,13 +57,19 @@ def run(self, is_reset_event, is_start_event, is_using_everything=False, is_chan
self.is_using_everything_this_cycle = is_using_everything
# Calling the super method, but being explicit about which one I am looking for
- PhysicsFollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+ FollowablePath.run(self, is_reset_event, is_start_event, is_changing_coordinates)
+
+ can_change_attribute = self.is_started and self.game_object is not None
+ should_change_attribute = can_change_attribute and is_changing_coordinates
+
+ if is_using_everything and should_change_attribute:
+ self.game_object.__dict__[self.attribute_modifying] = self.get_distance(self.current_time)
def set_initial_distance(self, initial_distance):
"""Sets the initial distance, so the height of the parabola is equal to the vertex"""
self.initial_distance = initial_distance
- self.set_all_variables(self.initial_distance + self.height_of_path, self.time, self.initial_distance)
+ self.set_all_variables(self.initial_distance + self.height_of_path, self.time_to_vertex, self.initial_distance)
def get_velocity_displacement(self):
"""
@@ -107,7 +112,7 @@ def get_value_at_time(self, time):
object: the value of the attribute this path is modifying at 'time'"""
if self.is_using_everything_this_cycle:
- self.get_distance(time)
+ return self.get_distance(time)
else:
return self.get_displacement_due_to_velocity(0, time)
@@ -118,7 +123,7 @@ def get_delta_value(self, start_time, end_time):
object: the delta value of the attribute within the domain [start_time, end_time]"""
if self.is_using_everything_this_cycle:
- self.get_distance(end_time)
+ return 0
else:
return self.get_displacement_due_to_velocity(start_time, end_time)
diff --git a/game_qu/paths/piecewise_followable_path.py b/src/game_qu/paths/piecewise_followable_path.py
similarity index 100%
rename from game_qu/paths/piecewise_followable_path.py
rename to src/game_qu/paths/piecewise_followable_path.py
diff --git a/game_qu/paths/velocity_followable_path.py b/src/game_qu/paths/velocity_followable_path.py
similarity index 78%
rename from game_qu/paths/velocity_followable_path.py
rename to src/game_qu/paths/velocity_followable_path.py
index d5e6507..9f7a5dc 100644
--- a/game_qu/paths/velocity_followable_path.py
+++ b/src/game_qu/paths/velocity_followable_path.py
@@ -11,13 +11,9 @@ class VelocityFollowablePath(FollowablePath):
velocity = 0
left_edge_lines = []
top_edge_lines = []
- last_end_time = 0
times = [] # Stores the times that the get_coordinates() function was called
- total_time = 0 # Points to the current time
last_point = None
- is_unending = False
- previous_time = 0 # Points to last end time
def __init__(self, start_point, other_points, velocity, **kwargs):
""" Initializes the object. Here are the kwargs options:
@@ -52,22 +48,22 @@ def add_point(self, point):
# can't travel faster than one of its max velocities
time_to_travel_distance = max_value(x_time, y_time)
- end_time = time_to_travel_distance + self.last_end_time
+ end_time = time_to_travel_distance + self.max_time
self.add_time_point(point, end_time)
def add_time_point(self, point, end_time):
"""Adds the point to the path using the end_time as the x_coordinate for the x and y coordinate lines"""
- left_edge_line = LineSegment(Point(self.last_end_time, self.last_point.x_coordinate),
+ left_edge_line = LineSegment(Point(self.max_time, self.last_point.x_coordinate),
Point(end_time, point.x_coordinate))
- top_edge_line = LineSegment(Point(self.last_end_time, self.last_point.y_coordinate),
+ top_edge_line = LineSegment(Point(self.max_time, self.last_point.y_coordinate),
Point(end_time, point.y_coordinate))
self.left_edge_lines.append(left_edge_line)
self.top_edge_lines.append(top_edge_line)
- self.last_end_time = end_time
+ self.max_time = end_time
# The height for the path_line doesn't matter
self.last_point = point
@@ -81,20 +77,20 @@ def get_coordinates(self, should_increase_time=True):
if should_increase_time:
self.update_time()
- return self.get_coordinates_at_time(self.total_time)
+ return self.get_coordinates_at_time(self.current_time)
def update_time(self):
"""Updates the time variables for this object by the time the last game tick took"""
# The time should only be increased if it was not called that cycle
- if self.previous_time != VelocityCalculator.time:
- self.total_time += VelocityCalculator.time
- self.previous_time = VelocityCalculator.time
+ if self.last_time != VelocityCalculator.time:
+ self.current_time += VelocityCalculator.time
+ self.last_time = VelocityCalculator.time
- max_time = self.last_end_time
+ max_time = self.max_time
- if self.total_time > max_time and self.is_unending:
- self.total_time %= max_time
+ if self.current_time > max_time and self.has_max_time:
+ self.current_time %= max_time
def get_coordinates_at_time(self, time):
"""
@@ -127,7 +123,7 @@ def get_index_of_line(self, time):
def set_time(self, time):
"""Sets the time to the provided 'time'- if it is greater than the max time it is reduced to a smaller time"""
- self.total_time = time % self.max_time
+ self.current_time = time % self.max_time
def get_value_at_time(self, time):
"""
@@ -136,7 +132,6 @@ def get_value_at_time(self, time):
return self.get_coordinates_at_time(time)[1] # To get the y coordinate
-
def get_delta_value(self, start_time, end_time):
"""
Returns:
@@ -153,3 +148,35 @@ def __str__(self):
string += f"x {left_edge_line}, y {top_edge_line}\n"
return string
+
+ @property
+ def last_end_time(self):
+ return self.max_time
+
+ @last_end_time.setter
+ def last_end_time(self, value):
+ self.max_time = value
+
+ @property
+ def total_time(self):
+ return self.current_time
+
+ @total_time.setter
+ def total_time(self, value):
+ self.current_time = value
+
+ @property
+ def previous_time(self):
+ return self.last_time
+
+ @previous_time.setter
+ def previous_time(self, value):
+ self.last_time = value
+
+ @property
+ def is_unending(self):
+ return self.has_max_time
+
+ @is_unending.setter
+ def is_unending(self, value):
+ self.has_max_time = value
diff --git a/game_qu/pygame_abstraction/__init__.py b/src/game_qu/pygame_abstraction/__init__.py
similarity index 100%
rename from game_qu/pygame_abstraction/__init__.py
rename to src/game_qu/pygame_abstraction/__init__.py
diff --git a/game_qu/pygame_abstraction/keys.py b/src/game_qu/pygame_abstraction/keys.py
similarity index 100%
rename from game_qu/pygame_abstraction/keys.py
rename to src/game_qu/pygame_abstraction/keys.py
diff --git a/game_qu/pygame_abstraction/utility_functions.py b/src/game_qu/pygame_abstraction/utility_functions.py
similarity index 100%
rename from game_qu/pygame_abstraction/utility_functions.py
rename to src/game_qu/pygame_abstraction/utility_functions.py
diff --git a/game_qu/pygame_abstraction/variables.py b/src/game_qu/pygame_abstraction/variables.py
similarity index 100%
rename from game_qu/pygame_abstraction/variables.py
rename to src/game_qu/pygame_abstraction/variables.py
diff --git a/game_qu/pyglet_abstraction/__init__.py b/src/game_qu/pyglet_abstraction/__init__.py
similarity index 100%
rename from game_qu/pyglet_abstraction/__init__.py
rename to src/game_qu/pyglet_abstraction/__init__.py
diff --git a/game_qu/pyglet_abstraction/keys.py b/src/game_qu/pyglet_abstraction/keys.py
similarity index 100%
rename from game_qu/pyglet_abstraction/keys.py
rename to src/game_qu/pyglet_abstraction/keys.py
diff --git a/game_qu/pyglet_abstraction/utility_functions.py b/src/game_qu/pyglet_abstraction/utility_functions.py
similarity index 100%
rename from game_qu/pyglet_abstraction/utility_functions.py
rename to src/game_qu/pyglet_abstraction/utility_functions.py
diff --git a/game_qu/pyglet_abstraction/variables.py b/src/game_qu/pyglet_abstraction/variables.py
similarity index 100%
rename from game_qu/pyglet_abstraction/variables.py
rename to src/game_qu/pyglet_abstraction/variables.py