using UnityEngine;
using System.Collections;

public class Frog : MonoBehaviour {

	private SpriteRenderer spriteRenderer;
	public float framesPerSecond;
	private float count = 1f;
	public Sprite[] sprites;

	// Use this for initialization
	void Start () {
		spriteRenderer = renderer as SpriteRenderer;
	}

	public void Hop() {
		count = 0;
	}
	
	// Update is called once per frame
	void Update () {
		count += Time.deltaTime;
		int index = (int)(count * framesPerSecond);
		if (index >= sprites.Length) {
			index = 0;
		}
		spriteRenderer.sprite = sprites[ index ];
	}
}
