aboutsummaryrefslogtreecommitdiff
path: root/game/mainmenu/IShowScript.cpp
blob: adb6e898bb2ea9938278537795ee25eeb85d5b4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "IShowScript.h"
#include "api/Rigidbody.h"
#include "api/Transform.h"
#include "iostream"
#include <crepe/api/Camera.h>
#include "MainMenuConfig.h"

using namespace crepe;
using namespace std;

void IShowScript::frame_update(crepe::duration_t delta_time){
	if(this->transition)
	{
		cout << "transition:" << velocity << std::endl;
		Transform & cam = this->get_components_by_name<Transform>(MainMenuConfig::CAMERA_NAME).front();
		if(velocity < MainMenuConfig::VELOCITY_MAX && cam.position.x < MainMenuConfig::SLOW_DOWN) velocity += MainMenuConfig::VELOCITY_STEP * delta_time.count();
		else if(velocity > 20) velocity -= MainMenuConfig::VELOCITY_STEP * delta_time.count();
		if(cam.position.x < MainMenuConfig::END)	cam.position.x += (velocity * delta_time.count());
		if(cam.position.x >= MainMenuConfig::END) 
		{
			this->set_next_scene(this->get_scene_name());
		}

	}
}