File: KeyRotBehavior.cpp

package info (click to toggle)
pinball 0.3.20230219-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,572 kB
  • sloc: cpp: 15,776; makefile: 1,037; sh: 588; xml: 24
file content (30 lines) | stat: -rw-r--r-- 1,068 bytes parent folder | download | duplicates (9)
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
/***************************************************************************
                          KeyRorBehavior.cpp  -  description
                             -------------------
    begin                : Wed Jan 26 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

#include "Private.h"
#include "KeyRotBehavior.h"
#include "Group.h"
#include "Keyboard.h"

KeyRotBehavior::KeyRotBehavior() : Behavior() {
}

KeyRotBehavior::~KeyRotBehavior() {
}

void KeyRotBehavior::onTick() {
	EmAssert(this->getParent() != NULL, "KeyRotBehavior::onTick parent NULL");
	float x = 0, y = 0, z = 0;
	if (Keyboard::isKeyDown(SDLK_RIGHT)) y = 0.01f;	
	if (Keyboard::isKeyDown(SDLK_LEFT)) y = -0.01f;
	if (Keyboard::isKeyDown(SDLK_UP)) x = 0.01f;
	if (Keyboard::isKeyDown(SDLK_DOWN)) x = -0.01f;
	if (Keyboard::isKeyDown(SDLK_PAGEUP)) z = 0.01f;
	if (Keyboard::isKeyDown(SDLK_PAGEDOWN)) z = -0.01f;
	this->getParent()->addRotation(x, y, z);
}