#include "stdafx.h"
#include "GroundController.h"
#include "Engine/IRender.h"

void GroundController::Update()
{

}

void GroundController::RenderFG( IRender & render, GraphicComponent & comp )
{
	if ( m_updatedImage )
	{
		render.DestroyImage( m_imageFG );
		m_imageFG = render.LoadImage( m_imageNameFG.c_str() );
		render.DestroyImage( m_imageMG );
		m_imageMG = render.LoadImage( m_imageNameMG.c_str() );
		render.DestroyImage( m_imageBG );
		m_imageBG = render.LoadImage( m_imageNameBG.c_str() );
		m_updatedImage = false;
	}

	if ( !m_active )
		return;

	render.DrawImage( m_imageFG, 0, m_yFG );
}

void GroundController::RenderBG( IRender & render, GraphicComponent & comp )
{
	if ( m_updatedImage )
	{
		render.DestroyImage( m_imageFG );
		m_imageFG = render.LoadImage( m_imageNameFG.c_str() );
		render.DestroyImage( m_imageMG );
		m_imageMG = render.LoadImage( m_imageNameMG.c_str() );
		render.DestroyImage( m_imageBG );
		m_imageBG = render.LoadImage( m_imageNameBG.c_str() );
		m_updatedImage = false;
	}

	if ( !m_active )
		return;

	render.DrawImage( m_imageBG, 0, m_yBG );
}

void GroundController::RenderMG( IRender & render, GraphicComponent & comp )
{
	if ( m_updatedImage )
	{
		render.DestroyImage( m_imageFG );
		m_imageFG = render.LoadImage( m_imageNameFG.c_str() );
		render.DestroyImage( m_imageMG );
		m_imageMG = render.LoadImage( m_imageNameMG.c_str() );
		render.DestroyImage( m_imageBG );
		m_imageBG = render.LoadImage( m_imageNameBG.c_str() );
		m_updatedImage = false;
	}

	if ( !m_active )
		return;

	render.DrawImage( m_imageMG, 0, m_yMG );
}
