Tarik Demirović / Mbed 2 deprecated PAI_Grupa1_Projekat_Pong

Dependencies:   N5110 mbed

Loptica.cpp

Committer:
Vato
Date:
2014-06-05
Revision:
0:a5f6ba8c378e

File content as of revision 0:a5f6ba8c378e:

#include "Loptica.h"

void Loptica::setX(int broj)
{
    x = broj;
}

void Loptica::setY(int broj)
{
    y = broj;
}

int Loptica::dajX()
{
    return x;
}

int Loptica::dajY()
{
    return y;
}

int Loptica::dajKorakX()
{
    return x_korak;
}

int Loptica::dajKorakY()
{
    return y_korak;
}

void Loptica::postaviKorak(int xKorak, int yKorak)
{
    x_korak = xKorak;
    y_korak = yKorak;
}

void Loptica::crtajLopticu(N5110 &display)
{
    for(int i = -1; i < 2; i++)
        for(int j = -1; j < 2; j++)
            display.setPixel(x + j, y + i);
    
    display.refresh();
}

void Loptica::brisiLopticu(N5110 &display)
{
    for(int i = -1; i < 2; i++)
        for(int j = -1; j < 2; j++)
            display.clearPixel(x + j, y + i);
    
    display.refresh();
}

void Loptica::osvjeziPoziciju()
{
    x += x_korak;
    y += y_korak;
}