File: capanel.cpp

package info (click to toggle)
trophy 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 48,568 kB
  • sloc: cpp: 7,285; sh: 1,032; xml: 277; makefile: 94
file content (81 lines) | stat: -rw-r--r-- 2,113 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "capanel.h"
#include "catrophy.h"

/** Constructor.
*/
CAPanel::CAPanel()
{
    for( int c=0; c<CA_RACEMAXPLAYERS; ++c )
    {
        m_playerView.push_back(new CAPlayerView( CA_APP->m_RacePlayer[c] ));
    }
}

CAPanel::~CAPanel()
{
    for( unsigned int c=0; c<m_playerView.size(); ++c )
    {
        delete m_playerView[c];
    }
}


/** Displays the panel.
*/
void
CAPanel::display() 
{
    CL_Display::fill_rect( CL_Rect(0, 0, 120, CA_APP->height), CL_Color(0, 0, 0, 255) );

    CA_RES->panel_label->draw (0,0);

    // Display time:
    //
    CA_RES->font_lcd_13_green->set_alignment(origin_top_left, 0, 0);
    CA_RES->font_lcd_13_green->draw(20, 30, CA_APP->getTimeString());

    // Display speed view:
    //
    int speedIndex = (int)fabs(CA_APP->player[0]->getSpeed() / CA_APP->player[0]->getCar()->getMotor()->getMaxSpeed() * 10.0);
    if( speedIndex>10 ) speedIndex = 10;
    CA_RES->panel_speed->set_frame(speedIndex);
    CA_RES->panel_speed->draw (0, 57);

    // Display turbo view:
    //
    CA_RES->panel_turbolabel->draw (0, 88);
    int turboIndex = (int)fabs(CA_APP->player[0]->getTurbo() / CA_APP->player[0]->getCar()->maxTurbo * 9.0);
    CA_RES->panel_turbo->set_frame(turboIndex);
    CA_RES->panel_turbo->draw (0, 100);

    // Display ammo view
    int ammoIndex = (int)fabs(CA_APP->player[0]->getBullets() / 500.0 * 20.0);
    CA_RES->panel_ammo->set_frame(ammoIndex);
    CA_RES->panel_ammo->draw (0, 110);

    // Display player views:
    //
    for( unsigned int c=0; c<m_playerView.size(); ++c )
    {
        m_playerView[c]->display( c+1 );
    }

    // Display frames per second:
    //
    static int counter=0;
    static int fps=0;
    counter++;

    if( counter > 200 ) {
        counter=0;
        fps = (int)(CA_APP->framesPerSec);
    }

    char str[16];
    sprintf( str, "FPS: %d", fps );
    CL_Display::fill_rect( CL_Rect(10, CA_APP->height-20, 110, CA_APP->height-10), CL_Color(0, 0, 0, 255) );
    CA_RES->font_normal_14_white->set_alignment(origin_top_left, 0, 0);
    CA_RES->font_normal_14_white->draw(10, CA_APP->height-20, str);
}

// EOF