INFO702 - TPs
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Asteroid Struct Reference

An asteroid is a simple shape that moves linearly in some direction. More...

#include <objects.hpp>

Inheritance diagram for Asteroid:
MasterShape GraphicalShape

Public Member Functions

 Asteroid (QColor cok, QColor cko, double speed, double r)
 
virtual void advance (int step) override
 
- Public Member Functions inherited from MasterShape
 MasterShape (QColor cok, QColor cko)
 
void setGraphicalShape (GraphicalShape *f)
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 
virtual QPointF randomPoint () const override
 
virtual bool isInside (const QPointF &p) const override
 
virtual QRectF boundingRect () const override
 
State currentState () const
 
QColor currentColor () const
 

Protected Attributes

double _speed
 
- Protected Attributes inherited from MasterShape
GraphicalShape_f
 
State _state
 
QColor _cok
 
QColor _cko
 

Additional Inherited Members

- Public Types inherited from MasterShape
enum  State { Ok , Collision }
 

Detailed Description

An asteroid is a simple shape that moves linearly in some direction.

Definition at line 61 of file objects.hpp.

Constructor & Destructor Documentation

◆ Asteroid()

Asteroid::Asteroid ( QColor  cok,
QColor  cko,
double  speed,
double  r 
)

Definition at line 163 of file objects.cpp.

164 : MasterShape( cok, cko ), _speed( speed )
165{
166 // This shape is very simple : just a disk.
167 Disk* d = new Disk( r, this );
168 // Tells the asteroid that it is composed of just a disk.
169 this->setGraphicalShape( d );
170}
A disk is a simple graphical shape.
Definition objects.hpp:75
Polymorphic class that represents the top class of any complex shape.
Definition objects.hpp:38

Member Function Documentation

◆ advance()

void Asteroid::advance ( int  step)
overridevirtual

Reimplemented from MasterShape.

Definition at line 173 of file objects.cpp.

174{
175 if (!step) return;
176 setPos( mapToParent( _speed, 0.0 ) );
177 MasterShape::advance( step );
178}

Member Data Documentation

◆ _speed

double Asteroid::_speed
protected

Definition at line 67 of file objects.hpp.


The documentation for this struct was generated from the following files: