File: anim.cpp

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (69 lines) | stat: -rw-r--r-- 1,736 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/***************************************************************************
 Simple test. A cube should be visible in the middle of the screen.
 The arrow keys rotates the cube. 
 ***************************************************************************/

#include "Engine.h"
#include "Camera.h"
#include "Cube.h"
#include "Keyboard.h"
#include "StdAnimation.h"
#include "Grid.h"

/**
 * Main
 */
int main(int argc, char *argv[]) {
	cerr << "Simple emilia test." << endl;

	// Create the engine.
	Engine* engine = new Engine(argc, argv);
	engine->setLightning(0.5f, 0.1f);

	// Add a camera. Add some animiation to the camera.
	Group* groupC1 = new Group();
	Group* groupC2 = new Group();
	Group* groupC3 = new Group();
	Group* groupC4 = new Group();

	engine->add(groupC1);
	groupC1->add(groupC2);
	groupC2->add(groupC3);
	groupC3->add(groupC4);

	Cube* cube2 = new Cube(1.0, 1, 1, 0, 1);
	groupC2->addShape3D(cube2);
	groupC2->setTranslation(0, 0, 2);

	Cube* cube3 = new Cube(1.0, 0, 1, 1, 1);
	groupC3->addShape3D(cube3);
	groupC3->setTranslation(0, 0, 2);

	Camera* camera = new Camera();
	groupC4->setCamera(camera);
	groupC4->setTranslation(0, 1, 2);
	engine->setEngineCamera(groupC4);

	Grid* grid = new Grid(NULL, 10, 10, 1, 0, 1, 1, 1, 1);
	engine->addShape3D(grid);
	
	StdAnimation* anim1 = new StdAnimation(60, EM_ROTATION);
	anim1->add(0,0,0);
	anim1->add(0.25,0.5,0);
	anim1->setEnd(0,1,0);
	groupC1->addBehavior(anim1);
	
	StdAnimation* anim3 = new StdAnimation(40, EM_TRANSLATION);
	anim3->add(0, 0, 2);
	anim3->add(0, 0, 4);
	anim3->setEnd(0, 0, 2);
	groupC3->addBehavior(anim3);
	
	while (!Keyboard::isKeyDown(SDLK_ESCAPE)) {
		engine->tick();
		engine->render();
		engine->swap();
	}
	delete(engine);
	return 0;
}