From: Andy Date: Thu, 19 Jan 2017 14:21:12 +0000 (-0500) Subject: Limb animation actually works X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=213d9ccfbb4752d4c62d6b7e6b3f9172cdf1bccc;p=clyne%2Fgamedev.git Limb animation actually works --- 213d9ccfbb4752d4c62d6b7e6b3f9172cdf1bccc diff --cc main.cpp index f04581a,7e06d7d..e17b910 --- a/main.cpp +++ b/main.cpp @@@ -80,55 -89,14 +89,14 @@@ int main(int argc, char *argv[] // game::engine.init(); - // used three times below - auto worldSys = game::engine.getSystem(); - - // - // initialize GLEW - // - #ifndef __WIN32__ - glewExperimental = GL_TRUE; - #endif - - auto glewError = glewInit(); - if (glewError != GLEW_OK) - UserError(std::string("GLEW was not able to initialize! Error: ") - + reinterpret_cast(glewGetErrorString(glewError))); - - // - // start the random number generator (TODO our own?) - // + // initialize the renderer + Render::init(); + // start the random number generator randInit(millis()); - // - // some basic OpenGL setup stuff - // - - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); - // enable v-sync (TODO but 1000 fps?) - SDL_GL_SetSwapInterval(0); - // hide the cursor - SDL_ShowCursor(SDL_DISABLE); - // switch to pixel grid - glViewport(0, 0, game::SCREEN_WIDTH, game::SCREEN_HEIGHT); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glClearColor(1, 1, 1, 1); - - // - // initialize shaders - // - - std::cout << "Initializing shaders!\n"; - Render::initShaders(); - Colors::init(); - - // - // load saved data + // load some saved data - // - game::briceLoad(); game::briceUpdate(); diff --cc src/components.cpp index 3096d39,b758cb6..b06bf84 --- a/src/components.cpp +++ b/src/components.cpp @@@ -308,19 -306,16 +313,19 @@@ std::vector developFrame(XMLElem std::string sname = sxml->Name(); if (sname == "src") { foffset = (sxml->Attribute("offset") != nullptr) ? - str2coord(sxml->Attribute("offset")) : vec2(0,0); + sxml->StrAttribute("offset") : vec2(0,0); fdraw = (sxml->Attribute("drawOffset") != nullptr) ? - str2coord(sxml->Attribute("drawOffset")) : vec2(0,0); + sxml->StrAttribute("drawOffset") : vec2(0,0); - + if (sxml->Attribute("size") != nullptr) { - fsize = str2coord(sxml->Attribute("size")); - fsize = sxml->Attribute("size"); - tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), foffset, fsize), fdraw)); ++ fsize = sxml->StrAttribute("size"); + sd = new SpriteData(sxml->GetText(), foffset, fsize); } else { - tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), foffset), fdraw)); + sd = new SpriteData(sxml->GetText(), foffset); } + if (sxml->QueryUnsignedAttribute("limb", &limb) == XML_NO_ERROR) + sd->limb = limb; + tmpf.push_back(std::make_pair(*sd, fdraw)); } sxml = sxml->NextSiblingElement(); }