diff options
| author | Simon Chiang <[email protected]> | 2021-04-23 09:46:41 -0600 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2021-05-26 16:08:45 -0500 |
| commit | d5115606c96b0fe0affd72e6e0b72edce7e51042 (patch) | |
| tree | 5d750d974dc947163dc4cb37a0c9bbac9266a207 /samples/04_physics_and_collisions | |
| parent | 1404fd05a99cf745c33a4316b9d5e1562083c3ae (diff) | |
| download | dragonruby-game-toolkit-contrib-d5115606c96b0fe0affd72e6e0b72edce7e51042.tar.gz dragonruby-game-toolkit-contrib-d5115606c96b0fe0affd72e6e0b72edce7e51042.zip | |
Typo fixes
Diffstat (limited to 'samples/04_physics_and_collisions')
15 files changed, 34 insertions, 34 deletions
diff --git a/samples/04_physics_and_collisions/01_simple/app/main.rb b/samples/04_physics_and_collisions/01_simple/app/main.rb index 5e3f9b7..9075d89 100644 --- a/samples/04_physics_and_collisions/01_simple/app/main.rb +++ b/samples/04_physics_and_collisions/01_simple/app/main.rb @@ -10,7 +10,7 @@ # This sample app shows collisions between two boxes. -# Runs methods needed for game to run properly. +# Runs methods needed for the game to run properly. def tick args tick_instructions args, "Sample app shows how to move a square over time and determine collision." defaults args @@ -33,7 +33,7 @@ def defaults args end def render args - # If the game state denotes that a collision has occured, + # If the game state denotes that a collision has occurred, # render a solid square, otherwise render a border instead. if args.state.center_box_collision args.outputs.solids << args.state.center_box @@ -47,7 +47,7 @@ end # Generally in a pipeline for a game engine, you have rendering, # game simulation (calculation), and input processing. -# This fuction represents the game simulation. +# This function represents the game simulation. def calc args position_moving_box args determine_collision_center_box args diff --git a/samples/04_physics_and_collisions/02_moving_objects/app/main.rb b/samples/04_physics_and_collisions/02_moving_objects/app/main.rb index e3e9261..9c39363 100644 --- a/samples/04_physics_and_collisions/02_moving_objects/app/main.rb +++ b/samples/04_physics_and_collisions/02_moving_objects/app/main.rb @@ -56,7 +56,7 @@ =end -# Calls methods needed for game to run properly +# Calls methods needed for the game to run properly def tick args tick_instructions args, "Use LEFT and RIGHT arrow keys to move and SPACE to jump." defaults args diff --git a/samples/04_physics_and_collisions/04_box_collision/app/main.rb b/samples/04_physics_and_collisions/04_box_collision/app/main.rb index af85fef..e407f0d 100644 --- a/samples/04_physics_and_collisions/04_box_collision/app/main.rb +++ b/samples/04_physics_and_collisions/04_box_collision/app/main.rb @@ -42,7 +42,7 @@ class PoorManPlatformerPhysics # Sets default values for variables. # The ||= sign means that the variable will only be set to the value following the = sign if the value has - # not already been set before. Intialization happens only in the first frame. + # not already been set before. Initialization happens only in the first frame. def defaults state.tile_size = 64 state.gravity = -0.2 @@ -161,7 +161,7 @@ class PoorManPlatformerPhysics # Calls methods needed to determine collisions between player and world_collision rects. def calc_box_collision - return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key + return unless state.world_lookup.keys.length > 0 # return unless hash has at least 1 key collision_floor! collision_left! collision_right! @@ -189,7 +189,7 @@ class PoorManPlatformerPhysics return unless state.dx < 0 # return unless player is moving left player_rect = [state.x - 0.1, state.y, state.tile_size, state.tile_size] - # Goes through world_collision_rects to find all intersections beween the player's left side and the + # Goes through world_collision_rects to find all intersections between the player's left side and the # right side of a world_collision_rect. left_side_collisions = state.world_collision_rects .find_all { |r| r[:left_right].intersect_rect?(player_rect, collision_tollerance) } diff --git a/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb b/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb index 126759a..42ccf22 100644 --- a/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb +++ b/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb @@ -91,7 +91,7 @@ class MetroidvaniaStarter state.sprite_selected ||= 1 state.map_saved_at ||= 0 - # Sets all the cordinate values for the sprite selection screen into a grid + # Sets all the coordinate values for the sprite selection screen into a grid # Displayed when 's' is pressed by player to access sprites if state.sprite_coords == [] # if sprite_coords is an empty array count = 1 @@ -223,7 +223,7 @@ class MetroidvaniaStarter # Calls methods that determine whether the player collides with any world_collision_rects. def calc_box_collision - return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key + return unless state.world_lookup.keys.length > 0 # return unless hash has at least 1 key collision_floor collision_left collision_right diff --git a/samples/04_physics_and_collisions/06_jump_physics/app/main.rb b/samples/04_physics_and_collisions/06_jump_physics/app/main.rb index da01e91..9d7a976 100644 --- a/samples/04_physics_and_collisions/06_jump_physics/app/main.rb +++ b/samples/04_physics_and_collisions/06_jump_physics/app/main.rb @@ -36,7 +36,7 @@ class VerticalPlatformer s.new_entity_strict(:platform, hash) # platform key end - # calls methods needed for game to run properly + # calls methods needed for the game to run properly def tick defaults render diff --git a/samples/04_physics_and_collisions/07_jump_physics/app/main.rb b/samples/04_physics_and_collisions/07_jump_physics/app/main.rb index da01e91..9d7a976 100644 --- a/samples/04_physics_and_collisions/07_jump_physics/app/main.rb +++ b/samples/04_physics_and_collisions/07_jump_physics/app/main.rb @@ -36,7 +36,7 @@ class VerticalPlatformer s.new_entity_strict(:platform, hash) # platform key end - # calls methods needed for game to run properly + # calls methods needed for the game to run properly def tick defaults render diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb index 9254ee4..db6687a 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb @@ -110,8 +110,8 @@ class Block #Find the vector that is perpendicular to the slope perpVect = { x: x, y: y } - mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magniude of the perpVect - perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magniude to make it a unit vector + mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magnitude of the perpVect + perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magnitude to make it a unit vector previousPosition = { # calculate an ESTIMATE of the previousPosition of the ball x:args.state.ball.center.x-args.state.ball.velocity.x, @@ -140,7 +140,7 @@ class Block dampener = 0.3 ynew *= dampener * 0.5 - #If the bounce is very low, that means the ball is rolling and we don't want to dampenen the X velocity + #If the bounce is very low, that means the ball is rolling and we don't want to dampen the X velocity if ynew > -0.1 xnew *= dampener end @@ -152,7 +152,7 @@ class Block args.state.ball.velocity.x = -xnew args.state.ball.velocity.y = -ynew - #Set the position of the ball to the previous position so it doesn't warp throught the block + #Set the position of the ball to the previous position so it doesn't warp through the block args.state.ball.center.x = previousPosition.x args.state.ball.center.y = previousPosition.y end diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb index f5883ad..22d3711 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb @@ -60,7 +60,7 @@ begin :default_methods center = args.grid.w / 2 for i in (0...5) - #Create a ramp of blocks. Not going to be perfect because of the float to integer conversion and anisotropic to isotropic coversion + #Create a ramp of blocks. Not going to be perfect because of the float to integer conversion and anisotropic to isotropic conversion args.state.blocks.append(Block.new((center + 100 + (i * horizontal_offset)).to_i, 100 + (vertical_offset * i) + (i * block_size), block_size, rotation)) args.state.blocks.append(Block.new((center - 100 - (i * horizontal_offset)).to_i, 100 + (vertical_offset * i) + (i * block_size), block_size, -rotation)) end diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb index 52045de..daf95ec 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb @@ -1,11 +1,11 @@ class Peg def initialize(x, y, block_size) - @x = x # x cordinate of the LEFT side of the peg - @y = y # y cordinate of the RIGHT side of the peg + @x = x # x coordinate of the LEFT side of the peg + @y = y # y coordinate of the RIGHT side of the peg @block_size = block_size # diameter of the peg @radius = @block_size/2.0 # radius of the peg - @center = { # cordinatees of the CENTER of the peg + @center = { # coordinatees of the CENTER of the peg x: @x+@block_size/2.0, y: @y+@block_size/2.0 } @@ -116,8 +116,8 @@ class Peg } perpVect = {x: pointB.x - pointA.x, y:pointB.y - pointA.y} # perpVect is to be VECTOR of the perpendicular tangent - mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magniude of the perpVect - perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magniude to make it a unit vector + mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magnitude of the perpVect + perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magnitude to make it a unit vector perpVect = {x: -perpVect.y, y: perpVect.x} # swap the x and y and multiply by -1 to make the vector perpendicular args.state.display_value = perpVect if perpVect.y > 0 #ensure perpVect points upward @@ -130,12 +130,12 @@ class Peg } yInterc = pointA.y + -slope*pointA.x - if slope == INFINITY # the perpVect presently either points in the correct dirrection or it is 180 degrees off we need to correct this + if slope == INFINITY # the perpVect presently either points in the correct direction or it is 180 degrees off we need to correct this if previousPosition.x < pointA.x perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} yInterc = -INFINITY end - elsif previousPosition.y < slope*previousPosition.x + yInterc # check if ball is bellow or above the collider to determine if perpVect is - or + + elsif previousPosition.y < slope*previousPosition.x + yInterc # check if ball is below or above the collider to determine if perpVect is - or + perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} end @@ -148,7 +148,7 @@ class Peg fbx = velocityMag * Math.cos(theta_ball) #the x component of the ball's velocity fby = velocityMag * Math.sin(theta_ball) #the y component of the ball's velocity - repelMag = getRepelMagnitude( # the magniude of the collision vector + repelMag = getRepelMagnitude( # the magnitude of the collision vector args, fbx, fby, @@ -173,7 +173,7 @@ class Peg if args.state.ball.center.y > @center.y # if the ball is above the middle of the peg we need to temporarily ignore some of the gravity args.state.ball.velocity.y = ynew + GRAVITY * 0.01 else - args.state.ball.velocity.y = ynew - GRAVITY * 0.01 # if the ball is bellow the middle of the peg we need to temporarily increase the power of the gravity + args.state.ball.velocity.y = ynew - GRAVITY * 0.01 # if the ball is below the middle of the peg we need to temporarily increase the power of the gravity end args.state.ball.center.x+= args.state.ball.velocity.x # update the position of the ball so it never looks like the ball is intersecting the circle diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb index 9cb1954..0b302f3 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb @@ -42,7 +42,7 @@ class Vector2d Vector2d.new(@x/mag, @y/mag) end - #TODO delet? + #TODO delete? def distABS vect (((vect.x-@x)**2+(vect.y-@y)**2)**0.5).abs() end diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb b/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb index 9571669..679f3a4 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb @@ -82,7 +82,7 @@ class LinearCollider #if at least on point is in the rectangle then collision? is true - otherwise false for point in points #Check whether a given point lies inside a rectangle or not: - #if the sum of the area of traingls, PAB, PBC, PCD, PAD equal the area of the rec, then an intersection has occured + #if the sum of the area of traingls, PAB, PBC, PCD, PAD equal the area of the rec, then an intersection has occurred areaRec = triArea.call(rpointA, rpointB, rpointC)+triArea.call(rpointA, rpointC, rpointD) areaSum = [ triArea.call(point, rpointA, rpointB),triArea.call(point, rpointB, rpointC), @@ -148,7 +148,7 @@ class LinearCollider perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} yInterc = -INFINITY end - elsif previousPosition.y < slope*previousPosition.x + yInterc #check if ball is bellow or above the collider to determine if perpVect is - or + + elsif previousPosition.y < slope*previousPosition.x + yInterc #check if ball is below or above the collider to determine if perpVect is - or + perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} end diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb b/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb index b2905fb..228eb9d 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb @@ -29,7 +29,7 @@ end begin :default_methods def init_blocks args block_size = args.state.board_width / 8 - #Space inbetween each block + #Space in between each block block_offset = 4 args.state.squares ||=[ diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb b/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb index 9cb1954..0b302f3 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb @@ -42,7 +42,7 @@ class Vector2d Vector2d.new(@x/mag, @y/mag) end - #TODO delet? + #TODO delete? def distABS vect (((vect.x-@x)**2+(vect.y-@y)**2)**0.5).abs() end diff --git a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb index 69ada5b..0a20583 100644 --- a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb +++ b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb @@ -1,4 +1,4 @@ -#The LinearCollider (theoretically) produces collisions upon a line segment defined point.y two x,y cordinates +#The LinearCollider (theoretically) produces collisions upon a line segment defined point.y two x,y coordinates class LinearCollider @@ -6,13 +6,13 @@ class LinearCollider #last [Array of length 2] end of the line segment as a x,y cordinate #inorder for the LinearCollider to be functional the line segment must be said to have a thickness - #(as it is unlikly that a colliding object will land exactly on the linesegment) + #(as it is unlikely that a colliding object will land exactly on the linesegment) #extension defines if the line's thickness extends negatively or positively #extension :pos extends positively #extension :neg extends negatively - #thickness [float] how thick the line should be (should always be atleast as large as the magnitude of the colliding object) + #thickness [float] how thick the line should be (should always be at least as large as the magnitude of the colliding object) def initialize (pointA, pointB, extension=:neg, thickness=10) @pointA = pointA @pointB = pointB diff --git a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb index 97cf286..37ea141 100644 --- a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb +++ b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb @@ -43,7 +43,7 @@ class Vector2d Vector2d.new(@x/mag, @y/mag) end - #TODO delet? + #TODO delete? def distABS vect (((vect.x-@x)**2+(vect.y-@y)**2)**0.5).abs() end |
