INQ241B
Mobile Apps

Review 2

A Miniature Practice Test

  1. What is a sprite?

  2. 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
      end
    end function
  3. Describe how the sprites in the above script will behave when run.

  4. Create a script that uses a sprite set to add 100 rectangles to random locations on the screen. The rectangles should be animated like they are falling. That is each rectangle’s y speed should increase every frame of animation.