Skip to content

Glue Bonus

noooway edited this page Mar 7, 2017 · 24 revisions
  1. Detect collision with 'glue' bonus
function bonuses.bonus_collected( i, bonus, ball, platform )
   .....
   elseif bonuses.is_glue( bonus ) then
      platform.react_on_glue_bonus()
   end
   .....
end

function bonuses.is_glue( single_bonus )
   local col = single_bonus.bonustype % 10
   return ( col == 2 )
end
  1. When glue bonus is caught, platform tile is changed and glued flag is raised.
function platform.react_on_glue_bonus()
   platform.glued = true
   if platform.size == "small" then
      platform.quad = love.graphics.newQuad(
         platform.small_tile_x_pos + platfrom.glued_x_pos_shift,
         platform.small_tile_y_pos,
         platform.small_tile_width,
         platform.small_tile_height,
         platform.tileset_width,
         platform.tileset_height )
   elseif platform.size == "norm" then
      platform.quad = love.graphics.newQuad(
         platform.norm_tile_x_pos + platfrom.glued_x_pos_shift,
         platform.norm_tile_y_pos,
         platform.norm_tile_width,
         platform.norm_tile_height,
         platform.tileset_width,
         platform.tileset_height )
   elseif platform.size == "large" then
      platform.quad = love.graphics.newQuad(
         platform.large_tile_x_pos + platfrom.glued_x_pos_shift,
         platform.large_tile_y_pos,
         platform.large_tile_width,
         platform.large_tile_height,
         platform.tileset_width,
         platform.tileset_height )
   end   
end
  1. Ball-platform collision depends on the value of the glued flag.
local first_launch_speed = vector( -150, -300 )
ball.platform_launch_speed = first_launch_speed:clone()

function ball.platform_rebound( shift_ball, platform )
   ball.increase_collision_counter()
   ball.increase_speed_after_collision()
   if not platform.glued then
      ball.normal_rebound( shift_ball )
      ball.rotate_speed( shift_ball, platform )
   else
      ball.normal_rebound( shift_ball )
      ball.rotate_speed( shift_ball, platform )
      ball.platform_launch_speed = ball.speed:clone()
      ball.stuck_to_platform = true      
      ball.speed = vector( 0, 0 )
      local platform_center = vector(
         platform.position.x + platform.width / 2,
         platform.position.y + platform.height / 2 )
      local ball_center = ball.position:clone()
      ball.separation_from_platform_center =
         ball_center - platform_center
      print( ball.separation_from_platform_center )
   end
end

function ball.launch_from_platform()
   if ball.stuck_to_platform then
      ball.stuck_to_platform = false
      ball.speed = ball.platform_launch_speed:clone()
   end
end
  1. The glued effect is removed if any other bonus is caught, the ball is lost, or the next level is reached. ...
function platform.remove_glued_effect()
   platform.glued = false
   if platform.size == "small" then
      platform.quad = love.graphics.newQuad(
         platform.small_tile_x_pos,
         platform.small_tile_y_pos,
         platform.small_tile_width,
         platform.small_tile_height,
         platform.tileset_width,
         platform.tileset_height )
   elseif platform.size == "norm" then
      platform.quad = love.graphics.newQuad(
         platform.norm_tile_x_pos,
         platform.norm_tile_y_pos,
         platform.norm_tile_width,
         platform.norm_tile_height,
         platform.tileset_width,
         platform.tileset_height )
   elseif platform.size == "large" then
      platform.quad = love.graphics.newQuad(
         platform.large_tile_x_pos,
         platform.large_tile_y_pos,
         platform.large_tile_width,
         platform.large_tile_height,
         platform.tileset_width,
         platform.tileset_height )
   end      
end

    Home
    Acknowledgements
    Todo

Chapter 1: Prototype

  1. The Ball, The Brick, The Platform
  2. Game Objects as Lua Tables
  3. Bricks and Walls
  4. Detecting Collisions
  5. Resolving Collisions
  6. Levels

    Appendix A: Storing Levels as Strings
    Appendix B: Optimized Collision Detection (draft)

Chapter 2: General Code Structure

  1. Splitting Code into Several Files
  2. Loading Levels from Files
  3. Straightforward Gamestates
  4. Advanced Gamestates
  5. Basic Tiles
  6. Different Brick Types
  7. Basic Sound
  8. Game Over

    Appendix C: Stricter Modules (draft)
    Appendix D-1: Intro to Classes (draft)
    Appendix D-2: Chapter 2 Using Classes.

Chapter 3 (deprecated): Details

  1. Improved Ball Rebounds
  2. Ball Launch From Platform (Two Objects Moving Together)
  3. Mouse Controls
  4. Spawning Bonuses
  5. Bonus Effects
  6. Glue Bonus
  7. Add New Ball Bonus
  8. Life and Next Level Bonuses
  9. Random Bonuses
  10. Menu Buttons
  11. Wall Tiles
  12. Side Panel
  13. Score
  14. Fonts
  15. More Sounds
  16. Final Screen
  17. Packaging

    Appendix D: GUI Layouts
    Appendix E: Love-release and Love.js

Beyond Programming:

  1. Game Design
  2. Minimal Marketing (draft)
  3. Finding a Team (draft)

Archive

Clone this wiki locally