// // Monsterz // // Copyright: (c) 2005-2011 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See // http://sam.zoy.org/projects/COPYING.WTFPL for more details. // #if defined HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include "core.h" using namespace lol; #include "interface.h" #include "title.h" #include "board.h" #include "monsterz.h" /* * Interface implementation class */ class InterfaceData { friend class Interface; private: Title *title; Board *board; TileSet *tiles; enum { INIT, TITLE, GAME, } state; }; /* * Public Interface class */ Interface::Interface() : data(new InterfaceData()) { data->title = NULL; data->board = NULL; data->tiles = Tiler::Register(PNG_TILES, 48, 0, 1.0f); data->state = InterfaceData::INIT; position = ivec3(0, 0, 1); bbox[0] = position; bbox[1] = bbox[0] + ivec3(640, 480, 0); } void Interface::TickGame(float deltams) { WorldEntity::TickGame(deltams); switch (data->state) { case InterfaceData::INIT: data->title = new Title(); Ticker::Ref(data->title); data->state = InterfaceData::TITLE; break; case InterfaceData::TITLE: if (data->title->IsClicked()) { Ticker::Unref(data->title); data->title = NULL; data->board = new Board(Board::GAME_HUNT, ivec2(8, 8), 7, 8); Ticker::Ref(data->board); data->state = InterfaceData::GAME; } break; case InterfaceData::GAME: break; } } void Interface::TickDraw(float deltams) { WorldEntity::TickDraw(deltams); ivec3 mouse(Input::GetMousePos()); if (Platform::GetMouseCount() && mouse.x >= 0 && mouse.y >= 0) { mouse += ivec3(-6, 6 - 48, 30); Scene::GetDefault()->AddTile(data->tiles, 22, mouse, 0); } } Interface::~Interface() { if (data->title) Ticker::Unref(data->title); if (data->board) Ticker::Unref(data->board); Tiler::Deregister(data->tiles); delete data; }