Ignore:
Timestamp:
Feb 2, 2011, 1:56:53 AM (10 years ago)
Author:
sam
Message:

Implement the title screen. Click on it to start a game.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/input.cpp

    r330 r332  
    3131public:
    3232    InputData()
    33       : mouse(-1, -1),
    34         buttons(0, 0, 0),
    35         nentities(0)
     33      : mouse(-1),
     34        buttons(0),
     35        nentities(0),
     36        lastfocus(0)
    3637    { }
    3738
     
    4344    WorldEntity *entities[MAX_ENTITIES];
    4445    int nentities;
     46    WorldEntity *lastfocus;
    4547}
    4648inputdata;
     
    121123    {
    122124        if (data->entities[n] == best)
     125        {
    123126            data->entities[n]->mousepos = (int2)((int3)coord - best->bbox[0]);
     127            if (best != data->lastfocus)
     128                data->entities[n]->pressed = data->buttons;
     129        }
    124130        else
     131        {
    125132            data->entities[n]->mousepos = int2(-1);
     133            /* FIXME */
     134            data->entities[n]->released = 0;
     135            data->entities[n]->pressed = 0;
     136            data->entities[n]->clicked = 0;
     137        }
    126138    }
     139
     140    data->lastfocus = best;
    127141}
    128142
     
    131145    data->buttons[index] = 1;
    132146
    133     /* FIXME: parse all subscribed entities and update them */
     147    if (data->lastfocus)
     148    {
     149        if (!data->lastfocus->pressed[index])
     150            data->lastfocus->clicked[index] = 1;
     151        data->lastfocus->pressed[index] = 1;
     152        data->lastfocus->released[index] = 0;
     153    }
    134154}
    135155
     
    138158    data->buttons[index] = 0;
    139159
    140     /* FIXME: parse all subscribed entities and update them */
     160    if (data->lastfocus)
     161    {
     162        if (data->lastfocus->pressed[index])
     163            data->lastfocus->released[index] = 1;
     164        data->lastfocus->pressed[index] = 0;
     165        data->lastfocus->clicked[index] = 0;
     166    }
    141167}
    142168
Note: See TracChangeset for help on using the changeset viewer.