deplacement v6
Fork of Deplacement by
Deplacement.cpp@2:7e0d789e1be8, 2017-02-02 (annotated)
- Committer:
- aure
- Date:
- Thu Feb 02 10:37:03 2017 +0000
- Revision:
- 2:7e0d789e1be8
- Parent:
- 1:662d3c47637f
- Child:
- 3:965871a8c5ff
k
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aure | 0:d6b2da5ef6cb | 1 | #include "Deplacement.h" |
aure | 1:662d3c47637f | 2 | #include "mbed.h" |
aure | 0:d6b2da5ef6cb | 3 | |
aure | 0:d6b2da5ef6cb | 4 | |
aure | 1:662d3c47637f | 5 | Deplacement::Deplacement() //constructeur |
aure | 1:662d3c47637f | 6 | { |
aure | 1:662d3c47637f | 7 | posx=0; |
aure | 1:662d3c47637f | 8 | posy=0; |
aure | 1:662d3c47637f | 9 | this->vitesse=0; //pointeur this |
aure | 1:662d3c47637f | 10 | } |
aure | 1:662d3c47637f | 11 | |
aure | 1:662d3c47637f | 12 | Deplacement::~Deplacement() |
aure | 0:d6b2da5ef6cb | 13 | { |
aure | 0:d6b2da5ef6cb | 14 | |
aure | 1:662d3c47637f | 15 | } |
aure | 1:662d3c47637f | 16 | |
aure | 1:662d3c47637f | 17 | ///////////////////////////////////////////////////// |
aure | 1:662d3c47637f | 18 | |
aure | 1:662d3c47637f | 19 | void Deplacement::setVitesse(float v) |
aure | 1:662d3c47637f | 20 | { |
aure | 1:662d3c47637f | 21 | this->vitesse=v; |
aure | 1:662d3c47637f | 22 | } |
aure | 1:662d3c47637f | 23 | |
aure | 1:662d3c47637f | 24 | ///////////////////////////////////////////////////// |
aure | 1:662d3c47637f | 25 | |
aure | 1:662d3c47637f | 26 | void Deplacement::tourner_droite() |
aure | 1:662d3c47637f | 27 | { |
aure | 2:7e0d789e1be8 | 28 | int copie=0; |
aure | 1:662d3c47637f | 29 | m3pi.right(this->vitesse); |
aure | 2:7e0d789e1be8 | 30 | |
aure | 2:7e0d789e1be8 | 31 | posx=copie; |
aure | 2:7e0d789e1be8 | 32 | posx=posy; |
aure | 2:7e0d789e1be8 | 33 | posy=-copie; |
aure | 2:7e0d789e1be8 | 34 | |
aure | 1:662d3c47637f | 35 | } |
aure | 1:662d3c47637f | 36 | |
aure | 1:662d3c47637f | 37 | void Deplacement::tourner_gauche() |
aure | 1:662d3c47637f | 38 | { |
aure | 2:7e0d789e1be8 | 39 | int copie=0; |
aure | 1:662d3c47637f | 40 | m3pi.left(this->vitesse); |
aure | 2:7e0d789e1be8 | 41 | |
aure | 2:7e0d789e1be8 | 42 | posx=copie; |
aure | 2:7e0d789e1be8 | 43 | posx=-posy; |
aure | 2:7e0d789e1be8 | 44 | posy=copie; |
aure | 1:662d3c47637f | 45 | } |
aure | 1:662d3c47637f | 46 | |
aure | 1:662d3c47637f | 47 | void Deplacement::avancer() |
aure | 1:662d3c47637f | 48 | { |
aure | 1:662d3c47637f | 49 | m3pi.forward(this->vitesse); |
aure | 2:7e0d789e1be8 | 50 | posy++; |
aure | 1:662d3c47637f | 51 | } |
aure | 1:662d3c47637f | 52 | |
aure | 1:662d3c47637f | 53 | void Deplacement::reculer() |
aure | 1:662d3c47637f | 54 | { |
aure | 1:662d3c47637f | 55 | m3pi.backward(this->vitesse); |
aure | 2:7e0d789e1be8 | 56 | posy--; |
aure | 1:662d3c47637f | 57 | } |
aure | 1:662d3c47637f | 58 | |
aure | 2:7e0d789e1be8 | 59 | void Deplacement::RAZ() |
aure | 2:7e0d789e1be8 | 60 | { |
aure | 2:7e0d789e1be8 | 61 | posx=0; |
aure | 2:7e0d789e1be8 | 62 | posy=0; |
aure | 2:7e0d789e1be8 | 63 | this->vitesse=0; |
aure | 2:7e0d789e1be8 | 64 | |
aure | 2:7e0d789e1be8 | 65 | } |
aure | 1:662d3c47637f | 66 | |
aure | 1:662d3c47637f | 67 | |
aure | 1:662d3c47637f | 68 | |
aure | 1:662d3c47637f | 69 | |
aure | 1:662d3c47637f | 70 | |
aure | 1:662d3c47637f | 71 |