Skip to content

StarCall

Dave Luk edited this page May 13, 2016 · 17 revisions

Overview

In this lesson we will learn to make a game using the canvas, imagesprites, procedures, and timer.

New Concepts

Canvas:

A surface where you can put objects on a given location.

Image Sprite

An interactive image that can be put on a canvas. It reacts to collisions and touches. Sprite Canvas

Clock

Keeping track of timing and current time.

Timer

Let's Get Started

Designer

We will need:

  • Canvas (x1)
  • Image sprite (x3)

For the score counter:

  • Horizontal layouts (x3)
  • Labels (x4)
  • Button (x1)
  • Timer (x1)

For music:

  • Player(x1)

Designer

##Specific Properties

  • set screen orientation at Screen to be portrait
  • set layer (z) for meteor sprite above the earth sprite
  • set layer (z) for gameover sprite above all
  • set timerInterval to a small number (i.e. 100) for responsive time tracking.

Mechanics

  1. Initial Setup

    When you start the game, some settings need to be put into place:

    • Make sure game can run (not game over)
    • Establish basic speeds and music
    • Start the game (start calling meteors)

    init

  2. Score and time tracking

    Every time player stops a meteor, they get a point! also keep track how long they survived!

    When the procedure is called:

    • We will increase the score by 1.

    If the game is still going:

    • Every time the timer ticks, we increase the time survived by the interval amount.

    score

  3. Sprite behavior

    • Spawn / Movement

      This is where you make the meteor with new location and speeds.

      When this procedure is called:

      • Pick a new spot for the horizontal location! From the left of the screen to the right.
      • Make sure the meteor is heading downwards.
      • Set the meteor's speed
      • It's all set! Make it visible.

      Spawn

    • Interaction

      This is when the player taps the meteor.

      If the game is still going:

      • Hide the tapped meteor
      • Then we call the procedure to increase the score AND speed of next meteors.
      • After that we call the procedure to make new meteor

      interaction

  4. Game over!

    The player lost! Tell them.

    If the meteor touches any of the bottom edges:

    • Then we need to show them they lost
    • Stop the game/meteors from falling

    gameOver

  5. Reset button

**Let them play the game again!**
* Reset the variables to original values
* Hide the game-over sprite
* Start the game

![reset](https://raw.githubusercontent.com/cppignite/lessons/master/StarCall/Img/resetting.PNG)

Stretch Goals

  • More random behavior!
    • Angle of launch
    • Changing direction
      • Zig-zag
      • Slow curve
      • Simple change
    • Teleporting?
    • Slow-down/speed-up
  • Difficulty Curve Tweaks (The Current difficulty is linear, It gets really hard!)
    • Easier
      • Square-root/logarithmic functions
      • Piece-wise linear functions (for example, from speed 1-10 growth is 0.5, 10-50 is 0.3, 50+ is 0.1)
    • Harder
      • exponential/power functions
  • New features/mechanics!
    • Meteor size variable
    • New Type of meteors
    • Other interaction methods
    • Gyroscope for tilting
    • Long touches for special meteors

Media & Assets

  1. Starsinthesky.jpg
  2. fireball.png
  3. game-over.png
  4. Magellanic Clouds.mp3
  5.  [earth.png](https://raw.githubusercontent.com/cppignite/lessons/master/StarCall/Media/earth.png)
    

External References