Tarik Demirović / Mbed 2 deprecated PAI_Grupa1_Projekat_Pong

Dependencies:   N5110 mbed

Committer:
Vato
Date:
Thu Jun 05 17:37:09 2014 +0000
Revision:
0:a5f6ba8c378e
PAI Pong v1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vato 0:a5f6ba8c378e 1 #include "Reket.h"
Vato 0:a5f6ba8c378e 2
Vato 0:a5f6ba8c378e 3 int Reket::dajX1()
Vato 0:a5f6ba8c378e 4 {
Vato 0:a5f6ba8c378e 5 return x1;
Vato 0:a5f6ba8c378e 6 }
Vato 0:a5f6ba8c378e 7
Vato 0:a5f6ba8c378e 8 int Reket::dajX2()
Vato 0:a5f6ba8c378e 9 {
Vato 0:a5f6ba8c378e 10 return x2;
Vato 0:a5f6ba8c378e 11 }
Vato 0:a5f6ba8c378e 12
Vato 0:a5f6ba8c378e 13 int Reket::dajY1()
Vato 0:a5f6ba8c378e 14 {
Vato 0:a5f6ba8c378e 15 return y1;
Vato 0:a5f6ba8c378e 16 }
Vato 0:a5f6ba8c378e 17
Vato 0:a5f6ba8c378e 18 int Reket::dajY2()
Vato 0:a5f6ba8c378e 19 {
Vato 0:a5f6ba8c378e 20 return y2;
Vato 0:a5f6ba8c378e 21 }
Vato 0:a5f6ba8c378e 22
Vato 0:a5f6ba8c378e 23 void Reket::crtajReket(N5110 &display)
Vato 0:a5f6ba8c378e 24 {
Vato 0:a5f6ba8c378e 25 for(int i = y1; i <= y2; i++)
Vato 0:a5f6ba8c378e 26 {
Vato 0:a5f6ba8c378e 27 display.setPixel(x1, i);
Vato 0:a5f6ba8c378e 28 display.setPixel(x2, i);
Vato 0:a5f6ba8c378e 29 }
Vato 0:a5f6ba8c378e 30
Vato 0:a5f6ba8c378e 31 display.refresh();
Vato 0:a5f6ba8c378e 32 }
Vato 0:a5f6ba8c378e 33
Vato 0:a5f6ba8c378e 34 void Reket::brisiReket(N5110 &display)
Vato 0:a5f6ba8c378e 35 {
Vato 0:a5f6ba8c378e 36 for(int i = y1; i <= y2; i++)
Vato 0:a5f6ba8c378e 37 {
Vato 0:a5f6ba8c378e 38 display.clearPixel(x1, i);
Vato 0:a5f6ba8c378e 39 display.clearPixel(x2, i);
Vato 0:a5f6ba8c378e 40 }
Vato 0:a5f6ba8c378e 41
Vato 0:a5f6ba8c378e 42 display.refresh();
Vato 0:a5f6ba8c378e 43 }
Vato 0:a5f6ba8c378e 44
Vato 0:a5f6ba8c378e 45 void Reket::osvjeziPoziciju(AnalogIn &p1)
Vato 0:a5f6ba8c378e 46 {
Vato 0:a5f6ba8c378e 47 if (p1 < 1.0/3.0)
Vato 0:a5f6ba8c378e 48 {
Vato 0:a5f6ba8c378e 49 y1 -= 2;
Vato 0:a5f6ba8c378e 50 y2 -= 2;
Vato 0:a5f6ba8c378e 51 if(y1 < 0 or y2 < 7){
Vato 0:a5f6ba8c378e 52 y1 = 0;
Vato 0:a5f6ba8c378e 53 y2 = 7;
Vato 0:a5f6ba8c378e 54 }
Vato 0:a5f6ba8c378e 55 }
Vato 0:a5f6ba8c378e 56
Vato 0:a5f6ba8c378e 57 if (p1 > 2.0/3.0)
Vato 0:a5f6ba8c378e 58 {
Vato 0:a5f6ba8c378e 59 y1 += 2;
Vato 0:a5f6ba8c378e 60 y2 += 2;
Vato 0:a5f6ba8c378e 61 if(y2 > 47 or y1 > 40)
Vato 0:a5f6ba8c378e 62 {
Vato 0:a5f6ba8c378e 63 y2 = 47;
Vato 0:a5f6ba8c378e 64 y1 = 40;
Vato 0:a5f6ba8c378e 65 }
Vato 0:a5f6ba8c378e 66 }
Vato 0:a5f6ba8c378e 67 }