123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #include "PlayerKam.h"
- #include "Globals.h"
- PlayerKam::PlayerKam( Framework::Bildschirm3D* zScreen )
- : Kam3D()
- {
- setBildschirmPosition( 0, 0 );
- setBildschirmSize( zScreen->getBackBufferSize() );
- setStyle( Kam3D::Style::Tick | Kam3D::Style::Movable | Kam3D::Style::Rotatable );
- setRotation( { 0, 0, 0 } );
- }
- void PlayerKam::setDirection( Framework::Vec2<float> direction )
- {
- if( direction.getLengthSq() > 0 )
- {
- float rotZ = std::atan2( direction.y, direction.x ) + (float)PI / 2;
- setRotation( { (float)PI / 2.f, getRotation().y, rotZ } );
- }
- }
- void PlayerKam::doTastaturEreignis( Framework::TastaturEreignis& te )
- {
- char action[ 2 ];
- if( te.id == TE_Press )
- {
- action[ 0 ] = 1;
- if( te.taste == 'w' || te.taste == 'W' )
- {
- action[ 1 ] = 0;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'a' || te.taste == 'A' )
- {
- action[ 1 ] = 1;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 's' || te.taste == 'S' )
- {
- action[ 1 ] = 2;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'd' || te.taste == 'D' )
- {
- action[ 1 ] = 3;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == T_Shift )
- {
- action[ 1 ] = 4;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'q' || te.taste == 'Q' )
- {
- action[ 1 ] = 5;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'e' || te.taste == 'E' )
- {
- action[ 1 ] = 6;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == T_Space )
- {
- action[ 1 ] = 7;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- }
- if( te.id == TE_Release )
- {
- action[ 0 ] = 0;
- if( te.taste == 'w' || te.taste == 'W' )
- {
- action[ 1 ] = 0;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'a' || te.taste == 'A' )
- {
- action[ 1 ] = 1;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 's' || te.taste == 'S' )
- {
- action[ 1 ] = 2;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'd' || te.taste == 'D' )
- {
- action[ 1 ] = 3;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == T_Shift )
- {
- action[ 1 ] = 4;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'q' || te.taste == 'Q' )
- {
- action[ 1 ] = 5;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == 'e' || te.taste == 'E' )
- {
- action[ 1 ] = 6;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- if( te.taste == T_Space )
- {
- action[ 1 ] = 7;
- network->zFactoryClient()->sendPlayerAction( action, 2 );
- }
- }
- }
- void PlayerKam::doMausEreignis( Framework::MausEreignis& me )
- {
- }
- bool PlayerKam::tick( double time )
- {
- __int64 style = 0;
- if( hatStyle( Style::Movable ) )
- style |= Style::Movable;
- if( hatStyle( Style::Rotatable ) )
- style |= Style::Rotatable;
- if( hatStyle( Style::Zoomable ) )
- style |= Style::Zoomable;
- removeStyle( Style::Movable | Style::Rotatable | Style::Zoomable );
- bool result = Kam3D::tick( time );
- addStyle( style );
- return result;
- }
|