pawker/app/actors/bug.rb
def generate_start_target(args, wall: nil)
      random =
        case wall || [:left, :top, :right].sample # , :bottom
        when :left
          {
            x: -1 * (rand(WIDTH / 2) + WIDTH / 2),
            y: rand(NOKIA_HEIGHT -  2 * HEIGHT) + HEIGHT,
            angle: 270
          }

        when :top
          {
            x: rand(NOKIA_WIDTH -  2 * WIDTH) + WIDTH,
            y: NOKIA_HEIGHT - rand(WIDTH / 2),
            angle: 180
          }

        when :right
          {
            x: NOKIA_WIDTH - rand(WIDTH / 2),
            y: rand(NOKIA_HEIGHT - 2 * HEIGHT) + HEIGHT,
            angle: 90
          }

        # Not using this because the cards interfere with the bugs too much
        when :bottom
          {
            x: rand(NOKIA_WIDTH - WIDTH) + WIDTH / 2,
            y: -1 * rand(WIDTH / 2) - WIDTH / 2,
            angle: 0
          }

        end

      random.merge({
        w: WIDTH,
        h: HEIGHT,
        path: 'sprites/bug.png',
        a: 255,
        speed: 0,
      })
    end
# Ideally the start target is 2-4 pixels in from the edge of the screen.
#
# This is so that the bug slowly approaches the edge of the screen to give
# warning about where they're coming from before they take off.
Ideally the start target is 2-4 pixels in from the edge of the screen.
This is so that the bug slowly approaches the edge of the screen to give
warning about where they're coming from before they take off.
Ideally the start target is 2 - 4 pixels in from the edge of the screen . This is so that the bug slowly approaches the edge of the screen to give warning about where they ' re coming from before they take off .
def generate_start_target(args, wall: nil)
      random =
        case wall || [:left, :top, :right].sample 
        when :left
          {
            x: -1 * (rand(WIDTH / 2) + WIDTH / 2),
            y: rand(NOKIA_HEIGHT -  2 * HEIGHT) + HEIGHT,
            angle: 270
          }
        when :top
          {
            x: rand(NOKIA_WIDTH -  2 * WIDTH) + WIDTH,
            y: NOKIA_HEIGHT - rand(WIDTH / 2),
            angle: 180
          }
        when :right
          {
            x: NOKIA_WIDTH - rand(WIDTH / 2),
            y: rand(NOKIA_HEIGHT - 2 * HEIGHT) + HEIGHT,
            angle: 90
          }
        when :bottom
          {
            x: rand(NOKIA_WIDTH - WIDTH) + WIDTH / 2,
            y: -1 * rand(WIDTH / 2) - WIDTH / 2,
            angle: 0
          }
        end
      random.merge({
        w: WIDTH,
        h: HEIGHT,
        path: 'sprites/bug.png',
        a: 255,
        speed: 0,
      })
    end
def generate_start_target ( args , wall : nil ) random = case wall || [ :left , :top , :right ] . sample when :left { x : - 1 * ( rand ( WIDTH / 2 ) + WIDTH / 2 ) , y : rand ( NOKIA_HEIGHT - 2 * HEIGHT ) + HEIGHT , angle : 270 } when :top { x : rand ( NOKIA_WIDTH - 2 * WIDTH ) + WIDTH , y : NOKIA_HEIGHT - rand ( WIDTH / 2 ) , angle : 180 } when :right { x : NOKIA_WIDTH - rand ( WIDTH / 2 ) , y : rand ( NOKIA_HEIGHT - 2 * HEIGHT ) + HEIGHT , angle : 90 } when :bottom { x : rand ( NOKIA_WIDTH - WIDTH ) + WIDTH / 2 , y : - 1 * rand ( WIDTH / 2 ) - WIDTH / 2 , angle : 0 } end random . merge ( { w : WIDTH , h : HEIGHT , path : 'sprites/bug.png' , a : 255 , speed : 0 , } ) end
Ideally the start target is 2-4 pixels in from the edge of the screen.
Ideally the start target is 2 - 4 pixels in from the edge of the screen .
# , :bottom # Not using this because the cards interfere with the bugs too much
args
wall