diff --git a/app/main.rb b/app/main.rb index 9f2d5a1..151c6c8 100644 --- a/app/main.rb +++ b/app/main.rb @@ -5,9 +5,11 @@ GRAVITY = 0.5 MIN_GRAVITY = 0.1 MAX_GRAVITY = 2.0 +STEP_GRAVITY = 0.02 MIN_BOUNCE = 1.0 MAX_BOUNCE = 1.1 +STEP_BOUNCE = 0.0011 CX = 636 CY = 399 @@ -49,14 +51,25 @@ def tick args } end end + # MENU CONTROLS + if args.inputs.right && args.state.paused + args.state.gravity += STEP_GRAVITY if args.state.gravity < MAX_GRAVITY + elsif args.inputs.left && args.state.paused + args.state.gravity -= STEP_GRAVITY if args.state.gravity > MIN_GRAVITY + end + if args.inputs.up && args.state.paused + args.state.bounce += STEP_BOUNCE if args.state.bounce < MAX_BOUNCE + elsif args.inputs.down && args.state.paused + args.state.bounce -= STEP_BOUNCE if args.state.bounce > MIN_BOUNCE + end # LOOP if !args.state.paused #ball vector move_x = args.state.ball_vector[:x] move_y = args.state.ball_vector[:y] # apply gravity - move_y = move_y - GRAVITY + move_y = move_y - args.state.gravity args.state.ball_vector[:x] = move_x args.state.ball_vector[:y] = move_y @@ -67,8 +80,8 @@ def tick args new_y = y + move_y if bouncing?(new_x,new_y,cx,cy,cr) new_move_x, new_move_y = reflection_vector(x,y,cx,cy,move_x,move_y) - args.state.ball_vector[:x] = new_move_x * BOUNCE_ACCL - args.state.ball_vector[:y] = new_move_y * BOUNCE_ACCL + args.state.ball_vector[:x] = new_move_x * args.state.bounce + args.state.ball_vector[:y] = new_move_y * args.state.bounce # play sound sound = Math.rand(3)+1 args.outputs.sounds << "sounds/bounce#{sound}.wav" @@ -111,19 +124,22 @@ def tick args if args.state.paused # Render menu - args.outputs.labels << [640, 40, "Game is paused. Press to continue", 4, 1] + args.outputs.labels << [640, 40, "Press to start the game", 6, 1] # min_x = 440 # mid = 615 # max_x = 780 + # l = 340 + gravity_x = 440 + args.state.gravity * 179 args.outputs.sprites << { - x: 615, + x: gravity_x, y: 445, w: 32, h: 32, path: 'sprites/slider.png' } + bounce_x = 440 + (args.state.bounce - 1)*3400 args.outputs.sprites << { - x: 615, + x: bounce_x, y: 325, w: 32, h: 32, diff --git a/sprites/BG1_menu.png b/sprites/BG1_menu.png index a297a74..2a5cc74 100644 Binary files a/sprites/BG1_menu.png and b/sprites/BG1_menu.png differ