EtabliDAlchimiste::EtabliDAlchimiste(const Point& position, Direction direction) : Entity(position, direction) { m_size = {3, 2}; m_textures[Direction::Front] = OGetTexture("etabliDAlchimiste_front.png"); m_textures[Direction::Left] = OGetTexture("etabliDAlchimiste_left.png"); m_textures[Direction::Back] = OGetTexture("etabliDAlchimiste_back.png"); m_textures[Direction::Right] = OGetTexture("etabliDAlchimiste_right.png"); }
Trone::Trone(const Point& position, Direction direction) : Entity(position, direction) { m_size = {1, 1}; m_textures[Direction::Front] = OGetTexture("throne_front.png"); m_textures[Direction::Left] = OGetTexture("throne_left.png"); m_textures[Direction::Back] = OGetTexture("throne_back.png"); m_textures[Direction::Right] = OGetTexture("throne_right.png"); }
UnitAnimDef::UnitAnimDef(const std::string &texture, const Vector2 &offset, const Vector2 &size, bool hFlip, int in_fps, std::vector<Vector4> in_frames) : frameCount(static_cast<int>(in_frames.size())) , fps(in_fps) { pTexture = OGetTexture(texture.c_str()); assert(pTexture); frames = new sAnimFrame[frameCount]; int frameIndex = 0; float texSizeX = pTexture->getSizef().x; float texSizeY = pTexture->getSizef().y; for (auto &frameUVs : in_frames) { auto &frame = frames[frameIndex]; frame.offset = offset / 40.f; frame.size = size / 40.f; frame.UVs = frameUVs; frame.UVs.x /= texSizeX; frame.UVs.y /= texSizeY; frame.UVs.z /= texSizeX; frame.UVs.w /= texSizeY; frame.UVs.z += frame.UVs.x; frame.UVs.w += frame.UVs.y; if (hFlip) { std::swap(frame.UVs.x, frame.UVs.z); } ++frameIndex; } }
UnitAnimDef::UnitAnimDef(const std::string &texture, const POINT &spriteSize, const Vector2 &offset, float scale, bool hFlip, int in_fps, std::vector<int> in_frames) : frameCount(static_cast<int>(in_frames.size())) , fps(in_fps) { pTexture = OGetTexture(texture.c_str()); assert(pTexture); int colCount = pTexture->getSize().x / spriteSize.x; frames = new sAnimFrame[frameCount]; int frameIndex = 0; float texSizeX = pTexture->getSizef().x; float texSizeY = pTexture->getSizef().y; for (auto frameId : in_frames) { auto &frame = frames[frameIndex]; frame.offset = offset * scale / 40.f; frame.size = Vector2{(float)spriteSize.x * scale, (float)spriteSize.y * scale} / 40.f; frame.UVs.x = ((float)(frameId % colCount) * (float)spriteSize.x) / texSizeX; frame.UVs.y = ((float)(frameId / colCount) * (float)spriteSize.y) / texSizeY; frame.UVs.z = ((float)(frameId % colCount + 1) * (float)spriteSize.x) / texSizeX; frame.UVs.w = ((float)(frameId / colCount + 1) * (float)spriteSize.y) / texSizeY; if (hFlip) { std::swap(frame.UVs.x, frame.UVs.z); } ++frameIndex; } }
void render() { oRenderer->clear({0, 0, 0, 1}); oRenderer->setupFor2D(); oRenderer->renderStates.textures[0] = OGetTexture("onutLogo.png"); oRenderer->renderStates.vertexBuffer = pVertexBuffer; oRenderer->renderStates.indexBuffer = pIndexBuffer; oRenderer->drawIndexed(6); }
void render() { oRenderer->clear({0, 0, 0, 1}); // Lines oPrimitiveBatch->begin(OPrimitiveLineStrip); oPrimitiveBatch->draw(Vector2(10, 10), Color(1, 0, 0, 1)); oPrimitiveBatch->draw(Vector2(100, 100), Color(1, 1, 0, 1)); oPrimitiveBatch->draw(Vector2(75, 200), Color(0, 1, 0, 1)); oPrimitiveBatch->draw(Vector2(25, 50), Color(0, 0, 1, 1)); oPrimitiveBatch->end(); // Points oPrimitiveBatch->begin(OPrimitivePointList); oPrimitiveBatch->draw(Vector2(110, 10), Color(1, 0, 0, 1)); oPrimitiveBatch->draw(Vector2(110, 50), Color(1, 1, 0, 1)); oPrimitiveBatch->draw(Vector2(150, 50), Color(0, 1, 0, 1)); oPrimitiveBatch->draw(Vector2(150, 10), Color(0, 0, 1, 1)); oPrimitiveBatch->end(); // Triangles oPrimitiveBatch->begin(OPrimitiveTriangleList); oPrimitiveBatch->draw(Vector2(250, 10), Color(1, 0, 0, 1)); oPrimitiveBatch->draw(Vector2(200, 50), Color(1, 1, 0, 1)); oPrimitiveBatch->draw(Vector2(300, 50), Color(0, 1, 0, 1)); oPrimitiveBatch->draw(Vector2(250, 110), Color(0, 0, 1, 1)); oPrimitiveBatch->draw(Vector2(200, 150), Color(1, 0, 1, 1)); oPrimitiveBatch->draw(Vector2(300, 150), Color(0, 1, 1, 1)); oPrimitiveBatch->end(); // Textured oPrimitiveBatch->begin(OPrimitiveTriangleList, OGetTexture("onutLogo.png")); oPrimitiveBatch->draw(Vector2(350, 10), Color::White, Vector2(.5f, 0)); oPrimitiveBatch->draw(Vector2(300, 100), Color::White, Vector2(0, 1)); oPrimitiveBatch->draw(Vector2(400, 100), Color::White, Vector2(1, 1)); oPrimitiveBatch->end(); }
void render() { auto pNutTexture = OGetTexture("onutLogo.png"); auto pFrameTexture = OGetTexture("frameSmall.png"); auto pChainTexture = OGetTexture("chain.png"); // Clear oRenderer->clear(OColorHex(1d232d)); // Begin a batch oSpriteBatch->begin(batchTransform); // Opaque oSpriteBatch->drawRect(nullptr, Rect(0, 0, 64, 64)); oSpriteBatch->drawRect(nullptr, Rect(64, 0, 64, 64), Color(1, 0, 0, 1)); // Red oSpriteBatch->drawInclinedRect(nullptr, Rect(192, 0, 64, 64), -.5f); // Inclined // Textured oSpriteBatch->drawRect(pNutTexture, Rect(0, 64, 64, 64)); oSpriteBatch->drawRect(pNutTexture, Rect(64, 64, 64, 64), Color(1, 0, 0, 1)); // Tinted // Per vertex coloring oSpriteBatch->drawRectWithColors(nullptr, Rect(0, 128, 64, 64), {Color(1, 0, 0, 1), Color(1, 1, 0, 1), Color(0, 1, 0, 1), Color(0, 0, 1, 1)}); // Custom UVs oSpriteBatch->drawRectWithUVs(pNutTexture, Rect(64, 128, 64, 64), Vector4(0, 0, .5f, .5f)); // Split the texture in 4 corner (Good for corsairs) oSpriteBatch->draw4Corner(pNutTexture, Rect(128, 64, 160, 160)); // Scale 9, 9 Patch, 9 slice (whatever you guys call it) oSpriteBatch->drawRectScaled9(pFrameTexture, Rect(0, 256, 160, 160), Vector4(48, 48, 48, 48)); oSpriteBatch->drawRectScaled9(pFrameTexture, Rect(160, 256, 256, 160), Vector4(48, 48, 48, 48)); oSpriteBatch->drawRectScaled9RepeatCenters(pFrameTexture, Rect(416, 256, 256, 160), Vector4(48, 48, 48, 48)); // Sprites oSpriteBatch->drawSprite(pNutTexture, Vector2(64, 480)); oSpriteBatch->drawSprite(pNutTexture, Vector2(192, 480), Color::White, g_spriteAngle); oSpriteBatch->drawSprite(pNutTexture, Vector2(320, 440), Color::White, g_spriteAngle, .5f); oSpriteBatch->drawSprite(nullptr, Vector2(320, 500), Color::White, g_spriteAngle, 32.f); // With a custom matrix Matrix customTransform = Matrix::Identity; customTransform *= Matrix::CreateRotationZ(OConvertToRadians(g_spriteAngle)); customTransform *= Matrix::CreateScale(4.f, 0.5f, 1.f); customTransform *= Matrix::CreateTranslation(520, 120, 0); oSpriteBatch->drawSprite(pNutTexture, customTransform, Color::White); // Lines oSpriteBatch->drawBeam(pChainTexture, Vector2(448, 480), Vector2(648, 440), 32.0f, Color::White); oSpriteBatch->drawBeam(pChainTexture, Vector2(448, 520), Vector2(648, 480), 32.0f, Color::White, g_spriteAngle * .1f); // Blend modes oRenderer->renderStates.blendMode = OBlendAdd; oSpriteBatch->drawSprite(pNutTexture, Vector2(400, 50), Color::White, 0, .25f); oRenderer->renderStates.blendMode = OBlendAlpha; oSpriteBatch->drawSprite(pNutTexture, Vector2(450, 50), Color::White, 0, .25f); oRenderer->renderStates.blendMode = OBlendForceWrite; oSpriteBatch->drawSprite(pNutTexture, Vector2(500, 50), Color::White, 0, .25f); oRenderer->renderStates.blendMode = OBlendMultiply; oSpriteBatch->drawSprite(pNutTexture, Vector2(550, 50), Color::White, 0, .25f); oRenderer->renderStates.blendMode = OBlendOpaque; oSpriteBatch->drawSprite(pNutTexture, Vector2(600, 50), Color::White, 0, .25f); oRenderer->renderStates.blendMode = OBlendPreMultiplied; oSpriteBatch->drawSprite(pNutTexture, Vector2(650, 50), Color::White, 0, .25f); // Origin oSpriteBatch->drawSprite(pNutTexture, Vector2(400, 200), Color::White, 0, .25f, Vector2(0, 0)); oSpriteBatch->drawCross(Vector2(400, 200), 10.f, Color(1, 1, 0, 1)); oSpriteBatch->drawSprite(pNutTexture, Vector2(500, 200), Color::White, 0, .25f, Vector2(.5f, .5f)); oSpriteBatch->drawCross(Vector2(500, 200), 10.f, Color(1, 1, 0, 1)); oSpriteBatch->drawSprite(pNutTexture, Vector2(600, 200), Color::White, 0, .25f, Vector2(1, 1)); oSpriteBatch->drawCross(Vector2(600, 200), 10.f, Color(1, 1, 0, 1)); // Filtering oRenderer->renderStates.sampleFiltering = OFilterNearest; oSpriteBatch->drawSprite(pNutTexture, Vector2(725, 100), Color::White, 0.f, 1.5f); oRenderer->renderStates.sampleFiltering = OFilterLinear; oSpriteBatch->drawSprite(pNutTexture, Vector2(725, 300), Color::White, 0.f, 1.5f); // End and flush the batch oSpriteBatch->end(); }
void drawController(int index, const Vector2& position) { if (!OGetGamePad(index)->isConnected()) { oSpriteBatch->drawSprite(OGetTexture("gamepad.png"), position, Color(.5f)); } else { oSpriteBatch->drawSprite(OGetTexture(("gamepad" + std::to_string(index) + ".png").c_str()), position); oSpriteBatch->drawSprite(OGetTexture("lthumb.png"), position + OGetGamePadLeftThumb(index) * 12.f); oSpriteBatch->drawSprite(OGetTexture("rthumb.png"), position + OGetGamePadRightThumb(index) * 12.f); if (OGamePadPressed(OGamePadLeftThumb, index)) oSpriteBatch->drawSprite(OGetTexture("lthumbPress.png"), position + OGetGamePadLeftThumb(index) * 12.f); if (OGamePadPressed(OGamePadRightThumb, index)) oSpriteBatch->drawSprite(OGetTexture("rthumbPress.png"), position + OGetGamePadRightThumb(index) * 12.f); if (OGamePadPressed(OGamePadRightBumper, index)) oSpriteBatch->drawSprite(OGetTexture("rb.png"), position); if (OGamePadPressed(OGamePadLeftBumper, index)) oSpriteBatch->drawSprite(OGetTexture("lb.png"), position); if (OGamePadPressed(OGamePadBack, index)) oSpriteBatch->drawSprite(OGetTexture("back.png"), position); if (OGamePadPressed(OGamePadStart, index)) oSpriteBatch->drawSprite(OGetTexture("start.png"), position); if (OGamePadPressed(OGamePadA, index)) oSpriteBatch->drawSprite(OGetTexture("a.png"), position); if (OGamePadPressed(OGamePadB, index)) oSpriteBatch->drawSprite(OGetTexture("b.png"), position); if (OGamePadPressed(OGamePadX, index)) oSpriteBatch->drawSprite(OGetTexture("x.png"), position); if (OGamePadPressed(OGamePadY, index)) oSpriteBatch->drawSprite(OGetTexture("y.png"), position); if (OGamePadPressed(OGamePadDPadLeft, index)) oSpriteBatch->drawSprite(OGetTexture("dleft.png"), position); if (OGamePadPressed(OGamePadDPadRight, index)) oSpriteBatch->drawSprite(OGetTexture("dright.png"), position); if (OGamePadPressed(OGamePadDPadUp, index)) oSpriteBatch->drawSprite(OGetTexture("dup.png"), position); if (OGamePadPressed(OGamePadDPadDown, index)) oSpriteBatch->drawSprite(OGetTexture("ddown.png"), position); if (OGamePadPressed(OGamePadLeftTrigger, index)) oSpriteBatch->drawSprite(OGetTexture("lt.png"), position); if (OGamePadPressed(OGamePadRightTrigger, index)) oSpriteBatch->drawSprite(OGetTexture("rt.png"), position); } }
Mortar::Mortar() { pTexture = OGetTexture("mortar.png"); }
void Globals::init() { // FX FX::init(); // Define unit types { sUnitType u; u.typeName = "Spawner"; u.screenName = "Spawner"; u.category = eUnitCategory::BUILDLING; u.sizeType = eUnitSizeType::BOX; u.boxSize = {3, 3}; u.yOffset = 3; u.health = getInt("spawner_health", 500); u.armor = getInt("spawner_armor", 5); u.visionRange = getFloat("spawner_vision_range", 10); u.alertRange = getFloat("spawner_alert_range", 8); u.anims[BALT_DOWN | BALT_IDLE] = new UnitAnimDef{"buildings/buildings.png", {-40.f, -40.f}, {200.f, 200.f}, false, 0, {{240.f, 0.f, 200.f, 200.f}}}; u.anims[BALT_UP | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_LEFT | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_RIGHT | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.pFactory = new UnitFactory<Spawner>(); unitTypes[eUnitType::SPAWNER] = u; } { sUnitType u; u.typeName = "Tower"; u.screenName = "Tower"; u.category = eUnitCategory::BUILDLING; u.sizeType = eUnitSizeType::BOX; u.boxSize = {2, 2}; u.yOffset = 2; u.health = 300; u.armor = 3; u.visionRange = 10; u.alertRange = 8; u.attackRange = 8; u.attackType = eUnitAttackType::PROJECTILE; u.projectileUnitType = eUnitType::ARROW; u.attackCoolDown = .75f; u.attackDelay = 0.01f; u.anims[BALT_DOWN | BALT_IDLE] = new UnitAnimDef{"buildings/buildings.png", {0, -80.f}, {120.f, 200.f}, false, 120, {{480.f, 0.f, 120.f, 200.f}}}; u.anims[BALT_UP | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_LEFT | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_RIGHT | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_DOWN | BALT_ATTACK] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_UP | BALT_ATTACK] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_LEFT | BALT_ATTACK] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_RIGHT | BALT_ATTACK] = u.anims[BALT_DOWN | BALT_IDLE]; u.pFactory = new UnitFactory<Tower>(); unitTypes[eUnitType::TOWER] = u; } { sUnitType u; u.typeName = "Nexus"; u.screenName = "Nexus"; u.category = eUnitCategory::BUILDLING; u.sizeType = eUnitSizeType::BOX; u.boxSize = {4, 4}; u.yOffset = 4; u.health = 2000; u.armor = 5; u.visionRange = 10; u.alertRange = 8; u.anims[BALT_DOWN | BALT_IDLE] = new UnitAnimDef{"buildings/buildings.png", {-40.f, -40.f}, {240.f, 240.f}, false, 0, {{0, 0, 240.f, 240.f}}}; u.anims[BALT_UP | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_LEFT | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.anims[BALT_RIGHT | BALT_IDLE] = u.anims[BALT_DOWN | BALT_IDLE]; u.pFactory = new UnitFactory<Nexus>(); unitTypes[eUnitType::NEXUS] = u; } { sUnitType u; u.typeName = "MinionWaypoint"; u.category = eUnitCategory::NONE; u.sizeType = eUnitSizeType::BOX; u.boxSize = {2, 2}; u.pFactory = new UnitFactory<Waypoint>(); unitTypes[eUnitType::WAYPOINT] = u; } { sUnitType u; u.typeName = "Minion"; u.screenName = "Minion"; u.category = eUnitCategory::GROUND; u.sizeType = eUnitSizeType::RADIUS; u.radius = .25f; u.health = 40; u.visionRange = 7; u.alertRange = 6; u.attackRange = 5; u.moveSpeed = 2; u.attackType = eUnitAttackType::PROJECTILE; u.projectileUnitType = eUnitType::ARROW; u.attackCoolDown = 1.125f; u.attackDelay = .08f; static const int BALT_IDLE_FPS = 8; static const int BALT_WALK_FPS = 8; static const int BALT_ATTACK_FPS = 24; static const float MINION_SCALE = 2.f; u.anims[BALT_DOWN | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_IDLE_FPS, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; u.anims[BALT_DOWN | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_WALK_FPS, {2, 4, 3, 5}}; u.anims[BALT_DOWN | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_ATTACK_FPS, {6, 2, 7}}; u.anims[BALT_UP | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_IDLE_FPS, {8}}; u.anims[BALT_UP | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_WALK_FPS, {10, 13, 11, 12}}; u.anims[BALT_UP | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_ATTACK_FPS, {14, 10, 15}}; u.anims[BALT_LEFT | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_IDLE_FPS, {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}}; u.anims[BALT_LEFT | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_WALK_FPS, {18, 16, 19, 16}}; u.anims[BALT_LEFT | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, false, BALT_ATTACK_FPS, {20, 19, 21}}; u.anims[BALT_RIGHT | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, true, BALT_IDLE_FPS, {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}}; u.anims[BALT_RIGHT | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, true, BALT_WALK_FPS, {18, 16, 19, 16}}; u.anims[BALT_RIGHT | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, MINION_SCALE, true, BALT_ATTACK_FPS, {20, 19, 21}}; u.pFactory = new UnitFactory<Minion>(); unitTypes[eUnitType::MINION] = u; } { sUnitType u; u.typeName = "Arrow"; u.category = eUnitCategory::PROJECTILE; u.pFactory = new UnitFactory<Arrow>(); u.pTexture = OGetTexture("minions/arrow.png"); u.damage = 5.f; unitTypes[eUnitType::ARROW] = u; } { sUnitType u; u.typeName = "Gibs"; u.pFactory = new UnitFactory<Gibs>(); u.pTexture = OGetTexture("fx/gibs.png"); u.UVs = OUVS(u.pTexture, {0, 24, 10, 13}); unitTypes[eUnitType::GIBS_HEAD] = u; } { sUnitType u; u.typeName = "Gibs"; u.pFactory = new UnitFactory<Gibs>(); u.pTexture = OGetTexture("fx/gibs.png"); u.UVs = OUVS(u.pTexture, {7, 0, 6, 9}); unitTypes[eUnitType::GIBS_LARM] = u; } { sUnitType u; u.typeName = "Gibs"; u.pFactory = new UnitFactory<Gibs>(); u.pTexture = OGetTexture("fx/gibs.png"); u.UVs = OUVS(u.pTexture, {0, 15, 11, 9}); unitTypes[eUnitType::GIBS_TORSO] = u; } { sUnitType u; u.typeName = "Gibs"; u.pFactory = new UnitFactory<Gibs>(); u.pTexture = OGetTexture("fx/gibs.png"); u.UVs = OUVS(u.pTexture, {0, 0, 7, 8}); unitTypes[eUnitType::GIBS_RARM] = u; } { sUnitType u; u.typeName = "Gibs"; u.pFactory = new UnitFactory<Gibs>(); u.pTexture = OGetTexture("fx/gibs.png"); u.UVs = OUVS(u.pTexture, {0, 8, 6, 7}); unitTypes[eUnitType::GIBS_LFOOT] = u; } { sUnitType u; u.typeName = "Gibs"; u.pFactory = new UnitFactory<Gibs>(); u.pTexture = OGetTexture("fx/gibs.png"); u.UVs = OUVS(u.pTexture, {0, 9, 6, 6}); unitTypes[eUnitType::GIBS_RFOOT] = u; } { sUnitType u; u.typeName = "Hero"; u.screenName = "Hero"; u.category = eUnitCategory::GROUND; u.sizeType = eUnitSizeType::RADIUS; u.radius = .35f; u.health = 150; u.visionRange = 10; u.alertRange = 9; u.attackRange = 8; u.moveSpeed = 4; u.attackType = eUnitAttackType::PROJECTILE; u.projectileUnitType = eUnitType::ARROW; u.attackCoolDown = 1.125f; u.attackDelay = .08f; static const int BALT_IDLE_FPS = 12; static const int BALT_WALK_FPS = 12; static const int BALT_ATTACK_FPS = 24; static const float HERO_SCALE = 3.f; u.anims[BALT_DOWN | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_IDLE_FPS, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; u.anims[BALT_DOWN | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_WALK_FPS, {2, 4, 3, 5}}; u.anims[BALT_DOWN | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_ATTACK_FPS, {6, 2, 7}}; u.anims[BALT_UP | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_IDLE_FPS, {8}}; u.anims[BALT_UP | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_WALK_FPS, {10, 13, 11, 12}}; u.anims[BALT_UP | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_ATTACK_FPS, {14, 10, 15}}; u.anims[BALT_LEFT | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_IDLE_FPS, {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}}; u.anims[BALT_LEFT | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_WALK_FPS, {18, 16, 19, 16}}; u.anims[BALT_LEFT | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, false, BALT_ATTACK_FPS, {20, 19, 21}}; u.anims[BALT_RIGHT | BALT_IDLE] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, true, BALT_IDLE_FPS, {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}}; u.anims[BALT_RIGHT | BALT_WALK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, true, BALT_WALK_FPS, {18, 16, 19, 16}}; u.anims[BALT_RIGHT | BALT_ATTACK] = new UnitAnimDef{"minions/beggarPlateArmor.png", {16, 24}, {-8, -18}, HERO_SCALE, true, BALT_ATTACK_FPS, {20, 19, 21}}; u.pFactory = new UnitFactory<Hero>(); unitTypes[eUnitType::HERO] = u; } { sUnitType u; u.typeName = "SpawnPoint"; u.category = eUnitCategory::NONE; u.sizeType = eUnitSizeType::BOX; u.boxSize = {1, 1}; u.pFactory = new UnitFactory<SpawnPoint>(); unitTypes[eUnitType::SPAWN_POINT] = u; } { sUnitType u; u.category = eUnitCategory::PROJECTILE; u.pFactory = new UnitFactory<FallingFireBall>(); u.damage = 10.f; u.damageRadius = 1.0f; u.anims[BALT_DOWN | BALT_IDLE] = FX::s_FXAnims[FX_ANIM_FIRE_BALL]; unitTypes[eUnitType::FALLING_FIRE_BALL] = u; } { sUnitType u; u.category = eUnitCategory::ABILITY; u.pFactory = new UnitFactory<FireShowerAbility>(); unitTypes[eUnitType::ABILITY_FIRE_SHOWER] = u; } { sUnitType u; u.category = eUnitCategory::ABILITY; u.pFactory = new UnitFactory<LightningBeamAbility>(); u.renderOnTop = true; u.damage = 10.f; u.pTexture = OGetTexture("lightningBeam.png"); unitTypes[eUnitType::ABILITY_LIGTHNING_BEAM] = u; } // Sounds pArrow_spawnSound = OGetSound("arrow.wav"); pArrow_spawnSound->setMaxInstance(4); pArrow_hit = OGetSound("arrowHit.wav"); pArrow_hit->setMaxInstance(2); pFireball_spawn = OGetSound("fireball.wav"); pFireball_spawn->setMaxInstance(5); pFireball_hit = OGetSound("fireballImpact.wav"); pFireball_hit->setMaxInstance(5); for (auto &unitType : unitTypes) { unitTypesByName[unitType.second.typeName] = unitType.first; } auto pHeader = new onut::UIControl("../../assets/ui/header.json"); pUIHeader = pHeader->getChild("header"); pUIHeader->retain(); pHeader->release(); hookButtonSounds(pUIHeader); }