INQ241A
Mobile Apps

Review 2

A Miniature Practice Test

  1. Draw what the following script will look like when it first starts.

    function main()
      var board := game→start
      var sprite 1 := board→create rectangle(100, 100)
      sprite 1→set pos(0, board→height / 2)
      sprite 1→set speed x(10)
      var sprite2 := board→create rectangle(100, 100)
      sprite 2→set pos(board→width, board→height / 2)
      board→on every frame do
          if sprite 1→overlaps with(sprite 2) then
            sprite 1→set x(0)
          else do nothing end if
          if math→random range(1, 2) = 1 then
            sprite 2→set color(colors→random)
          else do nothing end if
      end
    end function
  2. Describe how the sprites in the above script will behave when run.

  3. Create a script that displays a rectangle in a random location on the screen. It should be possible for the center of the rectangle to be located anywhere on the screen, no matter the size of the screen.