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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/interface.cpp

    r331 r332  
    2020#include "core.h"
    2121#include "interface.h"
     22#include "title.h"
     23#include "board.h"
    2224#include "monsterz.h"
    2325
     
    3133
    3234private:
     35    Title *title;
     36    Board *board;
    3337    int screen, tiles;
     38
     39    enum
     40    {
     41        INIT,
     42        TITLE,
     43        GAME,
     44    }
     45    state;
    3446};
    3547
     
    4153  : data(new InterfaceData())
    4254{
     55    data->title = NULL;
     56    data->board = NULL;
    4357    data->screen = Tiler::Register(PNG_BACKGROUND, 640, 480, 1.0f);
    4458    data->tiles = Tiler::Register(PNG_TILES, 48, 48, 1.0f);
     59    data->state = InterfaceData::INIT;
    4560
    4661    position = int3(0, 0, 1);
    4762    bbox[0] = position;
    4863    bbox[1] = bbox[0] + int3(640, 480, 0);
    49 
    50     Input::TrackMouse(this);
    5164}
    5265
     
    5467{
    5568    WorldEntity::TickGame(deltams);
     69
     70    switch (data->state)
     71    {
     72    case InterfaceData::INIT:
     73        data->title = new Title();
     74        Ticker::Ref(data->title);
     75        data->state = InterfaceData::TITLE;
     76        break;
     77    case InterfaceData::TITLE:
     78        if (data->title->IsClicked())
     79        {
     80            Ticker::Unref(data->title);
     81            data->title = NULL;
     82            data->board = new Board(int2(8, 8), 9);
     83            Ticker::Ref(data->board);
     84            data->state = InterfaceData::GAME;
     85        }
     86        break;
     87    case InterfaceData::GAME:
     88        break;
     89    }
    5690}
    5791
     
    73107Interface::~Interface()
    74108{
     109    if (data->title)
     110        Ticker::Unref(data->title);
     111    if (data->board)
     112        Ticker::Unref(data->board);
    75113    Tiler::Deregister(data->tiles);
    76114    Tiler::Deregister(data->screen);
Note: See TracChangeset for help on using the changeset viewer.