// -------------------------------------------------------------------------- // // Copyright (c) 2003 Thomas D. Marsh. All rights reserved. // // "SSC" is free software; you can redistribute it // and/or use it and/or modify it under the terms of // the "GNU General Public License" (GPL). // // -------------------------------------------------------------------------- #include "missile.h" #include "screen.h" #include "draw.h" #include "common.h" int MISSILE = -1; void Missile::move(double dt) { ScreenObject::move(dt); age += dt; if (age > MAX_MISSILE_AGE) setState(DEAD); } Missile::Missile(ObjectType owner, double rotation, double x, double y, double z, double fx, double fy, double fz) : ScreenObject(MISSILE_TYPE, MISSILE_RADIUS, MISSILE_MASS, 100, x, y, z, fx+sin(rotation)*MISSILE_SPEED, fy-cos(rotation)*MISSILE_SPEED, fz), age(0), owner_type(owner) { switch (owner_type) { case BOGEY_TYPE: r = b = 0; g = 1; break; case PLAYER_TYPE: r = 1; g = b = 0; default: break; } if (MISSILE == -1) { MISSILE = glGenLists(1); glNewList(MISSILE, GL_COMPILE); GLUquadricObj *m = gluNewQuadric(); gluSphere(m, radius, radius+3, 10); gluDeleteQuadric(m); glEndList(); } setState(ALIVE); } Missile::~Missile() { } bool Missile::collision(ScreenObject &obj) { return true; } void Missile::draw() { draw::setColor(r, g, b); glPushMatrix(); glTranslated(mPosition.x, -mPosition.y, mPosition.z); glCallList(MISSILE); glPopMatrix(); }