#include "Salamander.h"
#include "Camera.h"

#include "Body.h"
#include "CameraEvent.h"
#include "SDLHack.h"

Camera::Camera(Body& follow) :
	follow_(follow),
	translation_(Vec2(0.0, 0.0))
{
	
}

Camera::~Camera()
{
	
}

void Camera::update()
{
	// follow the body
	translation_.x_ = follow_.getTranslation().x_ + 200.0;
	translation_.y_ = follow_.getTranslation().y_ * 0.5 - 60.0;
	
	// random jitter
	//translation_ += Vec2(rand() % 100, rand() % 100) / 10;

	// update the scene
	SDLHack sdlhack; sdlhack.setCamera(translation_);

	// update everyone else
	events().send(CameraEvent(translation_));
}
