/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: */ #include "player.h" #include #include using namespace std; Player::Player () { // cout << "Player::Player" << endl; xCor = yCor = zCor = 0; shootLaser = new ShootLaser; shootRocket = new ShootRocket; } Player::~Player () { //delete shootLaser; } void Player::setPosition( float x, float y, float z) { xCor = x; yCor = y; zCor = z; } void Player::getPosition(float* x, float* y, float* z) { *x = xCor; *y = yCor; *z = zCor; } void Player::setCollisionRadius(float radius) { collisionRadius = radius; } void Player::goX(float x) { //cout << "Player::goX" << endl; xCor += x; } void Player::goY(float y) { yCor += y; } void Player::goZ(float z) { zCor += z; } void Player::shoot(int n) { shootLaser->addShoot(xCor,yCor+1.0,5); shootLaser->addShootExt(xCor,yCor,zCor,.1,.4,.0); shootLaser->addShootExt(xCor,yCor,zCor,-.1,.4,.0); //shootLaser->addShootdExt(xCor,yCor,zCor,-.1,.4,.0); //shootRocket->addBackParable(xCor,yCor,zCor); } //void Player::addIO(InputOutput *io) {} void Player::drawPlayer(float a, float b) { /*glPushMatrix(); glTranslatef(xCor, yCor, 3.0); glScalef(1.0, 3.0, 1.0); glutWireCube(1.0); glPopMatrix();*/ glPushMatrix(); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); GLfloat LPosition[4]={0,20,30,1}; glLightfv(GL_LIGHT0,GL_POSITION,&LPosition[0]); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glTranslatef(xCor,yCor,5.0); glRotatef(3*a,1.0,0.0,0.0); glRotatef(3*b,0.0,1.0,0.0); //glTranslatef(xCor,yCor,3.0); glBegin(GL_QUADS); glColor3f(.2,0.5,0.5); glNormal3f(-1.0,0.0,0.0); glVertex3f(-1.0,-1.0,-1.0); glVertex3f(-1.0,-1.0,1.0); glVertex3f(-1,1.0,0.4); glVertex3f(-1,1.0,-0.4); glNormal3f(1,0,0); glVertex3f(-.99,-1,-1); glVertex3f(-.99,-1,1); glVertex3f(-.99,1,.4); glVertex3f(-.99,1,-.4); glNormal3f(0.0,1.0,0.0); glVertex3f(-1,1.0,.4); glVertex3f(-1,1.0,-.4); glVertex3f(1,1.0,-.4); glVertex3f(1,1.0,.4); glNormal3f(0,-1,0); glVertex3f(-1,.99,.4); glVertex3f(-1,.99,-.4); glVertex3f(1,.99,-.4); glVertex3f(1,.99,.4); glNormal3f(1.0,0.0,0.0); glVertex3f(1,1,.4); glVertex3f(1,1,-.4); glVertex3f(1.0,-1.0,-1.0); glVertex3f(1.0,-1.0,1.0); glNormal3f(-1,0,0); glVertex3f(.99,1,.4); glVertex3f(.99,1,-.4); glVertex3f(.99,-1,-1); glVertex3f(.99,-1,1); glEnd(); glPopMatrix(); /* draw all the shoots additionaly */ glColor3f(0,0,1); shootLaser->drawShoot(); shootRocket->drawShoot(); //cout << "Player::drawPlayer" << endl; }