Nemesis game, stats

Stats.cpp

Committer:
musallambseiso
Date:
2017-05-01
Revision:
9:b9ad5e45aebf
Parent:
8:b8e8e2f335e1
Child:
10:c5ef17e93872

File content as of revision 9:b9ad5e45aebf:

#include "Stats.h"

Stats::Stats()
{

}

Stats::~Stats()
{

}

void Stats::grid_draw(N5110 &lcd)
{
    lcd.drawRect(0, 0, WIDTH, HEIGHT-8, FILL_TRANSPARENT);  // outer border
    lcd.drawLine(WIDTH-1, HEIGHT-8, WIDTH-1, HEIGHT, 1);    // health border, right side
    lcd.drawLine(WIDTH-11, HEIGHT-8, WIDTH-11, HEIGHT, 1);  // health border, left side
    lcd.drawLine(18, HEIGHT-1, WIDTH, HEIGHT-1, 1);         // bottom border
    lcd.drawLine(18, HEIGHT-8, 18, HEIGHT, 1);              // wave counter border, right side
}

void Stats::wave_draw(N5110 &lcd, int wave_counter)
{
    char buffer[14];
    int length = sprintf(buffer,"%2d",wave_counter);
    lcd.printString(buffer,0,5);
}

void Stats::draw_health(N5110 &lcd)
{
    lcd.drawLine(76,40,77,40,1);
    lcd.drawLine(79,40,80,40,1);
    lcd.drawLine(75,41,75,43,1);
    lcd.drawLine(81,41,81,43,1);
    lcd.setPixel(78,41);
    lcd.setPixel(76,44);
    lcd.setPixel(80,44);
    lcd.setPixel(77,45);
    lcd.setPixel(79,45);
    lcd.setPixel(78,46);
}

void Stats::draw_rocket1(N5110 &lcd, int state)
{
    lcd.drawLine(22, HEIGHT-3, 25, HEIGHT-3, state);
    lcd.drawLine(23, HEIGHT-4, 35, HEIGHT-4, state);
    lcd.drawLine(24, HEIGHT-5, 36, HEIGHT-5, state);
    lcd.drawLine(23, HEIGHT-6, 35, HEIGHT-6, state);
    lcd.drawLine(22, HEIGHT-7, 25, HEIGHT-7, state);
}

void Stats::draw_rocket2(N5110 &lcd, int state)
{
    lcd.drawLine(39, HEIGHT-3, 42, HEIGHT-3, state);
    lcd.drawLine(40, HEIGHT-4, 52, HEIGHT-4, state);
    lcd.drawLine(41, HEIGHT-5, 53, HEIGHT-5, state);
    lcd.drawLine(40, HEIGHT-6, 52, HEIGHT-6, state);
    lcd.drawLine(39, HEIGHT-7, 42, HEIGHT-7, state);
}

void Stats::draw_rocket3(N5110 &lcd, int state)
{
    lcd.drawLine(56, HEIGHT-3, 59, HEIGHT-3, state);
    lcd.drawLine(57, HEIGHT-4, 69, HEIGHT-4, state);
    lcd.drawLine(58, HEIGHT-5, 70, HEIGHT-5, state);
    lcd.drawLine(57, HEIGHT-6, 69, HEIGHT-6, state);
    lcd.drawLine(56, HEIGHT-7, 59, HEIGHT-7, state);
}

void Stats::check_rocket(N5110 &lcd, int ammo)
{
    if (ammo == 3) 
    {
        draw_rocket1(lcd, 1);
        draw_rocket2(lcd, 1);
        draw_rocket3(lcd, 1);
    } 
    else if (ammo == 2)
    {
        draw_rocket1(lcd, 1);
        draw_rocket2(lcd, 1);
        draw_rocket3(lcd, 2);
    }
    else if (ammo == 1)
    {
        draw_rocket1(lcd, 1);
        draw_rocket2(lcd, 2);
        draw_rocket3(lcd, 2);
    }
    else if (ammo == 0)
    {
        draw_rocket1(lcd, 2);
        draw_rocket2(lcd, 2);
        draw_rocket3(lcd, 2);
    }
}

void Stats::check_health(N5110 &lcd, int collisions)
{
    if (collisions == 0) 
    {
        lcd.drawLine(76,41,80,41,1);
        lcd.drawLine(76,42,80,42,1);
        lcd.drawLine(76,43,80,43,1);
        lcd.drawLine(77,44,79,44,1);
        lcd.setPixel(78,45);
    }
    else if (collisions == 1) 
    {
        lcd.drawLine(76,42,80,42,1);
        lcd.drawLine(76,43,80,43,1);
        lcd.drawLine(77,44,79,44,1);
        lcd.setPixel(78,45);
    }
    else if (collisions == 2) 
    {
        lcd.drawLine(76,43,80,43,1);
        lcd.drawLine(77,44,79,44,1);
        lcd.setPixel(78,45);
    }
    else if (collisions == 3) 
    {
        lcd.drawLine(77,44,79,44,1);
        lcd.setPixel(78,45);
    }
    else if (collisions == 4)
    {
        lcd.setPixel(78,45);
    }     
    else if (collisions >= 5)
    {
    }
}