package com.uoc.educationalVG.memorycon;

import java.util.List;

import com.uoc.educationalVG.framework.Game;
import com.uoc.educationalVG.framework.Graphics;
import com.uoc.educationalVG.framework.Input.TouchEvent;
import com.uoc.educationalVG.utils.Assets;
import com.uoc.educationalVG.utils.Settings;

/**
 * @author "Beginning Android 4 Games Development"
 * @author (adapted by Sergi Colina)
 * 
 */
public class HowToScreen extends GameScreen {
	
	public HowToScreen(Game game) {
		super(game);
	}   

	@Override
    public void update(float deltaTime) {
        Graphics g = game.getGraphics();
        List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
        game.getInput().getKeyEvents();       
        
        int len = touchEvents.size();
        for(int i = 0; i < len; i++) {
            TouchEvent event = touchEvents.get(i);
            if(event.type == TouchEvent.TOUCH_UP) {	//touch on screen
            	
            	if(inBounds(event, 130, g.getHeight() - 40, 75, 25) ) { // get back
            		game.setScreen(new MainMenuScreen(game));
                    if(Settings.isSoundEnabled())
                        Assets.getClick().play(1);
                    return;
                }
            }
        }
    }
    
   
    @Override
    public void present(float deltaTime) {
        Graphics g = game.getGraphics();
        g.drawPixmap(Assets.getHowToScreen(), 0, 0);
    }

    @Override
    public void pause() {        
        Settings.save(game.getFileIO());
    }

    @Override
    public void resume() {

    }

    @Override
    public void dispose() {

    }
}

