diff --git a/Aquaria/AStar.h b/Aquaria/AStar.h index f31c69c..9031fb9 100644 --- a/Aquaria/AStar.h +++ b/Aquaria/AStar.h @@ -18,4 +18,3 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// moved diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index d519f01..de82ab2 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -37,7 +37,6 @@ class TimelineRender : public RenderObject { void onRender() { -#ifdef BBGE_BUILD_OPENGL glLineWidth(1); glBegin(GL_LINES); glColor4f(1, 1, 1, 1); @@ -47,7 +46,6 @@ class TimelineRender : public RenderObject glVertex3f(x, 5, 0); } glEnd(); -#endif } }; @@ -100,11 +98,7 @@ void KeyframeWidget::shiftRight() void KeyframeWidget::onUpdate(float dt) { - /* - if (this->key == ae->currentKey) - color = Vector(0.75, 0.75, 1); - else - */ + Quad::onUpdate(dt); if (life != 1 || ae->editSprite->isAnimating()) return; switch(ae->editSprite->getCurrentAnimation()->getKeyframe(this->key)->lerpType) @@ -139,7 +133,7 @@ void KeyframeWidget::onUpdate(float dt) { if (core->mouse.buttons.left) { - //ae->selectionLocked = false; + movingWidget = this; ae->currentKey = this->key; } @@ -236,7 +230,7 @@ void AnimationEditor::applyState() editSprite->cull = false; editSprite->loadSkeletal(editingFile); editSprite->position = Vector(400,300); - //editSprite->scale = Vector(0.5, 0.5); + addAction(MakeFunctionEvent(AnimationEditor, lmbu), ActionMapper::MOUSE_BUTTON_LEFT, 0); addAction(MakeFunctionEvent(AnimationEditor, lmbd), ActionMapper::MOUSE_BUTTON_LEFT, 1); @@ -271,7 +265,7 @@ void AnimationEditor::applyState() addAction(MakeFunctionEvent(AnimationEditor, undo), KEY_Z, 0); addAction(MakeFunctionEvent(AnimationEditor, redo), KEY_Y, 0); - //addAction(MakeFunctionEvent(AnimationEditor, lockSelection), KEY_L, 0); + addAction(MakeFunctionEvent(AnimationEditor, cycleLerpType), KEY_L, 0); addAction(MakeFunctionEvent(AnimationEditor, selectPrevBone), KEY_UP, 0); @@ -294,32 +288,12 @@ void AnimationEditor::applyState() - /* - addAction("mbl", KEY_A); - addAction("mbr", KEY_D); - addAction("mbu", KEY_W); - addAction("mbd", KEY_S); - */ - - addAction(ACTION_SWIMLEFT, KEY_J); addAction(ACTION_SWIMRIGHT, KEY_K); addAction(ACTION_SWIMUP, KEY_UP); addAction(ACTION_SWIMDOWN, KEY_DOWN); - /* - addAction(ACTION_BONELEFT, KEY_NUMPAD4); - addAction(ACTION_BONERIGHT, KEY_NUMPAD6); - addAction(ACTION_BONEUP, KEY_NUMPAD8); - addAction(ACTION_BONEDOWN, KEY_NUMPAD2); - */ - //addAction("", ); - - /* - addAction(MakeFunctionEvent(AnimationEditor, zoomOut), KEY_NUMPAD2, 0); - addAction(MakeFunctionEvent(AnimationEditor, zoomIn), KEY_NUMPAD8, 0); - */ addRenderObject(editSprite, LR_ENTITIES); @@ -620,11 +594,11 @@ void AnimationEditor::rebuildKeyframeWidgets() offx = keyframeWidgets[i]->offset.x; } keyframeWidgets.clear(); - for (int i = 0; i < 1000; i++) + if (Animation *a = editSprite->getCurrentAnimation()) { - if (editSprite->getCurrentAnimation()) + for (int i = 0; i < 1000; i++) { - SkeletalKeyframe *key = editSprite->getCurrentAnimation()->getKeyframe(i); + SkeletalKeyframe *key = a->getKeyframe(i); if (!key) break; KeyframeWidget *k = new KeyframeWidget(i); k->offset.x = offx; @@ -670,35 +644,9 @@ void AnimationEditor::moveBoneStripPoint(const Vector &mov) b->strip[selectedStripPoint] = sel->changeStrip[selectedStripPoint] += mov*0.006f; sel->setGridPoints(sel->stripVert, sel->strip); - /* - float sz = sel->getStripSegmentSize(); - for (int i = selectedStripPoint; i > 0; i--) - { - Vector diff = sel->changeStrip[i] - sel->changeStrip[i-1]; - if (!diff.isLength2DIn(sz)) - { - diff.setLength2D(sz); - sel->changeStrip[i-1] = sel->changeStrip[i] - diff; - } - } - for (int i = selectedStripPoint; i < sel->changeStrip.size()-1; i++) - { - Vector diff = sel->changeStrip[i] - sel->changeStrip[i+1]; - if (!diff.isLength2DIn(sz)) - { - diff.setLength2D(sz); - sel->changeStrip[i+1] = sel->changeStrip[i] - diff; - } - } - b->strip = sel->changeStrip; - - - */ - - //sel->setStrip(sel->changeStrip); } } } @@ -710,7 +658,7 @@ void AnimationEditor::selectPrevBone() if (editingStrip) { - //moveBoneStripPoint(Vector(0, 1)); + } else { @@ -724,7 +672,7 @@ void AnimationEditor::selectNextBone() if (editingStrip) { - //moveBoneStripPoint(Vector(0, -1)); + } else { @@ -767,7 +715,7 @@ void AnimationEditor::update(float dt) if (core->mouse.buttons.middle) { editSprite->position += core->mouse.change; - //core->setMousePosition(Vector(400,300)); + } if (editingStrip) @@ -811,29 +759,7 @@ void AnimationEditor::update(float dt) updateEditingBone(); if (editingBone) { - /* - float amt = dt; - if (isActing("mbl")) - { - editingBone->position.x -= amt; - applyTranslation(); - } - if (isActing("mbr")) - { - editingBone->position.x += amt; - applyTranslation(); - } - if (isActing("mbu")) - { - editingBone->position.y -= amt; - applyTranslation(); - } - if (isActing("mbd")) - { - editingBone->position.y += amt; - applyTranslation(); - } - */ + } } if (editingBone && boneEdit == 1) @@ -1053,8 +979,8 @@ void AnimationEditor::lmbd() { pushUndo(); updateEditingBone(); - if (editingBone /*&& (editSprite->position - core->mouse.position).isLength2DIn(400)*/ - /*&& core->mouse.position.x > 200 && core->mouse.position.y < 560*/ + if (editingBone + && core->mouse.position.x > 400-200 && core->mouse.position.x < 400+200 && core->mouse.position.y > 300-200 && core->mouse.position.y < 300+200 ) @@ -1148,7 +1074,7 @@ void AnimationEditor::rmbd() updateEditingBone(); if (editingBone) { - //cursorOffset = editingBone->position + editSprite->position - core->mouse.position; + cursorOffset = core->mouse.position; rotOffset = editingBone->rotation.z; boneEdit = 2; @@ -1307,8 +1233,8 @@ void AnimationEditor::rmbu() void AnimationEditor::mmbd() { - //editingBone = editSprite->getSelectedBone(ignoreBone); - //cloneBoneAhead(); + + } void AnimationEditor::cloneBoneAhead() @@ -1429,8 +1355,8 @@ void AnimationEditor::loadSkin() std::string file = dsq->getUserInputString("Enter skin file to load:"); if (file.empty()) return; - //this->editingFile = file; - //loadFile(); + + SkeletalSprite::clearCache(); editSprite->loadSkin(file); } @@ -1453,7 +1379,7 @@ void AnimationEditor::moveNextWidgets(float dt) s = 1; } } - + } void AnimationEditor::toggleRenderBorders() diff --git a/Aquaria/AquariaComboBox.cpp b/Aquaria/AquariaComboBox.cpp index 84cd7b5..ef47181 100644 --- a/Aquaria/AquariaComboBox.cpp +++ b/Aquaria/AquariaComboBox.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. AquariaComboBox::AquariaComboBox(Vector textscale) : RenderObject() { - //Quad *bar, *window, *scrollBtnUp, *scrollBtnDown, *scrollBar; + bar = new Quad("gui/combo-drop", Vector(0,0)); addChild(bar, PM_POINTER); @@ -120,7 +120,7 @@ void AquariaComboBox::onUpdate(float dt) if (alpha.x < 1) return; - //window->alpha.interpolateTo(1, 0.2); + if (enqueuedSelectItem != -1) { @@ -375,7 +375,7 @@ void AquariaComboBoxItem::onUpdate(float dt) { color = selectedColor; label->color = selectedColor; - //alphaMod = 1; + if (!mb && core->mouse.buttons.left) { mb = true; @@ -396,6 +396,6 @@ void AquariaComboBoxItem::onUpdate(float dt) label->color = unselectedColor; mb = false; - //alphaMod = 0.5; + } } diff --git a/Aquaria/AquariaCompileConfig.h b/Aquaria/AquariaCompileConfig.h index 150ee25..64ea423 100644 --- a/Aquaria/AquariaCompileConfig.h +++ b/Aquaria/AquariaCompileConfig.h @@ -5,7 +5,7 @@ // Define BBGE_SKIP_CONFIG_HEADERS to use CMake-only configuration. #ifndef BBGE_SKIP_CONFIG_HEADERS - //#define AQUARIA_DEMO 1 + #define AQUARIA_BUILD_CONSOLE 1 #define AQUARIA_BUILD_SCENEEDITOR 1 diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index 9f1383b..8271b90 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -77,7 +77,7 @@ void AquariaGuiElement::setCanDirMove(bool on) void AquariaGuiElement::setFocus(bool v) { hasFocus = v; - + if (v) { currentFocus = this; @@ -100,17 +100,11 @@ void AquariaGuiElement::setFocus(bool v) void AquariaGuiElement::updateMovement(float dt) { - //debugLog("in update movement"); + if (hasFocus && isGuiVisible() && canDirMove && canDirMoveGlobal && hasInput()) { - //debugLog("has focus"); - /* - if (alpha.x <= 0 || alphaMod <= 0) - { - setFocus(false); - return; - } - */ + + if (guiMoveTimer > 0) { @@ -162,14 +156,13 @@ void AquariaGuiElement::updateMovement(float dt) if (gui) { gui->setFocus(true); - //this->setFocus(false); - + guiMoveTimer = moveDelay; } } - + if (!gui) { debugLog("updating closest"); @@ -461,21 +454,12 @@ AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetT bg->alphaMod = 0; addChild(bg, PM_POINTER); - /* - label = new BitmapText(&dsq->smallFont); - label->setText("KeyConfig"); - label->parentManagedPointer = 1; - label->position = Vector(0, -10); - label->scale = Vector(0.8, 0.8); - addChild(label); - */ - //keyConfigFont = new DebugFont(6, "keyConfig"); keyConfigFont = new TTFText(&dsq->fontArialSmallest); keyConfigFont->setAlign(ALIGN_CENTER); - //keyConfigFont->position = Vector(0, -10); + addChild(keyConfigFont, PM_POINTER); @@ -523,16 +507,7 @@ void AquariaKeyConfig::toggleEnterKey(int on) bg->alphaMod = 0.5; bg->color = Vector(0.5, 0.5, 0.5); } - /* - if (on) - { - label->scale = Vector(2, 2); - } - else - { - label->scale = Vector(1, 1); - } - */ + } void AquariaKeyConfig::setLock(int lock) @@ -546,9 +521,7 @@ void AquariaKeyConfig::onUpdate(float dt) if (inLoop) return; - - AquariaGuiElement::updateMovement(dt); @@ -562,7 +535,7 @@ void AquariaKeyConfig::onUpdate(float dt) int *k = 0; ActionInput *ai = 0; - + if (inputSetType != INPUTSET_OTHER) { ai = dsq->user.control.actionSet.getActionInputByName(actionInputName); @@ -640,15 +613,8 @@ void AquariaKeyConfig::onUpdate(float dt) { if (i != KEY_ESCAPE) { - /* - if (i == KEY_DELETE || i == KEY_BACKSPACE) - else - { - */ - /* - if (i == KEY_0 || i == KEY_1 || i == KEY_2 || i == KEY_3 || i == KEY_4 || i == KEY_5 || i == KEY_6 || i == KEY_7 - || i == KEY_8 || i == KEY_9) - */ + + if (i >= KEY_0 && i <= KEY_9) { *value = i-KEY_0; @@ -714,7 +680,7 @@ void AquariaKeyConfig::onUpdate(float dt) if (dsq->game->getKeyState(i)) { *k = i; - + while (dsq->game->getKeyState(i)) { dsq->main(0.1); @@ -745,11 +711,11 @@ void AquariaKeyConfig::onUpdate(float dt) } - if (!keyDown && (core->mouse.buttons.left || core->mouse.buttons.right/* || core->getKeyState(KEY_RETURN)*/)) + if (!keyDown && (core->mouse.buttons.left || core->mouse.buttons.right)) { keyDown = true; } - else if (keyDown && (!core->mouse.buttons.left && !core->mouse.buttons.right /*&& !core->getKeyState(KEY_RETURN)*/)) + else if (keyDown && (!core->mouse.buttons.left && !core->mouse.buttons.right )) { keyDown = false; @@ -805,18 +771,15 @@ AquariaMenuItem::AquariaMenuItem() : Quad(), ActionMapper(), AquariaGuiElement() glowFont->position = Vector(0, -sz/2, 0); glowFont->setBlendType(BLEND_ADD); glowFont->alpha = 0; - //glowFont->scale.interpolateTo(Vector(1.1,1.1), 0.5, -1, 1, 1); + addChild(glowFont, PM_POINTER, RBP_OFF); - //setTexture("bubble"); - //this->shareAlphaWithChildren = true; + + width = 0; height = 0; highlighted = false; - /* - width = 256; - height = 64; - */ + cull = false; followCamera = 1; addAction(MakeFunctionEvent(AquariaMenuItem, onClick), ActionMapper::MOUSE_BUTTON_LEFT, 0); @@ -887,10 +850,9 @@ void AquariaMenuItem::onClick() dsq->playMenuSelectSfx(); event.call(); - - //glowFont->scale.interpolateTo(Vector(4,4), 0.5, 1, 1); - //glowFont->alpha.interpolateTo(0, 0.5); - //scale.interpolateTo(Vector(4, 4), 3); + + + } } @@ -899,7 +861,7 @@ void AquariaMenuItem::setLabel(const std::string &label) font->setText(label); glowFont->setText(label); } - + void AquariaMenuItem::toggleHighlight(bool state) { highlighted = state; @@ -913,7 +875,7 @@ void AquariaMenuItem::toggleHighlight(bool state) { glowFont->alpha.interpolateTo(0.3, 0.2); } - //scale.interpolateTo(Vector(1.1, 1.1), 0.2); + } else { @@ -922,11 +884,11 @@ void AquariaMenuItem::toggleHighlight(bool state) else glowFont->alpha.interpolateTo(0, 0.2); } - //scale.interpolateTo(Vector(1,1), 0.2); + } void AquariaMenuItem::onUpdate(float dt) -{ +{ AquariaGuiElement::updateMovement(dt); if (font) @@ -951,16 +913,13 @@ void AquariaMenuItem::onUpdate(float dt) quad->alpha.x = alpha.x; } - /* - font->position = this->position; - font->alpha = this->alpha; - */ + if (hasInput()) { if (alpha.x == 1) { bool on = true; - + if (isCursorInMenuItem()) { @@ -969,9 +928,9 @@ void AquariaMenuItem::onUpdate(float dt) } else on = false; - + if (!on && highlighted) - toggleHighlight(false); + toggleHighlight(false); } else { diff --git a/Aquaria/AquariaMenuItem.h b/Aquaria/AquariaMenuItem.h index ee7a85a..fc8beb4 100644 --- a/Aquaria/AquariaMenuItem.h +++ b/Aquaria/AquariaMenuItem.h @@ -84,7 +84,7 @@ public: bool useQuad(const std::string &tex); void useGlow(const std::string &tex, int w, int h); void useSound(const std::string &tex); - + virtual bool isCursorInMenuItem(); Vector getGuiPosition(); bool isGuiVisible(); @@ -120,7 +120,7 @@ protected: bool selected; static bool closed; bool done; - + int slotIndex; bool empty; Quad *gfx; @@ -168,9 +168,9 @@ public: bool isGuiVisible(); static AquariaKeyConfig *waitingForInput; - + void setLock(int lock); - + protected: int locked; void toggleEnterKey(int on); @@ -179,13 +179,13 @@ protected: bool keyDown; - + std::string actionInputName; InputSetType inputSetType; int inputIdx; - //BitmapText *label; - //DebugFont *keyConfigFont; + + TTFText *keyConfigFont; Quad *bg; }; @@ -247,18 +247,6 @@ protected: std::vector shownItems; }; -/* -class SelectionList : public RenderObject -{ -public: - SelectionList(std::string file, std::string font, int items); - void reload(); - virtual void onSelect(int idx){} -protected: - void load(); - std::vector list; -}; -*/ #endif diff --git a/Aquaria/AquariaSaveSlot.cpp b/Aquaria/AquariaSaveSlot.cpp index 609f64f..33d87d9 100644 --- a/Aquaria/AquariaSaveSlot.cpp +++ b/Aquaria/AquariaSaveSlot.cpp @@ -37,12 +37,8 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad() box->setWidthHeight(450, 96); box->alphaMod = 0; addChild(box, PM_POINTER); - //setTexture("dialogue-bg"); - //setTexture("HintBox"); - //renderQuad = false; - - //shareAlphaWithChildren = 1; + text1 = new BitmapText(&dsq->smallFont); text1->setFontSize(14); @@ -122,7 +118,7 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad() core->resetTimer(); screen->upperLeftTextureCoordinates = Vector(0, 1); screen->lowerRightTextureCoordinates = Vector(1, 0.25); - //screen->scale = Vector(0.4, 0.3); + if (screen->getWidth() == 0) screen->color = 0; @@ -131,7 +127,7 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad() screen->position = Vector(-250, 0) + Vector(-1.5, -1.6); addChild(screen, PM_POINTER); - closed = false; + closed = false; selected = false; } @@ -147,7 +143,7 @@ void AquariaSaveSlot::hide() glowText->alpha.interpolateTo(0, 0.5); box->alpha.interpolateTo(0, 0.5); if (!selected) - { + { screen->alpha.interpolateTo(0, 0.5); } } @@ -155,12 +151,12 @@ void AquariaSaveSlot::hide() void AquariaSaveSlot::close(bool trans) { done = true; - + if (trans) { screen->alpha.interpolateTo(0, 0.1); text1->alpha.interpolateTo(0, 0.1); - + setLife(1); setDecayRate(10); fadeAlphaWithLife = 1; @@ -171,7 +167,7 @@ void AquariaSaveSlot::close(bool trans) setDecayRate(2); fadeAlphaWithLife = 1; } - //shareAlphaWithChildren = 1; + } void AquariaSaveSlot::transition() @@ -204,10 +200,10 @@ void AquariaSaveSlot::onUpdate(float dt) if (core->mouse.position.x < position.x + 150 && core->mouse.position.x > position.x - 300 && core->mouse.position.y < position.y+32 && core->mouse.position.y > position.y-32) { - //setBlendType(BLEND_ADD); + glowText->alpha.interpolateTo(0.5, 0.2); screen->color.interpolateTo(Vector(1,1,1), 0.1); - //screen->scale.interpolateTo(Vector(1.2, 1.2), 0.2); + if ((core->mouse.buttons.left || core->mouse.buttons.right) && !mbDown) { mbDown = true; @@ -218,22 +214,22 @@ void AquariaSaveSlot::onUpdate(float dt) if (!(empty && dsq->saveSlotMode == SSM_LOAD)) { selected = true; - // pick this file - dsq->playMenuSelectSfx(); + + dsq->playMenuSelectSfx(); closed = true; if (dsq->saveSlotMode == SSM_LOAD) { - //dsq->clearSaveSlots(); + dsq->hideSaveSlots(); this->moveToFront(); - //screen->enableMotionBlur(10, 5); + screen->position.interpolateTo(Vector(400-position.x, 300-position.y), 1.0, 0, 0, 1); dsq->tfader->alpha.interpolateTo(1, 1); dsq->toggleCursor(false); core->main(1); - - //core->main(2); + + } bool didIt = dsq->onPickedSaveSlot(this); @@ -241,10 +237,9 @@ void AquariaSaveSlot::onUpdate(float dt) if (didIt) { done = true; - - //alpha = 0.9; - //setBlendType(BLEND_DEFAULT); - //glowText->alpha.interpolateTo(0, 0.2); + + + return; } else @@ -258,7 +253,7 @@ void AquariaSaveSlot::onUpdate(float dt) else { glowText->alpha.interpolateTo(0, 0.2); - //screen->scale.interpolateTo(Vector(1, 1), 0.2); + screen->color.interpolateTo(Vector(0.7, 0.7, 1), 0.3); } if ((core->mouse.buttons.left || core->mouse.buttons.right) && !mbDown) @@ -404,7 +399,7 @@ std::string AquariaSaveSlot::getSaveDescription(const XMLDocument &doc) float s = dsq->continuity.seconds; dsq->continuity.seconds = time; dsq->continuity.getHoursMinutesSeconds(&hours, &minutes, &seconds); - + const char *loccstr = startData->Attribute("sceneDisplayName"); std::string location = (loccstr && *loccstr) ? loccstr : getPrettySceneName_internal(startData); @@ -416,8 +411,8 @@ std::string AquariaSaveSlot::getSaveDescription(const XMLDocument &doc) std::ostringstream os; os << location << std::endl; os << hours << ":" << numToZeroString(minutes, 2) << showLoc; - // << ": " << seconds; - //" T: " << time; + + dsq->continuity.seconds = s; diff --git a/Aquaria/AutoMap.cpp b/Aquaria/AutoMap.cpp index b0e6fad..5e32162 100644 --- a/Aquaria/AutoMap.cpp +++ b/Aquaria/AutoMap.cpp @@ -25,11 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define AUTOMAP_GRIDTILE 512 -//#define FOR(ir,mx) for (int ir=0;iraddTexture("particles/glow"); + setTexture("particles/glow"); paintColor = Vector(1,1,1); @@ -52,17 +52,7 @@ AutoMap::AutoMap() : RenderObject(), ActionMapper() shadowTex = 0; } -/* -void AutoMap::create(const std::string &startMap) -{ - bool done = false; - - while (!done) - { - dsq->game->smallLoadXML("NAIJACAVE"); - } -} -*/ + void AutoMap::destroy() { @@ -84,7 +74,7 @@ void AutoMap::toggle(bool on) { const float t = 0.2; if (on) - { + { autoMapMode = 0; dsq->game->togglePause(true); dsq->fade(1, t); @@ -93,50 +83,17 @@ void AutoMap::toggle(bool on) core->overrideEndLayer = LR_MAX; vis = true; - /* - for (Children::iterator i = children.begin(); i != children.end(); i++) - { - (*i)->safeKill(); - } - Vector c(dsq->game->cameraMax.x/2, dsq->game->cameraMax.y/2); - int drawsz = AUTOMAP_GRIDTILE/TILE_SIZE; - int hsz = drawsz*0.5f; - c *= AUTOMAP_GRIDTILE; - c /= TILE_SIZE; - c += Vector(hsz, hsz); - - FOR(x,MAX_AUTOMAP_GRID) - { - FOR(y,MAX_AUTOMAP_GRID) - { - if (grid[x][y]) - { - Quad *q = new Quad; - q->setTexture("particles/WhiteGlow"); - - float rx = float(x * AUTOMAP_GRIDTILE)/float(TILE_SIZE) + hsz - c.x; - float ry = float(y * AUTOMAP_GRIDTILE)/float(TILE_SIZE) + hsz - c.y; - - q->position = Vector(rx, ry); - q->color = Vector(0,0,0); - addChild(q); - } - } - } - */ - - //alpha.interpolateTo(1, 0.5); alpha = 1; dsq->fade(0, t); - dsq->main(t); + dsq->main(t); } else { dsq->fade(1, t); - dsq->main(t); + dsq->main(t); core->overrideStartLayer = 0; core->overrideEndLayer = 0; @@ -161,7 +118,7 @@ void AutoMap::setGridFromWorld(Vector worldPos, int gridValue) os << "AutoMap::setGridFromWorld - exceeded grid size"; os << "(" << gx <<", " << gy << ")"; debugLog(os.str()); - return; + return; } grid[gx][gy] = gridValue; @@ -169,11 +126,8 @@ void AutoMap::setGridFromWorld(Vector worldPos, int gridValue) void AutoMap::initGrid() { - /* - int xsz = dsq->game->cameraMax.x/200; - int ysz = dsq->game->cameraMax.y/200; - */ - //std::vector grid + + for (int x=0;xgame->avatar) { setGridFromWorld(dsq->game->avatar->position, 0); } - + if (vis && alpha.x == 1) { const float maxScale=1.25, minScale=0.5; blip.update(dt); - /* - static Vector lastHeldPos; - if (core->mouse.buttons.left) - { - if (!lastHeldPos.isZero() && !(core->mouse.position - lastHeldPos).isLength2DIn(32)) - { - Vector diff = core->mouse.position - lastHeldPos; - int len = diff.getLength2D(); - for (int i = 0; i < len; i+=8) - { - paint(lastHeldPos + diff * i); - } - } - else - { - paint(core->mouse.position); - } - lastHeldPos = core->mouse.position; - } - else - { - lastHeldPos = Vector(0,0); - } - */ - //bool c=false; - Vector sTarget=scale; + + Vector sTarget=scale; float spd = 0.5; if (core->mouse.scrollWheelChange < 0) { @@ -261,7 +191,7 @@ void AutoMap::onUpdate(float dt) { offset += core->mouse.change*scale; } - //scale.interpolateTo(sTarget, 0.1); + } } @@ -275,39 +205,31 @@ void AutoMap::lmb() void AutoMap::onRender() { -// if (!doRender) return; + if (alpha.x == 0) return; -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, 0); RenderObject::lastTextureApplied = 0; float alphaValue = alpha.x; - - - //int sz2 = 80;//80; + int ysz = dsq->game->cameraMax.y/TILE_SIZE; int xsz = dsq->game->cameraMax.x/TILE_SIZE; - //TileVector t(dsq->game->avatar->position); + TileVector t(Vector(dsq->game->cameraMax.x/2, dsq->game->cameraMax.y/2)); int skip = 4; glLineWidth(skip); - + if (alphaValue > 0) { - /* - if (core->getWindowHeight() == 600) - { - skip = 2; - } - */ - //for (int y = t.y-sz2; y < t.y+sz2; y+=skip) + + for (int y = 0; y < ysz; y += skip) { float f = float(y)/float(ysz); @@ -317,12 +239,12 @@ void AutoMap::onRender() glBegin(GL_LINES); int rowStart = -1; int x = 0; - //for (x = t.x-sz2; x < t.x+sz2; x++) + for (x = 0; x < xsz; x++) { if (dsq->game->getGrid(TileVector(x,y))!=OT_BLACK) { - if (rowStart == -1) + if (rowStart == -1) { rowStart = x; } @@ -345,45 +267,8 @@ void AutoMap::onRender() glEnd(); } - /* - glColor4f(0,0,0,alphaValue); - glPointSize(8); - //shadowTex->apply(); - glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - int rx=0,ry=0; - int sz = (AUTOMAP_GRIDTILE/TILE_SIZE)*0.5f; - for (int x = 0; x < MAX_AUTOMAP_GRID; x++) - { - for (int y = 0; y < MAX_AUTOMAP_GRID; y++) - { - if (grid[x][y]) - { - rx = float(x * AUTOMAP_GRIDTILE)/float(TILE_SIZE) + TILE_SIZE/2 - t.x; - ry = float(y * AUTOMAP_GRIDTILE)/float(TILE_SIZE) + TILE_SIZE/2 - t.y; - //glVertex2f(rx, ry); - glTexCoord2f(0, 1.0); - glVertex3f(rx-sz, ry+sz, 0.0f); - glTexCoord2f(0, 1.0); - glVertex3f(rx+sz, ry+sz, 0.0f); - - glTexCoord2f(1, 0); - glVertex3f(rx+sz, ry-sz, 0.0f); - - glTexCoord2f(1, 0); - glVertex3f(rx-sz, ry-sz, 0.0f); - } - } - } - glEnd(); - */ - /* - shadowTex->unbind(); - glDisable(GL_TEXTURE_2D); - */ - //glDisable(GL_TEXTURE_2D); } TileVector nt(dsq->game->avatar->position); @@ -399,7 +284,6 @@ void AutoMap::onRender() glColor4f(0.5,0.75,1, alphaValue*0.5f); drawCircle(blip.x*16, 8); -#endif } diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index eddce96..20a6b12 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -26,17 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Shot.h" #include "GridRender.h" -//#include "CommonEvents.h" - -//#include - -//#define AQ_TEST_QUADTRAIL - -#ifdef AQ_TEST_QUADTRAIL - #include "QuadTrail.h" - - static QuadTrail *quadTrail = 0; -#endif const float MULT_DMG_CRABCOSTUME = 0.75; const float MULT_DMG_FISHFORM = 1.5; @@ -165,7 +154,7 @@ void Avatar::bindInput() dsq->user.control.actionSet.importAction(this, "SongSlot8", ACTION_SONGSLOT8); dsq->user.control.actionSet.importAction(this, "SongSlot9", ACTION_SONGSLOT9); dsq->user.control.actionSet.importAction(this, "SongSlot10", ACTION_SONGSLOT10); - + dsq->user.control.actionSet.importAction(this, "Look", ACTION_LOOK); /* @@ -174,7 +163,7 @@ void Avatar::bindInput() dsq->user.control.actionSet.importAction(this, "SongSlot7", "f7"); dsq->user.control.actionSet.importAction(this, "SongSlot8", "f8"); */ - + dsq->user.control.actionSet.importAction(this, "Roll", ACTION_ROLL); /* @@ -1091,7 +1080,7 @@ void Avatar::onDamage(DamageData &d) core->sound->playSfx("Poison"); else core->sound->playSfx("Pain"); - + setHeadTexture("Pain", 1); @@ -1151,7 +1140,7 @@ void Avatar::onDamage(DamageData &d) dsq->emote.playSfx(EMOTE_NAIJALOW); dsq->game->hasPlayedLow = 1; } - + dsq->gameSpeed.ensureData(); dsq->gameSpeed.data->path.clear(); @@ -1639,7 +1628,7 @@ void Avatar::changeForm(FormType form, bool effects, bool onInit, FormType lastF refreshModel("FishForm", ""); //rotationOffset.interpolateTo(Vector(0,0,-90), 0.5); //refreshModel("NaijaFish", ""); - + collideRadius = COLLIDE_RADIUS_FISH; setCanLockToWall(false); setCollisionAvoidanceData(COLLIDE_RANGE_FISH, COLLIDE_MOD_FISH); @@ -1970,7 +1959,7 @@ void Avatar::updateTargets(float dt, bool override) // crappy hack for now, assuming one target: targets.clear(); - + Vector dir = getAim(); Vector checkPos = position + dir; Vector distPos = position; @@ -1991,7 +1980,7 @@ void Avatar::updateTargets(float dt, bool override) if (!override && core->mouse.buttons.right) { maxTargetDelay = 90; - + dsq->spawnParticleEffect("TargetAquired", t.pos); wasDown = true; } @@ -2048,7 +2037,7 @@ void Avatar::updateTargetQuads(float dt) /* for (int i = 0; i < targetQuads.size(); i++) { - + } */ @@ -2104,7 +2093,7 @@ void Avatar::updateTargetQuads(float dt) //targetQuads[i]->position.interpolateTo(dsq->getGameCursorPosition(),tt); /* std::ostringstream os; - os << "setting targetQuads[i] to game cursor, is running = " << targetQuads[i]->isRunning(); + os << "setting targetQuads[i] to game cursor, is running = " << targetQuads[i]->isRunning(); debugLog(os.str()); */ @@ -2290,7 +2279,7 @@ bool Avatar::fireAtNearestValidEntity(const std::string &shot) { checkUpgradeForShot(s); - + skeletalSprite.transitionAnimate("fireBlast", 0.1, 0, ANIMLAYER_ARMOVERRIDE); s->position = p; @@ -2371,9 +2360,9 @@ void Avatar::formAbility(int ability) { if (dsq->continuity.dualFormMode == Continuity::DUALFORM_NAIJA) { - + // ~~~~~~~~~~ SOUL SCREAM - + if (chargeLevelAttained == 1) { if (dsq->continuity.dualFormCharge >= requiredDualFormCharge) @@ -2869,7 +2858,7 @@ int Avatar::getNumShots() void Avatar::doShock(const std::string &shotName) { - + int c = 0; //int maxHit = 2 + dsq->continuity.getSpellLevel(SPELL_SHOCK)*2; @@ -2950,7 +2939,6 @@ void Avatar::doShock(const std::string &shotName) - if (sz == 0) { for (int i = 0; i < thits; i++) @@ -3443,7 +3431,7 @@ void Avatar::lockToWall() { if (!dsq->mod.isActive() && !dsq->continuity.getFlag("lockedToWall")) { - + if (!dsq->game->isControlHint()){ dsq->continuity.setFlag("lockedToWall", 1); dsq->game->setControlHint(dsq->continuity.stringBank.get(13), 1, 0, 0, 6, "", true); @@ -3649,15 +3637,9 @@ void Avatar::clearWeb() Avatar::Avatar() : Entity(), ActionMapper() { canDie = true; - + urchinDelay = 0; jellyDelay = 0; -#ifdef AQ_TEST_QUADTRAIL - quadTrail = new QuadTrail(100, 32); - quadTrail->setTexture("Particles/QuadTrail"); - quadTrail->setBlendType(BLEND_ADD); - dsq->game->addRenderObject(quadTrail, LR_PARTICLES); -#endif curWebPoint = 0; @@ -3842,18 +3824,18 @@ Avatar::Avatar() : Entity(), ActionMapper() { targetQuads[i] = new ParticleEffect; /* - targetQuads[i]->setTexture("missingImage"); + targetQuads[i]->setTexture("missingImage"); targetQuads[i]->alpha = 0; */ targetQuads[i]->load("EnergyBlastTarget"); // HACK: should have its own layer? dsq->game->addRenderObject(targetQuads[i], LR_PARTICLES); - } + } lightFormGlow = new Quad("Naija/LightFormGlow", 0); lightFormGlow->alpha = 0; - + lightFormGlow->scale.interpolateTo(Vector(5.5, 5.5), 0.4, -1, 1); //lightFormGlow->positionSnapTo = &position; dsq->game->addRenderObject(lightFormGlow, LR_ELEMENTS13); @@ -4218,7 +4200,7 @@ void Avatar::startWallBurst(bool useCursor) wallPushVec = wallNormal; else { - wallPushVec = (goDir*0.5f + wallNormal*0.5f); + wallPushVec = (goDir*0.5f + wallNormal*0.5f); } } //wallPushVec = (goDir*0.9f + wallNormal*0.1f); @@ -4297,7 +4279,7 @@ Vector Avatar::getVectorToCursor(bool trueMouse) { //return getVectorToCursorFromScreenCentre(); Vector pos = dsq->getGameCursorPosition(); - + if (!trueMouse && dsq->inputMode != INPUT_MOUSE) return getFakeCursorPosition(); @@ -4775,7 +4757,7 @@ void Avatar::setHeadTexture(const std::string &name, float time) if (dsq->continuity.form == FORM_NORMAL /*&& dsq->continuity.costume.empty()*/) { if (!name.empty() && (nocasecmp(lastHeadTexture, "singing")==0)) return; - + lastHeadTexture = name; stringToUpper(lastHeadTexture); std::string t = "Naija/"; @@ -5044,7 +5026,7 @@ void Avatar::updateRoll(float dt) stopRoll(); } } - + if (!_isUnderWater && isActing(ACTION_ROLL)) { stopRoll(); @@ -5090,7 +5072,7 @@ void Avatar::updateRoll(float dt) if (rollDelay <= 0) stopRoll(); } - + if (isActing(ACTION_ROLL)) { if (_isUnderWater) @@ -5109,7 +5091,7 @@ void Avatar::updateRoll(float dt) rotation.z -= amt; } rotation.capRotZ360(); - + rollDelay = 1.0; } } @@ -5418,9 +5400,6 @@ void Avatar::onUpdate(float dt) looking = 0; -#ifdef AQ_TEST_QUADTRAIL - quadTrail->addPoint(position); -#endif if (lightFormGlow) { @@ -5476,7 +5455,7 @@ void Avatar::onUpdate(float dt) curWebPoint = web->addPoint(position); } } - + if (!dsq->game->isPaused() && isActing(ACTION_LOOK) && !dsq->game->avatar->isSinging() && dsq->game->avatar->isInputEnabled() && !dsq->game->isInGameMenu()) { looking = 1; @@ -5623,7 +5602,7 @@ void Avatar::onUpdate(float dt) core->sound->playSfx("NaijaGasp"); core->main(0.75); - + dsq->voiceOnce("Naija_VeilCrossing"); core->main(10*0.1f); @@ -6102,7 +6081,7 @@ void Avatar::onUpdate(float dt) jellyDelay -= dt; if (jellyDelay < 0) { - jellyDelay = JELLYCOSTUME_HEALDELAY; + jellyDelay = JELLYCOSTUME_HEALDELAY; Vector d; if (!vel.isZero()) @@ -6213,7 +6192,7 @@ void Avatar::onUpdate(float dt) bool isMovingSlow = false; float len = 0; - + if (dsq->isMiniMapCursorOkay() && !isActing(ACTION_ROLL) && _isUnderWater && !riding && !boneLock.on && (movingOn || ((dsq->inputMode == INPUT_JOYSTICK || dsq->inputMode== INPUT_KEYBOARD) || (core->mouse.buttons.left || bursting)))) @@ -6797,7 +6776,7 @@ void Avatar::onUpdate(float dt) //debugLog("above water bounce"); - + Vector n = getWallNormal(TileVector(lastPosition)); n *= vel.getLength2D(); @@ -6816,7 +6795,7 @@ void Avatar::onUpdate(float dt) if (vel.y < 0) { //debugLog("Vel less than 0"); - + } if (vel.y == 0) { @@ -6827,14 +6806,14 @@ void Avatar::onUpdate(float dt) if (vel.isLength2DIn(500)) vel.setLength2D(500); - + vel.capLength2D(800); position = lastPosition; this->doCollisionAvoidance(1, 4, 0.5, 0, 500); - + /* vel = -vel; if (vel.y < 0) diff --git a/Aquaria/Avatar.h b/Aquaria/Avatar.h index aa90524..ccdee0e 100644 --- a/Aquaria/Avatar.h +++ b/Aquaria/Avatar.h @@ -118,7 +118,7 @@ public: bool blind; bool wasUnderWater; float shotDelay; - //Timer shockTimer; + Timer useItemDelay; Timer lockToWallDelay; float spellCharge; @@ -146,7 +146,7 @@ public: float burstDelay; bool bursting; BurstType lastBurstType; - //void damage(int amount); + bool isCharging(); void setBlind(float time); @@ -265,7 +265,7 @@ public: float songInterfaceTimer; void removeEatData(int idx); - //std::listbittenEntities; + typedef std::list BittenEntities; BittenEntities bittenEntities; Target getNearestTarget(const Vector &checkPos, const Vector &distPos, Entity *source, DamageType dt, bool override=false, std::vector *ignore=0, EntityList *entityList=0); @@ -306,7 +306,7 @@ public: float rollDelay; bool canSetBoneLock(); - + void revert(); void doBindSong(); void doShieldSong(); @@ -333,7 +333,7 @@ public: float elementEffectMult; bool blockBackFlip; - + protected: void setSongIconPositions(); @@ -386,7 +386,7 @@ protected: void updateCursor(float dt); bool rolling; int rollDidOne; - + void startRoll(int dir); void stopRoll(); int getQuadrantDirection(int lastQuad, int quad); @@ -431,9 +431,9 @@ protected: bool checkWarpAreas(); float splashDelay; - //Hair *hair; - //Item *currentItem; + + void onUpdate(float dt); void onRender(); diff --git a/Aquaria/Beam.cpp b/Aquaria/Beam.cpp index 6f31c6b..b754fdb 100644 --- a/Aquaria/Beam.cpp +++ b/Aquaria/Beam.cpp @@ -31,7 +31,7 @@ Beam::Beam(Vector pos, float angle) : Quad() addType(SCO_BEAM); cull = false; trace(); - //rotation.z = angle; + this->angle = angle; position = pos; @@ -91,17 +91,13 @@ void Beam::killAllBeams() void Beam::trace() { float angle = MathFunctions::toRadians(this->angle); - //(float(-this->angle)/180.0f)*PI; - //float angle = rotation.z; + + Vector mov(sinf(angle), cosf(angle)); TileVector t(position); Vector startTile(t.x, t.y); - /* - std::ostringstream os; - os << "rotation.z = " << rotation.z << " mov(" << mov.x << ", " << mov.y << ")"; - debugLog(os.str()); - */ + int moves = 0; while (!dsq->game->isObstructed(TileVector(startTile.x, startTile.y))) @@ -114,38 +110,24 @@ void Beam::trace() t = TileVector(startTile.x, startTile.y); endPos = t.worldVector(); - /* - offset = endPos - position; - offset /= 2; - offset *= -1; - */ - //width = (endPos - position).getLength2D(); } void Beam::render() { - /* - glLineWidth(4); - glColor4f(1,1,1,1); - glBegin(GL_LINES); - glVertex2f(position.x, position.y); - glVertex2f(endPos.x, endPos.y); - glEnd(); - */ + Quad::render(); } void Beam::onRender() { -#ifdef BBGE_BUILD_OPENGL - //glDisable(GL_CULL_FACE); + Vector diff = endPos - position; Vector side = diff; - //side.normalize2D(); + side.setLength2D(beamWidth*2); Vector sideLeft = side.getPerpendicularLeft(); Vector sideRight = side.getPerpendicularRight(); @@ -160,7 +142,6 @@ void Beam::onRender() glTexCoord2f(0, 1); glVertex2f(sideRight.x, sideRight.y); glEnd(); -#endif } void Beam::onUpdate(float dt) diff --git a/Aquaria/BitBlotLogo.cpp b/Aquaria/BitBlotLogo.cpp index 6747d0f..f94573e 100644 --- a/Aquaria/BitBlotLogo.cpp +++ b/Aquaria/BitBlotLogo.cpp @@ -32,39 +32,31 @@ bool BitBlotLogo::watchQuit(float time) { core->main(time); return false; -/* - dsq->watch(time); - if (quitFlag > 0) - { - skipLogo(); - return true; - } - return false; -*/ + } void BitBlotLogo::doShortBitBlot() { dsq->overlay->color = Vector(0,0,0); dsq->overlay->alpha = 0; - + dsq->overlay2->color = Vector(1,1,1); dsq->overlay2->alpha = 1; dsq->overlay2->alpha.interpolateTo(0, 0.25); - + Quad *bg = new Quad; bg->setWidthHeight(800, 600); bg->position = Vector(400,300); bg->followCamera = 1; addRenderObject(bg, LR_HUD); - + Quad *logo = new Quad("BitBlot/Logo.png", Vector(400,300)); logo->followCamera = 1; logo->scale = Vector(0.6,0.6); addRenderObject(logo, LR_HUD); - + core->main(1.5); - + dsq->overlay2->alpha.interpolateTo(1, 0.5); core->main(0.5); } @@ -78,7 +70,7 @@ void BitBlotLogo::skipLogo() void BitBlotLogo::getOut() { - //dsq->continuity.reset(); + #ifdef AQUARIA_DEMO dsq->title(); @@ -91,17 +83,17 @@ void BitBlotLogo::getOut() } void BitBlotLogo::applyState() -{ +{ StateObject::applyState(); quitFlag = 0; logo = 0; dsq->toggleCursor(0); dsq->toggleBlackBars(1); - //dsq->setBlackBarsColor(Vector(1,1,1)); + dsq->jiggleCursor(); - + dsq->forceInputGrabOff(); - + if (dsq->user.demo.shortLogos) { skipLogo(); @@ -109,7 +101,7 @@ void BitBlotLogo::applyState() } logo = 1; - + if (core->getKeyState(KEY_ESCAPE)) { skipLogo(); @@ -127,7 +119,7 @@ void BitBlotLogo::applyState() landscape->followCamera = 1; landscape->alpha = 1; landscape->shareAlphaWithChildren = 1; - + for (int i = 2; i < 5 + rand()%10; i++) { @@ -143,7 +135,7 @@ void BitBlotLogo::applyState() bird->update((rand()%100)*0.1f); } - //if (true) + if (rand()%100 < 40) { SkeletalSprite *dragon = new SkeletalSprite(); @@ -161,7 +153,7 @@ void BitBlotLogo::applyState() } std::vector windmills; - int numWindmills = rand()%3; + int numWindmills = rand()%3; for (int i = 0; i < numWindmills; i++) { SkeletalSprite *windmill = new SkeletalSprite(); @@ -215,7 +207,7 @@ void BitBlotLogo::applyState() logob->scale = Vector(0.6, 0.6); logob->offset = Vector(-4, 0); logob->offset.interpolateTo(Vector(4,0), 0.05, -1, 1); - + addRenderObject(logob, LR_ENTITIES); RenderObject *lines = new RenderObject(); @@ -254,12 +246,12 @@ void BitBlotLogo::applyState() dsq->overlay->alpha.interpolateTo(0, 1); - //sound->playSfx("BBSplash"); + sound->playMusic("bblogo", SLT_NONE); if (watchQuit(1.0)) return; - //sound->playSfx("normalform"); + dsq->overlay2->color = Vector(1,1,1); @@ -272,23 +264,20 @@ void BitBlotLogo::applyState() sound->playSfx("normalform"); - //landscape->alpha.interpolateTo(1, 2); + white->alpha.interpolateTo(0, 2); landscape->position.interpolateTo(Vector(400,400), 5); - /* - if (core->afterEffectManager) - core->afterEffectManager->addEffect(new ShockEffect(Vector(core->width/2, core->height/2),core->screenCenter, 0.1,0.03,30,0.2f, 0.5)); - */ + landscape->scale.interpolateTo(Vector(1.1, 1.1), 5); scanline->alpha.interpolateTo(0, 1); - //scanline->scale.interpolateTo(Vector(5, 5), 1); + logo->scale.interpolateTo(Vector(2, 2), 1); - //logo->offset.interpolateTo(Vector(0, -300), 1); + logo->alpha.interpolateTo(0, 1); lines->alpha.interpolateTo(0, 4); @@ -300,36 +289,12 @@ void BitBlotLogo::applyState() dsq->overlay2->alpha.interpolateTo(1, 2); if (watchQuit(2.0)) return; - - + + getOut(); - /* - // BOING - dsq->toggleCursor(0); - Quad *logo = new Quad("BitBlot/Logo.png", Vector(400,300)); - logo->followCamera = 1; - addRenderObject(logo); - //logo->scale = Vector(0.6, 0.6); - logo->scale = Vector(0, 0); - core->setClearColor(Vector(1,1,1)); - dsq->overlay->alpha = 1; - dsq->overlay->alpha.interpolateTo(0, 1); - core->main(0.5); - logo->scale.path.addPathNode(Vector(0,0), 0); - logo->scale.path.addPathNode(Vector(0,0), 0.4); - logo->scale.path.addPathNode(Vector(1.2,1.2), 0.8); - logo->scale.path.addPathNode(Vector(1.0, 1.0), 0.85); - logo->scale.path.addPathNode(Vector(1.1, 1.1), 0.95); - logo->scale.path.addPathNode(Vector(1,1), 1.0); - logo->scale.startPath(1); - core->main(2); - - dsq->overlay->alpha.interpolateTo(1, 1.5); - core->main(1.5); - */ } void BitBlotLogo::removeState() @@ -341,15 +306,7 @@ void BitBlotLogo::removeState() void BitBlotLogo::update(float dt) { StateObject::update(dt); - - /* - if (quitFlag == 0) - { - if (core->getKeyState(KEY_ESCAPE)) - { - quitFlag = 1; - } - } - */ + + } diff --git a/Aquaria/CollideEntity.cpp b/Aquaria/CollideEntity.cpp index 876fb73..717fe8d 100644 --- a/Aquaria/CollideEntity.cpp +++ b/Aquaria/CollideEntity.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "CollideEntity.h" #include "DSQ.h" #include "Game.h" -//#include "ParticleEffects.h" + CollideEntity::CollideEntity() : Entity() { @@ -51,7 +51,7 @@ void CollideEntity::bounce(float ba) if (getState() == STATE_PUSH) { dsq->spawnParticleEffect("HitSurface", dsq->game->lastCollidePosition); - //dsq->effectCollisionSmoke(position); + sound("RockHit"); // HACK: replace damage function //damage(pushDamage); @@ -64,13 +64,13 @@ void CollideEntity::bounce(float ba) { if (!vel.isZero()) { - float len = vel.getLength2D(); + float len = vel.getLength2D(); Vector I = vel/len; - Vector N = dsq->game->getWallNormal(dsq->game->lastCollidePosition); + Vector N = dsq->game->getWallNormal(dsq->game->lastCollidePosition); if (!N.isZero()) { - //2*(-I dot N)*N + I + vel = 2*(-I.dot(N))*N + I; vel.setLength2D(len*ba); } @@ -94,25 +94,19 @@ void CollideEntity::bounce(float ba) } break; } - //mov.setLength2D(-len * ba); + onBounce(); } void CollideEntity::updateMovement(float dt) -{ +{ if (isEntityDead()) return; if (position.isFollowingPath()) return; vel.capLength2D(getMaxSpeed()*maxSpeedLerp.x); - /* - if (vel.getSquaredLength2D() > sqr(getMaxSpeed())) - { - vel.setLength2D(getMaxSpeed()); - vel.z = 0; - } - */ - //Vector lastPos = pos; + + updateVel2(dt); @@ -132,27 +126,13 @@ void CollideEntity::updateMovement(float dt) { position.y = dsq->game->getWaterLevel()+collideRadius; } - + } } - /* - if (!canLeaveWater) - { - if (waterBubble) - { - } - else - { - if (position.y-collideRadius < dsq->game->getWaterLevel()) - { - - } - } - } - */ + bool collided = false; - + if (vel.x != 0 || vel.y != 0) { @@ -161,8 +141,8 @@ void CollideEntity::updateMovement(float dt) if (isv(EV_COLLIDELEVEL,1)) { - - + + bool doesFreeRange = !isPullable(); if (doesFreeRange) @@ -174,8 +154,8 @@ void CollideEntity::updateMovement(float dt) } } } - - //Vector lastPosition = lastPos; + + Vector newPosition = position + (getMoveVel() * dt); position = newPosition; @@ -191,7 +171,7 @@ void CollideEntity::updateMovement(float dt) } } else - { + { if (!freeRange && ((!canLeaveWater && !isUnderWater() && wasUnderWater) || dsq->game->collideCircleWithGrid(position, hw))) { position = lastPosition; @@ -211,7 +191,7 @@ void CollideEntity::updateMovement(float dt) { attachedEntities[i]->position = this->position + attachedEntitiesOffsets[i]; attachedEntities[i]->rotation = this->rotation; - } + } wasUnderWater = underWater; } diff --git a/Aquaria/CollideEntity.h b/Aquaria/CollideEntity.h index 48e9885..556036e 100644 --- a/Aquaria/CollideEntity.h +++ b/Aquaria/CollideEntity.h @@ -30,15 +30,15 @@ public: virtual ~CollideEntity(); float bounceAmount; float weight; - void updateMovement(float dt); + void updateMovement(float dt); void entityDied(Entity *e); -protected: +protected: virtual void onHitWall(){} void onUpdateFrozen(float dt); - + virtual void onBounce() {} void bounce(float ba); - + }; #endif diff --git a/Aquaria/Continuity.cpp b/Aquaria/Continuity.cpp index 6e035a7..0cebb8b 100644 --- a/Aquaria/Continuity.cpp +++ b/Aquaria/Continuity.cpp @@ -304,11 +304,7 @@ void Continuity::sortFood() switch (dsq->continuity.foodSortType) { - /* - case FOODSORT_UNSORTED: - sortOrder = sortByUnsort; - break; - */ + case FOODSORT_BYTYPE: sortOrder = sortByType; break; @@ -321,8 +317,7 @@ void Continuity::sortFood() } - //IngredientData *plantLeaf = dsq->continuity.getIngredientHeldByName("PlantLeaf"); - //int oldHeld = plantLeaf->held; + if (doSort) { @@ -391,11 +386,11 @@ void Continuity::sortFood() ingredients.push_back(sort[i]); } sort.clear(); - //dsq->continuity.ingredients = sort; + } - //IngredientData *plantLeaf2 = dsq->continuity.getIngredientHeldByName("PlantLeaf"); - //int newHeld = plantLeaf2->held; + + } void Continuity::setRegen(float t) @@ -564,7 +559,7 @@ std::string Continuity::getIEString(IngredientData *data, int i) os << dsq->continuity.stringBank.get(210); os << " " << dsq->continuity.stringBank.get(205) << " " << (fx.magnitude*5) << " " << dsq->continuity.stringBank.get(203); return os.str(); - //return dsq->continuity.stringBank.get(210); + break; case IET_ENERGY: os << dsq->continuity.stringBank.get(211) << " " << fx.magnitude; @@ -829,7 +824,7 @@ bool Continuity::applyIngredientEffects(IngredientData *data) dsq->centerMessage(getIEString(data, i), y); dsq->continuity.setWeb(webTime); - //dsq->centerMessage(dsq->continuity.stringBank.get(216), y); + } break; case IET_ALLSTATUS: @@ -1477,8 +1472,8 @@ void Continuity::castSong(int num) os << "Could not find song with index [" << num << "]"; debugLog(os.str()); } - //float et = 0.5; - //float et = 10; + + float et = 0.5; std::ostringstream os; os << "Song/SongSlot-" << dsq->continuity.getSongSlotByType(num); @@ -1487,7 +1482,7 @@ void Continuity::castSong(int num) effect->setTexture(os.str()); effect->position = selected->position + selected->offset; effect->scale.interpolateTo(Vector(3,3), et); - //effect->setBlendType(RenderObject::BLEND_ADD); + effect->alpha.ensureData(); effect->alpha.data->path.addPathNode(0, 0); effect->alpha.data->path.addPathNode(0.5, 0.1); @@ -1536,12 +1531,7 @@ void Continuity::castSong(int num) sound->playSfx("Heal"); selected->heal(2); - /* - Wynia *wynia = new Wynia; - wynia->trackTo(selected); - wynia->position = selected->position; - core->getTopStateData()->addRenderObject(wynia, PROJECTILES); - */ + selected->skeletalSprite.animate("healSelf", 0, 1); break; case SONG_TIME: @@ -1575,7 +1565,7 @@ void Continuity::castSong(int num) { if (!dsq->game->avatar->isNearObstruction(2) && !dsq->game->avatar->state.lockedToWall && !(dsq->game->li->position - dsq->game->avatar->position).isLength2DIn(400)) { - //dsq->game->avatar->disableInput(); + dsq->overlay->color = Vector(1,1,1); dsq->fade(1, 0.3); dsq->main(0.3); @@ -1583,7 +1573,7 @@ void Continuity::castSong(int num) dsq->fade(0, 0.3); dsq->main(0.3); dsq->overlay->color = 0; - //dsq->game->avatar->enableInput(); + } else if ((dsq->game->li->position - dsq->game->avatar->position).isLength2DIn(500)) { @@ -1597,13 +1587,7 @@ void Continuity::castSong(int num) { core->sound->playSfx("Denied"); } - /* - } - else - { - core->sound->playSfx("SongFail"); - } - */ + } else { @@ -1785,12 +1769,8 @@ loop: // make sure last note is more or less close if (song.notes.size()-last < 2) { - //rank += song.size()-last; - /* - std::ostringstream os; - os << "songCheck: " << songChecks[i].songIdx << " completed with rank " << rank; - debugLog(os.str()); - */ + + songChecks[i].pass = true; songChecks[i].rank = rank; @@ -1813,11 +1793,7 @@ loop: } } - /* - std::ostringstream os; - os << "lowest rank: " << lowestRank; - debugLog(os.str()); - */ + return songIdx; } @@ -1835,7 +1811,7 @@ int Continuity::checkSong(const Song &song) Song *s = &songBank[i]; if (s->notes.empty()) continue; int j = 0; - //if (s->size() == song.size()) + { bool foundSong = false; int currentNote = 0; @@ -1867,7 +1843,7 @@ int Continuity::checkSong(const Song &song) } } if (j != song.notes.size()-1) foundSong = false; - //if (j == s->size()) + if (foundSong) { return i; @@ -1910,7 +1886,7 @@ void Continuity::update(float dt) statsAndAchievements->RunFrame(); } - if (dsq->game->isActive() && !dsq->game->isPaused() /*&& !(getWorldType() == WT_SPIRIT)*/) + if (dsq->game->isActive() && !dsq->game->isPaused() ) { if (liPowerTimer.updateCheck(dt)) @@ -2011,18 +1987,14 @@ void Continuity::update(float dt) if (regenTimer.isActive()) { - /* - static float regenBit = 0; - regenBit += dt; - if (regenBit > 1) - */ + { Avatar *a = dsq->game->avatar; if (a) { a->heal(dt*0.5f); } - //regenBit = 0; + } } } @@ -2104,17 +2076,14 @@ void Continuity::applyWorldEffects(WorldType type, bool transition, bool affectM { core->postProcessingFx.blendType = 1; core->postProcessingFx.intensity = 0.2f; - core->postProcessingFx.layer = LR_AFTER_EFFECTS;//LR_AFTER_EFFECTS; + core->postProcessingFx.layer = LR_AFTER_EFFECTS; core->postProcessingFx.renderLayer = LR_AFTER_EFFECTS; core->postProcessingFx.enable(FXT_RADIALBLUR); } dsq->game->avatar->canWarp = false; - /* - if (affectMusic) - dsq->sound->toggleEffects(1); - */ + dsq->game->backupSceneColor = dsq->game->sceneColor; dsq->game->sceneColor.interpolateTo(Vector(0.4, 0.8, 0.9), time); dsq->game->avatar->applyWorldEffects(type); @@ -2124,23 +2093,15 @@ void Continuity::applyWorldEffects(WorldType type, bool transition, bool affectM dsq->game->avatar->canWarp = true; core->postProcessingFx.disable(FXT_RADIALBLUR); - //worldType = WT_SPIRIT; - /* - if (affectMusic) - dsq->sound->toggleEffects(0); - */ - //dsq->game->sceneColor.interpolateTo(dsq->game->backupSceneColor, time); + + + dsq->game->sceneColor.interpolateTo(Vector(1,1,1), time); dsq->game->avatar->applyWorldEffects(type); } if (time > 0) { - /* - dsq->game->avatar->slowToRest(); - dsq->game->avatar->disableInput(); - core->main(time); - dsq->game->avatar->enableInput(); - */ + } worldType = type; } @@ -2291,12 +2252,7 @@ void Continuity::setFlag(std::string flag, int v) flags[flag] = v; } -/* -void Continuity::setActivePet(int flag) -{ - setFlag(FLAG_ACTIVEPET, flag); -} -*/ + void Continuity::loadPetData() { @@ -2474,7 +2430,6 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData, } worldMap->SetAttribute("b", os.str().c_str()); -#ifdef AQUARIA_BUILD_MAPVIS if (dsq->game->worldMapRender) { std::ostringstream os; @@ -2487,7 +2442,6 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData, } worldMap->SetAttribute("va", os.str().c_str()); } -#endif } doc.InsertEndChild(worldMap); @@ -2789,20 +2743,7 @@ void Continuity::loadFile(int slot) e = e->NextSiblingElement("Flag"); } - /* - if (debugEntityflags) - { - for (EntityFlags::iterator i = entityFlags.begin(); i != entityFlags.end(); i++) - { - if ((*i).first == name) - { - std::ostringstream os; - os << "Duplicate entity flag: " << name << " please report this error"; - errorLog(os.str()); - } - } - } - */ + XMLElement *efx = doc.FirstChildElement("EFX"); if (efx) @@ -3018,7 +2959,6 @@ void Continuity::loadFile(int slot) } -#ifdef AQUARIA_BUILD_MAPVIS if (worldMap->Attribute("va") && dsq->continuity.worldMap.getNumWorldMapTiles()) { std::istringstream is(worldMap->Attribute("va")); @@ -3027,7 +2967,7 @@ void Continuity::loadFile(int slot) int idx; - //worldMapTiles.clear(); + while (is >> idx) { @@ -3044,7 +2984,6 @@ void Continuity::loadFile(int slot) tile->stringToData(is); } } -#endif } @@ -3322,13 +3261,7 @@ void Continuity::loadFile(int slot) void Continuity::setNaijaModel(std::string model) { - /* - naijaModel = model; - if (dsq->game->avatar) - { - dsq->game->avatar->refreshModel(); - } - */ + } int Continuity::getFlag(int flag) @@ -3404,7 +3337,7 @@ public: timer = 0; - //GemGet *q = this; + setTexture("Gems/" + gem); @@ -3424,11 +3357,7 @@ public: setLife(timeScale+0.1f); setDecayRate(1); - /* - q->position.path.addPathNode(Vector(400,400), 0.6); - q->position.path.addPathNode(dsq->game->miniMapRender->position, 0.9); - q->position.startPath(t); - */ + } protected: float timer; @@ -3496,26 +3425,7 @@ GemData *Continuity::pickupGem(std::string name, bool effects) GemGet *gg = new GemGet(g.name); dsq->game->addRenderObject(gg, LR_MINIMAP); - /* - Quad *q = new Quad; - q->setTexture("Gems/" + g.name); - q->followCamera = 1; - q->scale = Vector(0, 0); - q->scale.path.addPathNode(Vector(0,0), 0); - q->scale.path.addPathNode(Vector(1,1), 0.3); - q->scale.path.addPathNode(Vector(1,1), 0.6); - q->scale.path.addPathNode(Vector(0.5,0.5), 0.9); - q->scale.path.addPathNode(Vector(0.1,0.1), 1); - q->scale.startPath(t); - - q->position = Vector(400,400); - q->position.path.addPathNode(Vector(400,400), 0.6); - q->position.path.addPathNode(dsq->game->miniMapRender->position, 0.9); - q->position.startPath(t); - - dsq->game->addRenderObject(q, LR_MESSAGEBOX); - */ if (!getFlag("tokenHint")) @@ -3523,8 +3433,8 @@ GemData *Continuity::pickupGem(std::string name, bool effects) setFlag("tokenHint", 1); dsq->game->setControlHint(dsq->continuity.stringBank.get(4), false, false, false, 8); } - //dsq->watch(1); - //dsq->resetTimer(); + + } // return the last one @@ -3580,7 +3490,7 @@ void Continuity::reset() dsq->game->recipeMenu.currentPage = 0; } - //worldMapTiles.clear(); + speedMult = biteMult = fishPoison = defenseMult = 1; speedMult2 = 1; @@ -3636,12 +3546,12 @@ void Continuity::reset() loadEatBank(); dsq->loadElementEffects(); form = FORM_NORMAL; - //cm.reset(); + naijaModel = "Naija"; costume = ""; dsq->emote.load("data/naijaemote.txt"); - //learnSong(SONG_SONGDOOR1); + worldType = WT_NORMAL; @@ -3669,7 +3579,7 @@ void Continuity::reset() inFile >> spd; speedTypes.push_back(spd); } - //selectedSpell = SpellType(0); + if (!dsq->mod.isActive()) { diff --git a/Aquaria/Credits.cpp b/Aquaria/Credits.cpp index 7a06281..d058308 100644 --- a/Aquaria/Credits.cpp +++ b/Aquaria/Credits.cpp @@ -32,7 +32,7 @@ namespace AQCredits void watchSlide(int slide) { - float t = 10;//15; + float t = 10; if (!(slide >= 0 && slide < slides.size())) return; @@ -81,9 +81,9 @@ void Credits::applyState() dsq->setCutscene(1,0); core->resetCamera(); - + core->sound->stopMusic(); - + // load everything here: bg1 = new Quad("particles/gas", Vector(400,300)); @@ -185,12 +185,12 @@ void Credits::applyState() { core->main(1); } - + dsq->setCutscene(0); dsq->game->transitionToScene("thirteenlair"); #endif - //dsq->title(); + } void Credits::removeState() diff --git a/Aquaria/CurrentRender.cpp b/Aquaria/CurrentRender.cpp index fd40034..04fc66f 100644 --- a/Aquaria/CurrentRender.cpp +++ b/Aquaria/CurrentRender.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CurrentRender::CurrentRender() : RenderObject() { cull = false; - //alpha = 0.2f; + setTexture("Particles/Current"); texture->repeat = true; rippleDelay = 2; @@ -35,32 +35,12 @@ void CurrentRender::onUpdate(float dt) { RenderObject::onUpdate(dt); - /* - rippleDelay -= dt; - if (rippleDelay < 0) - { - for (int i = 0; i < dsq->game->paths.size()-1; i++) - { - Path *p = dsq->game->paths[i]; - for (int n = 0; n < p->nodes.size()-1; i++) - { - PathNode *n1 = &p->nodes[n]; - PathNode *n2 = &p->nodes[n+1]; - Vector diff = n2->position - n1->position; - Vector pos = n1->position + diff*p->animOffset; - // spawn effect at pos - if (core->afterEffectManager) - core->afterEffectManager->addEffect(new ShockEffect(Vector(core->width/2, core->height/2),pos,0.04,0.06,15,0.2f)); - } - } - rippleDelay = 1.0; - } - */ + + } void CurrentRender::onRender() { -#ifdef BBGE_BUILD_OPENGL // note: Leave cull_face disabled!? //glDisable(GL_CULL_FACE); //int qs = 0; @@ -69,86 +49,12 @@ void CurrentRender::onRender() if (p->active) { - /* - std::ostringstream os; - os << "animOffset: " << p->animOffset; - debugLog(os.str()); - */ + int w2 = p->rect.getWidth()/2; - /* - if (false) - { - float offset = 0; - glBegin(GL_QUAD_STRIP); - int sz = p->nodes.size(); - float len = 0; - float totalLength = 0; - for (int n = 0; n < sz-1; n++) - { - totalLength += (p->nodes[n+1].position - p->nodes[n].position).getLength2D(); - } - - float texScale = totalLength/256.0f; - - Vector p1, p2, diff, pl, pr; - for (int n = 0; n < sz; n++) - { - PathNode *n1 = &p->nodes[n]; - p1 = n1->position; - if (n == sz-1) - { - PathNode *n2 = &p->nodes[n-1]; - p2 = n2->position; - diff = p1-p2; - } - else - { - PathNode *n2 = &p->nodes[n+1]; - p2 = n2->position; - diff = p2-p1; - } - len = diff.getLength2D(); - float add = len/totalLength; - //texScale = len/totalLength; - - pl = diff.getPerpendicularLeft(); - pr = diff.getPerpendicularRight(); - - pl.setLength2D(w2); - pr.setLength2D(w2); - Vector r1 = p1+pl; - - Vector r4 = p1+pr; - - - if (n == 0 || n == sz-1) - { - glColor4f(1, 1, 1, 0); - } - else - { - glColor4f(1, 1, 1, 1); - } - //(0+p->animOffset)*texScale + - glTexCoord2f((offset)*texScale+p->animOffset, 0); - glVertex2f(r1.x, r1.y); - - glTexCoord2f((offset)*texScale+p->animOffset, 1); - //(0+p->animOffset)*texScale + - glVertex2f(r4.x, r4.y); - - offset += add; - - } - glEnd(); - } - else - */ - if (true) { int sz = p->nodes.size()-1; @@ -165,23 +71,7 @@ void CurrentRender::onRender() p2 += d*0.75f; diff = p2 - p1; - //bool edge = false; - /* - if (n == 0) - { - p1 -= diff*0.25f; - edge = true; - } - - if (n == sz-1) - { - p2 += diff*0.25f; - edge = true; - } - - diff = p2-p1; - */ if (!diff.isZero()) { @@ -202,21 +92,12 @@ void CurrentRender::onRender() Vector r8 = p2+pr; float len = diff.getLength2D(); float texScale = len/256.0f; - //float texScale2 = texScale; - /* - if (edge) - texScale *= 2; - */ - /* - if (edge) - texScale2 *= 4; - */ if (isTouchingLine(p1, p2, dsq->screenCenter, dsq->cullRadius+p->rect.getWidth()/2.0f)) { - //qs++; + glBegin(GL_QUAD_STRIP); glColor4f(1,1,1,0); @@ -274,7 +155,7 @@ void CurrentRender::onRender() if (isTouchingLine(p1, p2, dsq->screenCenter, dsq->cullRadius)) { - //qs++; + glBegin(GL_QUADS); if (n==0) glColor4f(1,1,1,0); @@ -305,18 +186,11 @@ void CurrentRender::onRender() } } } - //glEnd(); + } - //glEnable(GL_CULL_FACE); - /* - std::ostringstream os; - os << "current quads: " << qs; - debugLog(os.str()); - */ -#endif } diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 0f71e36..6199d93 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -40,9 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Network.h" -#ifdef BBGE_BUILD_OPENGL #include -#endif #ifdef BBGE_BUILD_VFS #include "ttvfs.h" @@ -57,7 +55,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void Linux_CopyTree(const char *src, const char *dst) { - //printf("Linux_CopyTree('%s', '%s')...\n", src, dst); + struct stat statbuf; if (stat(src, &statbuf) == -1) @@ -148,7 +146,7 @@ int setInpGrab = -1; Vector savesz; /// WARNING: this is just to init, the actual value is set from user settings! -#define PARTICLE_AMOUNT_DEFAULT 2048 // 64 // 1024 // 2048 +#define PARTICLE_AMOUNT_DEFAULT 2048 #ifdef AQUARIA_DEMO #define APPNAME "Aquaria Demo" @@ -174,13 +172,10 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir) almb = armb = 0; bar_left = bar_right = bar_up = bar_down = barFade_left = barFade_right = 0; - + difficulty = DIFF_NORMAL; - /* - if (exists("easy")) - difficulty = DIFF_EASY;//DIFF_NORMAL; - */ + watchQuitFlag = false; watchForQuit = false; @@ -220,8 +215,8 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir) renderObjectLayers.resize(LR_MAX); entities.resize(64, 0); - - //Emitter::particleLayer = LR_PARTICLES; + + sortEnabled = false; shakeCameraTimer = shakeCameraMag = 0; avgFPS.resize(dsq->user.video.fpsSmoothing); @@ -231,7 +226,7 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir) for (int i = 0; i < 16; i++) firstElementOnLayer[i] = 0; - //stream = 0; + } DSQ::~DSQ() @@ -256,18 +251,18 @@ void DSQ::onAltTab() // actually toggle void DSQ::toggleFullscreen() { - //if (!core->isNested() && !core->sound->isPlayingVoice()) { + core->toggleScreenMode(!_fullscreen); user.video.full = _fullscreen; - //} + } // for handling the input, not the actual switch functionality void DSQ::onSwitchScreenMode() { - //if (!core->isNested() && !core->sound->isPlayingVoice()) + { - + #if defined(BBGE_BUILD_WINDOWS) || defined(BBGE_BUILD_UNIX) if (getAltState()) { toggleFullscreen(); @@ -280,9 +275,7 @@ void DSQ::forceInputGrabOff() { toggleInputGrabPlat(false); setInpGrab = 0; -#ifdef BBGE_BUILD_SDL SDL_ShowCursor(SDL_DISABLE); -#endif } void DSQ::rumble(float leftMotor, float rightMotor, float time) @@ -333,7 +326,7 @@ void DSQ::loadElementEffects() debugLog("loading wavy"); efxType = EFX_WAVY; is >> e.segsy >> e.wavy_radius >> e.wavy_flip; - // >> e.wavy_min >> e.wavy_max >> e.wavy_flip; + } else if (type == "EFX_ALPHA") { @@ -408,7 +401,7 @@ void DSQ::centerText(const std::string &text) BitmapText *t = new BitmapText(&font); - + t->position =pos; t->alpha.ensureData(); @@ -417,26 +410,18 @@ void DSQ::centerText(const std::string &text) t->alpha.data->path.addPathNode(1, 0.8); t->alpha.data->path.addPathNode(0, 1); t->alpha.startPath(time); - /* - t->scale = Vector(0.7, 0.7); - t->scale.interpolateTo(Vector(1, 1), 6); - */ + t->followCamera = 1; t->setLife(time + 0.5f); t->setDecayRate(1); - //t->scrollText(text, 0.1); + t->setText(text); getTopStateData()->addRenderObject(t, LR_HUD); } void DSQ::destroyFonts() { - /* - if (font) { delete font; font = 0; } - if (smallFont) { delete smallFont; smallFont = 0; } - if (subsFont) { delete subsFont; subsFont = 0; } - if (goldFont) { delete goldFont; goldFont = 0; } - */ + debugLog("destroyFonts..."); font.destroy(); smallFont.destroy(); @@ -500,15 +485,8 @@ void DSQ::loadFonts() } debugLog("done loadFonts"); - /* - //gold - smallFont.fontTopColor = Vector(1,0.9,0.5); - smallFont.fontBtmColor = Vector(0.6,0.5,0.25); - */ - //Texture::format = GL_LUMINANCE_ALPHA; - - //Texture::format = 0; + } void DSQ::onReloadResources() @@ -518,42 +496,21 @@ void DSQ::onReloadResources() loadFonts(); setTexturePointers(); -} +} void DSQ::debugMenu() { if (isDeveloperKeys() || (mod.isActive() && mod.isDebugMenu())) { -/* -#if defined(BBGE_BUILD_MACOSX) - if (core->getCtrlState()) -#elif defined(BBGE_BUILD_WINDOWS) || defined(BBGE_BUILD_UNIX) -*/ + if (core->getShiftState()) -//#endif + { core->frameOutputMode = false; dsq->game->togglePause(true); std::string s = dsq->getUserInputString(dsq->continuity.stringBank.get(2012), ""); stringToUpper(s); - /* - char c=0; - is >> str; - */ - - /* - if (dsq->postProcessingFx.isEnabled(FXT_RADIALBLUR)) - { - dsq->postProcessingFx.disable(FXT_RADIALBLUR); - } - else - { - dsq->postProcessingFx.enable(FXT_RADIALBLUR); - dsq->postProcessingFx.radialBlurColor = Vector(1,1,1); - dsq->postProcessingFx.intensity = 0.1; - } - */ if (!dsq->game->isSceneEditorActive()) @@ -615,24 +572,10 @@ void DSQ::debugMenu() { dsq->quitNestedMain(); } - /* - else if (c == '4') - { - dsq->continuity.learnSong(SONG_FISHFORM); - } + else if (c == '5') { - dsq->continuity.learnSong(SONG_NATUREFORM); - } - */ - else if (c == '5') - { - /* - if (dsq->game->avatar->isInvincible()) - dsq->game->avatar->setInvincible(false); - else - dsq->game->avatar->setInvincible(true); - */ + dsq->game->invinciblity = !dsq->game->invinciblity; } else if (c == '6') @@ -669,11 +612,7 @@ void DSQ::debugMenu() is >> read >> num; dsq->continuity.learnSong(num); - /* - std::ostringstream os; - os << "debug: Learned Song: " << num << " from s: " << s; - debugLog(os.str()); - */ + } else if (c == 'F') { @@ -714,8 +653,8 @@ void DSQ::debugMenu() else if (c == 'U') { dsq->demo.renderFramesToDisk(); - //dsq->demo.togglePlayback(true); - //core->frameOutputMode = false; + + } else if (c == 'K') { @@ -738,7 +677,7 @@ void DSQ::debugMenu() } - //dsq->game->togglePause(false); + } } } @@ -825,14 +764,14 @@ void DSQ::setVersionLabelText() #ifdef AQUARIA_DEMO os << " Demo"; #endif - + os << " v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_REVISION; - + if (!isFinalCandidate && !isGoldMaster && VERSION_BETA) { os << "b" << VERSION_BETA; } - + if (isFinalCandidate) { os << "fc" << VERSION_FC; @@ -843,7 +782,7 @@ void DSQ::setVersionLabelText() } else if (isGoldMaster) { - //os << "gm" << VERSION_GM; + } #ifdef AQUARIA_CUSTOM_BUILD_ID @@ -856,7 +795,6 @@ void DSQ::setVersionLabelText() versionLabel->setText(os.str()); } -#ifdef BBGE_BUILD_SDL static bool sdlVideoModeOK(const int w, const int h, const int bpp) { #ifdef BBGE_BUILD_SDL2 @@ -873,7 +811,6 @@ static bool sdlVideoModeOK(const int w, const int h, const int bpp) return SDL_VideoModeOK(w, h, bpp, SDL_OPENGL | SDL_FULLSCREEN); #endif } -#endif void DSQ::init() { @@ -908,7 +845,7 @@ This build is not yet final, and as such there are a couple things lacking. They useFrameBuffer = false; gameSpeed = 1; - + // steam gets inited in here Core::init(); @@ -951,18 +888,11 @@ This build is not yet final, and as such there are a couple things lacking. They addStateInstance(new Intro); addStateInstance(new Nag); - //addStateInstance(new Logo); - //addStateInstance(new SCLogo); - //addStateInstance(new IntroText); - //addStateInstance(new Intro); - //packReadInfo("mus.dat"); this->setBaseTextureDirectory("gfx/"); - //sound->setMusicVolume(0); -// PHYSFS_addToSearchPath("gfx",1); -// PHYSFS_addToSearchPath("gfx.zpk",0 ); + bool mipmapsEnabled=true; bool fullscreen = true; @@ -971,9 +901,9 @@ This build is not yet final, and as such there are a couple things lacking. They voiceOversEnabled = true; - //core->messageBox("info", "loading user settings"); + user.load(false); - + particleManager->setSize(user.video.numParticles); fullscreen = user.video.full; @@ -1024,17 +954,8 @@ This build is not yet final, and as such there are a couple things lacking. They return; } - /* - debugLog("Setting Music Volume..."); - if (musicVolume != 0) - { - musicVolume = 0.9; - } - sound->setMusicVolume(musicVolume); - debugLog("OK"); - */ -#ifdef BBGE_BUILD_SDL + SDL_Init(SDL_INIT_VIDEO); if (fullscreen && !sdlVideoModeOK(user.video.resx, user.video.resy, user.video.bits)) { @@ -1044,7 +965,6 @@ This build is not yet final, and as such there are a couple things lacking. They if (!sdlVideoModeOK(user.video.resx, user.video.resy, user.video.bits)) fullscreen = false; // last chance. } -#endif debugLog("Init Graphics Library..."); initGraphicsLibrary(user.video.resx, user.video.resy, fullscreen, user.video.vsync, user.video.bits); @@ -1061,7 +981,7 @@ This build is not yet final, and as such there are a couple things lacking. They sound->setVoiceFader(0.5); sound->event_playVoice.set(MakeFunctionEvent(DSQ, onPlayVoice)); sound->event_stopVoice.set(MakeFunctionEvent(DSQ, onStopVoice)); - //sound->reverbKeyword = "naija_"; + debugLog("OK"); debugLog("Init Input Library..."); @@ -1074,10 +994,7 @@ This build is not yet final, and as such there are a couple things lacking. They { debugLog("Init Joystick Library..."); initJoystickLibrary(); - /* - if (joystickEnabled) - joystickOverrideMouse = true; - */ + debugLog("OK"); } @@ -1093,7 +1010,7 @@ This build is not yet final, and as such there are a couple things lacking. They Vector loadShift(2, 0); - + Vector sz(800.0f/1024.0f, 600.0f/768.0f); @@ -1120,28 +1037,8 @@ This build is not yet final, and as such there are a couple things lacking. They sider->followCamera = 1; sider->scale = sz; addRenderObject(sider, LR_HUD); - /* - DebugFont *loadingFont = new DebugFont(6, "LOADING"); - loadingFont->alpha = 1; - loadingFont->setAlign(DebugFont::ALIGN_CENTER); - loadingFont->position = Vector(400,300) + loadShift; - loadingFont->followCamera = 1; - addRenderObject(loadingFont, LR_HUD); - Vector shift(-12, 0); - DebugFont *lbit1 = new DebugFont(32, "["); - //lbit1->setAlign(DebugFont::ALIGN_CENTER); - lbit1->position = Vector(100,300) + shift; - lbit1->followCamera = 1; - addRenderObject(lbit1, LR_HUD); - - DebugFont *lbit2 = new DebugFont(32, "]"); - //lbit2->setAlign(DebugFont::ALIGN_CENTER); - lbit2->position = Vector(700,300) + shift; - lbit2->followCamera = 1; - addRenderObject(lbit2, LR_HUD); - */ core->render(); core->showBuffer(); @@ -1159,7 +1056,7 @@ This build is not yet final, and as such there are a couple things lacking. They loadBit(LOAD_PARTICLES); - + debugLog("Loading Sound Cache..."); sound->loadSoundCache("sfx/cache/", ".ogg", loadBitForSoundCache); @@ -1207,14 +1104,14 @@ This build is not yet final, and as such there are a couple things lacking. They #ifdef AQUARIA_BUILD_CONSOLE debugLog("Creating console"); console = new DebugFont; - //(&dsq->smallFont); + { console->position = Vector(10 - virtualOffX,400); console->followCamera = 1; console->alpha = 0; - //console->setAlign(ALIGN_LEFT); - //console->setWidth(12); - //console->setFontSize(12); + + + console->setFontSize(6); } addRenderObject(console, LR_DEBUG_TEXT); @@ -1226,17 +1123,17 @@ This build is not yet final, and as such there are a couple things lacking. They if (isDeveloperKeys()) { - //cmDebug = new BitmapText(&dsq->font); + cmDebug = new DebugFont(); { - //cmDebug->position = Vector(450,250); - //cmDebug->position = Vector(500,350); + + cmDebug->position = Vector(20 - virtualOffX,50); cmDebug->followCamera = 1; cmDebug->alpha = 0; - //cmDebug->setAlign(ALIGN_LEFT); - //cmDebug->setWidth(12); - //cmDebug->setFontSize(18); + + + cmDebug->setFontSize(6); } addRenderObject(cmDebug, LR_DEBUG_TEXT); @@ -1247,7 +1144,7 @@ This build is not yet final, and as such there are a couple things lacking. They versionLabel = new BitmapText(&smallFont); { setVersionLabelText(); - //versionLabel->position = Vector(10 - core->getVirtualOffX(), 575); + versionLabel->followCamera = 1; versionLabel->setAlign(ALIGN_LEFT); versionLabel->scale = Vector(0.7, 0.7); @@ -1255,7 +1152,7 @@ This build is not yet final, and as such there are a couple things lacking. They versionLabel->alpha = 0; } addRenderObject(versionLabel, LR_REGISTER_TEXT); - + subbox = new Quad(); subbox->position = Vector(400,580); @@ -1268,14 +1165,14 @@ This build is not yet final, and as such there are a couple things lacking. They addRenderObject(subbox, LR_SUBTITLES); subtext = new BitmapText(&dsq->subsFont); - //subtext->position = Vector(400,570); + subtext->position = Vector(400,570); subtext->followCamera = 1; subtext->alpha = 0; subtext->setFontSize(14); subtext->setWidth(800); subtext->setAlign(ALIGN_CENTER); - //subtext->setFontSize(12); + addRenderObject(subtext, LR_SUBTITLES); #ifdef BBGE_BUILD_ACHIEVEMENTS_INTERNAL @@ -1376,7 +1273,7 @@ This build is not yet final, and as such there are a couple things lacking. They overlay2->followCamera = 1; } addRenderObject(overlay2, LR_OVERLAY); - + overlay3 = new Quad; { overlay3->position = Vector(400,300); @@ -1445,19 +1342,19 @@ This build is not yet final, and as such there are a couple things lacking. They addRenderObject(profRender, LR_DEBUG_TEXT); #endif - //fpsText = new BitmapText(&dsq->smallFont); + fpsText = new DebugFont; { fpsText->color = Vector(1,1,1); fpsText->setFontSize(6); - //fpsText->position = Vector(10,15+200); + fpsText->position = Vector(10 - virtualOffX,580); fpsText->position.z = 5; - //fpsText->position += Vector(0,-200); - //fpsText->setAlign(ALIGN_LEFT); + + fpsText->setText("FPS"); fpsText->alpha= 0; - //fpsText->followCamera = 1; + } addRenderObject(fpsText, LR_DEBUG_TEXT); @@ -1511,21 +1408,15 @@ This build is not yet final, and as such there are a couple things lacking. They renderObjectLayerOrder[LR_ENTITIES_MINUS3] = -1; renderObjectLayerOrder[LR_ENTITIES_MINUS2] = -1; - /*if (!Entity::blurShader.isLoaded()) - { - //Entity::blurShader.load("data/shaders/stan.vert", "data/shaders/hoblur.frag"); - }*/ + setMousePosition(core->center); - - //dsq->continuity.reset(); + + loadBit(LOAD_FINISHED); - /* - sound->playSfx("defense", 0.5); - sound->playSfx("visionwakeup"); - */ + // Don't do transitions for a faster start up in dev mode if (!isDeveloperKeys()) @@ -1549,10 +1440,7 @@ This build is not yet final, and as such there are a couple things lacking. They setInputGrab(1); - /* - removeRenderObject(disk); - disk = 0; - */ + bindInput(); @@ -1688,7 +1576,7 @@ void DSQ::recreateBlackBars() void DSQ::setBlackBarsColor(Vector color) { if (bar_left && bar_right) - { + { bar_left->color = bar_right->color = barFade_left->color = barFade_right->color = color; } } @@ -1735,7 +1623,7 @@ int DSQ::getEntityLayerToLayer(int lcode) if (lcode == -4) return LR_ENTITIES_MINUS4; // in front of elements11 else if (lcode == -3) - return LR_ENTITIES_MINUS3; // in front of elements2 + return LR_ENTITIES_MINUS3; // in front of elements2 else if (lcode == -2) return LR_ENTITIES_MINUS2; // in front of elements3 else if (lcode == -1) @@ -1831,38 +1719,7 @@ int DSQ::getRandNote() if (c > 8) break; } lastRand = r; - /* - static std::vector lastRand; - int r = -1; - int c = 0; - - while (r == -1 && c < 8) - { - r = rand()%8; - for (int i = 0; i < lastRand.size(); i++) - { - if (lastRand[i] == r) - { - r = -1; - break; - } - } - c++; - } - - if (r == -1) - r = rand()%8; - - std::ostringstream os; - os << "r: " << r; - debugLog(os.str()); - - lastRand.push_back(r); - - if (lastRand.size() > 4) - lastRand.resize(4); - */ return r; } @@ -1913,7 +1770,7 @@ void DSQ::toggleVersionLabel(bool on) float a = 0; if (on) a = 1; - + versionLabel->alpha.interpolateTo(a, 1); } @@ -1955,9 +1812,9 @@ void DSQ::toggleRenderCollisionShapes() void DSQ::takeScreenshot() { - //takeScreenShot(); + doScreenshot = true; - //saveScreenshotTGA("screen.tga"); + } void DSQ::unloadDevice() @@ -2009,7 +1866,7 @@ void DSQ::debugLog(const std::string &s) consoleLines.push_back(s); if (consoleLines.size() > MAX_CONSOLELINES) { - //consoleLines.size()-MAX_CONSOLELINES + for (int i = 0; i < consoleLines.size()-1; i++) { consoleLines[i] = consoleLines[i+1]; @@ -2042,31 +1899,12 @@ int DSQ::getEntityTypeIndexByName(std::string s) void DSQ::toggleMuffleSound(bool toggle) { - /* - if (sound->isPlayingMusic()) - { - #ifdef BBGE_BUILD_WINDOWS - if (toggle) - { - BASS_ChannelSetFX(sound->getMusicStream(), 1, BASS_FX_FLANGER); - BASS_FXREVERB rev; - rev.fHighFreqRTRatio = 0; - rev.fInGain = 0; - rev.fReverbMix = 0.001; - rev.fReverbTime = 1000; - BASS_FXSetParameters(sound->getMusicStream(), &rev); - } - else - BASS_ChannelRemoveFX(sound->getMusicStream(), BASS_FX_DISTORTION); - #endif - } - */ } void DSQ::loadModsCallback(const std::string &filename, intptr_t param) { - //errorLog(filename); + int pos = filename.find_last_of('/')+1; int pos2 = filename.find_last_of('.'); std::string name = filename.substr(pos, pos2-pos); @@ -2113,12 +1951,7 @@ void DSQ::startSelectedMod() mod.load(e->path); mod.start(); - /* - if (dsq->game->sceneToLoad.empty()) - { - mod.setActive(false); - } - */ + } } @@ -2296,16 +2129,7 @@ void DSQ::shutdown() scriptInterface.shutdown(); precacher.clean(); - /* - if (title)delete title; - if (game) delete game; - if (logo) delete logo; - if (gameOver) delete gameOver; - if (scLogo) delete scLogo; - if (introText) delete introText; - if (animationEditor) delete animationEditor; - if (intro) delete intro; - */ + core->particleManager->clearParticleBank(); Shot::clearShotBank(); @@ -2346,7 +2170,7 @@ void DSQ::shutdown() removeRenderObject(overlay3); removeRenderObject(overlayRed); removeRenderObject(tfader); - //removeRenderObject(messageLabelBG); + removeRenderObject(fpsText); if (bar_left) @@ -2396,7 +2220,7 @@ void DSQ::shutdown() continuity.shutdown(); - //script.shutdown(); + Core::shutdown(); } @@ -2439,42 +2263,8 @@ void DSQ::setCursor(CursorType type) void DSQ::toggleEffects() { - /* - static int tester = 0; - float t = 3; - if (!tester) - sound->crossover("battletest-town", t); - else - sound->crossover("battletest-battle", t); - tester = !tester; - */ - /* - static int effectToggler = 0; - effectToggler ++; - switch (effectToggler) - { - case 1: - postProcessingFx.enable(FXT_RADIALBLUR); - postProcessingFx.radialBlurColor = Vector(1,1,1); - postProcessingFx.intensity = 0.1; - break; - case 2: - postProcessingFx.intensity = 0.05; - break; - case 3: - postProcessingFx.intensity = 0.2; - break; - case 4: - postProcessingFx.intensity = 0.4; - break; - default: - case 0: - effectToggler = 0; - postProcessingFx.disable(FXT_RADIALBLUR); - break; - } - */ + } void DSQ::clickRingEffect(Vector pos, int type, Vector color, float ut) @@ -2586,19 +2376,19 @@ void DSQ::doLoadMenu() doSaveSlotMenu(SSM_LOAD); if (selectedSaveSlot != 0) { - //loaded = true; + dsq->doScreenTrans = true; } else { - //loaded = false; + clearSaveSlots(true); } } void DSQ::doSavePoint(const Vector &position) { -// if (!e) return; + dsq->game->avatar->setv(EV_LOOKAT, 0); core->sound->playSfx("MemoryCrystalActivate"); @@ -2622,7 +2412,7 @@ void DSQ::doSavePoint(const Vector &position) dsq->game->avatar->fhTo(false); dsq->game->avatar->position.interpolateTo(position, 1, 0, 0, 1); dsq->game->avatar->myZoom.interpolateTo(Vector(1,1),0.5); - // override = + dsq->game->avatar->skeletalSprite.animate("save", 0, 3); dsq->game->clearControlHint(); dsq->main(2); @@ -2633,8 +2423,8 @@ void DSQ::doSavePoint(const Vector &position) dsq->game->togglePause(0); core->resetTimer(); dsq->game->avatar->setv(EV_LOOKAT, 1); - //dsq->game->avatar->skeletalSprite.animate("unsave", 0, 3); - //dsq->continuity.saveFile(0); + + } void DSQ::playNoEffect() @@ -2653,7 +2443,7 @@ void DSQ::clearMenu(float t) menu[i]->setLife(1); menu[i]->setDecayRate(1/t); menu[i]->fadeAlphaWithLife = 1; - //menu[i]->alpha.interpolateTo(0, 0.5); + } menu.clear(); } @@ -2673,19 +2463,7 @@ void DSQ::screenMessage(const std::string &msg) b->setDecayRate(1); core->getTopStateData()->addRenderObject(b, LR_DEBUG_TEXT); - /* - DebugFont *d = new DebugFont; - d->position = Vector(400,300); - d->setFontSize(16); - d->setText(msg); - d->alpha = 0; - d->alpha.interpolateTo(1, 0.75); - d->setLife(2); - d->setDecayRate(1); - d->followCamera = 1; - core->getTopStateData()->addRenderObject(d, LR_DEBUG_TEXT); - debugLog(msg); - */ + } void DSQ::onExitSaveSlotMenu() @@ -2715,7 +2493,7 @@ bool DSQ::onPickedSaveSlot(AquariaSaveSlot *slot) { doit = true; } - + if (doit) { selectedSaveSlot = slot; @@ -2943,19 +2721,15 @@ void DSQ::createSaveSlots(SaveSlotMode ssm) cancel = new AquariaMenuItem(); - //menu[0]->setLabel("Cancel"); + cancel->useGlow("glow", 200, 50); cancel->event.set(MakeFunctionEvent(DSQ,onExitSaveSlotMenu)); - cancel->position = Vector(665, 545); // 670 + cancel->position = Vector(665, 545); addRenderObject(cancel, LR_MENU); menu[0] = cancel; - /* - menu[1] = new Quad("Cancel", Vector(750,580)); - menu[1]->followCamera = 1; - addRenderObject(menu[1], LR_MENU); - */ + arrowUp = new AquariaMenuItem(); arrowUp->useQuad("gui/arrow-left"); @@ -3014,14 +2788,14 @@ void DSQ::title(bool fade) } main(1); - + resetTimer(); - + if (fade) dsq->sound->stopMusic(); user.save(); - + if (mod.isActive()) { mod.shutdown(); @@ -3029,7 +2803,7 @@ void DSQ::title(bool fade) // Will be re-loaded on demand unloadMods(); - + // VERY important dsq->continuity.reset(); @@ -3101,7 +2875,7 @@ void DSQ::hideSaveSlotCrap() if (blackout) blackout->alpha = 0; - + if (saveSlotPageCount) saveSlotPageCount->alpha = 0; } @@ -3145,7 +2919,7 @@ void DSQ::clearSaveSlots(bool trans) saveSlots.clear(); - //watch(0.25); + if (trans) { @@ -3156,7 +2930,7 @@ void DSQ::clearSaveSlots(bool trans) if (i != 1) { menu[i]->alpha = 0; - //menu[i]->alpha.interpolateTo(0, 0.01); + } } if (menu.size() >= 2) @@ -3169,7 +2943,7 @@ void DSQ::clearSaveSlots(bool trans) disableMiniMapOnNoInput = true; } clearMenu(); - //watch(0.5); + if (dsq->game->miniMapRender) dsq->game->miniMapRender->slide(0); @@ -3224,7 +2998,7 @@ void DSQ::doSaveSlotMenu(SaveSlotMode ssm, const Vector &position) } saveSlotMode = SSM_NONE; - + createSaveSlots(ssm); const int firstSaveSlot = user.data.savePage * saveSlotPageSize; if (user.data.saveSlot >= firstSaveSlot && user.data.saveSlot < firstSaveSlot + saveSlots.size()) @@ -3239,7 +3013,7 @@ void DSQ::doSaveSlotMenu(SaveSlotMode ssm, const Vector &position) saveSlotMode = ssm; - //core->globalScale.interpolateTo(Vector(1, 1), 0.5); + resetTimer(); core->main(-1); @@ -3363,7 +3137,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl bgLabel->followCamera = 1; bgLabel->alpha = 0; bgLabel->alpha.interpolateTo(1, t); - //bgLabel->setWidthHeight(512*0.9f, 256*0.9f); + bgLabel->scale = Vector(0.5, 0.5); bgLabel->scale.interpolateTo(Vector(1,1), t); addRenderObject(bgLabel, LR_CONFIRM); @@ -3376,19 +3150,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl float t2 = 0.05; - /* - Quad *yes = new Quad("gui/yes", Vector(350, 400)); - yes->followCamera = 1; - yes->alpha = 0; - yes->alpha.interpolateTo(1, t2); - addRenderObject(yes, LR_CONFIRM); - Quad *no = new Quad("gui/no", Vector(450, 400)); - no->followCamera = 1; - no->alpha = 0; - no->alpha.interpolateTo(1, t2); - addRenderObject(no, LR_CONFIRM); - */ AquariaMenuItem *yes=0; AquariaMenuItem *no=0; @@ -3399,7 +3161,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl yes->useQuad("gui/ok"); yes->useGlow("glow", 64, 50); yes->event.set(MakeFunctionEvent(DSQ,onConfirmYes)); - + yes->position = Vector(400, 340); addRenderObject(yes, LR_CONFIRM); @@ -3415,7 +3177,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl yes->useQuad("yes"); yes->useGlow("glow", 64, 50); yes->event.set(MakeFunctionEvent(DSQ,onConfirmYes)); - + yes->position = Vector(330, 340); addRenderObject(yes, LR_CONFIRM); @@ -3445,7 +3207,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl yes->setDirMove(DIR_DOWN, yes); yes->setDirMove(DIR_LEFT, yes); } - + BitmapText *txt = new BitmapText(&dsq->smallFont); txt->followCamera = 1; txt->position = Vector(400,250); @@ -3518,26 +3280,18 @@ std::string DSQ::getUserInputString(std::string labelText, std::string t, bool a bg->alpha = 0; addRenderObject(bg, LR_DEBUG_TEXT); - /* - DebugFont *label = new DebugFont(); - label->setFontSize(10); - label->setText(labelText); - label->position = Vector(20,250 - label->getNumLines()*10); - label->followCamera = 1; - label->alpha = 0; - label->alpha.interpolateTo(1, trans); - */ + TTFText *label = new TTFText(&dsq->fontArialSmall); label->setText(labelText); - label->position = Vector(-400 + 20, -12); //- label->getNumLines()*10 + label->position = Vector(-400 + 20, -12); bg->addChild(label, PM_POINTER); TTFText *inputText = new TTFText(&dsq->fontArialBig); - //inputText->setFontSize(14); + inputText->position = Vector(-400 + 20,8+8); bg->addChild(inputText, PM_POINTER); - //addRenderObject(inputText, LR_DEBUG_TEXT); + bg->show(); main(trans); @@ -3657,11 +3411,7 @@ std::string DSQ::getUserInputString(std::string labelText, std::string t, bool a sound->playSfx("Menu-Close"); - /* - inputText->offset.interpolateTo(Vector(800, 0), 0.2); - label->offset.interpolateTo(Vector(800, 0), 0.2); - bg->offset.interpolateTo(Vector(800, 0), 0.2); - */ + bg->hide(); main(0.2); @@ -3720,60 +3470,20 @@ void DSQ::voiceOnce(const std::string &file) void DSQ::voiceInterupt(const std::string &f) { sound->playVoice(f, SVT_INTERRUPT); - /* - voxQueue.clear(); - if (streamingVoice) - { - streamingVoice = false; - if (stream) - { - BASS_ChannelSlideAttributes(stream, -1, -2, -101, 500); - stream = 0; - } - } - voice(f); - */ + } -/* -void DSQ::updateVoiceVolume() -{ - if (streamingVoice) - { - BASS_ChannelSlideAttributes(stream, -1, user.audio.voxvol*100.0f, -101, 100); - } -} -*/ + void DSQ::onPlayVoice() { - /* - if (user.audio.subtitles) - { - std::string fn = "scripts/vox/" + sound->lastVoice + ".txt"; - std::ifstream inf(fn.c_str()); - if (inf.is_open()) - { - std::string dia; - std::getline(inf, dia); - if (!dia.empty()) - hint(dia); - } - inf.close(); - } - */ } void DSQ::onStopVoice() { subtitlePlayer.end(); - /* - if (user.audio.subtitles) - { - hint(""); - } - */ + } void DSQ::voice(const std::string &f, float volMod) @@ -3911,7 +3621,7 @@ void DSQ::onMouseInput() range = 100; else limitRange = false; - //limitRange = core->mouse.buttons.left; + if (limitRange) { Vector diff = core->mouse.position - core->center; @@ -3931,7 +3641,7 @@ void DSQ::prepScreen(bool t) if (t) { cursor->offset = Vector(2000, 0); - //cursor->renderQuad = false; + if (game->miniMapRender) game->miniMapRender->offset = Vector(2000,0); if (fpsText) @@ -3939,7 +3649,7 @@ void DSQ::prepScreen(bool t) } else { - //cursor->renderQuad = true; + cursor->offset = Vector(0,0); if (game->miniMapRender) game->miniMapRender->offset = Vector(0,0); @@ -3988,14 +3698,9 @@ void DSQ::vision(std::string folder, int num, bool ignoreMusic) { Quad *q = new Quad; std::string label = "visions/"+folder+"/"+numToZeroString(i, 2)+".png"; - //debugLog(label); + q->setTexture(label); - /* - if (q->getWidth() == q->getHeight()) - q->setWidthHeight(800,800); - else - q->setWidthHeight(800,600); - */ + q->setWidthHeight(800,600); q->followCamera = 1; q->position = Vector(400,300); @@ -4047,7 +3752,7 @@ void DSQ::vision(std::string folder, int num, bool ignoreMusic) } bool DSQ::isDeveloperKeys() -{ +{ #ifdef AQUARIA_DEMO return false; #endif @@ -4075,7 +3780,7 @@ void DSQ::watch(float t, int canQuit) watchForQuit = false; bool wasInputEnabled = false; - + if (dsq->game && dsq->game->avatar) { wasInputEnabled = dsq->game->avatar->isInputEnabled(); @@ -4146,7 +3851,7 @@ void DSQ::bindInput() #endif #if defined(BBGE_BUILD_WINDOWS) || defined(BBGE_BUILD_UNIX) addAction(MakeFunctionEvent(DSQ, onSwitchScreenMode), KEY_RETURN, 1); - //addAction(MakeFunctionEvent(DSQ, onAltTab), KEY_TAB, 0); + #endif if (isDeveloperKeys()) { @@ -4157,32 +3862,21 @@ void DSQ::bindInput() addAction(MakeFunctionEvent(DSQ, toggleRenderCollisionShapes), KEY_RETURN, 0); } addAction(MakeFunctionEvent(DSQ, debugMenu), KEY_BACKSPACE, 0); -#if BBGE_BUILD_SDL addAction(MakeFunctionEvent(DSQ, takeScreenshot ), KEY_PRINTSCREEN, 0); -#endif addAction(MakeFunctionEvent(DSQ, takeScreenshotKey ), KEY_P, 0); } void DSQ::jiggleCursor() { -#ifdef BBGE_BUILD_SDL // hacky SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_DISABLE); -#endif } float skipSfxVol = 1.0; void DSQ::onUpdate(float dt) { - /* - if (hintTimer > 0) - { - hintTimer -= dt; - if (hintTimer <= 0) - closeHint(); - } - */ + if (isSkippingCutscene()) { @@ -4208,9 +3902,7 @@ void DSQ::onUpdate(float dt) { pollEvents(); ActionMapper::onUpdate(sec); -#ifdef BBGE_BUILD_SDL SDL_Delay(int(sec*1000)); -#endif render(); showBuffer(); resetTimer(); @@ -4270,13 +3962,13 @@ void DSQ::onUpdate(float dt) subtitlePlayer.update(dt); - + Core::onUpdate(dt); demo.update(dt); // HACK: not optimal - + if (inputMode != INPUT_KEYBOARD && game->isActive()) { if (almb && (ActionMapper::getKeyState(almb->key[0]) || ActionMapper::getKeyState(almb->key[1]))) @@ -4294,27 +3986,7 @@ void DSQ::onUpdate(float dt) if (armb && ActionMapper::getKeyState(armb->joy[0])) mouse.buttons.right = DOWN; - /* - if (routeShoulder) - { - if (joystick.leftTrigger > 0.7) - mouse.buttons.left = DOWN; - else if (joystick.leftShoulder) - mouse.buttons.left = DOWN; - } - */ - /* - if (joystick.buttons[1]) - mouse.buttons.right = DOWN; - if (routeShoulder) - { - if (joystick.rightTrigger > 0.7) - mouse.buttons.right = DOWN; - else if (joystick.rightShoulder) - mouse.buttons.right = DOWN; - } - */ // not going to happen anymore! // bye, bye xbox360 controller @@ -4326,30 +3998,17 @@ void DSQ::onUpdate(float dt) mouse.buttons.middle = DOWN; } - /* - if (!mouse.buttons.middle) - mouse.buttons.middle = joystick.buttons[4]; - */ - //|| (game->avatar && game->avatar->isSinging()) - /* - if (core->getTopStateObject() != game || game->isPaused() || (game->avatar && game->avatar->getState() == Entity::STATE_TITLE)) - core->updateCursorFromJoystick(dt, user.control.joyCursorSpeed); - else - { - core->mouse.position = Vector(400,300); - } - */ - //core->mouse.position = Vector(400,300); + } if (joystickEnabled) { - //if (!dsq->game->isInGameMenu()) + { if (dsq->inputMode != INPUT_JOYSTICK) { - //if (!core->joystick.position.isZero() || !core->joystick.rightStick.isZero()) + const float thresh = 0.6; if (core->joystick.anyButton() || !core->joystick.position.isLength2DIn(thresh) || !core->joystick.rightStick.isLength2DIn(thresh)) { @@ -4359,8 +4018,8 @@ void DSQ::onUpdate(float dt) } else if (dsq->inputMode != INPUT_MOUSE) { - ///if (core->mouse.change.getLength2D() > core->joystick.position.getLength2D()) - //if (!core->mouse.change.isZero()) + + if ((!core->mouse.change.isLength2DIn(5) || (core->getMouseButtonState(0) || core->getMouseButtonState(1))) && !core->joystick.anyButton()) { //debugLog("setting mouse input mode"); @@ -4379,47 +4038,24 @@ void DSQ::onUpdate(float dt) dsq->setInputMode(INPUT_KEYBOARD); } } - + // check the actual values, since mouse.buttons.left might be overwritten by keys int cb = 0; if (user.control.flipInputButtons) cb = 1; - + if (dsq->inputMode == INPUT_KEYBOARD && (core->getMouseButtonState(cb))) { dsq->setInputMode(INPUT_MOUSE); } - /*if (isDeveloperKeys()) - { - if (core->getCtrlState()) - { - if (core->getKeyState(KEY_LEFT)) - core->adjustWindowPosition(-5, 0); - if (core->getKeyState(KEY_RIGHT)) - core->adjustWindowPosition(5, 0); - if (core->getKeyState(KEY_UP)) - core->adjustWindowPosition(0, -5); - if (core->getKeyState(KEY_DOWN)) - core->adjustWindowPosition(0, 5); - } - }*/ + if (isDeveloperKeys() && cmDebug && cmDebug->alpha == 1 && fpsText) { std::ostringstream os; - /* - os << "id: " << continuity.cm.id << " - "; - os << "ego: " << continuity.cm.ego << " - "; - os << "sEgo: " << continuity.cm.superEgo << " - "; - os << "cd: " << continuity.cm.getCommonDemoninator(); - os << std::endl; - */ - /* - os << "id.p: " << continuity.cm.getPercentID() << std::endl; - os << "ego.p: " << continuity.cm.getPercentEGO() << std::endl; - os << "sEgo.p: " << continuity.cm.getPercentSEGO() << std::endl; - */ + + if (dsq->game->avatar) { Avatar *avatar = dsq->game->avatar; @@ -4503,15 +4139,9 @@ void DSQ::onUpdate(float dt) os << " | evQ: " << core->eventQueue.getSize(); os << " | sndQ: " << core->dbg_numThreadDecoders; os << " | dt: " << core->get_current_dt(); - /* - os << " | s: " << dsq->continuity.seconds; - os << " cr: " << core->cullRadius; - os << " r: " << core->redBits << " g: " << core->greenBits << " b: " << core->blueBits; - os << " a: " << core->alphaBits; - */ - //<< "(" << core->mouse.position.x << ", " << core->mouse.position.y << ")"; - // << "|" - //os << float(1/dt) << " Instant"; + + + fpsText->setText(os.str()); } @@ -4528,7 +4158,7 @@ void DSQ::onUpdate(float dt) cameraOffset = Vector((rand()%int(shakeCameraMag))-shakeCameraMag/2.0f, (rand()%int(shakeCameraMag))-shakeCameraMag/2.0f); } } - + static int lastWidth = 0; static int lastHeight = 0; if (lastWidth != width || lastHeight != height) { @@ -4536,18 +4166,18 @@ void DSQ::onUpdate(float dt) } lastWidth = width; lastHeight = height; - + static bool lastfullscreen = false; - + if (lastfullscreen != _fullscreen) { setInpGrab = -1; } lastfullscreen = _fullscreen; - + if (game && game->avatar && game->avatar->isInputEnabled() && !game->isPaused() && !game->isInGameMenu()) { - //debugLog("enabled"); + if (setInpGrab != 1) { toggleInputGrabPlat(true); @@ -4556,15 +4186,14 @@ void DSQ::onUpdate(float dt) } else { - //debugLog("not enabled"); + if (setInpGrab != 0) { toggleInputGrabPlat(false); setInpGrab = 0; } } - - + updatepecue(dt); @@ -4579,13 +4208,7 @@ void DSQ::onUpdate(float dt) void DSQ::lockMouse() { - /* - if (core->getVirtualWidth() > 800 && core->mouse.position.x >= 800) - { - core->mouse.position.x = 800; - core->setMousePosition(core->mouse.position); - } - */ + } void DSQ::shakeCamera(float mag, float time) @@ -4641,24 +4264,18 @@ void DSQ::playVisualEffect(int vfx, Vector position, Entity *target) { case VFX_SHOCK: { - /* - dsq->game->sceneColor2 = Vector(1,1,1); - dsq->game->sceneColor2.interpolateTo(Vector(1,0.7,0.7), 1.2, 1, 1); - */ - //dsq->game->avatar->damage(1); + + core->sound->playSfx("ShockWave"); - //dsq->spawnParticleEffect("ShockWave", position); + float t =1.0; Quad *q = new Quad; q->position = position; q->scale = Vector(0,0); q->scale.interpolateTo(Vector(5,5),t); - /* - q->color = Vector(1,1,1); - q->color.interpolateTo(Vector(1,0,0),t-t*0.05f); - */ + q->alpha.ensureData(); q->alpha.data->path.addPathNode(0, 0); q->alpha.data->path.addPathNode(0.75, 0.25); @@ -4669,7 +4286,7 @@ void DSQ::playVisualEffect(int vfx, Vector position, Entity *target) q->setTexture("particles/EnergyRing"); if (target) q->positionSnapTo = &target->position; - //q->rotation.interpolateTo(Vector(0,0,360), t+0.1f); + game->addRenderObject(q, LR_PARTICLES); if (target && target->getEntityType() == ET_AVATAR) @@ -4708,16 +4325,13 @@ void DSQ::playVisualEffect(int vfx, Vector position, Entity *target) q->alpha.ensureData(); q->alpha.data->path.addPathNode(0, 0); q->alpha.data->path.addPathNode(1, 0.3); - //q->alpha.data->path.addPathNode(0.75, 0.75); + q->alpha.data->path.addPathNode(0, 1); q->alpha.startPath(t); q->setBlendType(RenderObject::BLEND_ADD); q->rotation.z = rand()%360; q->setTexture("particles/EnergyRing"); - /* - if (target) - q->positionSnapTo = &target->position; - */ + q->rotation.interpolateTo(Vector(0,0,q->rotation.z + 360), t+0.1f); game->addRenderObject(q, LR_PARTICLES); } @@ -4731,17 +4345,14 @@ void DSQ::playVisualEffect(int vfx, Vector position, Entity *target) q->alpha.ensureData(); q->alpha.data->path.addPathNode(0, 0); q->alpha.data->path.addPathNode(0.8, 0.25); - //q->alpha.data->path.addPathNode(0.75, 0.75); + q->alpha.data->path.addPathNode(0, 1); q->alpha.startPath(t); q->setBlendType(RenderObject::BLEND_ADD); - /* - if (target) - q->positionSnapTo = &target->position; - */ + q->setTexture("particles/EnergyDeltas"); q->rotation.z = rand()%360; - //q->rotation.interpolateTo(Vector(0,0,-360), t+0.1f); + game->addRenderObject(q, LR_PARTICLES); } } @@ -4750,10 +4361,7 @@ void DSQ::playVisualEffect(int vfx, Vector position, Entity *target) if (core->afterEffectManager) core->afterEffectManager->addEffect(new ShockEffect(Vector(core->width/2, core->height/2),core->screenCenter,0.04,0.06,15,0.2f)); break; - /* - case VFX_BIGRIPPLE: - break; - */ + } } @@ -4808,7 +4416,7 @@ void DSQ::modifyDt(float &dt) if (skippingCutscene) dt = 0.07f; - + gameSpeed.update(dt); dt *= gameSpeed.x; @@ -4929,7 +4537,7 @@ void DSQ::updatepecue(float dt) { if (!core->particlesPaused) { - //for (std::vector::iterator i = pecue.begin(); i != pecue.end(); i++) + int nz = 0; for (int i = 0; i < pecue.size(); i++) { @@ -4964,10 +4572,8 @@ void AquariaScreenTransition::capture() width = core->getWindowWidth(); height = core->getWindowHeight(); -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D,screen_texture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height); -#endif dsq->cursor->alpha = oldAlpha; diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 7acb2be..6b7864e 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -161,7 +161,7 @@ enum AquariaActions ACTION_MULTISELECT , ACTION_TOGGLEWORLDMAPEDITOR , - + ACTION_LOOK , ACTION_TOGGLEHELPSCREEN, ACTION_PLACE_AVATAR, @@ -191,16 +191,7 @@ enum WorldMapRevealMethod }; -/* -class Title; -class GameOver; -class Logo; -class Entity; -class SCLogo; -class IntroText; -class AnimationEditor; -class Intro; -*/ + struct SubLine { SubLine() { timeStamp = 0; } @@ -229,7 +220,7 @@ public: void go(const std::string &subs); void update(float dt); void end(); - + void hide(float t = 0); void show(float t = 0); @@ -268,11 +259,11 @@ public: void start(); void stop(); void load(const std::string &path); - + void update(float dt); void recache(); - + const std::string& getBaseModPath() const; bool isActive(); @@ -282,7 +273,7 @@ public: const std::string& getPath() const; const std::string& getName() const; - + void shutdown(); bool isShuttingDown(); @@ -551,23 +542,7 @@ enum Layers class Avatar; -/* -class GardenHoleData -{ -public: - GardenHoleData(); - float timePlanted, timeLastChecked, lastTimeGrown; - int plantedItem; - unsigned int state; - int slotsUsed; -}; -class GardenData -{ -public: - GardenHoleData holeData[256]; -}; -*/ #define MAPVIS_SUBDIV 64 @@ -857,12 +832,7 @@ const int FLAG_SECRET03 = 236; const int FLAG_COLLECTIBLE_START = 500; const int FLAG_COLLECTIBLE_END = 600; -/* -const int FLAG_PET_NAUTILUS = 601; -const int FLAG_PET_DUMBO = 602; -const int FLAG_PET_BLASTER = 603; -const int FLAG_PET_PIRANHA = 604; -*/ + struct PetData { @@ -907,7 +877,7 @@ public: void drop(int type); void entityDied(Entity *eDead); - + void achieve(const std::string &achievement); void initFoodSort(); @@ -1016,7 +986,7 @@ public: Song *getSongByIndex(int idx); - + bool hasSong(int song); int getSongTypeBySlot(int slot); int getSongSlotByType(int type); @@ -1037,7 +1007,7 @@ public: typedef std::list Gems; Gems gems; - + typedef std::list Beacons; Beacons beacons; @@ -1084,7 +1054,7 @@ public: void removeEmptyIngredients(); void spawnAllIngredients(const Vector &position); - + std::vector unsortedOrder; typedef std::vector Recipes; @@ -1149,10 +1119,10 @@ public: enum { DUALFORM_NAIJA = 0, DUALFORM_LI = 1 }; int dualFormMode, dualFormCharge; - + BeaconData *getBeaconByIndex(int index); void setBeacon(int index, bool v, Vector pos=Vector(0,0,0), Vector color=Vector(1,1,1)); - + int foodSortType; std::vector sortByType, sortByHeal, sortByIngredients, sortByUnsort; @@ -1250,7 +1220,7 @@ public: void init(); void shutdown(); - + void toggleInputGrabPlat(bool on); void toggleBlackBars(bool on, float t=0); @@ -1266,7 +1236,7 @@ public: CountedPtr texCursor, texCursorSwim, texCursorBurst, texCursorSing, texCursorLook; void setBlackBarsColor(Vector color); - + void toggleFullscreen(); void setTexturePointers(); @@ -1293,7 +1263,7 @@ public: Game *game; bool isQuitFlag(); - + void jiggleCursor(); SFXLoops loops; @@ -1466,7 +1436,7 @@ public: void setStory(); bool disableMiniMapOnNoInput; - + std::string returnToScene; Demo demo; @@ -1477,7 +1447,7 @@ public: #endif BitmapText *versionLabel; ProfRender *profRender; - + void setVersionLabelText(); float menuSelectDelay; @@ -1515,7 +1485,7 @@ public: void loadFonts(); - + void instantQuit(); void centerText(const std::string &text); @@ -1548,13 +1518,13 @@ public: }; Difficulty difficulty; - + std::string getSaveDirectory(); void clickRingEffect(Vector position, int type=0, Vector color=Vector(1,1,1), float ut=0); - + void bindInput(); - + void forceInputGrabOff(); int weird; diff --git a/Aquaria/Demo.cpp b/Aquaria/Demo.cpp index 7874683..1a57bf7 100644 --- a/Aquaria/Demo.cpp +++ b/Aquaria/Demo.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "DSQ.h" #include "Game.h" #include "Avatar.h" -//const float key = 0.1; + Demo::Demo() { time = 0; @@ -38,11 +38,11 @@ void Demo::toggleRecord(bool on) mode = DEMOMODE_RECORD; time = 0; timeDiff = 0; - frame = 0; + frame = 0; } else { - mode = DEMOMODE_NONE; + mode = DEMOMODE_NONE; } } @@ -54,7 +54,7 @@ void Demo::togglePlayback(bool on) mode = DEMOMODE_PLAYBACK; time = 0; timeDiff = 0; - frame = 0; + frame = 0; } else { @@ -74,25 +74,11 @@ void Demo::save(const std::string &name) { togglePlayback(false); toggleRecord(false); - + std::string filename = "" + name + ".demo"; - /* - XMLDocument doc; - // UNFINISHED - for (int i = 0; i < frames.size(); i++) - { - //DemoFrame *frame = &frames[i]; - XMLElement *xmlDemoFrame = doc.NewElement("DemoFrame"); - std::ostringstream os; - //os << frame->avatarPos.x << " " << frame->avatarPos.y << " " << frame->mouse; - //xmlDemoFrame->SetAttribute("a", os.str().c_str()); - doc.InsertEndChild(xmlDemoFrame); - } - doc.SaveFile(filename.c_str()); - */ } void Demo::load(const std::string &name) @@ -103,10 +89,8 @@ void Demo::load(const std::string &name) // UNFINISHED std::string filename = "" + name + ".demo"; - //XMLDocument doc; - //doc.LoadFile(filename.c_str()); - //doc.FirstChildElement(""); + } void Demo::clearRecordedFrames() @@ -124,7 +108,7 @@ void Demo::update(float dt) if (core->getNestedMains() > 1) return; if (mode == DEMOMODE_RECORD) - { + { DemoFrame f; f.avatarPos = dsq->game->avatar->position; f.vel = dsq->game->avatar->vel; @@ -136,13 +120,7 @@ void Demo::update(float dt) frames.push_back(f); - /* - timeDiff += dt; - if (timeDiff > key) - { - timeDiff -= key; - } - */ + time += dt; if (getQuitKey()) @@ -153,18 +131,18 @@ void Demo::update(float dt) } else if (mode == DEMOMODE_PLAYBACK) { - //core->updateMouse = false; + while (frame < frames.size()) { DemoFrame *f = &frames[frame]; if (f->t <= time) { // temporarily deactivate for seahorse footage - + dsq->game->avatar->vel = f->vel; dsq->game->avatar->vel2 = f->vel2; dsq->game->avatar->rotation.z = f->rot; dsq->game->avatar->position = f->avatarPos; - + core->mouse = f->mouse; @@ -174,18 +152,18 @@ void Demo::update(float dt) { break; } - - // + + } time += dt; - //core->updateMouse = true; - if (getQuitKey() || (!frames.empty() && frame >= frames.size())) { + + if (getQuitKey() || (!frames.empty() && frame >= frames.size())) { togglePlayback(false); dsq->centerMessage(dsq->continuity.stringBank.get(2011)); } - + } } diff --git a/Aquaria/Element.cpp b/Aquaria/Element.cpp index c18bac7..670632e 100644 --- a/Aquaria/Element.cpp +++ b/Aquaria/Element.cpp @@ -100,7 +100,6 @@ void Element::updateEffects(float dt) /// check player position { // if a big wavy doesn't work, this is probably why - //if ((position - ent->position).isLength2DIn(1024)) { ElementEffectData *eff = this->eff; @@ -142,7 +141,7 @@ void Element::updateEffects(float dt) eff->wavy[i].x = eff->wavy[i].x*eff->wavyLerpIn + (eff->wavySave[i].x*(1.0f-eff->wavyLerpIn)); } } - + if (eff->wavyLerpIn < 1) { eff->wavyLerpIn += dt*lerpSpd; @@ -163,9 +162,9 @@ void Element::updateEffects(float dt) eff->wavyMagnitude = 0; } - //std::cout << "setting grid from wav w/ wavyWaving\n"; + setGridFromWavy(); - + } else { @@ -210,7 +209,7 @@ void Element::setGridFromWavy() { if (drawGrid) { - //std::cout << "set grid from wavy (" << xDivs << ", " << yDivs << ")\n" + const float w = float(getWidth()); for (int x = 0; x < xDivs-1; x++) { @@ -220,7 +219,7 @@ void Element::setGridFromWavy() const float tmp = eff->wavy[wavy_y].x / w; if (wavy_y < eff->wavy.size()) { - + drawGrid[x][y].x = tmp - 0.5f; drawGrid[x+1][y].x = tmp + 0.5f; } @@ -262,11 +261,7 @@ void Element::setElementEffectByIndex(int eidx) break; case EFX_WAVY: { - /* - char buf[256]; - sprintf(buf, "setting wavy segsy: %d radius: %d min: %d max: %d", e.segsy, e.wavy_radius, e.wavy_min, e.wavy_max); - debugLog(buf); - */ + eff->wavy.resize(e.segsy); float bity = float(getHeight())/float(e.segsy); for (int i = 0; i < eff->wavy.size(); i++) @@ -287,7 +282,7 @@ void Element::setElementEffectByIndex(int eidx) setStatic(true); break; } - + if (eff) { eff->elementEffectIndex = eidx; @@ -317,10 +312,10 @@ void Element::render() renderBorderColor = Vector(1,1,1); } renderBorder = true; - //errorLog("!^!^$"); + } #endif - + Quad::render(); renderBorder = false; @@ -340,11 +335,11 @@ void Element::fillGrid() } else if (elementFlag == EF_SOLID2) { - dsq->game->fillGridFromQuad(this, OT_INVISIBLE, false); + dsq->game->fillGridFromQuad(this, OT_INVISIBLE, false); } else if (elementFlag == EF_SOLID3) { - dsq->game->fillGridFromQuad(this, OT_INVISIBLEIN, false); + dsq->game->fillGridFromQuad(this, OT_INVISIBLEIN, false); } } } diff --git a/Aquaria/Element.h b/Aquaria/Element.h index c2802c3..32422be 100644 --- a/Aquaria/Element.h +++ b/Aquaria/Element.h @@ -43,7 +43,7 @@ enum ElementFlag }; struct ElementEffectData -{ +{ ElementEffectData(); int elementEffectType; diff --git a/Aquaria/Elements.h b/Aquaria/Elements.h index 404bf35..4fd07c9 100644 --- a/Aquaria/Elements.h +++ b/Aquaria/Elements.h @@ -25,5 +25,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - #endif diff --git a/Aquaria/Emote.cpp b/Aquaria/Emote.cpp index ccff447..0eda8cb 100644 --- a/Aquaria/Emote.cpp +++ b/Aquaria/Emote.cpp @@ -50,7 +50,7 @@ void Emote::playSfx(int index) if (emoteTimer > 0) return; int r = 0; - + if (emotes[index].variations > 1) { r = (rand()%emotes[index].variations)+1; diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index 7e3f30c..2601550 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Shot.h" #include "PathFinding.h" -//Shader Entity::blurShader; + void Entity::stopPull() { @@ -83,15 +83,7 @@ void Entity::generateCollisionMask(int ovrCollideRadius) } } -/* -void Entity::clearv() -{ - for (int i = 0; i < EV_MAX; i++) - { - vs[i] = 0; - } -} -*/ + bool Entity::setBoneLock(const BoneLock &boneLock) { @@ -116,40 +108,18 @@ bool Entity::setBoneLock(const BoneLock &boneLock) this->boneLock.circleOffset = this->position - (boneLock.entity->getWorldPosition()); this->boneLock.circleOffset.setLength2D(boneLock.entity->collideRadius); this->boneLock.origRot = boneLock.entity->rotation.z; - /* - this->boneLock = boneLock; - this->boneLock.localOffset = this->position - (boneLock.entity->getWorldPosition()); - this->boneLock.localOffset = boneLock.entity->getInvRotPosition(this->boneLock.localOffset); - this->boneLock.circleOffset = this->position - (boneLock.entity->position); - this->boneLock.circleOffset.setLength2D(boneLock.entity->collideRadius); - this->boneLock.origRot = boneLock.entity->getWorldRotation(); - //this->boneLock.origRot = MathFunctions::toRadians(this->boneLock.origRot); - MathFunctions::calculateAngleBetweenVectorsInRadians(boneLock.entity->position + boneLock.entity->getForward(), boneLock.entity->position, this->boneLock.origRot); - //position, boneLock.entity->position, - MathFunctions::calculateAngleBetweenVectorsInRadians(position, boneLock.entity->position, this->boneLock.offRot); - while (this->boneLock.origRot > PI) - this->boneLock.origRot -= PI; - while (this->boneLock.origRot < 0) - this->boneLock.origRot += PI; - while (this->boneLock.offRot > PI) - this->boneLock.offRot -= PI; - while (this->boneLock.offRot < 0) - this->boneLock.offRot += PI; - //this->boneLock.offRot = atanf(this->boneLock.circleOffset.y / this->boneLock.circleOffset.x); - // - //this->boneLock.localOffset = boneLock.bone->getOriginCollidePosition(this->boneLock.localOffset); - */ + } else { this->boneLock = boneLock; - //this->boneLock.localOffset = this->position - boneLock.bone->getWorldPosition(); + this->boneLock.localOffset = this->position - (boneLock.bone->getWorldPosition()); this->boneLock.localOffset = boneLock.bone->getInvRotPosition(this->boneLock.localOffset); this->boneLock.origRot = boneLock.bone->getWorldRotation(); - //this->boneLock.localOffset = boneLock.bone->getOriginCollidePosition(this->boneLock.localOffset); + } } @@ -190,9 +160,9 @@ Entity::Entity() setv(EV_VINEPUSH, 1); setv(EV_BEASTBURST, 1); setv(EV_WEBSLOW, 100); - //debugLog("Entity::Entity()"); - //clampOnSwitchDir = true; - //registerEntityDied = false; + + + invincible = false; lanceDelay = 0; lance = 0; @@ -213,11 +183,11 @@ Entity::Entity() pauseFreeze = true; canLeaveWater = false; targetPriority = 0; - //renderPass = RENDER_ALL; - //crawling = 0; + + ridingOnEntity = 0; targetRange = 32; - //energyChargeTarget = energyShotTarget = true; + deathSound = "GenericDeath"; entityID = 0; hair = 0; @@ -244,14 +214,14 @@ Entity::Entity() entityType = EntityType(0); targets.resize(10); attachedTo = 0; - //target = 0; + frozenTimer = 0; canBeTargetedByAvatar = false; activationRange = 0; activationType = ACT_NONE; pushDamage = 0; - //debugLog("dsq->addEntity()"); + dsq->addEntity(this); maxSpeed = 300; @@ -260,24 +230,18 @@ Entity::Entity() invincibleBreak = false; activationRadius = 40; activationRange = 600; - //affectedBySpells = true; -// followAvatar = false; + + followEntity = 0; bubble = 0; - /* - copySkel.parentManagedStatic = 1; - copySkel.updateAfterParent = 1; - addChild(©Skel); - */ - //debugLog("skeletalSprite init"); skeletalSprite.updateAfterParent = 1; skeletalSprite.setAnimationKeyNotify(this); addChild(&skeletalSprite, PM_STATIC); - //debugLog("damageTarget stuff"); + setDamageTarget(DT_AVATAR_NATURE, false); setDamageTarget(DT_AVATAR_LIZAP, true); @@ -289,7 +253,7 @@ Entity::Entity() minimapIcon = 0; - //debugLog("End Entity::Entity()"); + } Entity::~Entity() @@ -472,9 +436,9 @@ float Entity::followPath(Path *p, float speed, int dir, bool deleteOnEnd) } //debugLog("Calculating Time"); float time = position.data->path.getLength()/speed; - //debugLog("Starting"); + position.data->path.getPathNode(0)->value = position; - position.startPath(time);//, 1.0f/2.0f); + position.startPath(time); return time; } @@ -485,64 +449,45 @@ float Entity::moveToPos(Vector dest, float speed, int dieOnPathEnd, bool swim) Vector start = position; followEntity = 0; - //watchingEntity = 0; + position.ensureData(); position.data->path.clear(); position.stop(); swimPath = swim; - //debugLog("Generating path to: " + path->name); + PathFinding::generatePath(this, TileVector(start), TileVector(dest)); - //int sz = position.data->path.getNumPathNodes(); - //position.data->path.addPathNode(path->nodes[0].position, 1); - //VectorPath old = position.data->path; - /*std::ostringstream os; - os << "Path length: " << sz; - debugLog(os.str());*/ + + //debugLog("Regenerating section"); - //int ms = sz % 12; - /* - if (sz > 12) - { - int node = sz/2; - dsq->pathFinding.generatePath(this, TileVector(position), TileVector(position.path.getPathNode(node)->value)); - old.splice(position.data->path, node); - position.data->path = old; - } - */ + + this->vel = 0; //debugLog("Molesting Path"); PathFinding::molestPath(position.data->path); - //position.data->path.realPercentageCalc(); - //position.data->path.cut(4); + + //debugLog("forcing path to minimum 2 nodes"); PathFinding::forceMinimumPath(position.data->path, start, dest); - //debugLog("Done"); - //debugLog("Calculating Time"); + + float time = position.data->path.getLength()/speed; - //debugLog("Starting"); + position.data->path.getPathNode(0)->value = position; - position.startPath(time);//, 1.0f/2.0f); + position.startPath(time); + - /* - if (dieOnPathEnd) - position.endOfPathEvent.set(MakeFunctionEvent(Entity, safeKill)); - */ - //debugLog("Set delete on Path end"); deleteOnPathEnd = dieOnPathEnd; - //debugLog("End of Generate Path"); - //position.startSpeedPath(dsq->continuity.getSpeedType(speedType)); - //position.startPath(((position.data->path.getNumPathNodes()*TILE_SIZE*4)-2)/dsq->continuity.getSpeedType(speedType)); return time; } @@ -554,8 +499,8 @@ void Entity::stopFollowingPath() void Entity::flipToTarget(Vector pos) { - //if (dsq->game->avatar->position.x > r->position.x) - //else if (dsq->game->avatar->position.x < r->position.x) + + if (pos.x > position.x) { @@ -595,16 +540,10 @@ void Entity::destroy() this->stopAllSounds(); this->unlinkAllSounds(); - /* + if (hair) { - hair->safeKill(); - hair = 0; - } - */ - if (hair) - { - // let the engine clean up hair + hair = 0; } Shot::targetDied(this); @@ -624,14 +563,7 @@ bool Entity::checkSurface(int tcheck, int state, float statet) } } return false; - /* - checkSurfaceDelay = math.random(3)+1 - if entity_clampToSurface(me, 0.5, 3) then - entity_setState(me, STATE_WALL, 2 + math.random(2)) - else - checkSurfaceDelay = 0.1 - end - */ + } void Entity::rotateToSurfaceNormal(float t, int n, int rot) @@ -689,25 +621,23 @@ bool Entity::clampToSurface(int tcheck, Vector usePos, TileVector hitTile) tcheck = 40; bool clamped = false; // HACK: ensure entity gets to location - //t = 0; - //setCrawling(true); setv(EV_CRAWLING, 1); burstTimer.stop(); // do stuff Vector pos = TileVector(usePos).worldVector(); if (!hitTile.isZero()) { - //debugLog("using hitTile"); + pos = hitTile.worldVector(); clamped = true; } else { - //debugLog("NOT using hitTile"); + if (vel.getSquaredLength2D() < 1) { longCheck: - //debugLog("LongCheck"); + for (int i = 0; i < tcheck; i++) { int bit = i*TILE_SIZE; @@ -772,7 +702,7 @@ bool Entity::clampToSurface(int tcheck, Vector usePos, TileVector hitTile) } else { - //debugLog("VelCheck"); + Vector v = vel; v.normalize2D(); for (int i = 0; i < tcheck; i++) @@ -793,23 +723,20 @@ bool Entity::clampToSurface(int tcheck, Vector usePos, TileVector hitTile) { Vector n = dsq->game->getWallNormal(pos); n *= getv(EV_WALLOUT); - //pos += n; + Vector diff = getWorldPosition() - pos; - //e->offset.interpolateTo(diff, t); + offset = diff; offset.interpolateTo(n, t); position = pos; - //e->rotateToSurfaceNormal(t); + rotateToSurfaceNormal(0); setv(EV_CLAMPING, 1); - //e->position.interpolateTo(pos, t); - /* - debugLog("interpolating position"); - e->position.interpolateTo(Vector(0,0,0), t); - */ + + } else position = pos; @@ -842,7 +769,7 @@ void Entity::revive(float a) if (getState() != STATE_IDLE) perform(STATE_IDLE); onHealthChange(a); - //health += a; + } bool Entity::isGoingToBeEaten() @@ -955,7 +882,7 @@ bool Entity::isNearObstruction(int sz, int type, TileVector *hitTile) break; case OBSCHECK_8DIR: { - //debugLog("8dir"); + for (int d = 0; d <= sz; d++) { @@ -1035,13 +962,7 @@ bool Entity::touchAvatarDamage(int radius, float dmg, const Vector &override, fl { usePosition = getWorldCollidePosition(collidePos); - /* - std::ostringstream os; - os << "position(" << position.x << ", " << position.y << ") - "; - os << "usePosition(" << usePosition.x << ", " << usePosition.y << ") - "; - os << "collidePos(" << collidePos.x << ", " << collidePos.y << ")"; - debugLog(os.str()); - */ + } if (radius == 0 || (dsq->game->avatar->getWorldPosition() - usePosition).getSquaredLength2D() < sqr(radius+dsq->game->avatar->collideRadius)) @@ -1057,8 +978,8 @@ bool Entity::touchAvatarDamage(int radius, float dmg, const Vector &override, fl { Vector diff = dsq->game->avatar->position - position; diff.setLength2D(speed); - //dsq->game->avatar->vel += diff; - //dsq->game->avatar->push(v, pushTime, , 0); + + dsq->game->avatar->push(diff, pushTime, speed, dmg); } else if (speed > 0) @@ -1068,41 +989,27 @@ bool Entity::touchAvatarDamage(int radius, float dmg, const Vector &override, fl diff.setLength2D(speed); dsq->game->avatar->vel += diff; } - /* - if (pushTime != 0) - { - Vector v = (dsq->game->avatar->position - this->position); - v.setLength2D(1000); - dsq->game->avatar->push(v, pushTime, 800, 0); - } - */ - //dsq->game->avatar->damage(dmg); + + return true; } return false; } const float sct = 0.15; -//const float blurMax = 0.04; + const float blurMax = 0.01; const float blurMin = 0.0; -/* -const float blurMax = 0.05; -const float blurMin = 0.0; -*/ + void Entity::onFHScale() { flipScale.interpolateTo(Vector(1, 1), sct); _fh = !_fh; - /* - copySkel.fhTo(!_fh); - skeletalSprite.alpha.interpolateTo(1, 0.5); - copySkel.alpha.interpolateTo(0, 0.5); - */ - //skeletalSprite.alpha.interpolateTo(1,sct); - //blurShaderAnim.interpolateTo(Vector(blurMin,0,0), sct); + + + fhScale = 0; } @@ -1113,22 +1020,12 @@ void Entity::onFH() if (!fhScale) { flipScale = Vector(1,1); - /* - copySkel.children = skeletalSprite.children; - copySkel.scale = skeletalSprite.scale; - copySkel.position = skeletalSprite.scale; - copySkel.animations = skeletalSprite.animations; - */ - //skeletalSprite.alpha.interpolateTo(0, sct*2); - //skeletalSprite.alpha.interpolateTo(0.5, sct); - //flipScale.interpolateTo(Vector(1.5, 1), sct); flipScale.interpolateTo(Vector(0.6, 1), sct); - //blurShaderAnim = Vector(blurMin); - //blurShaderAnim.interpolateTo(Vector(blurMax,0,0), sct/2); + fhScale = 1; } @@ -1191,7 +1088,7 @@ void Entity::update(float dt) if (dieTimer <0) { dieTimer = 0; - //safeKill(); + setLife(1); setDecayRate(1); fadeAlphaWithLife = 1; @@ -1214,26 +1111,8 @@ void Entity::update(float dt) } } - /* - skeletalSprite.setFreeze(false); - skeletalSprite.update(dt); - */ - /* - std::string bgAction; - if (frozenTimer > 0) - { - bgAction = currentAction; - currentAction = "frozen"; - } - */ - /* - if (!bgAction.empty()) - { - currentAction = bgAction; - } - */ } updateBoneLock(); @@ -1271,7 +1150,7 @@ bool Entity::pathBurst(bool wallJump) else position.data->pathTimeMultiplier = 1.5; burstTimer.start(1); - //void pathBurst();r + return true; } return false; @@ -1341,7 +1220,7 @@ void Entity::movementDetails(Vector v) flipHorizontal(); } } -// offset.interpolateTo(sinf(ondulateTimer)*v.getPerpendicularLeft()*32, 0.5); + if (skeletalSprite.isLoaded()) { if (burstTimer.isActive()) @@ -1369,24 +1248,11 @@ void Entity::slowToStopPath(float t) bool Entity::isSlowingToStopPath() { bool v = (slowingToStopPath > 0); - /* - if (v) - debugLog("isSlowingToStopPath: true"); - */ + return v; } -/* -void Entity::updateAvatarRollPull(float dt) -{ - if (dsq->game->avatar->isRolling()) - { - if (position - dsq->game->avatar->position) - { - } - } -} -*/ + bool Entity::updateCurrents(float dt) { @@ -1397,7 +1263,7 @@ bool Entity::updateCurrents(float dt) //if (isUnderWater()) // why? { - //Path *p = dsq->game->getNearestPath(position, PATH_CURRENT); + if (!dsq->game->isWorldPaused()) { for (Path *p = dsq->game->getFirstPathOfType(PATH_CURRENT); p; p = p->nextOfType) @@ -1417,11 +1283,7 @@ bool Entity::updateCurrents(float dt) accum += dir; c++; - /* - dir.setLength2D(p->currentMod); - vel2 += dir*dt; - vel2.capLength2D(p->currentMod); - */ + } } } @@ -1471,15 +1333,10 @@ bool Entity::updateCurrents(float dt) } else { - //vel2.capLength2D(cap); + } } - /* - if (!inCurrent && !vel2.isZero() && !vel2.isInterpolating()) - { - vel2.interpolateTo(Vector(0,0,0), 1); - } - */ + return inCurrent; } @@ -1524,55 +1381,14 @@ bool Entity::isSittingOnInvisibleIn() return false; - //bool invisibleIn = false; - ////Vector f = getForward(); - //Vector f = getNormal(); - //TileVector t(position); - //float tx = float(t.x); - //float ty = float(t.y); - //float otx = float(t.x); - //float oty = float(t.y); - // - //for (int check = 0; check < 4; check++) - //{ - // /* - // std::ostringstream os; - // os << "check: " << check << " p(" << position.x <<", " << position.y << ") f(" << f.x << ", " << f.y << ") t(" << tx << ", " << ty << ") tile found: " << dsq->game->getGrid(TileVector(tx, ty)); - // debugLog(os.str()); - // */ - // if (dsq->game->getGrid(TileVector(tx, ty))==OT_EMPTY) - // { - // } - // else if (dsq->game->getGrid(TileVector(tx, ty))==OT_INVISIBLEIN) - // { - // invisibleIn = true; - // //debugLog("invisible in!"); - // break; - // } - // else - // { - // //debugLog("obstruction, aborting"); - // break; - // } - // tx -= f.x; - // ty -= f.y; - // /* - // tx = float(t.x) - f.x*float(check); - // ty = float(t.y) - f.y*float(check); - // */ - //} - //return invisibleIn; + } void Entity::moveOutOfWall() { - /* - Vector v = getWorldCollidePosition(Vector(0,-1)); - // HACK: is normalize necessary here? (distance of 1 presumabley) - Vector n = (v - position); - n.normalize2D(); - */ + + Vector n = getNormal(); TileVector t(position); int c = 0; @@ -1582,7 +1398,7 @@ void Entity::moveOutOfWall() c++; if (c > 6) { - //debugLog("entity: " + name + " exceeded max moveOutOfWall()"); + useValue = false; break; } @@ -1697,12 +1513,11 @@ void Entity::onUpdate(float dt) break; } - //blurShaderAnim.update(dt); + } - //vel2=0; Vector lastPos = position; if (ridingOnEntity) @@ -1715,24 +1530,20 @@ void Entity::onUpdate(float dt) hair->color.x = color.x * multColor.x; hair->color.y = color.y * multColor.y; hair->color.z = color.z * multColor.z; - //hair->color = this->color; + } if (slowingToStopPath > 0) { - /* - std::ostringstream os; - os << "slowingToStopPath: " << slowingToStopPath; - debugLog(os.str()); - */ + slowingToStopPathTimer += dt; position.ensureData(); if (slowingToStopPathTimer >= slowingToStopPath) { - // done + position.data->pathTimeMultiplier = 1; -// stopFollowingPath(); + idle(); slowingToStopPath = 0; slowingToStopPathTimer = 0; @@ -1816,34 +1627,14 @@ void Entity::onUpdate(float dt) if (bubble) bubble->position = this->position; - /* - if (frozenTimer > 0) - { - frozenTimer --; - if (frozenTimer <= 0) - { - frozenTimer = 0; - popBubble(); - } - } - */ + if (getState() == STATE_PUSH) { - //vel = pushVec * this->time; + vel = pushVec; } - /* - else if (this->currentAction == "freeze") - { - if (this->enqueuedAction != "freeze") - { - this->enqueuedAction = ""; - } - if (canBeFrozen) - vel = Vector(0,0,0); - } - */ + else if (followEntity) { Vector lastPos = position; @@ -1871,14 +1662,14 @@ void Entity::onUpdate(float dt) Vector mov = followEntity->position + off - this->position; if (mov.getSquaredLength2D() > sqr(96)) { - //following = true; + int spd = mov.getLength2D(); spd -= 64; if (spd < 0) spd = 0; else if (spd < 400) spd *= 2; - //spd /= ; + else spd = 800; @@ -1898,11 +1689,7 @@ void Entity::onUpdate(float dt) if (stickToNaijasHead) { position = dsq->game->avatar->headPosition; - /* - std::ostringstream os; - os << "pos(" << dsq->game->avatar->headPosition.x << ", " <game->avatar->headPosition.y << ")"; - debugLog(os.str()); - */ + } updateLance(dt); @@ -1912,14 +1699,7 @@ void Entity::updateBoneLock() { if (boneLock.on) { - /* - Vector pos = boneLock.bone->getWorldCollidePosition(boneLock.localOffset); - Vector bpos = boneLock.bone->getWorldPosition(); - position = pos; - boneLock.wallNormal = pos - bpos; - boneLock.wallNormal.normalize2D(); - rotateToVec(boneLock.wallNormal, 0.01); - */ + Vector lastPosition = position; @@ -1946,36 +1726,11 @@ void Entity::updateBoneLock() } - /* - Vector bpos = boneLock.bone->getWorldPosition(); - boneLock.wallNormal = position - bpos; - rotateToVec(boneLock.wallNormal, 0.01); - */ - - //debugLog("wall normal"); - - - - - /* - Vector p = boneLock.bone->getWorldPosition(); - Vector o = boneLock.localOffset; - position = p+o; - - boneLock.wallNormal = o; - boneLock.wallNormal.normalize2D(); - */ - - onUpdateBoneLock(); - /* - wallNormal = o; - wallNormal.normalize2D(); - rotateToVec(wallNormal, 0); - */ - //position = boneLock.bone->getWorldPosition() + boneLock.localOffset; - //rotation = boneLock.bone->getWorldRotation(); + + + } } @@ -1991,7 +1746,7 @@ void Entity::idle() position.stopPath(); perform(Entity::STATE_IDLE); skeletalSprite.stopAllAnimations(); - //skeletalSprite.animate("idle", -1, 0); + onIdle(); skeletalSprite.transitionAnimate(getIdleAnimName(), 0.3, -1); @@ -2072,10 +1827,10 @@ Entity* Entity::getRiding() void Entity::attachEntity(Entity *e, Vector offset) { attachedEntities.push_back(e); - //e->position - position + attachedEntitiesOffsets.push_back(offset); e->attachedTo = this; - //dsq->game->avatar->position - avatarOffset; + } void Entity::detachEntity(Entity *e) @@ -2097,14 +1852,7 @@ void Entity::detachEntity(Entity *e) } } -//if (fabsf(rotation.z - angle) > 180) -//{ -// rotation.z += 360; -//} -/* -if (rotation.z > 270 && angle > -45 && angle < 0) - angle = 360 + angle; -*/ + void Entity::rotateToVec(Vector addVec, float time, float offsetAngle) { @@ -2126,27 +1874,6 @@ void Entity::rotateToVec(Vector addVec, float time, float offsetAngle) rotation.z = rotation.z - 360; - /* - if (rotation.z >= 270 && angle < 90) - { - rotation.stop(); - rotation.z -= 360; - } - if (rotation.z <= 90 && angle > 270) - { - rotation.stop(); - rotation.z += 360; - } - */ - - /* - if (fabsf(angle - rotation.z) > 180) - { - // something's wrong - rotation.z += 360; - } - */ - if (time == 0) rotation = Vector(0,0,angle); @@ -2224,15 +1951,12 @@ void Entity::push(const Vector &vec, float time, float maxSpeed, float dmg) maxSpeed = this->maxSpeed; } this->pushMaxSpeed = maxSpeed; - /* - Vector v = vec; - v.setLength2D(maxSpeed); - */ + setState(STATE_PUSH, time); pushVec = vec; pushVec.z = 0; } - //vel += pushVec; + } void Entity::setMaxSpeed(float ms) @@ -2408,7 +2132,7 @@ void Entity::onEnterState(int action) sound("Gulp"); } popBubble(); - //dsq->game->avatar->entityDied(this); + Shot::targetDied(this); if (!calledEntityDied) { @@ -2493,43 +2217,13 @@ void Entity::onExitState(int action) break; } - /* - // this is bad, prevents DEATH - // try to prevent exitState from changing from deathscene - if (health <= 0) - { - enqueuedState = STATE_NONE; - } - */ - /* - else if (action == "freezeRecover") - { - enqueuePerform("idle", -1); - } - else if (action == "freeze") - { - if (nextAction == "freeze") - { - } - else - { - popBubble(); - //enqueuePerform("idle", -1); - } - } - */ + } void Entity::popBubble() { - /* - if (currentAction == "freeze") - { - sound("pop"); - enqueuePerform("freezeRecover",1); - } - */ + if (bubble) { @@ -2543,17 +2237,7 @@ void Entity::popBubble() } } -/* -bool Entity::onDamage(int amount, Spell *spell, Entity *attacker) -{ - if (bubble) - { - popBubble(); - onDamage(1, spell, attacker); - } - return true; -} -*/ + bool Entity::isHit() { @@ -2563,7 +2247,7 @@ bool Entity::isHit() bool Entity::isInvincible() { return (invincible); - //|| (invincibleBreak && damageTimer.isActive()) + } void Entity::setInvincible(bool inv) @@ -2614,7 +2298,7 @@ bool Entity::updateLocalWarpAreas(bool affectAvatar) if (!p->nodes.empty()) { PathNode *n = &p->nodes[0]; - if (p && n) // && core->getNestedMains() == 1 + if (p && n) { if (p->warpMap.empty() && !p->warpNode.empty() && p->isCoordinateInside(position)) { @@ -2670,7 +2354,7 @@ bool Entity::damage(const DamageData &dmgData) DamageData d = dmgData; if (d.damageType == DT_NONE) return false; - //if () return true; + if (isEntityDead()) { //DUPE: same as below @@ -2683,14 +2367,10 @@ bool Entity::damage(const DamageData &dmgData) this->multColor = Vector(1,1,1); this->multColor.stop(); - /* - std::ostringstream os; - os << "starting damage timer: " << vars->damageTime; - debugLog(os.str()); - */ + if (dmgData.useTimer) damageTimer.start(damageTime); - //3 + //DUPE: same as above //HACK: hackish @@ -2768,32 +2448,10 @@ void Entity::clampToHit() dist.setLength2D(collideRadius); position = dsq->game->lastCollidePosition + dist; setv(EV_CRAWLING, 1); - //setCrawling(true); + } -/* -void Entity::damage(int amount, Spell *spell, Entity *attacker) -{ - //if (dsq->continuity.getWorldType() != WT_NORMAL) return; - if (!takeDamage) return; - if (isEntityDead()) return; - if (invincibleBreak && this->multColor.isInterpolating()) return; - if (onDamage(amount, spell, attacker)) - { - //color = currentColor; - this->multColor.interpolateTo(Vector(1, 0.5, 0.5), 0.1, 3, 1); - health -= amount; - if (health <= 0) - { - if (attacker) - attacker->getEXP(exp); - health = 0; - entityDead = true; - perform(STATE_DEAD); - } - } -} -*/ + void Entity::doEntityAvoidance(float dt, int range, float mod, Entity *ignore) { @@ -2842,24 +2500,18 @@ void Entity::render() else renderBorderColor = Vector(0.5,0.5,0.5); renderBorder = true; - //errorLog("!^!^$"); + } #endif // HACK: need to multiply base + etc skeletalSprite.setColorMult(this->color, this->alpha.x); - /*bool set=false; - if (beautyFlip && blurShader.isLoaded() && flipScale.isInterpolating() && dsq->user.video.blur) - { - //swizzle - blurShader.setValue(color.x, color.y, color.z, blurShaderAnim.x); - blurShader.bind(); - set = true; - }*/ + + Quad::render(); - //if (beautyFlip && blurShader.isLoaded() && flipScale.isInterpolating()) - //if (set) - // blurShader.unbind(); + + + renderBorder = false; skeletalSprite.clearColorMult(); color = bcolor; @@ -2870,7 +2522,7 @@ void Entity::doGlint(const Vector &position, const Vector &scale, const std::str { float glintTime = 0.4; Quad *glint = new Quad; - //glint->setBlendType(RenderObject::BLEND_ADD); + glint->setBlendType(bt); glint->setTexture(tex); glint->scale = Vector(0.5,0.5); @@ -2881,7 +2533,7 @@ void Entity::doGlint(const Vector &position, const Vector &scale, const std::str glint->alpha.data->path.addPathNode(1, 0.7); glint->alpha.data->path.addPathNode(0, 1); glint->alpha.startPath(glintTime); - //glint->rotation.interpolateTo(Vector(0,0,360), glintTime); + glint->rotation.z = this->rotation.z; glint->setLife(glintTime); glint->setDecayRate(1); @@ -2897,27 +2549,7 @@ void Entity::doSpellAvoidance(float dt, int range, float mod) { BBGE_PROF(Entity_doSpellAvoidance); Vector accum; - /* - int c = 0; - for (int i = 0; i < dsq->game->spells.size(); i++) - { - Spell *s = dsq->game->spells[i]; - if ((s->position - this->position).getSquaredLength2D() < sqr(range)) - { - Vector d = this->position - s->position; - d.z=0; - d |= range - d.getLength2D(); - accum += d; - c++; - } - } - if (accum.x != 0 || accum.y != 0) - { - accum /= c; - accum /= range; - vel += accum*getMaxSpeed()*mod; - } - */ + int c = 0; for (Shot::Shots::iterator i = Shot::shots.begin(); i != Shot::shots.end(); i++) { @@ -3006,14 +2638,7 @@ void Entity::setID(int id) int Entity::getID() { - /* - for (int i = 0; i < dsq->entities.size(); i++) - { - if (dsq->entities[i] == this) - return i+1; - } - return 0; - */ + return entityID; } @@ -3037,15 +2662,11 @@ bool Entity::doCollisionAvoidance(float dt, int search, float mod, Vector *vp, f b.setLength2D((waterBubble->rect.getWidth()*0.5f) - b.getLength2D()); if (b.isLength2DIn(search*TILE_SIZE)) { - /* - std::ostringstream os; - os << "b( " << b.x << ", " << b.y << ")"; - debugLog(os.str()); - */ + accum -= b; c++; - //vel -= accum*getMaxSpeed()*mod; - //return true; + + } } } diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index 00efb01..114210e 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -217,7 +217,7 @@ public: ACT_RANGE = 1 }; void destroy(); - //void damage(int amount, Spell *spell=0, Entity *attacker=0); + bool isEntityDead() const {return entityDead;} std::string name; Vector vel; @@ -238,14 +238,13 @@ public: void push(const Vector &vec, float time, float maxSpeed, float dmg); bool canSetState(int state); - + virtual void message(const std::string &msg, int v) {} virtual int messageVariadic(lua_State *L, int nparams) { return 0; } bool isUnderWater(const Vector &o=Vector()); - //virtual void onHitBySpell(Spell *spell) {} - //virtual void onCollide(Entity *e); + virtual bool damage(const DamageData &d); virtual bool canShotHit(const DamageData &d) { return true; } @@ -313,7 +312,7 @@ public: STATE_TITLE =24 }; virtual void onNotify(Entity *notify){} - //void followPath(Path *p, int spd, int loop, bool deleteOnEnd = false); + float followPath(Path *p, float speed, int dir, bool deleteOnEnd = false); Entity *attachedTo; bool touchAvatarDamage(int radius, float dmg, const Vector &override=Vector(-1,-1,-1), float speed=0, float pushTime = 0, Vector collidePos = Vector(0,0,0)); @@ -334,7 +333,7 @@ public: void doEntityAvoidance(float dt, int range, float mod, Entity *ignore =0); void setMaxSpeed(float ms); Entity *findTarget(int dist, int type, int t=0); - //bool hasTarget() { return target != 0; } + bool hasTarget(int t=0); bool isTargetInRange(int range, int t=0); void doGlint(const Vector &position, const Vector &scale=Vector(2,2), const std::string &tex="Glint", RenderObject::BlendTypes bt=BLEND_DEFAULT); @@ -419,10 +418,7 @@ public: Vector ridingOnEntityOffset; void moveOutOfWall(); bool isSittingOnInvisibleIn(); - /* - void setCrawling(bool on) { crawling = on; } - bool isCrawling() { return crawling; } - */ + void flipToVel(); bool isInCurrent() { return inCurrent; } void clearTargetPoints(); @@ -456,10 +452,10 @@ public: void clampToHit(); bool updateLocalWarpAreas(bool affectAvatar); virtual void entityDied(Entity *e); - //bool registerEntityDied; + bool clampToSurface(int tcheck=0, Vector usePos=Vector(0,0), TileVector hitTile=TileVector(0,0)); bool checkSurface(int tcheck, int state, float statet); - //static Shader blurShader; + std::string naijaReaction; Vector lookAtPoint; Vector getLookAtPoint(); @@ -533,7 +529,7 @@ protected: int lance; Bone *lanceBone; void updateLance(float dt); - //InterpolatedVector blurShaderAnim; + int fhScale, fvScale; @@ -555,9 +551,9 @@ protected: Vector getMoveVel(); DisabledDamageTypes disabledDamageTypes; - //bool crawling; - //Vector backupPos, backupVel; + + virtual void onIdle() {} virtual void onHeal(int type){} virtual void onDamage(DamageData &d){} @@ -578,7 +574,7 @@ protected: virtual void onFreeze(){} - //Entity *target; + std::vectortargets; virtual void onAlwaysUpdate(float dt){} virtual void onUpdateFrozen(float dt){} @@ -589,7 +585,7 @@ protected: void onEnterState(int action); void onExitState(int action); - //virtual bool onDamage(int amount, Spell *spell, Entity *attacker); + bool invincibleBreak; bool entityDead; @@ -606,10 +602,10 @@ protected: float pushMaxSpeed; std::string currentAnim; - + protected: - + Timer poisonTimer, poisonBitTimer; float poison; private: diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 7efaaec..c96cb9f 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -251,7 +251,7 @@ void FoodHolder::setIngredient(IngredientData *i, bool effects) if (effects) { core->sound->playSfx("Wok"); - + ing->scale.ensureData(); ing->scale.data->path.clear(); ing->scale.data->path.addPathNode(Vector(1,1),0); @@ -560,7 +560,7 @@ void FoodSlot::onUpdate(float dt) dsq->game->foodLabel->alpha.interpolateTo(0, 2); dsq->game->foodDescription->alpha.interpolateTo(0, 2); - + break; //return; } @@ -814,7 +814,7 @@ void TreasureSlot::onUpdate(float dt) if (doubleClickTimer > 0) { doubleClickTimer = 0; - + dsq->game->onUseTreasure(flag); } else @@ -822,7 +822,7 @@ void TreasureSlot::onUpdate(float dt) dsq->sound->playSfx("treasure-select", 0.5); dsq->spawnParticleEffect("menu-switch", worldRightCenter, 0, 0, LR_HUD3, 1); - + dsq->game->treasureLabel->setText(treasureName); dsq->game->treasureLabel->alpha = 1; @@ -889,7 +889,7 @@ void TreasureSlot::refresh() h = sz; w = (width*sz)/height; } - + setWidthHeight(w*scl, h*scl); std::string parse = dsq->continuity.stringBank.get(flag); @@ -1122,7 +1122,7 @@ Ingredient *Game::spawnIngredient(const std::string &ing, const Vector &pos, int Ingredient *i = 0; for (int c = 0; c < times; c++) { - //HACK: + //HACK: if (nocasecmp(ing, "poultice")==0) use = "LeafPoultice"; @@ -1295,7 +1295,7 @@ void Game::showInGameMenu(bool ignoreInput, bool optionsOnly, MenuPage menuPage) if (avatar && core->getNestedMains()==1 && !avatar->isSinging() && (ignoreInput || avatar->isInputEnabled())) { //dsq->toggleInputGrabPlat(false); - + dsq->game->clearControlHint(); selectedTreasureFlag = -1; @@ -1449,7 +1449,7 @@ void Game::showInGameMenu(bool ignoreInput, bool optionsOnly, MenuPage menuPage) useMenuPage = dsq->continuity.lastMenuPage; } } - + switch(useMenuPage) { @@ -1490,7 +1490,7 @@ void Game::showInGameMenu(bool ignoreInput, bool optionsOnly, MenuPage menuPage) } } } - + if (!optionsOnly) { @@ -1500,14 +1500,14 @@ void Game::showInGameMenu(bool ignoreInput, bool optionsOnly, MenuPage menuPage) menu[i]->alpha.interpolateTo(1, 0.15); } - + menuIconGlow->alpha.interpolateTo(1, 0.5); } menuOpenTimer = 0; inGameMenu = true; - + dsq->routeShoulder = false; @@ -1515,7 +1515,7 @@ void Game::showInGameMenu(bool ignoreInput, bool optionsOnly, MenuPage menuPage) dsq->screenTransition->transition(MENUPAGETRANSTIME); - + if (optionsOnly) { @@ -1553,7 +1553,7 @@ void Game::hideInGameMenu(bool effects, bool cancel) resBox->close(); //dsq->toggleInputGrabPlat(true); - + if (effects) core->sound->playSfx("Menu-Close"); @@ -1588,7 +1588,7 @@ void Game::hideInGameMenu(bool effects, bool cancel) toggleMainMenu(false); toggleKeyConfigMenu(false); } - + menuIconGlow->alpha = 0; for (i = 0; i < menu.size(); i++) @@ -1614,8 +1614,8 @@ void Game::hideInGameMenu(bool effects, bool cancel) menuBg->alpha.interpolateTo(0, t); menuBg->scale.interpolateTo(menuBg->scale*0.5f, t); menuBg2->alpha.interpolateTo(0, t); - - + + if (menuSongs) menuSongs->alpha.interpolateTo(0, t); @@ -1645,8 +1645,7 @@ void Game::hideInGameMenu(bool effects, bool cancel) for (int i = 0; i < songTips.size(); i++) songTips[i]->alpha = 0; - - + for (int i = 0; i < dropIngrNames.size(); i++) @@ -1654,7 +1653,7 @@ void Game::hideInGameMenu(bool effects, bool cancel) dsq->game->spawnIngredient(dropIngrNames[i], avatar->position + Vector(0,-96), 1, 1); } dropIngrNames.clear(); - + if (effects) dsq->quitNestedMain(); @@ -1866,7 +1865,7 @@ void Game::transitionToScene(std::string scene) } sceneToLoad = scene; stringToLower(sceneToLoad); - + core->enqueueJumpState("Game", false); } @@ -1949,7 +1948,6 @@ void Game::clearObsRows() void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim) { -#ifdef BBGE_BUILD_OPENGL if (q->texture) { std::vector obs; @@ -2079,7 +2077,6 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim) } glPopMatrix(); } -#endif } std::string Game::getNoteName(int n, const std::string &pre) @@ -2764,7 +2761,6 @@ void Game::setTimerText(float time) void Game::generateCollisionMask(Quad *q, float overrideCollideRadius /* = 0 */) { -#ifdef BBGE_BUILD_OPENGL if (q->texture) { if (overrideCollideRadius) @@ -2868,7 +2864,6 @@ void Game::generateCollisionMask(Quad *q, float overrideCollideRadius /* = 0 */) rot += 360; */ } -#endif } void Game::addPath(Path *p) @@ -3217,10 +3212,10 @@ void Game::sortFood() dsq->continuity.sortByUnsort.push_back(FoodSortOrder(IT_NONE, IET_NONE, dsq->continuity.ingredients[i].name)); } */ - + std::vector foodHolderNames; foodHolderNames.resize(foodHolders.size()); - + for (int i = 0; i < foodHolders.size(); i++) { IngredientData *ing = foodHolders[i]->getIngredient(); if (ing) { @@ -3233,22 +3228,22 @@ void Game::sortFood() dsq->continuity.foodSortType++; if (dsq->continuity.foodSortType >= MAX_FOODSORT) dsq->continuity.foodSortType = 0; - + dsq->continuity.sortFood(); - + // rebuild the page - + refreshFoodSlots(false); - + /* toggleFoodMenu(false); toggleFoodMenu(true); */ - + dsq->sound->playSfx("shuffle"); dsq->sound->playSfx("menu-switch", 0.5); dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - + for (int i = 0; i < foodHolders.size(); i++) { if (!foodHolderNames[i].empty()) { IngredientData *ing = dsq->continuity.getIngredientHeldByName(foodHolderNames[i]); @@ -3336,7 +3331,7 @@ void Game::createInGameMenu() int h = controllabels->getHeight(); controllabels->position = Vector(checkx-16-w/2.0f, checky + h/2.0f - 14); options->addChild(controllabels, PM_POINTER); - + int scheckx=270; @@ -3471,7 +3466,7 @@ void Game::createInGameMenu() // Vector(575,250); - + songLabel = new BitmapText(&dsq->smallFont); { @@ -3486,7 +3481,6 @@ void Game::createInGameMenu() - ToolTip *tip = 0; foodTips.clear(); @@ -3579,24 +3573,24 @@ void Game::createInGameMenu() int offy = -20; #define SB(x) dsq->continuity.stringBank.get(x) - + TTFText *header_action = new TTFText(&dsq->fontArialSmall); header_action->setText(SB(2101)); header_action->position = Vector(140, 80+offy); group_keyConfig->addChild(header_action, PM_POINTER); - + TTFText *header_key1 = new TTFText(&dsq->fontArialSmall); header_key1->setText(SB(2102)); header_key1->position = Vector(350, 80+offy); header_key1->setAlign(ALIGN_CENTER); group_keyConfig->addChild(header_key1, PM_POINTER); - + TTFText *header_key2 = new TTFText(&dsq->fontArialSmall); header_key2->setText(SB(2103)); header_key2->position = Vector(475, 80+offy); header_key2->setAlign(ALIGN_CENTER); group_keyConfig->addChild(header_key2, PM_POINTER); - + TTFText *header_joy = new TTFText(&dsq->fontArialSmall); header_joy->setText(SB(2104)); header_joy->position = Vector(600, 80+offy); @@ -3620,7 +3614,7 @@ void Game::createInGameMenu() AquariaKeyConfig* s1y = addAxesConfigLine(group_keyConfig, SB(2118), "s1ay", 340+offy, 130); AquariaKeyConfig* s2x = addAxesConfigLine(group_keyConfig, SB(2119), "s2ax", 340+offy, 260); AquariaKeyConfig* s2y = addAxesConfigLine(group_keyConfig, SB(2120), "s2ay", 340+offy, 380); - + s1x->setDirMove(DIR_LEFT, s1x); s1x->setDirMove(DIR_RIGHT, s1y); @@ -3634,7 +3628,7 @@ void Game::createInGameMenu() s2y->setDirMove(DIR_RIGHT, s2y); offy += 20; - + addKeyConfigLine(group_keyConfig, SB(2121), "PrevPage", 340+offy); addKeyConfigLine(group_keyConfig, SB(2122), "NextPage", 360+offy); addKeyConfigLine(group_keyConfig, SB(2123), "CookFood", 380+offy); @@ -3643,7 +3637,7 @@ void Game::createInGameMenu() addKeyConfigLine(group_keyConfig, SB(2126), "FoodDrop", 440+offy); addKeyConfigLine(group_keyConfig, SB(2127), "Look", 460+offy); - + addKeyConfigLine(group_keyConfig, SB(2128), "ToggleHelp", 480+offy); #undef SB @@ -3656,7 +3650,7 @@ void Game::createInGameMenu() group_keyConfig->position = Vector(0, -40); addRenderObject(group_keyConfig, LR_OVERLAY); - + cook = new AquariaMenuItem; cook->useQuad("Gui/cook-button"); @@ -3774,7 +3768,7 @@ void Game::createInGameMenu() showRecipe->followCamera = 1; showRecipe->position = Vector(575,250); addRenderObject(showRecipe, LR_MENU); - + float scrollx = 555; recipeMenu.scroll = new Quad("gui/recipe-scroll", Vector(scrollx, 200)); recipeMenu.scroll->followCamera = 1; @@ -3801,7 +3795,7 @@ void Game::createInGameMenu() recipeMenu.page->setText(dsq->continuity.stringBank.get(2006)); recipeMenu.page->alpha = 0; addRenderObject(recipeMenu.page, LR_RECIPES); - + recipeMenu.prevPage = new AquariaMenuItem; recipeMenu.prevPage->useQuad("Gui/arrow-left"); recipeMenu.prevPage->useSound("click"); @@ -3845,8 +3839,6 @@ void Game::createInGameMenu() - - int outer = 0; int inner = 0; for (i = 0; i < songSlots.size(); i++) @@ -3953,13 +3945,13 @@ void Game::createInGameMenu() menu[4]->position = Vector(400,ty+10); int gs = 40; - + menu[5]->event.set(MakeFunctionEvent(Game, switchToSongMenu)); menu[5]->useQuad("gui/icon-songs"); menu[5]->useGlow("particles/glow", gs, gs); menu[5]->useSound("Click"); menu[5]->position = Vector(400-60, 350); - + menuIconGlow = new Quad("particles/glow", menu[5]->position); menuIconGlow->alphaMod = 0.4; menuIconGlow->alpha = 0; @@ -4014,7 +4006,7 @@ void Game::createInGameMenu() ((AquariaMenuItem*)menu[4])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[6])); - + // ---------- FOOD MENU @@ -4026,7 +4018,7 @@ void Game::createInGameMenu() for (i = 0; i < foodSlots.size(); i++) { foodSlots[i] = new FoodSlot(i); - + float angle = (float(food)/float(foodSlots.size()))*PI*2; foodSlots[i]->position = worldCenter + Vector(sinf(angle), cosf(angle))*foodSlotRadius; @@ -4073,7 +4065,7 @@ void Game::createInGameMenu() // ---------- TREASURES - + int treasureSlotRadius = 96; treasureSlots.resize(treasurePageSize); @@ -6127,16 +6119,16 @@ void Game::toggleWorldMap() void Game::applyState() { bool verbose = true; - applyingState = true; + applyingState = true; helpText = 0; helpUp = helpDown = 0; inHelpScreen = false; helpBG = 0; helpBG2 = 0; - + dsq->returnToScene = ""; - + // new place where mods get stopped! // this lets recaching work // (presumably because there has been time for the garbage to be cleared) @@ -6155,7 +6147,7 @@ void Game::applyState() enqueuedPreviewRecipe = 0; dsq->toggleBlackBars(false); - + dsq->setTexturePointers(); @@ -6226,9 +6218,9 @@ void Game::applyState() { dsq->game->setElementLayerVisible(i-LR_ELEMENTS1, true); } - + dsq->applyParallaxUserSettings(); - + controlHintTimer = 0; cameraConstrained = true; // reset parallax @@ -6462,15 +6454,12 @@ void Game::applyState() - if (toFlip == 1) { dsq->game->avatar->flipHorizontal(); toFlip = -1; } - - // li @@ -6943,7 +6932,7 @@ void Game::applyState() { dsq->toggleCursor(true, 0.5); } - + dsq->forceInputGrabOff(); debugLog("Game::applyState Done"); @@ -7366,7 +7355,7 @@ void Game::onCook() goto endcook; } } - + if(!data) { dsq->sound->playSfx("Denied"); @@ -7412,7 +7401,7 @@ void Game::onCook() //dsq->main(0.2); - + if (longAnim) { float ft = 0.8; @@ -7719,7 +7708,7 @@ void Game::setControlHint(const std::string &h, bool left, bool right, bool midd controlHint_image->alpha.interpolateTo(0, hintTransTime); } - + controlHint_text->position.x = 400 - controlHint_text->getSetWidth()/2 + 25; //400 - controlHint_bg->getWidth()/2 + 25; controlHint_text->setAlign(ALIGN_LEFT); @@ -7858,7 +7847,7 @@ void Game::toggleHelpScreen(bool on, const std::string &label) helpWasPaused = isPaused(); togglePause(true); - + std::string data; // These say "Mac" but we use them on Linux, too. @@ -7879,7 +7868,7 @@ void Game::toggleHelpScreen(bool on, const std::string &label) } fname = localisePath("data/help_start.txt"); appendFileToString(data, fname); - + // These say "Mac" but we use them on Linux, too. #if defined(BBGE_BUILD_UNIX) fname = localisePath("data/help_end_mac.txt"); @@ -7927,7 +7916,7 @@ void Game::toggleHelpScreen(bool on, const std::string &label) int line = helpText->findLine(label); helpText->offset.interpolateTo(Vector(0, -helpText->getLineHeight()*line), -1200); } - + //helpText->offset.interpolateTo(Vector(0, -400), 4, -1, 1); //test->position = Vector(400,300); addRenderObject(helpText, LR_HELP); @@ -7972,7 +7961,7 @@ void Game::toggleHelpScreen(bool on, const std::string &label) { core->getRenderObjectLayer(i)->visible = false; } - + core->resetTimer(); dsq->screenTransition->transition(MENUPAGETRANSTIME); @@ -8447,7 +8436,7 @@ void Game::preLocalWarp(LocalWarpType localWarpType) { dsq->game->avatar->warpInLocal = Vector(0,0,0); } - + dsq->screenTransition->capture(); core->resetTimer(); } @@ -9092,7 +9081,7 @@ void Game::toggleFoodMenu(bool f) if (dsq->game->avatar) { Path *p=0; - if (dsq->continuity.getFlag(FLAG_UPGRADE_WOK) > 0 + if (dsq->continuity.getFlag(FLAG_UPGRADE_WOK) > 0 || ((p=dsq->game->getNearestPath(dsq->game->avatar->position, PATH_COOK)) && p->isCoordinateInside(dsq->game->avatar->position))) { @@ -9173,7 +9162,7 @@ void Game::toggleFoodMenu(bool f) foodLabel->alphaMod = 0; foodLabel->alpha = 0; foodDescription->alpha = 0; - foodSort->alpha = 0; + foodSort->alpha = 0; showRecipe->alpha = 0; liCrystal->alpha = 0; @@ -9276,7 +9265,7 @@ void Game::toggleKeyConfigMenu(bool f) { const float t = 0; playingSongInMenu = -1; - + if (f && !keyConfigMenu) { @@ -9322,13 +9311,13 @@ void Game::toggleKeyConfigMenu(bool f) opt_cancel->alpha = 1; opt_save->alpha = 1; - + opt_save->position = opt_save_original + Vector(0, 120); opt_cancel->position = opt_cancel_original + Vector(0, 120); opt_cancel->setFocus(true); - + menuIconGlow->alpha = 0; //dsq->screenTransition->transition(MENUPAGETRANSTIME); @@ -9345,7 +9334,7 @@ void Game::toggleKeyConfigMenu(bool f) opt_save->position = opt_save_original; opt_cancel->position = opt_cancel_original; - + menuIconGlow->alpha = 1; } } @@ -9364,7 +9353,7 @@ void Game::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) { dsq->continuity.lastOptionsMenuPage = currentMenuPage; } - + toggleFoodMenu(false); optionsMenu = true; voxslider->setValue(dsq->user.audio.voxvol); @@ -9434,7 +9423,7 @@ void Game::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) liCrystal->alpha = 1; optionsMenu = true; - + menuIconGlow->alpha = 0; /* @@ -9447,7 +9436,7 @@ void Game::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) lips->alpha = 0; keyConfigButton->alpha = 0; - + options->alpha.interpolateTo(0, t); opt_cancel->alpha = 0; @@ -9465,7 +9454,7 @@ void Game::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) optionsMenu = false; - + if (!optionsOnly) { for (int i = 0; i <= 1; i++) @@ -9503,12 +9492,12 @@ void Game::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) //((AquariaMenuItem*)menu[4])->setFocus(true); - + menuBg2->alpha.interpolateTo(1, t); } - + menuIconGlow->alpha = 1; - + } } @@ -9752,7 +9741,7 @@ void Game::updateCursor(float dt) // instant during map fadeout). if (dsq->inputMode == INPUT_MOUSE || isSceneEditorActive() || dsq->game->isPaused()) dsq->cursor->alphaMod = 0.5; - + /* dsq->cursor->offset.stop(); dsq->cursor->offset = Vector(0,0); @@ -10000,7 +9989,7 @@ const float helpTextScrollSpeed = 800.0f; const float helpTextScrollClickAmount = 340.0f; const float helpTextScrollClickTime = -helpTextScrollSpeed; void Game::onHelpDown() -{ +{ float to = helpText->offset.y - helpTextScrollClickAmount; if (to < -helpText->getHeight() + core->getVirtualHeight()) { @@ -10393,7 +10382,7 @@ void Game::update(float dt) if (cameraFollow) { Vector dest = *cameraFollow; - + if (avatar) { if (avatar->looking && !dsq->game->isPaused()) { @@ -10732,7 +10721,7 @@ void Game::removeState() const float fadeTime = 0.25; dsq->toggleVersionLabel(false); - + dsq->subtitlePlayer.hide(fadeTime); dropIngrNames.clear(); diff --git a/Aquaria/Game.h b/Aquaria/Game.h index ff49f85..687a120 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -58,7 +58,7 @@ struct RecipeMenu Quad *scrollEnd; BitmapText *header, *page, *description; AquariaMenuItem *nextPage, *prevPage; - + void toggle(bool on, bool watch=false); void createPage(int p); @@ -68,7 +68,7 @@ struct RecipeMenu void goPrevPage(); int getNumPages(); int getNumKnown(); - + int currentPage; bool on; @@ -100,7 +100,7 @@ const float MIN_SIZE = 0.1; #undef AQUARIA_BUILD_SCENEEDITOR #endif -//#include "GridRender.h" + class GridRender; class MiniMapRender; class WaterSurfaceRender; @@ -487,9 +487,9 @@ public: void updateSelectedElementPosition(Vector position); int selectedEntityType; - //int curEntity; + SelectedEntity selectedEntity; - //EntityGroups::iterator page; + int entityPageNum; void checkForRebuild(); @@ -633,7 +633,7 @@ public: void removeState(); void update(float dt); void onLeftMouseButton(); - //std::vectoritems; + Avatar *avatar; Entity *li; @@ -642,7 +642,7 @@ public: FoodSlot *moveFoodSlotToFront; - //void doChoiceMenu(Vector position, std::vector choices); + std::string getSelectedChoice() { return selectedChoice; } @@ -824,8 +824,8 @@ public: Precacher tileCache; - //void cameraPanToNode(Path *p, int speed=500); - //void cameraRestore(); + + void setCameraFollow(Vector *position); Shot *fireShot(Entity *firer, const std::string &particleEffect, Vector position, bool big, Vector direction, Entity *target, int homing=0, int velLenOverride=0, int targetPt=-1); Shot *fireShot(const std::string &bankShot, Entity *firer, Entity *target=0, const Vector &pos=Vector(0,0,0), const Vector &aim=Vector(0,0,0), bool playSfx=true); @@ -910,7 +910,7 @@ public: void selectEntityFromGroups(); InterpolatedVector cameraInterp; - //InterpolatedVector tintColor; + float getWaterLevel(); void setMusicToPlay(const std::string &musicToPlay); Vector lastCollidePosition; @@ -1047,7 +1047,7 @@ protected: bool isCooking; void doMenuSectionHighlight(int sect); - + float cookDelay; float ingOffY; @@ -1058,7 +1058,7 @@ protected: void onPrevRecipePage(); void onNextRecipePage(); - + typedef std::vector CookList; CookList cookList; @@ -1163,12 +1163,7 @@ protected: float deathTimer; - /* - void onAssignMenuScreenItemToSlot0(); - void onAssignMenuScreenItemToSlot1(); - void onAssignMenuScreenItemToSlot2(); - void onAssignMenuScreenItemToSlot3(); - */ + void onInGameMenuInventory(); void onInGameMenuSpellBook(); diff --git a/Aquaria/GameplayVariables.cpp b/Aquaria/GameplayVariables.cpp index 8d7bfcd..a6eccf3 100644 --- a/Aquaria/GameplayVariables.cpp +++ b/Aquaria/GameplayVariables.cpp @@ -56,11 +56,7 @@ void GameplayVariables::load() inFile >> s >> zoomNaija; inFile >> s >> maxOutOfWaterSpeed; inFile >> s >> defaultCameraLerpDelay; - /* - inFile >> s >> initialId; - inFile >> s >> initialEgo; - inFile >> s >> initialSuperEgo; - */ + inFile.close(); } diff --git a/Aquaria/GasCloud.cpp b/Aquaria/GasCloud.cpp index 7d41e6a..22257f9 100644 --- a/Aquaria/GasCloud.cpp +++ b/Aquaria/GasCloud.cpp @@ -29,8 +29,8 @@ GasCloud::GasCloud(Entity *source, const Vector &position, const std::string &pa this->poisonTime = poisonTime; this->particles = particles; - //this->gfx = gfx; - //this->isMoney = isMoney; + + this->position = position; this->damage = damage; this->radius = radius; @@ -46,10 +46,10 @@ GasCloud::GasCloud(Entity *source, const Vector &position, const std::string &pa emitter->load(particles); emitter->start(); emitter->setDie(true); - //emitter->parentManagedStatic = true; - //addChild(&emitter); + + dsq->game->addRenderObject(emitter, LR_PARTICLES); - //setDamageTarget(DT_ENEMY_GAS, false) + setEntityType(ET_NEUTRAL); deathSound = ""; @@ -96,32 +96,7 @@ void GasCloud::onUpdate(float dt) } } - /* - pTimer += dt; - while (pTimer > pSpawnRate) - { - int a = rand()%360; - int r = rand()%radius; - Vector pos = position; - pos += Vector(sinf(a)*r, cosf(a)*r); - Quad *quad = new Quad; - { - quad->rotation.z = rand()%360; - quad->position = pos; - quad->color = color; - quad->setTexture(gfx); - quad->alpha.path.addPathNode(0, 0); - quad->alpha.path.addPathNode(0.5, 0.2); - quad->alpha.path.addPathNode(0.5, 0.8); - quad->alpha.path.addPathNode(0, 1); - quad->alpha.startPath(3); - quad->scale = Vector(0.5, 0.5); - quad->scale.interpolateTo(Vector(2,2),4); - } - dsq->getTopStateData()->addRenderObject(quad, LR_PARTICLES); - pTimer -= pSpawnRate; - } - */ + } else { diff --git a/Aquaria/GridRender.cpp b/Aquaria/GridRender.cpp index fa6c9cd..cfe67da 100644 --- a/Aquaria/GridRender.cpp +++ b/Aquaria/GridRender.cpp @@ -24,18 +24,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. GridRender::GridRender(ObsType obsType) : RenderObject() { color = Vector(1, 0, 0); - //color = Vector(0.2,0.2,1); + position.z = 5; cull = false; alpha = 0.5f; this->obsType = obsType; blendEnabled = false; - //setTexture("grid"); + } void GridRender::onUpdate(float dt) { - RenderObject::onUpdate(dt); + RenderObject::onUpdate(dt); if (obsType != OT_BLACK) { blendEnabled = true; } } @@ -46,22 +46,13 @@ inline static void doRenderGrid(int x, int startCol, int endCol) const int drawy1 = startCol*TILE_SIZE; const int drawy2 = (endCol+1)*TILE_SIZE; -#ifdef BBGE_BUILD_OPENGL glBegin(GL_QUADS); glVertex3i(drawx1, drawy2, 0.0f); glVertex3i(drawx2, drawy2, 0.0f); glVertex3i(drawx2, drawy1, 0.0f); glVertex3i(drawx1, drawy1, 0.0f); glEnd(); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->blitD3DVerts(0, - drawx1, drawy1, - drawx2, drawy1, - drawx2, drawy2, - drawx1, drawy2); -#endif } void GridRender::onRender() @@ -159,11 +150,10 @@ void SongLineRender::clear() void SongLineRender::onRender() { int w=core->getWindowWidth(); - //core->getWindowWidth(&w); + int ls = (4*w)/1024.0f; if (ls < 0) ls = 1; -#ifdef BBGE_BUILD_OPENGL glLineWidth(ls); const int alphaLine = pts.size()*(0.9f); float a = 1; @@ -173,11 +163,10 @@ void SongLineRender::onRender() if (i < alphaLine) a = float(i)/float(alphaLine); else - a = 1; + a = 1; glColor4f(pts[i].color.x, pts[i].color.y, pts[i].color.z, a); glVertex2f(pts[i].pt.x, pts[i].pt.y); } glEnd(); -#endif } diff --git a/Aquaria/Hair.cpp b/Aquaria/Hair.cpp index 09f5177..b1479a2 100644 --- a/Aquaria/Hair.cpp +++ b/Aquaria/Hair.cpp @@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Hair.h" #include "DSQ.h" -// nodes = 40 -// segmentLength = 3 + + Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject() { this->segmentLength = segmentLength; @@ -33,8 +33,8 @@ Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject() cull = false; hairNodes.resize(nodes); - // nodes: 20 length: 6 - //segmentLength = 3; + + for (int i = 0; i < hairNodes.size(); i++) { float perc = (float(i)/(float(hairNodes.size()))); @@ -47,64 +47,14 @@ Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject() void Hair::exertWave(float dt) { - /* - Vector diff = headPos - position; - Vector diff2; - if (!isFlippedHorizontal()) - diff2 = diff.getPerpendicularLeft(); - else - diff2 = diff.getPerpendicularRight(); - Vector diff3 = position - headPos; - float len =diff2.getLength2D(); - diff3.setLength2D(len); - hairTimer += dt; - while (hairTimer > 2.0f) - { - hairTimer -= 2.0f; - } - float useTimer = hairTimer; - if (useTimer > 1.0f) - useTimer = 1.0f - (hairTimer-1); - float frc = 0.5; - diff = (diff2*(frc*(1.0f-(useTimer*0.5f))) + diff3*(frc); - - diff.setLength2D(400); - //if (!vel.isLength2DIn(10)) - exertForce(diff, dt); - */ } void Hair::exertGravityWave(float dt) { - /* - Vector diff = headPos - position; - Vector diff2; - if (!isFlippedHorizontal()) - diff2 = diff.getPerpendicularLeft(); - else - diff2 = diff.getPerpendicularRight(); - Vector diff3 = position - headPos; - float len =diff2.getLength2D(); - diff3.setLength2D(len); - hairTimer += dt; - while (hairTimer > 2.0f) - { - hairTimer -= 2.0f; - } - float useTimer = hairTimer; - if (useTimer > 1.0f) - useTimer = 1.0f - (hairTimer-1); - float frc = 0.333333; - diff = (diff2*(frc*(1.0f-(useTimer*0.5f))) + diff3*(frc) + Vector(0,len)*(frc*(0.5f+useTimer*0.5f))); - - diff.setLength2D(400); - //if (!vel.isLength2DIn(10)) - exertForce(diff, dt); - */ } void Hair::setHeadPosition(const Vector &vec) @@ -125,16 +75,15 @@ HairNode *Hair::getHairNode(int idx) void Hair::onRender() { -#ifdef BBGE_BUILD_OPENGL - //glDisable(GL_CULL_FACE); + glBegin(GL_QUAD_STRIP); float texBits = 1.0f / (hairNodes.size()-1); - //float height2 = 2.5f; + Vector pl, pr; for (int i = 0; i < hairNodes.size(); i++) { - //glNormal3f( 0.0f, 0.0f, 1.0f); + if (i != hairNodes.size()-1) { @@ -144,14 +93,6 @@ void Hair::onRender() pr = diffVec.getPerpendicularRight(); } - /* - if (hairNodes[i].problem) - { - glColor3f(1,0,0); - } - else - glColor3f(1,1,1); - */ glTexCoord2f(0, texBits*i); @@ -159,99 +100,33 @@ void Hair::onRender() glTexCoord2f(1, texBits*i); glVertex3f( hairNodes[i].position.x + pr.x, hairNodes[i].position.y + pr.y, 0); - //float angle = 0; - /* - float angle = 0; - if (i < hairNodes.size()-1) - { - MathFunctions::calculateAngleBetweenVectorsInDegrees(hairNodes[i+1].position, hairNodes[i].position, angle); - angle += 90; - angle = (angle*PI)/180.0f; - } - */ - /* - glTexCoord2f(0, 1-texBits*i); - glVertex3f(hairNodes[i].position.x -sinf(angle)*hairWidth, hairNodes[i].position.y + cosf(angle)*height2, 0); - glTexCoord2f(1, 1-texBits*i); - glVertex3f( hairNodes[i].position.x + sinf(angle)*hairWidth, hairNodes[i].position.y + cosf(angle)*height2, 0); - */ + + } glEnd(); - /* - glColor3f(1,1,1); - for (int i = 0; i < hairNodes.size(); i++) - { - std::ostringstream os; - os << hairNodes[i].angleDiff; - core->print(hairNodes[i].position.x, hairNodes[i].position.y, os.str().c_str(), 6); - } - */ - //glEnable(GL_CULL_FACE); -#endif + } void Hair::onUpdate(float dt) { RenderObject::onUpdate(dt); - /* - // straighten hair - if (hairNodes.size()>2) - { - Vector d1 = hairNodes[1].position - hairNodes[0].position; - for (int i = 2; i < hairNodes.size(); i++) - { - Vector d2 = hairNodes[i].position - hairNodes[i-1].position; - Vector wantPos = hairNodes[i-1].position + d1; - float perc = 1.0f-float(i)/float(hairNodes.size()); - hairNodes[i].position += (wantPos - hairNodes[i].position)*dt*(40 * perc); - //Vector d1 = hairNodes[i-1].position - hairNodes[i-2].position; - //Vector d2 = hairNodes[i].position - hairNodes[i-1].position; - //float prod = d1.dot2D(d2); - ////if (prod < 0.5f) - //{ - // d1.setLength2D(segmentLength); - // - // Vector wantPos = (hairNodes[i-1].position + d1)*0.5f + hairNodes[i].position*0.5f; - // hairNodes[i].position += (wantPos - hairNodes[i].position)*dt*10; - // break; - //} - } - } - */ + } void Hair::updatePositions() { BBGE_PROF(Hair_updatePositions); - //int minLength = 1; - /* - Vector accum; + + for (int i = 1; i < hairNodes.size(); i++) { Vector diff = hairNodes[i].position - hairNodes[i-1].position; - accum += diff; - } - accum /= float(hairNodes.size()-1); - */ - for (int i = 1; i < hairNodes.size(); i++) - { - Vector diff = hairNodes[i].position - hairNodes[i-1].position; - /* - if (diff.getLength2D() < 1) - { - diff = accum; - } - */ - /* - if (diff.getLength2D() <= 1) - { - diff = hairNodes[i].position - hairNodes[0].position; - } - */ + + if (diff.getLength2D() < segmentLength) { @@ -260,181 +135,13 @@ void Hair::updatePositions() } else if (diff.getLength2D() > segmentLength) { - //diff |= segmentLength; + diff.setLength2D(segmentLength); hairNodes[i].position = hairNodes[i-1].position + diff; } - /* - if (i > 1) - { - Vector d1 = hairNodes[i-1].position - hairNodes[i-2].position; - Vector d2 = hairNodes[i].position - hairNodes[i-1].position; - float prod = d1.dot2D(d2); - float a1 = 0, a2 = 0; - float maxAngle = 0.3; - MathFunctions::calculateAngleBetweenVectorsInRadians(d1, Vector(0,0,0), a1); - MathFunctions::calculateAngleBetweenVectorsInRadians(d2, Vector(0,0,0), a2); - float a = a2 - a1; - hairNodes[i].angleDiff = a; - if (fabsf(a) > maxAngle) - { - float len = d2.getLength2D(); - //d2 = d1; - Vector dt1 = d1; - Vector dt2 = d1; - dt1.rotate2D(-maxAngle); - dt2.rotate2D(maxAngle); - - //if (a < 0) - // d2.rotate2D(-maxAngle); - //else - // d2.rotate2D(maxAngle); - - //d2.setLength2D(len); - //hairNodes[i].position = hairNodes[i-1].position + d2; - - dt1 = hairNodes[i-1].position + dt1; - dt2 = hairNodes[i-1].position + dt2; - if ((hairNodes[i].position - dt1).getSquaredLength2D() < (hairNodes[i].position - dt2).getSquaredLength2D()) - { - hairNodes[i].position = dt1; - } - else - hairNodes[i].position = dt2; - hairNodes[i].problem = true; - } - else - { - hairNodes[i].problem = false; - } - } - */ - - /* - int diffLength = segmentLength * 2; - Vector accum; - int c=0; - for (int j = 0; j < hairNodes.size(); j++) - { - if (j != i && j != i-1 && j != i+1) - { - Vector diff = hairNodes[i].position - hairNodes[j].position; - - if (diff.getLength2D() < diffLength) - { - diff.setLength2D(diffLength); - //hairNodes[i].position = hairNodes[j].position + diff; - accum += hairNodes[j].position + diff; - c++; - //break; - } - } - } - - if (!accum.isZero()) - { - accum /= c; - - //hairNodes[i].position = (hairNodes[i].position + accum)*0.5f; - hairNodes[i].position = accum; - } - */ - - /* - if (i > 1) - { - Vector d1 = hairNodes[i-1].position - hairNodes[i-2].position; - Vector d2 = hairNodes[i].position - hairNodes[i-1].position; - float prod = d1.dot2D(d2); - if (prod < -0.5f) - { - //d1.setLength2D(d2.getLength2D()); - Vector wantPos = hairNodes[i-1].position + d1; - hairNodes[i].position = wantPos;//hairNodes[i].position*0.75f + wantPos*0.25f; - // - //d2 = (d2 + d1)*0.5f; - //hairNodes[i].position = hairNodes[i-1].position + d1; - } - } - */ - /* - if (i > 1) - { - //float a1,a2; - float a1=0; - // MathFunctions::calculateAngleBetweenVectorsInRadians(hairNodes[i].position, hairNodes[i-1].position, a1); - - MathFunctions::calculateAngleBetweenVectorsInRadians(hairNodes[i-1].position, hairNodes[i-2].position, a1); - - Vector d1 = hairNodes[i-1].position - hairNodes[i-2].position; - Vector d2 = hairNodes[i].position - hairNodes[i-1].position; - - float a=0; - MathFunctions::calculateAngleBetweenVectorsInRadians(d2, d1, a); - //float d = a2 - a1, c=PI/2; - - float c=PI/2; - float d=0; - - bool adjust = 0; - if (a > c) - { - d = a1 + c; - adjust = 1; - } - else if (a < -c) - { - d = a1 - c; - adjust = -1; - } - if (adjust) - { - Vector add(sinf(d), cosf(d)); - add.setLength2D(d2.getLength2D()); - hairNodes[i].position = hairNodes[i-1].position + add; - } - //Vector diff2 = hairNodes[i-1] - hairNodes[i-2].position; - - //hairNodes[i].position = hairNodes[i-1].position + diff; - } - */ - /* - if (i < hairNodes.size()-1) - { - Vector diff2 = hairNodes[i+1].position - hairNodes[i].position; - float a=0,c=PI/2; - bool adjust = false; - MathFunctions::calculateAngleBetweenVectorsInRadians(hairNodes[i+1].position, hairNodes[i].position, a); - if (a > c) - { - a = c; - adjust = true; - } - else if (a < -c) - { - a = -c; - adjust = true; - } - if (adjust) - { - Vector add(sinf(a), cosf(a)); - add *= diff2.getLength2D(); - hairNodes[i+1].position = hairNodes[i].position + add; - } - } - */ - /* - else if (diff.getLength2D() < minLength) - { - */ - /* - diff.setLength2D(minLength); - hairNodes[i].position = hairNodes[i-1].position + diff; - */ - //} } @@ -474,15 +181,7 @@ void Hair::exertForce(const Vector &force, float dt, int usePerc) hairNodes[i].position += force*dt; break; } - /* - Vector diff = hairNodes[i].position - hairNodes[i-1].position; - if (diff.getSquaredLength2D() > sqr(segmentLength)) - { - diff |= segmentLength; - hairNodes[i].position = hairNodes[i-1].position + diff; - } - */ } } diff --git a/Aquaria/Ingredient.cpp b/Aquaria/Ingredient.cpp index 321c1a5..89a46f5 100644 --- a/Aquaria/Ingredient.cpp +++ b/Aquaria/Ingredient.cpp @@ -38,7 +38,7 @@ bool IngredientData::hasIET(IngredientEffectType iet) for (IngredientEffects::iterator i = effects.begin(); i != effects.end(); i++) { if ((*i).type == iet) - return true; + return true; } return false; } @@ -59,7 +59,7 @@ Ingredient::Ingredient(const Vector &pos, IngredientData *data, int amount) velocity = randVector(mag)*0.5f + Vector(0, -mag)*0.5f; else velocity = Vector(0,-mag*0.5f); - gravity = Vector(0, 250); //300 + gravity = Vector(0, 250); scale = Vector(0.2,0.2); scale.interpolateTo(Vector(1, 1), 0.75); @@ -89,7 +89,7 @@ bool Ingredient::isRotKind() IngredientData *Ingredient::getIngredientData() { - return data; + return data; } void Ingredient::eat(Entity *e) @@ -110,12 +110,7 @@ void Ingredient::onUpdate(float dt) if (dsq->game->collideCircleWithGrid(position, 24)) { position = lastPosition; - /* - if (velocity.x < velocity.y) - velocity.x = -velocity.x; - else - velocity.y = -velocity.y; - */ + velocity = 0; } @@ -145,7 +140,7 @@ void Ingredient::onUpdate(float dt) dsq->game->pickupIngredientEffects(data); dsq->spawnParticleEffect("IngredientCollect", position); - + dsq->sound->playSfx("pickup-ingredient"); } } diff --git a/Aquaria/Intro.cpp b/Aquaria/Intro.cpp index ece4b00..281d624 100644 --- a/Aquaria/Intro.cpp +++ b/Aquaria/Intro.cpp @@ -227,7 +227,7 @@ void Intro::update(float dt) dsq->toggleBlackBars(1); dsq->setBlackBarsColor(Vector(0,0,0)); - + cachy.precacheTex("intro/*.png"); meteors.clear(); @@ -245,7 +245,7 @@ void Intro::update(float dt) dsq->sound->loadLocalSound("aqfocus"); dsq->sound->loadLocalSound("thewave"); dsq->sound->loadLocalSound("screaming"); - + SkeletalSprite *citybg = new SkeletalSprite(); citybg->loadSkeletal("citybg"); @@ -278,7 +278,7 @@ void Intro::update(float dt) } addRenderObject(eric, LR_ENTITIES); - + dsq->overlay->alpha = 0; dsq->overlay2->alpha = 0; @@ -288,7 +288,7 @@ void Intro::update(float dt) dsq->overlay2->color.interpolateTo(Vector(0,0,0), 1); dsq->overlay2->alpha = 1; - + core->cacheRender(); @@ -404,7 +404,7 @@ void Intro::update(float dt) // -- floating city in clouds - + dsq->setClearColor(Vector(0.4,0.4,0.4)); /* @@ -474,7 +474,7 @@ void Intro::update(float dt) if (waitQuit(2)) return; - + // -- window @@ -514,7 +514,7 @@ void Intro::update(float dt) ericHead->alpha = 0; - + // -- brush float brusht=7; @@ -544,7 +544,7 @@ void Intro::update(float dt) dsq->sound->playSfx("aqfocus", 0.8); if (waitQuit(1.5)) return; - + if (waitQuit(2)) return; @@ -764,8 +764,6 @@ void Intro::update(float dt) if (waitQuit(1.9)) return; - - dsq->overlay->color = Vector(0,0,0); dsq->fade(1, 0.1); @@ -817,7 +815,7 @@ void Intro::update(float dt) play4.name = "bgloop-interior"; play4.loops = -1; play4.time = 1; - play4.fade = SFT_IN; + play4.fade = SFT_IN; void *bgLoop = dsq->sound->playSfx(play4); if (waitQuit(3)) return; @@ -835,7 +833,7 @@ void Intro::update(float dt) core->sound->playVoice("titleb"); dsq->sound->playSfx("heartbeat", 0.2); - + if (waitQuit(2.5)) return; underwaterBG->alphaMod = 0; diff --git a/Aquaria/Logo.cpp b/Aquaria/Logo.cpp index 1c83e1a..e811d81 100644 --- a/Aquaria/Logo.cpp +++ b/Aquaria/Logo.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void Logo::JumpTitle::act() { - //dsq->title(); + } Logo::Logo() : StateObject() @@ -36,25 +36,8 @@ void Logo::applyState() core->setClearColor(Vector(1,1,1)); - //glClearColor(1,1,1,0); - //core->enable2D(800); - - /* - Quad *q = new Quad; - { - q->setTexture("zs"); - q->width=800; - q->height=100; - q->position = Vector(400,300); - q->alpha = 0; - q->alpha.interpolateTo(1, 3, 0); - } - addRenderObject(q); - - addAction(&jumpTitle, MOUSE_BUTTON_LEFT, 1); - */ Quad *q = new Quad; { diff --git a/Aquaria/Main.cpp b/Aquaria/Main.cpp index 9af0c15..6bb1661 100644 --- a/Aquaria/Main.cpp +++ b/Aquaria/Main.cpp @@ -66,20 +66,6 @@ static void CheckConfig(void) } -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) - int WINAPI WinMain( HINSTANCE hInstance, // Instance - HINSTANCE hPrevInstance, // Previous Instance - LPSTR lpCmdLine, // Command Line Parameters - int nCmdShow) // Window Show State - { - #ifdef _DEBUG - _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); - _CrtSetReportMode ( _CRT_ERROR, _CRTDBG_MODE_DEBUG); - #endif - - std::string dsqParam = GetCommandLine(); - -#else extern "C" int main(int argc,char *argv[]) { @@ -102,7 +88,6 @@ static void CheckConfig(void) extraDataDir = AQUARIA_EXTRA_DATA_DIR; #endif -#endif CheckConfig(); diff --git a/Aquaria/ManaBall.cpp b/Aquaria/ManaBall.cpp index 23a50a4..b0200a4 100644 --- a/Aquaria/ManaBall.cpp +++ b/Aquaria/ManaBall.cpp @@ -86,8 +86,8 @@ void ManaBall::onUpdate(float dt) this->scale.interpolateTo(Vector(0,0),1); setLife(1); setDecayRate(1); - //this->shareAlphaWithChildren = 1; - //this->fadeAlphaWithLife = 1; + + } } @@ -99,7 +99,7 @@ void ManaBall::onUpdate(float dt) if (diff.isLength2DIn(96)) { use(dsq->game->avatar); - //position.interpolateTo(dsq->game->avatar->position, 0.5); + } else { @@ -122,7 +122,7 @@ void ManaBall::onUpdate(float dt) else { position.interpolateTo(dsq->game->avatar->position, 0.2); - //position = ; + } } position.z = 0.5; diff --git a/Aquaria/MiniMapRender.cpp b/Aquaria/MiniMapRender.cpp index 7759d94..824ac86 100644 --- a/Aquaria/MiniMapRender.cpp +++ b/Aquaria/MiniMapRender.cpp @@ -171,7 +171,7 @@ MiniMapRender::MiniMapRender() : RenderObject() texMinimapBtm = core->addTexture("gui/minimap/btm"); texMinimapTop = core->addTexture("gui/minimap/top"); texNaija = core->addTexture("gems/naija-token"); - texHealthBar = core->addTexture("particles/glow-masked"); + texHealthBar = core->addTexture("particles/glow-masked"); texMarker = core->addTexture("gui/minimap/marker"); buttons.clear(); @@ -295,7 +295,7 @@ float MiniMapRender::getMiniMapHeight() const void MiniMapRender::onUpdate(float dt) { - RenderObject::onUpdate(dt); + RenderObject::onUpdate(dt); position.x = core->getVirtualWidth() - core->getVirtualOffX() - getMiniMapWidth()/2; position.y = 600 - getMiniMapHeight()/2; @@ -323,7 +323,7 @@ void MiniMapRender::onUpdate(float dt) { radarHide = true; } - + if(!radarHide) { for (Path *p = dsq->game->getFirstPathOfType(PATH_RADARHIDE); p; p = p->nextOfType) @@ -378,7 +378,7 @@ void MiniMapRender::onUpdate(float dt) _isCursorIn = false; if (alpha.x == 1) - { + { if (!dsq->game->isInGameMenu() && (!dsq->game->isPaused() || (dsq->game->isPaused() && dsq->game->worldMapRender->isOn()))) { if (isCursorInButtons()) @@ -433,7 +433,7 @@ void MiniMapRender::onUpdate(float dt) { if (doubleClickDelay > 0 && !core->isStateJumpPending()) { - + if (dsq->continuity.gems.empty()) dsq->continuity.pickupGem("Naija-Token"); @@ -475,7 +475,6 @@ void MiniMapRender::onUpdate(float dt) void MiniMapRender::onRender() { -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, 0); RenderObject::lastTextureApplied = 0; @@ -760,7 +759,6 @@ void MiniMapRender::onRender() glBindTexture(GL_TEXTURE_2D, 0); -#endif } void MiniMapRender::renderIcon(MinimapIcon *ico, const Vector& pos) diff --git a/Aquaria/Mod.cpp b/Aquaria/Mod.cpp index 58cb592..beddd31 100644 --- a/Aquaria/Mod.cpp +++ b/Aquaria/Mod.cpp @@ -33,9 +33,9 @@ void refreshBaseModPath() Mod::Mod() { clear(); - + enqueueModStart = 0; - + shuttingDown = false; } @@ -92,12 +92,12 @@ bool Mod::loadModXML(XMLDocument *d, std::string modName) const std::string& Mod::getBaseModPath() const { refreshBaseModPath(); - + return baseModPath; } void Mod::load(const std::string &p) -{ +{ clear(); refreshBaseModPath(); @@ -108,10 +108,10 @@ void Mod::load(const std::string &p) setLocalisationModPath(path); setActive(true); - + XMLDocument d; loadModXML(&d, p); - + XMLElement *mod = d.FirstChildElement("AquariaMod"); if (mod) { @@ -204,7 +204,7 @@ void Mod::start() core->main(t); core->sound->stopMusic(); - + enqueueModStart = 1; dsq->recentSaveSlot = -1; } @@ -296,7 +296,7 @@ void Mod::update(float dt) if (enqueueModStart) { enqueueModStart = 0; - + applyStart(); } } diff --git a/Aquaria/ModSelector.h b/Aquaria/ModSelector.h index 46339ad..3849cf7 100644 --- a/Aquaria/ModSelector.h +++ b/Aquaria/ModSelector.h @@ -149,7 +149,7 @@ public: void showPanel(int id); void updateFade(); - + void initModAndPatchPanel(); void initNetPanel(); diff --git a/Aquaria/Network.cpp b/Aquaria/Network.cpp index 64acdc9..df82275 100644 --- a/Aquaria/Network.cpp +++ b/Aquaria/Network.cpp @@ -2,7 +2,7 @@ #include "DSQ.h" #include "Network.h" #include "ByteBuffer.h" -//#include "VFSTools.h" + #include "MT.h" #include #include @@ -44,7 +44,7 @@ public: protected: virtual void _OnClose() { - //puts("_OnClose()"); + minihttp::HttpSocket::_OnClose(); const Request& r = GetCurrentRequest(); @@ -57,7 +57,7 @@ protected: } virtual void _OnOpen() { - //puts("_OnOpen()"); + minihttp::HttpSocket::_OnOpen(); const Request& r = GetCurrentRequest(); @@ -68,7 +68,7 @@ protected: { const Request& r = GetCurrentRequest(); RequestData *data = (RequestData*)(r.user); - //printf("_OnRequestDone(): %s\n", r.resource.c_str()); + if(data->fp) { fclose(data->fp); @@ -91,11 +91,7 @@ protected: { if(!size) return; - /*if(GetStatusCode() != minihttp::HTTP_OK) - { - printf("NETWORK: Got %u bytes with status code %u", size, GetStatusCode()); - return; - }*/ + const Request& r = GetCurrentRequest(); RequestData *data = (RequestData*)(r.user); if(!data->fp && !data->fail) diff --git a/Aquaria/ParticleEditor.cpp b/Aquaria/ParticleEditor.cpp index 5b973f1..22f9db8 100644 --- a/Aquaria/ParticleEditor.cpp +++ b/Aquaria/ParticleEditor.cpp @@ -46,8 +46,8 @@ void ParticleEditor::applyState() addAction(MakeFunctionEvent(ParticleEditor, load), KEY_F1, 0); addAction(MakeFunctionEvent(ParticleEditor, reload), KEY_F5, 0); - //addAction(MakeFunctionEvent(ParticleEditor, start), KEY_F5, 0); - //addAction(MakeFunctionEvent(ParticleEditor, stop), KEY_F6, 0); + + addAction(MakeFunctionEvent(ParticleEditor, start), MOUSE_BUTTON_LEFT, 0); addAction(MakeFunctionEvent(ParticleEditor, stop), MOUSE_BUTTON_RIGHT, 0); @@ -64,8 +64,8 @@ void ParticleEditor::applyState() core->cameraPos = Vector(0,0); emitter = new ParticleEffect; - //emitter->followCamera = 1; - //emitter->position = Vector(400,300); + + addRenderObject(emitter, LR_ENTITIES); dsq->overlay->alpha.interpolateTo(0, 0.5); diff --git a/Aquaria/Path.cpp b/Aquaria/Path.cpp index 289a621..f6aa65f 100644 --- a/Aquaria/Path.cpp +++ b/Aquaria/Path.cpp @@ -391,7 +391,7 @@ void Path::refreshScript() std::string dummy; is >> dummy; - float v = 0; + float v = 0; is >> v; if (v != 0) currentMod = v; @@ -454,20 +454,15 @@ void Path::refreshScript() spawnEnemyDistance = 0; is >> dummy >> spawnEnemyName >> spawnEnemyDistance >> spawnEnemyNumber; neverSpawned = true; - /* - if (!spawnedEntity && !nodes.empty()) - { - spawnedEntity = dsq->game->createEntity(spawnEnemyName, 0, nodes[0].position, 0, false, ""); - } - */ + } else if (label == "pe") { std::string dummy, particleEffect; SimpleIStringStream is(name); is >> dummy >> particleEffect; - //core->removeRenderObject(&emitter, Core::DO_NOT_DESTROY_RENDER_OBJECT); - //core->getTopStateData()->addRenderObject(&emitter, LR_PARTICLES); + + setEmitter(particleEffect); } @@ -552,10 +547,7 @@ void Path::update(float dt) if (pathType == PATH_CURRENT && !dsq->game->isWorldPaused()) { animOffset -= currentMod*(dt/830); - /* - while (animOffset < -1.0f) - animOffset += 1.0f; - */ + } if (pathType == PATH_GEM && dsq->game->avatar) { @@ -603,10 +595,7 @@ void Path::update(float dt) Entity *e = *i; if (e) { - /* - if (e->getEntityType() == ET_AVATAR && dsq->continuity.form == FORM_SPIRIT) - continue; - */ + if (dsq->game->collideCircleVsLine(e, start, end, rect.getWidth()*0.5f)) { if (e->getEntityType() == ET_AVATAR) @@ -621,24 +610,13 @@ void Path::update(float dt) d.damage = 0.1; d.damageType = DT_STEAM; e->damage(d); - //a->position = a->lastPosition; + } Vector push; push = e->position - dsq->game->lastCollidePosition; - // old method: - /* - int d1 = ((mid + left)-e->position).getSquaredLength2D(); - if (((mid + right)-e->position).getSquaredLength2D() < d1) - { - push = right; - } - else - { - push = left; - } - */ + push.setLength2D(1000*dt); if (e->vel2.isLength2DIn(1000) && !e->isNearObstruction(3)) @@ -650,11 +628,7 @@ void Path::update(float dt) if (dsq->game->collideCircleVsLine(e, start, end, rect.getWidth()*0.25f)) { push.setLength2D(100); - /* - Vector oldVel = e->vel; - Vector nvel = v; - nvel.setLength2D(e->vel); - */ + e->vel = 0; e->vel += push; } diff --git a/Aquaria/PathFinding.cpp b/Aquaria/PathFinding.cpp index d1eee58..750755a 100644 --- a/Aquaria/PathFinding.cpp +++ b/Aquaria/PathFinding.cpp @@ -58,7 +58,7 @@ void PathFinding::forceMinimumPath(VectorPath &path, const Vector &start, const { if (path.getNumPathNodes() <= 2) { - //debugLog(" Path is <= 2 nodes... setting up simple path"); + path.clear(); path.addPathNode(start, 0); path.addPathNode(dest, 1); @@ -105,7 +105,7 @@ void PathFinding::molestPath(VectorPath &path) } } } - + // use wall normal to push out node a bit std::vector newNormals; newNormals.resize(normals.size()); diff --git a/Aquaria/PathFinding.h b/Aquaria/PathFinding.h index f152e6c..4366a89 100644 --- a/Aquaria/PathFinding.h +++ b/Aquaria/PathFinding.h @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PATHFINDING_H #include "../BBGE/Base.h" -//#include "Astar.h" + #include "TileVector.h" #include diff --git a/Aquaria/PathRender.cpp b/Aquaria/PathRender.cpp index 28afb93..41b12e9 100644 --- a/Aquaria/PathRender.cpp +++ b/Aquaria/PathRender.cpp @@ -22,15 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. PathRender::PathRender() : RenderObject() { - //color = Vector(1, 0, 0); + position.z = 5; cull = false; alpha = 0.5f; } void PathRender::onRender() -{ -#ifdef BBGE_BUILD_OPENGL +{ const int pathcount = dsq->game->getNumPaths(); if (pathcount <= 0) return; @@ -68,9 +67,9 @@ void PathRender::onRender() glVertex2f(nd->position.x+p->rect.x1, nd->position.y+p->rect.y2); glVertex2f(nd->position.x+p->rect.x2, nd->position.y+p->rect.y2); glVertex2f(nd->position.x+p->rect.x2, nd->position.y+p->rect.y1); - glVertex2f(nd->position.x+p->rect.x1, nd->position.y+p->rect.y1); + glVertex2f(nd->position.x+p->rect.x1, nd->position.y+p->rect.y1); glEnd(); - + glColor4f(1, 1, 1, 0.3); glBegin(GL_LINES); glVertex2f(nd->position.x+p->rect.x1, nd->position.y+p->rect.y1); @@ -104,10 +103,9 @@ void PathRender::onRender() glColor4f(1, 0.5, 0.5, a); glPushMatrix(); - glTranslatef(nd->position.x, nd->position.y, 0); + glTranslatef(nd->position.x, nd->position.y, 0); drawCircle(32); glPopMatrix(); } } -#endif } diff --git a/Aquaria/RecipeMenuEntry.cpp b/Aquaria/RecipeMenuEntry.cpp index b3efa88..85c3b0d 100644 --- a/Aquaria/RecipeMenuEntry.cpp +++ b/Aquaria/RecipeMenuEntry.cpp @@ -36,12 +36,12 @@ namespace RecipeMenuNamespace } using namespace RecipeMenuNamespace; - + RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe) { selected = 0; - // Quad *result, *i1, *i2, *i3; - // Recipe *recipe; + + data = dsq->continuity.getIngredientDataByName(recipe->result); if (data) @@ -51,16 +51,16 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe glow->setBlendType(BLEND_ADD); glow->alphaMod = 0; addChild(glow, PM_POINTER); - + result = new Quad("ingredients/" + data->gfx, Vector(-100,0)); result->scale = Vector(0.7, 0.7); addChild(result, PM_POINTER); - + BitmapText *text = new BitmapText(&dsq->smallFont); text->scale = Vector(0.7, 0.7); text->color = 0; text->position = result->position + Vector(0, 18); - + text->setText(processFoodName(data->displayName)); addChild(text, PM_POINTER); } @@ -70,7 +70,7 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe addChild(equals, PM_POINTER); int c = 0; - //int size = (recipe->names.size() + recipe->types.size())-1; + int size=0; for (int i = 0; i < recipe->names.size(); i++) @@ -81,7 +81,7 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe size --; - + for (int i = 0; i < recipe->names.size(); i++) { debugLog("recipe name: " + recipe->names[i].name); @@ -93,21 +93,21 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe ing[c] = new Quad("ingredients/" + data->gfx, Vector(100*c,0)); ing[c]->scale = Vector(0.7, 0.7); addChild(ing[c], PM_POINTER); - + BitmapText *text = new BitmapText(&dsq->smallFont); text->scale = Vector(0.7, 0.7); text->color = 0; text->position = ing[c]->position + Vector(0, 18); text->setText(processFoodName(data->displayName)); addChild(text, PM_POINTER); - + if (c < size) { Quad *plus = new Quad("gui/recipe-plus", Vector(100*c+50, 0)); plus->scale = Vector(0.7, 0.7); addChild(plus, PM_POINTER); } - + c++; if (c > 3) { @@ -117,17 +117,17 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe } } } - + for (int i = 0; i < recipe->types.size(); i++) { - //debugLog("recipe type: " + recipe->types[i].typeName); + for (int j = 0; j < recipe->types[i].amount; j++) { // any type of whatever... BitmapText *text = new BitmapText(&dsq->smallFont); text->color = 0; text->scale = Vector(0.8, 0.8); - text->position = Vector(100*c, 0); //-20 + text->position = Vector(100*c, 0); std::string typeName = dsq->continuity.getIngredientDisplayName(recipe->types[i].typeName); @@ -139,16 +139,16 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe text->setText(typeName); addChild(text, PM_POINTER); - + if (c < size) { Quad *plus = new Quad("gui/recipe-plus", Vector(100*c+50, 0)); plus->scale = Vector(0.7, 0.7); addChild(plus, PM_POINTER); } - + c++; - } + } } description = 0; @@ -180,15 +180,15 @@ void RecipeMenuEntry::onUpdate(float dt) glow->alphaMod = 0.2; std::ostringstream ds; - //ds << data->name << ": "; - //ds << "* "; + + for (int i = 0; i < data->effects.size(); i++) { ds << dsq->continuity.getIEString(data, i); if (i == data->effects.size()-1) { - // do nothing - //ds << "."; + + } else { @@ -198,7 +198,7 @@ void RecipeMenuEntry::onUpdate(float dt) game->recipeMenu.description->setText(ds.str()); game->recipeMenu.description->offset = Vector(0, -10 * (game->recipeMenu.description->getNumLines()-1)); - // description->setText(ds.str()); + selected = 1; } else @@ -235,7 +235,7 @@ void RecipeMenu::slide(RenderObject *r, bool in, float t) if (in) { r->alpha = 1; - //r->alpha.interpolateTo(1, 0.2); + r->offset = Vector(0,oy); r->offset.interpolateTo(Vector(0,0), t, 0, 0, 1); } @@ -261,20 +261,15 @@ int RecipeMenu::getNumKnown() int RecipeMenu::getNumPages() { - int numKnown = dsq->continuity.recipes.size();//getNumKnown(); + int numKnown = dsq->continuity.recipes.size(); int numPages = (numKnown/pageSize); - /* - for (int i = 0; i < dsq->continuity.recipes.size(); i++) - { - debugLog("r: " + dsq->continuity.recipes[i].result); - } - */ - + + std::ostringstream os; os << "numKnown: " << numKnown << " pagesSize: " << pageSize << " numPages: " << numPages; debugLog(os.str()); - + return numPages; } @@ -285,12 +280,12 @@ void RecipeMenu::goPrevPage() dsq->sound->playSfx("recipemenu-pageturn"); destroyPage(); - + currentPage--; - + if (currentPage < 0) currentPage = getNumPages(); - + createPage(currentPage); } @@ -301,15 +296,15 @@ void RecipeMenu::goNextPage() dsq->sound->playSfx("recipemenu-pageturn"); destroyPage(); - + currentPage++; - + int pages = getNumPages(); if (currentPage > pages) { currentPage = 0; } - + createPage(currentPage); } @@ -324,7 +319,7 @@ void RecipeMenu::toggle(bool on, bool watch) debugLog("RecipeMenu::toggle"); toggling = true; - + float t = 0.6; if (on) @@ -350,7 +345,7 @@ void RecipeMenu::toggle(bool on, bool watch) } createPage(currentPage); - + nextPage->alpha.interpolateTo(1, 0.2); prevPage->alpha.interpolateTo(1, 0.2); } @@ -365,7 +360,7 @@ void RecipeMenu::toggle(bool on, bool watch) if (this->on) dsq->sound->playSfx("recipemenu-close"); - + nextPage->alpha = 0; prevPage->alpha = 0; @@ -395,7 +390,7 @@ void RecipeMenu::createPage(int p) { RecipeMenuEntry *r = new RecipeMenuEntry(&dsq->continuity.recipes[i]); recipeMenuEntries.push_back(r); - //80 + num * 70 + r->position = Vector(500-5, 65 + num * 70); dsq->game->addRenderObject(r, scroll->layer); num++; @@ -409,21 +404,21 @@ void RecipeMenu::createPage(int p) } } } - + if (num == 0) { - + } description = new BitmapText(&dsq->smallFont); description->followCamera = 1; description->scale = Vector(0.7, 0.7); description->setAlign(ALIGN_LEFT); - description->position = Vector(364, 334); //most recent: (364, 334) //348, 328 + description->position = Vector(364, 334); //most recent: (364, 334) //348, 328 description->color = Vector(0,0,0);//Vector(0.7,0,0); description->setText(""); description->setWidth(500); // 1000?? - + dsq->game->addRenderObject(description, scroll->layer); std::ostringstream os2; diff --git a/Aquaria/SFXLoops.cpp b/Aquaria/SFXLoops.cpp index d00277d..ec32523 100644 --- a/Aquaria/SFXLoops.cpp +++ b/Aquaria/SFXLoops.cpp @@ -32,7 +32,7 @@ void SFXLoops::updateVolume() core->sound->updateChannelVolume(roll); core->sound->updateChannelVolume(charge); core->sound->updateChannelVolume(shield); - core->sound->updateChannelVolume(current); + core->sound->updateChannelVolume(current); core->sound->updateChannelVolume(trip); } diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index d68e97f..bd56924 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -93,7 +93,6 @@ std::string getMapTemplateFilename() void WarpAreaRender::onRender() { -#ifdef BBGE_BUILD_OPENGL for (int i = 0; i < dsq->game->warpAreas.size(); i++) { WarpArea *a = &dsq->game->warpAreas[i]; @@ -141,53 +140,6 @@ void WarpAreaRender::onRender() } glTranslatef(-a->position.x, -a->position.y,0); } -#endif -#ifdef BBGE_BUILD_DIRECTX - for (int i = 0; i < dsq->game->warpAreas.size(); i++) - { - WarpArea *a = &dsq->game->warpAreas[i]; - core->translateMatrixStack(a->position.x, a->position.y); - switch (a->warpAreaType[0]) - { - case 'B': - core->setColor(0, 0, 1, alpha.x); - break; - case 'R': - core->setColor(1,0,0,alpha.x); - break; - case 'G': - core->setColor(0,1,0,alpha.x); - break; - case 'Y': - core->setColor(1,1,0,alpha.x); - break; - case 'P': - core->setColor(1,0,1,alpha.x); - break; - } - if (a->radius) - { - // drawCircle(a->radius); - } - else - { - core->applyMatrixStackToWorld(); - core->blitD3D(0, a->w*2, a->h*2); - /* - glBegin(GL_QUADS); - { - glVertex2f(-a->w,-a->h); - glVertex2f(-a->w,a->h); - glVertex2f(a->w,a->h); - glVertex2f(a->w,-a->h); - } - glEnd(); - */ - } - core->translateMatrixStack(-a->position.x, -a->position.y); - //glTranslatef(-a->position.x, -a->position.y,0); - } -#endif } SceneEditor::SceneEditor() : ActionMapper(), on(false) @@ -217,8 +169,8 @@ void SceneEditor::changeDepth() { if (editingElement) { - //editingElement->parallax = 0.9; - //editingElement->followCamera = 0.001; + + editingElement->followCamera = 0.9; editingElement->cull = false; } @@ -280,7 +232,7 @@ public: if (doubleClickTimer > 0) doubleClickTimer -= dt; Quad::onUpdate(dt); - //if () + if (dsq->game->sceneEditor.selectedEntity.name == selectedEntity.name || (entType != -1 && dsq->game->sceneEditor.selectedEntity.typeListIndex == entType)) @@ -311,7 +263,7 @@ public: { dsq->game->sceneEditor.selectedEntity.setName(selectedEntity.name, selectedEntity.prevGfx); } - //se_changedEntityType = true; + if (doubleClickTimer > 0) { doubleClickTimer = 0; @@ -486,11 +438,7 @@ void SceneEditor::addMainMenuItem(const std::string &label, int bid) void SceneEditor::openMainMenu() { - /* - core->clearDebugMenu(); - core->addDebugMenuItem("", bid); - core->doModalDebugMenu(); - */ + if (core->getNestedMains()>1) { @@ -520,12 +468,9 @@ void SceneEditor::openMainMenu() addMainMenuItem("EDIT NODES (F7)", 108); addMainMenuItem("REGEN COLLISIONS (ALT-R)", 103); addMainMenuItem("RECACHE TEXTURES (CTRL-R)", 130); -// addMainMenuItem("REFRESH DATAFILES (F11)", 117); + addMainMenuItem("REGEN ROCK FROM MAPTEMPLATE (F11+F12)", 116); - /* - addMainMenuItem("RE-TEMPLATE (F11)", 104); - addMainMenuItem("RE-SKIN (F12)", 105); - */ + addMainMenuItem("SET BG GRADIENT", 110); addMainMenuItem("SET MUSIC", 111); addMainMenuItem("ENTITY GROUPS (CTRL-E)", 112); @@ -589,7 +534,7 @@ void SceneEditor::init() btnMenu->label->setText("Menu"); btnMenu->followCamera = 1; btnMenu->alpha = 0; - //btnMenu->event.set(MakeFunctionEvent(SceneEditor, openMainMenu)); + dsq->game->addRenderObject(btnMenu, LR_HUD); selectedEntityType = 0; @@ -601,7 +546,7 @@ void SceneEditor::init() text->followCamera = 1; text->position = Vector(125,20,4.5); - //text->setAlign(ALIGN_CENTER); + dsq->game->addRenderObject(text, LR_HUD); text->alpha = 0; selectedVariation = -1; @@ -613,13 +558,12 @@ void SceneEditor::init() dsq->game->addRenderObject(boxPromo, LR_HUD); on = false; - //addAction(MakeFunctionEvent(SceneEditor, addSpringPlant), KEY_K, 0); + addAction(MakeFunctionEvent(SceneEditor, loadScene), KEY_F1, 0); addAction(MakeFunctionEvent(SceneEditor, saveScene), KEY_F2, 0); - // removed in fc3 - //addAction(MakeFunctionEvent(SceneEditor, setGroup), KEY_G, 0); + addAction(MakeFunctionEvent(SceneEditor, moveToBack), KEY_Z, 0); addAction(MakeFunctionEvent(SceneEditor, moveToFront), KEY_X, 0); @@ -640,12 +584,6 @@ void SceneEditor::init() -/* - addAction(MakeFunctionEvent(SceneEditor, placeEntity), KEY_U, 0); - addAction(MakeFunctionEvent(SceneEditor, removeEntity), KEY_I, 0); - */ - //addAction(MakeFunctionEvent(SceneEditor, changeDepth), KEY_N, 0); - addAction(MakeFunctionEvent(SceneEditor, placeElement), KEY_SPACE, 1); addAction(MakeFunctionEvent(SceneEditor, enterName), KEY_N, 0); @@ -667,7 +605,7 @@ void SceneEditor::init() addAction(MakeFunctionEvent(SceneEditor, generateLevel), KEY_F11, 0); addAction(MakeFunctionEvent(SceneEditor, skinLevel), KEY_F12, 0); - //addAction(MakeFunctionEvent(SceneEditor, regenLevel), KEY_F12, 0); + addAction(MakeFunctionEvent(SceneEditor, nextEntityType), KEY_RIGHT, 0); addAction(MakeFunctionEvent(SceneEditor, prevEntityType), KEY_LEFT, 0); @@ -699,17 +637,6 @@ void SceneEditor::init() addAction(MakeFunctionEvent(SceneEditor, dumpObs), KEY_F8, 0); - /* - // OLD CRAP - addAction(MakeFunctionEvent(SceneEditor, rotateElement), KEY_MULTIPLY, 0); - addAction(MakeFunctionEvent(SceneEditor, rotateElement2), KEY_DIVIDE, 0); - addAction(MakeFunctionEvent(SceneEditor, scaleElementUp), KEY_NUMPAD7, 0); - addAction(MakeFunctionEvent(SceneEditor, scaleElementDown), KEY_NUMPAD1, 0); - addAction(MakeFunctionEvent(SceneEditor, scaleElement1), KEY_NUMPAD0, 0); - addAction(MakeFunctionEvent(SceneEditor, nextVariation), KEY_UP, 0); - addAction(MakeFunctionEvent(SceneEditor, prevVariation), KEY_DOWN, 0); - */ - addAction(ACTION_ZOOMIN, KEY_PGUP); addAction(ACTION_ZOOMOUT, KEY_PGDN); @@ -844,10 +771,10 @@ void SceneEditor::alignVert() void SceneEditor::createAquarian() { - //if (dsq->mod.isActive()) return; + static bool inCreateAqurian = false; if (inCreateAqurian) return; - //if (dsq->game->isPaused()) return; + inCreateAqurian = true; std::string t = dsq->getUserInputString("Enter Aquarian:", ""); stringToUpper(t); @@ -863,7 +790,7 @@ void SceneEditor::createAquarian() { v = 1024+26; } - //ElementTemplate et = dsq->game->getElementTemplateForLetter(v); + dsq->game->createElement(v, startPos + Vector(64*i,0), this->bgLayer); } inCreateAqurian = false; @@ -935,7 +862,7 @@ void SceneEditor::toggleWarpAreaRender() warpAreaRender->alpha.x = 0.5; else if (warpAreaRender->alpha.x >= 0.5f) warpAreaRender->alpha.x = 0; - //warpAreaRender->alpha.interpolateTo(1, 0.2); + } @@ -1038,7 +965,7 @@ void SceneEditor::editModeEntities() //target->alpha.interpolateTo(0, 0.5); editType = ET_ENTITIES; - //dsq->game->entityTypeList[curEntity].prevGfx + placer->setTexture(selectedEntity.prevGfx); placer->alpha = 0.5; pathRender->alpha = 0; @@ -1066,7 +993,7 @@ Element *SceneEditor::getElementAtCursor() { if (e->life == 1) { - if (e->isCoordinateInside(dsq->getGameCursorPosition()))//, minSelectionSize + if (e->isCoordinateInside(dsq->getGameCursorPosition())) { Vector v = dsq->getGameCursorPosition() - e->position; int dist = v.getSquaredLength2D(); @@ -1157,11 +1084,8 @@ void SceneEditor::deleteSelected() } else p->removeNode(selectedNode); - /* - if (p->nodes.size() > 1) - p->nodes.resize(p->nodes.size()-1); - */ - //selectedIdx = -1; + + } } } @@ -1362,11 +1286,7 @@ void SceneEditor::updateEntitySaveData(Entity *editingEntity) { if (editingEntity) { - /* - std::ostringstream os; - os << "oldPos (" << oldPosition.x << ", " << oldPosition.y << ")"; - debugLog(os.str()); - */ + EntitySaveData *d = dsq->game->getEntitySaveDataForEntity(editingEntity, oldPosition); if (d) { @@ -1374,22 +1294,18 @@ void SceneEditor::updateEntitySaveData(Entity *editingEntity) os << "idx1: " << d->idx << " "; os << "idx2: " << editingEntity->entityTypeIdx << " "; os << "name: " << editingEntity->name; - //os << "state: " << editingEntity->getState(); + debugLog(os.str()); - //debugLog("changing entity save data"); + d->x = editingEntity->position.x; d->y = editingEntity->position.y; editingEntity->startPos = Vector(d->x, d->y); - /* - std::ostringstream os2; - os2 << "setting savedata rot to: " << d->rot; - debugLog(os2.str()); - */ + d->rot = editingEntity->rotation.z; } else { - //debugLog("didn't get entity save data"); + } } } @@ -1458,7 +1374,7 @@ void SceneEditor::mouseButtonRightUp() checkForRebuild(); } state = ES_SELECTING; - //dsq->game->reconstructGrid(); + } @@ -1664,7 +1580,7 @@ bool getGrassPixel(pngRawInfo *png, int x, int y) { if (x >= png->Width || y >= png->Height || x < 0 || y < 0) return false; - //int c = ((x*png->Width)*3)+y*3; + int c = (y*png->Width)*png->Components + x*png->Components; if (png->Data[c] == 128 && png->Data[c+1] == 255 && @@ -1738,21 +1654,15 @@ void SceneEditor::skinLevel(pngRawInfo *png, int minX, int minY, int maxX, int m ) ) { - // do color check - /* - int ci = x+(y*png->Height); - if (png->data[ci] < pixelColor.x && - png->data[ci+1] < pixelColor.y && - png->data[ci+2] < pixelColor.z) - { - */ + + float dist=0; wallNormal = dsq->game->getWallNormal(t.worldVector(), 5, &dist, OT_MASK_BLACK); offset = wallNormal*(-TILE_SIZE*0.6f); MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), wallNormal, rot); rot = 180-(360-rot); addTile = true; - //} + } if (addTile) @@ -1788,7 +1698,7 @@ void SceneEditor::skinLevel(pngRawInfo *png, int minX, int minY, int maxX, int m Element *e = dsq->getElement(i); if (e->templateIdx <= 4 && e->templateIdx >= 1) { - if ((p - e->position).getSquaredLength2D() < sqr(120))//sqr(60*3+10)) // 120 + if ((p - e->position).getSquaredLength2D() < sqr(120)) { cantUse[e->templateIdx-1]++; } @@ -1811,40 +1721,6 @@ void SceneEditor::skinLevel(pngRawInfo *png, int minX, int minY, int maxX, int m e->offset = offset; - /* - bool addGrass = false; - int search = 2; - for (int dx = -search; dx < search; dx++) - { - for (int dy = -search; dy < search; dy++) - { - if (getGrassPixel(png, x+dx, y+dy)) - { - //std::ostringstream os; - //os << "found grass pixel at (" << x+dx << ", " << y+dy << ")"; - //debugLog(os.str()); - //errorLog ("add grass"); - addGrass = true; - break; - } - } - } - - if (addGrass) - { - //Vector detailPos = p + wallNormal*48; - Element *grassE = dsq->game->createElement(5, p, 0, &q); - //dsq->game->createElement(5, detailPos, 6, &q); - //grassE->offset = offset; - } - */ - - - /* - float sz = ((rand()%1000)/4000.0f); - e->scale = Vector(1+sz, 1+sz, 1); - */ - idx++; if(idx > 4) @@ -1866,13 +1742,11 @@ void SceneEditor::skinLevel(pngRawInfo *png, int minX, int minY, int maxX, int m void SceneEditor::generateLevel() { - //pngSetStandardOrientation(0); - std::string file=getMapTemplateFilename(); - //pngInfo info; - //PNG_ALPHA - //errorLog("generate level"); - // Y R G B P + std::string file=getMapTemplateFilename(); + + + int maxX=0, maxY=0; const int YELLOW=0, RED=1, GREEN=2, BLUE=3, PURPLE=4, ORANGE=5, BROWN=6, MAX=7; int firstColorX[MAX], firstColorY[MAX]; @@ -1894,10 +1768,10 @@ void SceneEditor::generateLevel() bool success = pngLoadRaw(file.c_str(), &rawinfo); if (success) { - //dsq->elements.clear(); + std::vector rows; std::vector positions; - const int maxRowCount = 9999;//9999;//9999; + const int maxRowCount = 9999; int rowCount = 0; if (rawinfo.Components < 3) { @@ -1905,7 +1779,7 @@ void SceneEditor::generateLevel() } int scale = TILE_SIZE; int c = 0; - //for (int y = rawinfo.Height-1; y >= 0; y--) + for (int y = 0; y < rawinfo.Height; y++) { Vector lastElement; @@ -1950,7 +1824,7 @@ void SceneEditor::generateLevel() } for (int i = 0; i < MAX; i++) { - //if (checkWarpPixel(rawinfo.Data, c, colorVects[i])) + bool p1, p2, p3; p1=p2=p3=false; int diff; @@ -1960,25 +1834,7 @@ void SceneEditor::generateLevel() p2 = (diff < 5); diff = fabsf((colorVects[i].z*255) - rawinfo.Data[c+2]); p3 = (diff < 5); - /* - p1 = (colorVects[i].x == 1 && rawinfo.Data[c] > 200); - if (!p1) - { - p1 = (colorVects[i].x == 0 && rawinfo.Data[c] < 32); - } - p2 = (colorVects[i].y == 1 && rawinfo.Data[c+1] > 200); - if (!p2) - { - p2 = (colorVects[i].y == 0 && rawinfo.Data[c+1] < 32); - if (!p2) - { - p2 = (colorVects[i].y == 0.5f && rawinfo.Data[c+1] > 96 && rawinfo.Data[c+1] < 164); - } - } - p3 = (colorVects[i].z == 1 && rawinfo.Data[c+2] > 200); - if (!p3) - p3 = (colorVects[i].z == 0 && rawinfo.Data[c+2] < 32); - */ + if (p1 && p2 && p3) { lastColorX[i] = x; @@ -1990,63 +1846,25 @@ void SceneEditor::generateLevel() } } } - /* - else if (checkPixel(1, 0, 0)) - { - lastColorX[RED] = x; - lastColorY[RED] = y; - if (firstColorX[RED] == -1) - { - firstColorX[RED] = x; - firstColorY[RED] = y; - } - } - */ - /* - else if ( rawinfo.Data[c] > 200 && - rawinfo.Data[c+1] < 32 && - rawinfo.Data[c+2] < 32) - { - } - else if (rawinfo. - */ + c += rawinfo.Components; if ((e==0 && firstRowElement) || (firstRowElement && rowCount >= maxRowCount && hasLastElement) || (firstRowElement && x == rawinfo.Width-1)) { - /* - if (x == rawinfo.Width-1) - row.x2 = rawinfo.Width-1; - else - { - */ - // HACK: it crashes here: - // because lastElement is garbage data - // fixed! + + + if (hasLastElement) row.x2 = lastElement.x; - //} + hasLastElement = false; firstRowElement = 0; bool add = true; - /* - for (int i = 0; i < rows.size(); i++) - { - if (rows[i].x1 == row.x1 && rows[i].x2 == row.x2) - { - if (abs(rows[i].y - row.y) <= TILE_SIZE+1) - { - rows[i].rows++; - add = false; - break; - } - } - } - */ + if (add) rows.push_back(row); } @@ -2073,7 +1891,7 @@ void SceneEditor::generateLevel() for (i = 0; i < rows.size(); i++) { int w = rows[i].x2 - rows[i].x1; - //int h = scale * rows[i].rows; + int useY = rows[i].y; if (rows[i].rows > 1) { @@ -2131,7 +1949,7 @@ void SceneEditor::generateLevel() this->skinMinY = 4; this->skinMaxX = maxX; this->skinMaxY = maxY; - //skinLevel(&rawinfo, 4, 4, maxX, maxY); + if (rawinfo.Data != NULL) free(rawinfo.Data); } @@ -2294,9 +2112,7 @@ void SceneEditor::action(int id, int state) this->bgLayer = newLayer; } - /* - Vector multiSelectPoint, secondMultiSelectPoint; - */ + if (id == ACTION_MULTISELECT && this->state == ES_SELECTING) { if (state) @@ -2398,7 +2214,7 @@ void destroyEntityPage() } if (se_grad) { - //se_grad->safeKill(); + se_grad->setLife(1); se_grad->setDecayRate(10); se_grad->fadeAlphaWithLife = 1; @@ -2421,8 +2237,8 @@ void createEntityPage() destroyEntityPage(); se_grad = new Quad(); - //Gradient() - //se_grad->makeHorizontal(Vector(0,0,0.3), Vector(0,0,0.1)); + + se_grad->scale = Vector(800, 500); se_grad->position = Vector(400,350); se_grad->followCamera = 1; @@ -2472,7 +2288,7 @@ void createEntityPage() { q->setWidthHeight((q->getWidth()*sizing) / q->getHeight(), sizing); } - //q->setWidthHeight(sizing, sizing); + q->followCamera = 1; dsq->game->addRenderObject(q, LR_HUD); qs.push_back(q); @@ -2528,12 +2344,12 @@ void SceneEditor::selectEntityFromGroups() if (core->mouse.position.y < 100) break; } - + if (core->getKeyState(KEY_ESCAPE)) break; if (core->getKeyState(KEY_SPACE)) break; - + if (!core->getKeyState(KEY_E)) ld = false; else if (!ld) @@ -2541,7 +2357,7 @@ void SceneEditor::selectEntityFromGroups() ld=true; nextEntityPage(); } - + if (!core->getKeyState(KEY_R)) rd = !true; else if (!rd) @@ -2713,7 +2529,7 @@ void SceneEditor::prevElement() cycleElementPrev(editingElement); editingElement = 0; } - else + else { doPrevElement(); } @@ -2874,7 +2690,7 @@ void SceneEditor::cloneSelectedElement() Element *e = dsq->game->createElement(e1->templateIdx, placer->position + Vector(40,40), e1->bgLayer, e1); e->elementFlag = e1->elementFlag; e->setElementEffectByIndex(e1->getElementEffectIndex()); - //e->repeatTextureToFill(e1->isRepeatingTextureToFill()); + } dsq->game->reconstructGrid(); } @@ -2938,7 +2754,7 @@ void SceneEditor::toggle(bool on) movingEntity = 0; dsq->toggleCursor(true); dsq->setCursor(CURSOR_NORMAL); - //core->flags.set(CF_CLEARBUFFERS); + dsq->darkLayer.toggle(false); @@ -2959,7 +2775,7 @@ void SceneEditor::toggle(bool on) else { btnMenu->alpha = 0; - //dsq->game->reconstructGrid(); + selectedElements.clear(); for (int i = 0; i < 9; i++) dsq->getRenderObjectLayer(LR_ELEMENTS1+i)->visible = true; @@ -2976,7 +2792,7 @@ void SceneEditor::toggle(bool on) dsq->game->avatar->enableInput(); text->alpha.interpolateTo(0, 0.2); placer->alpha.interpolateTo(0, 0.2); - //core->flags.unset(CF_CLEARBUFFERS); + dsq->darkLayer.toggle(true); dsq->game->rebuildElementUpdateList(); @@ -2998,8 +2814,8 @@ void SceneEditor::updateText() std::ostringstream os; os << dsq->game->sceneName << " bgL[" << bgLayer << "] (" << (int)dsq->cameraPos.x << "," << (int)dsq->cameraPos.y << ") (" - //<< (int)dsq->game->avatar->position.x - //<< "," << (int)dsq->game->avatar->position.y << "," << (int)dsq->game->avatar->position.z << ")" << " (" + + << (int)dsq->getGameCursorPosition().x << "," << (int)dsq->getGameCursorPosition().y << ")" << " "; switch(editType) { @@ -3254,7 +3070,7 @@ void SceneEditor::update(float dt) smallestDist = dist; selectedIdx = i; selectedNode = n; - //return; + } } } @@ -3442,7 +3258,7 @@ void SceneEditor::update(float dt) } else { - //editingElement->scale=oldScale + add; + editVec = (repeatScale ? oldRepeatScale : oldScale) + add; if (!uni && !repeatScale) { diff --git a/Aquaria/SchoolFish.cpp b/Aquaria/SchoolFish.cpp index 38005f6..7d21e16 100644 --- a/Aquaria/SchoolFish.cpp +++ b/Aquaria/SchoolFish.cpp @@ -50,12 +50,8 @@ SchoolFish::SchoolFish(const std::string &texname) : FlockEntity() float randScale = float(rand()%200)/1000.0f; scale = Vector(0.6f-randScale, 0.6f-randScale); - /* - float randColor = float(rand()%250)/1000.0f; - color = Vector(1-randColor, 1-randColor, 1-randColor); - */ - //color.interpolateTo(Vector(0.5, 0.5, 0.5), 2, -1, 1); + color.ensureData(); color.data->path.addPathNode(Vector(1,1,1), 0); color.data->path.addPathNode(Vector(1,1,1), 0.5); @@ -72,30 +68,24 @@ SchoolFish::SchoolFish(const std::string &texname) : FlockEntity() setEntityType(ET_ENEMY); canBeTargetedByAvatar = true; health = maxHealth = 1; - //scale = Vector(0.5, 0.5); + avoidTime=0; vel = Vector(-minUrgency, 0); setTexture(texname); flockType = FLOCK_FISH; - //updateCull = -1; + updateCull = 4000; collideRadius = 20; - //2 32 0.1 0.1 -0.03 0 4 0 + setSegs(8, 2, 0.1, 0.9, 0, -0.03, 8, 0); - /* - setDamageTarget(DT_AVATAR_SPORECHILD, false); - setDamageTarget(DT_AVATAR_ENERGYBLAST, false); - */ - //setAllDamageTargets(true); + + setDamageTarget(DT_AVATAR_LIZAP, false); - /* - setDamageTarget(DT_AVATAR_ENERGYBLAST, false); - setDamageTarget(DT_AVATAR_SHOCK, false); - */ - //setDamageTarget(DT_AVATAR_BITE, true); -// updateCull = 10248; + + + targetPriority = -1; setEatType(EAT_FILE, "SchoolFish"); @@ -111,7 +101,7 @@ void SchoolFish::onEnterState(int action) Entity::onEnterState(action); if (action == STATE_DEAD) { - //rotation.interpolateTo(Vector(0,0,180), 2); + vel.setLength2D(vel.getLength2D()*-1); oldFlockID = flock ? flock->flockID : -1; @@ -119,24 +109,11 @@ void SchoolFish::onEnterState(int action) doDeathEffects(0, false); - /* - alpha = 0; - alphaMod = 0; - */ + respawnTimer = 20 + rand()%20; alphaMod = 0; - /* - this->setLife(2); - this->setDecayRate(1); - this->fadeAlphaWithLife = true; - */ - /* - dsq->game->spawnIngredient("FishOil", position, 10); - dsq->game->spawnIngredient("FishMeat", position, 10); - dsq->game->spawnIngredient("SmallEgg", position, 10); - dsq->game->spawnIngredient("PlantLeaf", position, 60); - */ + if (!isGoingToBeEaten()) { @@ -182,54 +159,27 @@ void SchoolFish::updateVelocity(Vector &accumulator) vel.z = 0; if (fabsf(vel.y) > fabsf(vel.x)) { - /* - float sign = vel.y / fabsf(vel.y); - vel.y = fabsf(vel.x) * sign; - */ - //std::swap(vel.x, vel.y); - // going up - /* - float len = vel.getLength2D(); - if (vel.y < 0) - { - if (vel.x < 0) - vel.y = vel.x; - else - vel.y = -vel.x; - } - else - { - if (vel.x < 0) - vel.y = -vel.x; - else - vel.y = vel.x; - } - vel.setLength2D(len); - */ + + + } } inline void SchoolFish::avoid(Vector &accumulator, Vector pos, bool inv) { - //accumulator = Vector(0,0,0); + Vector change; if (inv) change = pos - this->position; else change = this->position - pos; - //change = position; - //change -= this->position; - change.setLength2D(maxUrgency); - //change |= maxUrgency; - //change = Vector(100,0); - //avoidTime = 2; - /* - std::ostringstream os; - os << "change(" << change.x << ", " << change.y << ")"; - debugLog (os.str()); - */ + + change.setLength2D(maxUrgency); + + + accumulator += change; } @@ -256,7 +206,6 @@ void SchoolFish::applyAvoidance(Vector &accumulator) } - //return; if (avoidTime>0) return; @@ -285,7 +234,7 @@ void SchoolFish::applyAvoidance(Vector &accumulator) const float tileMult = (float)TILE_SIZE / (float)obsCount; Vector change(obsSumX*tileMult, obsSumY*tileMult); change += position - t0.worldVector(); - //change |= 200; + float dist = change.getLength2D(); float ratio = dist / radius; @@ -346,7 +295,7 @@ void SchoolFish::applyCohesion(Vector &accumulator) change = dsq->game->avatar->position - position; change.setLength2D(maxUrgency*strengthCohesion); accumulator += change; - //avoid(accumulator, dsq->game->avatar->position, true); + } } } @@ -382,47 +331,8 @@ void SchoolFish::applySeparation(Vector &accumulator) void SchoolFish::onUpdate(float dt) { BBGE_PROF(SchoolFish_onUpdate); - /* - Quad::onUpdate(dt); - return; - */ - - /* - if (dsq->continuity.form == FORM_BEAST) - this->activationType = ACT_CLICK; - else - this->activationType = ACT_NONE; - */ - /* - if (burstDelay == 0) - { - maxSpeedLerp = 2; - Vector v = getNormal(); - vel = 0; - v *= -5000; - vel += v; - //float t = (100 + rand()%100)/100.0f; - float t = 2; - maxSpeedLerp.interpolateTo(1, t); - burstDelay = 10;// + (rand()%100)/100.0f; - //rotateToVec(v, 0, 90); - //rotation.interpolateTo(0, 1); - - if (v.x > 0 && !isfh()) - { - flipHorizontal(); - flipDelay = 0.5; - } - if (v.x < 0 && isfh()) - { - flipHorizontal(); - flipDelay = 0.5; - } - } - else - */ { burstDelay -= dt; @@ -437,13 +347,8 @@ void SchoolFish::onUpdate(float dt) if (this->layer < LR_ENTITIES) { - //debugLog("background fish!"); - /* - setDamageTarget(DT_AVATAR_SHOCK, false); - setDamageTarget(DT_AVATAR_BITE, false); - setDamageTarget(DT_AVATAR_VOMIT, false); - setDamageTarget(DT_AVATAR_ENERGYBLAST, false); - */ + + setEntityType(ET_NEUTRAL); collideRadius = 0; } @@ -463,18 +368,7 @@ void SchoolFish::onUpdate(float dt) } else { - /* - if (layer == LR_ENTITIES || layer == LR_ENTITIES2) - { - rippleTimer -= dt; - if (rippleTimer < 0) - { - if (core->afterEffectManager) - core->afterEffectManager->addEffect(new ShockEffect(Vector(core->width/2, core->height/2),position,0.04,0.06,15,0.2f)); - rippleTimer = 0.5; - } - } - */ + FlockEntity::onUpdate(dt); @@ -482,31 +376,7 @@ void SchoolFish::onUpdate(float dt) dsq->game->handleShotCollisions(this); - /* - soundDelay -= dt; - if (soundDelay <= 0) - { - //sound(swimSound, 1000 + rand()%100); - soundDelay = 4+(rand()%50)/100.0f; - } - */ - /* - 1. if distance_to(closest_boid) <= too_close then set direction away from closest_boid - 2. speed_of_neighbors := average(speed(x), for all x where distance_to(x) <= neighborhood_size) - direction_of_neighbors := avg(direction(x), for all x where distance_to(x) <= neighborhood_size) - if speed < speed_of_neighbors then increase speed - if speed > speed_of_neighbors then decrease speed - turn towards direction_of_neighbors - 3. position_of_neighbors := avg(position(x), for all x where distance_to(x) <= neighborhood_size) - turn towards position_of_neighbors - */ - - /* - FlockPiece flock; - getFlockInRange(160, &flock); - */ - // if flock in 160 ? if (true) { VectorSet newDirection; @@ -530,10 +400,6 @@ void SchoolFish::onUpdate(float dt) applyAvoidance(accumulator); updateVelocity(accumulator); - /* - if (dsq->game->isValidTarget(this, 0)) - doSpellAvoidance(dt, 96, dodgeAbility); - */ Vector lastPosition = position; @@ -542,57 +408,21 @@ void SchoolFish::onUpdate(float dt) if (dsq->game->isObstructed(position)) { position = lastPosition; - /* - Vector newPosition = position; - position = Vector(newPosition.x, lastPosition.y); - if (dsq->game->isObstructed(position)) - { - position = Vector(lastPosition.x, newPosition.y); - if (dsq->game->isObstructed(position)) - { - position = lastPosition; - } - } - */ + } - //updateCurrents(dt); + updateVel2(dt); - /* - if (flipDelay > 0) - { - flipDelay -= dt; - if (flipDelay < 0) - { - flipDelay = 0; - } - } - */ flipDelay = 0; - //dir.normalize2D(); + if (flipDelay <= 0) { const float amt = 0; - /* - if (fabsf(dir.x) > fabsf(dir.y)) - { - if (dir.x > amt && !isfh()) - { - flipHorizontal(); - flipDelay = 0.5; - } - if (dir.x < -amt && isfh()) - { - flipHorizontal(); - flipDelay = 0.5; - } - } - */ if (vel.x > amt && !isfh()) { flipHorizontal(); @@ -604,7 +434,6 @@ void SchoolFish::onUpdate(float dt) } - //rotateToVec(accumulator, 5, 90); float angle = atan2f(dir.x<0 ? -dir.y : dir.y, fabsf(dir.x)); angle = ((angle*180)/PI); @@ -613,11 +442,11 @@ void SchoolFish::onUpdate(float dt) angle = 45; if (angle < -45) angle = -45; - + rotation = Vector(0,0,angle); - //rotation.interpolateTo(Vector(0, 0, angle), 0); + } } @@ -626,19 +455,6 @@ void SchoolFish::onUpdate(float dt) void SchoolFish::onRender() { FlockEntity::onRender(); - /* - glDisable(GL_BLEND); - glPointSize(12); - glDisable(GL_LIGHTING); - glColor3f(1,1,1); - glBegin(GL_POINTS); - glVertex3f(0,0,0); - glEnd(); - glBegin(GL_LINES); - glVertex3f(0,0,0); - glVertex3f(vel.x*50, vel.y*50, 0); - glEnd(); - */ } diff --git a/Aquaria/SchoolFish.h b/Aquaria/SchoolFish.h index 53208c7..f133fe1 100644 --- a/Aquaria/SchoolFish.h +++ b/Aquaria/SchoolFish.h @@ -42,13 +42,13 @@ protected: void applyAlignment(Vector &accumulator, const Vector &dir); void applyAvoidance(Vector &accumulator); void updateVelocity(Vector &accumulator); - + void onEnterState(int action); void onUpdate(float dt); void onRender(); float avoidTime; - + }; #endif diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 994f5af..50d0655 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -2108,7 +2108,7 @@ luaFunc(getNoteColor) luaFunc(getRandNote) { - //int note = lua_tointeger(L, 1); + luaReturnNum(dsq->getRandNote()); } @@ -2230,11 +2230,7 @@ luaFunc(shot_setOut) Vector adjust = shot->velocity; adjust.setLength2D(outness); shot->position += adjust; - /* - std::ostringstream os; - os << "out(" << adjust.x << ", " << adjust.y << ")"; - debugLog(os.str()); - */ + } luaReturnNil(); } @@ -2496,7 +2492,7 @@ static size_t _shotFilter(lua_State *L) for(Shot::Shots::iterator it = Shot::shots.begin(); it != Shot::shots.end(); ++it) { Shot *s = *it; - + if (s->isActive() && s->life >= 1.0f) { if (dt == DT_NONE || s->getDamageType() == dt) @@ -2693,7 +2689,7 @@ luaFunc(entity_getBoneLockEntity) { BoneLock *b = e->getBoneLock(); ent = b->entity; - //ent = e->boneLock.entity; + } luaReturnPtr(ent); } @@ -2953,11 +2949,7 @@ luaFunc(isWithin) Vector v1 = getVector(L, 1); Vector v2 = getVector(L, 3); float dist = lua_tonumber(L, 5); - /* - std::ostringstream os; - os << "v1(" << v1.x << ", " << v1.y << ") v2(" << v2.x << ", " << v2.y << ")"; - debugLog(os.str()); - */ + Vector d = v2-v1; bool v = false; if (d.isLength2DIn(dist)) @@ -4049,29 +4041,13 @@ luaFunc(entity_isNearGround) Vector v = dsq->game->getWallNormal(e->position, sampleArea); if (!v.isZero()) { - //if (v.y < -0.5f && fabsf(v.x) < 0.4f) + if (v.y < 0 && fabsf(v.x) < 0.6f) { value = true; } } - /* - Vector v = e->position + Vector(0,e->collideRadius + TILE_SIZE/2); - std::ostringstream os; - os << "checking (" << v.x << ", " << v.y << ")"; - debugLog(os.str()); - TileVector t(v); - TileVector c; - for (int i = -5; i < 5; i++) - { - c.x = t.x+i; - c.y = t.y; - if (dsq->game->isObstructed(t)) - { - value = true; - } - } - */ + } luaReturnBool(value); } @@ -4680,7 +4656,7 @@ luaFunc(savePoint) Vector position; if (p) { - //dsq->game->avatar->moveToNode(p, 0, 0, 1); + position = p->nodes[0].position; } @@ -4818,7 +4794,7 @@ luaFunc(entity_damage) if (e) { DamageData d; - //d.attacker = e; + d.attacker = lua_isuserdata(L, 2) ? entity(L, 2) : NULL; d.damage = lua_tonumber(L, 3); d.damageType = (DamageType)lua_tointeger(L, 4); @@ -4991,11 +4967,7 @@ luaFunc(decrFlag) luaFunc(setFlag) { - /* - if (lua_isstring(L, 1)) - dsq->continuity.setFlag(lua_tostring(L, 1), lua_tonumber(L, 2)); - else - */ + dsq->continuity.setFlag(lua_tointeger(L, 1), lua_tointeger(L, 2)); luaReturnNil(); } @@ -5003,11 +4975,7 @@ luaFunc(setFlag) luaFunc(getFlag) { int v = 0; - /* - if (lua_isstring(L, 1)) - v = dsq->continuity.getFlag(lua_tostring(L, 1)); - else if (lua_isnumber(L, 1)) - */ + v = dsq->continuity.getFlag(lua_tointeger(L, 1)); luaReturnNum(v); @@ -6688,7 +6656,7 @@ luaFunc(playMusic) luaFunc(playMusicStraight) { dsq->sound->setMusicFader(1,0); - dsq->sound->playMusic(getString(L, 1), SLT_LOOP, SFT_IN, 0.5); //SFT_IN, 0.1);//, SFT_IN, 0.2); + dsq->sound->playMusic(getString(L, 1), SLT_LOOP, SFT_IN, 0.5); luaReturnNil(); } @@ -6813,7 +6781,7 @@ luaFunc(entity_adjustPositionBySurfaceNormal) e->position += v; } e->setv(EV_CRAWLING, 0); - //e->setCrawling(false); + } luaReturnNil(); } @@ -6827,16 +6795,10 @@ luaFunc(entity_moveAlongSurface) { e->lastPosition = e->position; - //if (!e->position.isInterpolating()) + { - /* - if (dsq->game->isObstructed(TileVector(e->position))) - { - e->moveOutOfWall(); - } - */ Vector v; if (e->ridingOnEntity) @@ -6846,58 +6808,22 @@ luaFunc(entity_moveAlongSurface) } else v = dsq->game->getWallNormal(e->position); - //int outFromWall = lua_tointeger(L, 5); + int outFromWall = e->getv(EV_WALLOUT); bool invisibleIn = e->isSittingOnInvisibleIn(); - /* - if (invisibleIn) - debugLog("Found invisibleIn"); - else - debugLog("NOT FOUND"); - */ - /* - for (int x = -2; x < 2; x++) - { - for (int y = -2; y< 2; y++) - { - if (dsq->game->getGrid(TileVector(x,y))== OT_INVISIBLEIN) - { - debugLog("found invisible in"); - invisibleIn = true; - break; - } - } - } - */ + if (invisibleIn) outFromWall -= TILE_SIZE; float t = 0.1; e->offset.interpolateTo(v*outFromWall, t); - /* - if (outFromWall) - { - //e->lastWallOffset = dsq->game->getWallNormal(e->position)*outFromWall; - //e->offset.interpolateTo(dsq->game->getWallNormal(e->position)*outFromWall, time*2); - //e->offset = v*outFromWall; - //float t = 0; - e->offset.interpolateTo(v*outFromWall, t); - //pos += e->lastWallOffset; - } - else - { - e->offset.interpolateTo(Vector(0,0), t); - //e->offset.interpolateTo(Vector(0,0), time*2); - //e->lastWallOffset = Vector(0,0);g - } - */ - // HACK: make this an optional parameter? - //e->rotateToVec(v, 0.1); + + float dt = lua_tonumber(L, 2); float speed = lua_tonumber(L, 3); - //int climbHeight = lua_tonumber(L, 4); + Vector mov; if (e->surfaceMoveDir==1) mov = Vector(v.y, -v.x); @@ -6910,49 +6836,8 @@ luaFunc(entity_moveAlongSurface) e->vel = 0; - /* - float adjustbit = float(speed)/float(TILE_SIZE); - if (e->isNearObstruction(0)) - { - Vector n = dsq->game->getWallNormal(e->position); - if (!n.isZero()) - { - Vector sp = e->position; - e->position += n * adjustbit * dt; - } - } - if (!e->isNearObstruction(1)) - { - Vector n = dsq->game->getWallNormal(e->position); - if (!n.isZero()) - { - Vector sp = e->position; - e->position -= n * adjustbit * dt; - } - } - */ - /* - Vector sp = e->position; - e->clampToSurface(); - */ - /* - e->position = sp; - e->internalOffset.interpolateTo(e->position-sp, 0.2); - */ - /* - e->position = e->lastPosition; - e->position.interpolateTo(to*0.5f + e->position*0.5f, 0.5); - */ - /* - Vector to = e->position; - e->position = e->lastPosition; - e->position.interpolateTo(to, 0.5); - */ - /* - e->position = sp; - e->internalOffset.interpolateTo(e->position - sp, 0.2); - */ - //e->clampToSurface(0.1); + + } } @@ -6961,7 +6846,7 @@ luaFunc(entity_moveAlongSurface) luaFunc(entity_rotateToSurfaceNormal) { - //ScriptedEntity *e = scriptedEntity(L); + Entity *e = entity(L); float t = lua_tonumber(L, 2); int n = lua_tointeger(L, 3); @@ -6970,7 +6855,7 @@ luaFunc(entity_rotateToSurfaceNormal) { e->rotateToSurfaceNormal(t, n, rot); } - //Entity *e = entity(L); + luaReturnNil(); } @@ -7219,11 +7104,7 @@ luaFunc(entity_pullEntities) Vector pull = pos - ent->position; pull.setLength2D(float(len) * dt); ent->vel2 += pull; - /* - std::ostringstream os; - os << "ent: " << ent->name << " + (" << pull.x << ", " << pull.y << ")"; - debugLog(os.str()); - */ + } } } @@ -7267,7 +7148,7 @@ luaFunc(entity_isRidingOnEntity) luaReturnPtr(NULL); } -//entity_setProperty(me, EP_SOLID, true) + luaFunc(entity_isProperty) { Entity *e = entity(L); @@ -7279,7 +7160,7 @@ luaFunc(entity_isProperty) luaReturnBool(v); } -//entity_setProperty(me, EP_SOLID, true) + luaFunc(entity_setProperty) { Entity *e = entity(L); @@ -7335,10 +7216,7 @@ luaFunc(entity_hurtTarget) d.damage = lua_tointeger(L, 2); e->getTargetEntity(e->currentEntityTarget)->damage(d); } - /* - if (e && e->getTargetEntity()) - e->getTargetEntity(e->currentEntityTarget)->damage(lua_tointeger(L, 2), 0, e); - */ + luaReturnNil(); } @@ -8194,7 +8072,7 @@ luaFunc(entity_getTarget) if (e) { retEnt = e->getTargetEntity(lua_tonumber(L, 2)); - //e->activate(); + } luaReturnPtr(retEnt); } @@ -8815,11 +8693,7 @@ luaFunc(entity_getFlag) luaFunc(isFlag) { int v = 0; - /* - if (lua_isstring(L, 1)) - v = dsq->continuity.getFlag(lua_tostring(L, 1)); - else if (lua_isnumber(L, 1)) - */ + bool f = false; if (lua_isnumber(L, 1)) { @@ -8831,11 +8705,7 @@ luaFunc(isFlag) v = dsq->continuity.getFlag(getString(L, 1)); f = (v == lua_tointeger(L, 2)); } - /* - int f = 0; - dsq->continuity.getFlag(lua_tostring(L, 1)); - */ luaReturnBool(f); } diff --git a/Aquaria/ScriptedEntity.cpp b/Aquaria/ScriptedEntity.cpp index 3bc00b2..e7f9ad1 100644 --- a/Aquaria/ScriptedEntity.cpp +++ b/Aquaria/ScriptedEntity.cpp @@ -39,7 +39,7 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E strandSpacing = 10; animKeyFunc = true; canShotHitFunc = true; - //runningActivation = false; + setEntityType(et); myTimer = 0; @@ -118,7 +118,7 @@ void ScriptedEntity::warpSegments() } void ScriptedEntity::init() -{ +{ if (script) { if (!script->call("init", this)) @@ -129,7 +129,7 @@ void ScriptedEntity::init() } void ScriptedEntity::postInit() -{ +{ if (script) { if (!script->call("postInit", this)) @@ -207,7 +207,7 @@ void ScriptedEntity::initSegments(int numSegments, int minDist, int maxDist, std else q->setTexture(bodyTex); q->setWidthHeight(w, h); - + if (i > 0 && i < segments.size()-1 && taper !=0) q->scale = Vector(1.0f-(i*taper), 1-(i*taper)); dsq->game->addRenderObject(q, LR_ENTITIES); @@ -231,7 +231,7 @@ void ScriptedEntity::setupEntity(const std::string &tex, int lcode) void ScriptedEntity::setupBasicEntity(const std::string& texture, int health, int manaBall, int exp, int money, float collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer) { - //this->updateCull = updateCull; + updateCull = -1; if (texture.empty()) @@ -326,7 +326,7 @@ void ScriptedEntity::onAlwaysUpdate(float dt) e->sound("RockHit"); dsq->spawnParticleEffect("rockhit", e->position, 0, 0); } - //e->push(vel, 0.2, 500, 0); + Vector add = vel; add.setLength2D(5000*dt); e->vel += add; @@ -343,7 +343,7 @@ void ScriptedEntity::onAlwaysUpdate(float dt) } if (isPullable()) - { + { Entity *followEntity = dsq->game->avatar; if (followEntity && dsq->game->avatar->pullTarget == this) { @@ -354,13 +354,13 @@ void ScriptedEntity::onAlwaysUpdate(float dt) } else if (!dist.isLength2DIn(800)) { - // break; + vel.setZero(); dsq->game->avatar->pullTarget->stopPull(); dsq->game->avatar->pullTarget = 0; } else if (!dist.isLength2DIn(128)) - { + { Vector v = dist; int moveSpeed = 1000; moveSpeed = 4000; @@ -390,7 +390,7 @@ void ScriptedEntity::updateStrands(float dt) if (strands.empty()) return; float angle = rotation.z; angle = (PI*(360-(angle-90)))/180.0; - //angle = (180*angle)/PI; + float sz = (strands.size()/2); for (int i = 0; i < strands.size(); i++) { @@ -434,7 +434,7 @@ void ScriptedEntity::shiftWorlds(WorldType lastWorld, WorldType worldType) } void ScriptedEntity::startPull() -{ +{ Entity::startPull(); beforePullMaxSpeed = getMaxSpeed(); becomeSolidDelay = false; @@ -642,7 +642,7 @@ void ScriptedEntity::songNoteDone(int note, float len) void ScriptedEntity::becomeSolid() { - //vel = 0; + float oldRot = 0; bool doRot=false; Vector n = dsq->game->getWallNormal(position); @@ -683,7 +683,7 @@ void ScriptedEntity::onHitWall() { becomeSolidDelay = true; } - + if (isEntityProperty(EP_BLOCKER) && !fillGridFromQuad) { Vector n = dsq->game->getWallNormal(position); @@ -703,10 +703,10 @@ void ScriptedEntity::onHitWall() } void ScriptedEntity::activate() -{ +{ if (runningActivation) return; Entity::activate(); - + runningActivation = true; if (script) { @@ -762,7 +762,7 @@ void ScriptedEntity::onDieEaten() void ScriptedEntity::onEnterState(int action) { CollideEntity::onEnterState(action); - + if (script) { if (!script->call("enterState", this)) @@ -772,7 +772,7 @@ void ScriptedEntity::onEnterState(int action) { case STATE_DEAD: if (!isGoingToBeEaten()) - { + { doDeathEffects(manaBallAmount); dsq->spawnParticleEffect(deathParticleEffect, position); onDieNormal(); @@ -799,7 +799,7 @@ void ScriptedEntity::onEnterState(int action) void ScriptedEntity::onExitState(int action) { - + if (script) { if (!script->call("exitState", this)) diff --git a/Aquaria/ScriptedEntity.h b/Aquaria/ScriptedEntity.h index 144a564..bd04cb6 100644 --- a/Aquaria/ScriptedEntity.h +++ b/Aquaria/ScriptedEntity.h @@ -50,7 +50,7 @@ public: void entityDied(Entity *e); void message(const std::string &msg, int v); int messageVariadic(lua_State *L, int nparams); - + static bool runningActivation; void sporesDropped(const Vector &pos, int type); @@ -101,8 +101,8 @@ protected: void onAlwaysUpdate(float dt); void updateStrands(float dt); bool animKeyFunc; - //void onPathEnd(); - + + void onExitTimer(); float myTimer; void onHitWall(); diff --git a/Aquaria/Shot.cpp b/Aquaria/Shot.cpp index 0fdff8b..348ebc2 100644 --- a/Aquaria/Shot.cpp +++ b/Aquaria/Shot.cpp @@ -345,7 +345,7 @@ void Shot::loadBankShot(const std::string &ident, Shot *setter) { std::string id = ident; stringToLower(id); - //setter->shotData = &shotBank[id]; + setter->applyShotData(&shotBank[id]); } } @@ -470,7 +470,7 @@ void Shot::onHitWall() if (!shotData->spawnEntity.empty()) { dsq->game->createEntity(shotData->spawnEntity, 0, position, 0, false, "", ET_ENEMY, true); - //(shotData->spawnEntity, 0, position, 0, false, ""); + if (shotData->spawnEntity == "NatureFormFlowers") { dsq->game->registerSporeDrop(position, 0); @@ -518,9 +518,9 @@ void Shot::reflectFromEntity(Entity *e) { firer = e; target = oldFirer; - //int d = (int)dt; - //d += DT_AVATAR;oll - //damageType = DamageType(d); + + + } } @@ -542,11 +542,7 @@ void Shot::targetDied(Entity *target) } - /* - std::ostringstream os; - os << "# of shots in list: " << c; - debugLog(os.str()); - */ + } bool Shot::isHitEnts() const @@ -585,13 +581,13 @@ void Shot::hitEntity(Entity *e, Bone *b) if (damageType == DT_AVATAR_BITE) { - //debugLog("Shot::hitEntity bittenEntities.push_back"); + dsq->game->avatar->bittenEntities.push_back(e); } bool damaged = e->damage(d); - // doesn't have anything to do with effectTime + if (shotData) { if (!damaged && checkDamageTarget && !shotData->alwaysDoHitEffects) @@ -611,11 +607,11 @@ void Shot::hitEntity(Entity *e, Bone *b) } - //debugLog("Shot hit enemy: " + e->name); + } else { - //debugLog("Shot hit 0 enemy"); + } if (doEffects) @@ -640,7 +636,7 @@ void Shot::hitEntity(Entity *e, Bone *b) } } - //d.bone = c.bone; + } void Shot::noSegs() @@ -679,11 +675,7 @@ void Shot::setAimVector(const Vector &aim) { velocity.setLength2D(shotData->maxSpeed); } - /* - std::ostringstream os; - os << "setting aim vector(" << aim.x << ", " << aim.y << ") to vel(" << velocity.x << ", " << velocity.y << ")"; - debugLog(os.str()); - */ + } void Shot::setTarget(Entity *target) @@ -737,7 +729,7 @@ void Shot::onUpdate(float dt) { if (velocity.isZero()) { - //velocity = Vector(rand()%100-50, rand()%100-50); + } else if (velocity.isLength2DIn(maxSpeed*0.75f)) { @@ -745,18 +737,7 @@ void Shot::onUpdate(float dt) } } - /* - if (!gravity.isZero()) - { - velocity += shotData->gravity * dt; - } - */ - /* - std::ostringstream os; - os << "shotVel(" << velocity.x << ", " << velocity.y << ")"; - debugLog(os.str()); - */ homingness += shotData->homingIncr*dt; if (shotData->homingMax != 0 && homingness > shotData->homingMax) @@ -779,7 +760,7 @@ void Shot::onUpdate(float dt) add.setLength2D(shotData->rotIncr); velocity += add * dt; } - //emitter.update(dt); + if (emitter) { emitter->position = position + offset; @@ -814,7 +795,7 @@ void Shot::onUpdate(float dt) return; } } - //TileVector t(position); + Vector diff; if (target) diff = target->getTargetPoint(targetPt) - this->position; @@ -846,13 +827,13 @@ void Shot::onUpdate(float dt) if (!N.isZero()) { - //2*(-I dot N)*N + I + velocity = 2*(-I.dot(N))*N + I; velocity *= len; } break; } - // fall through + } default: { diff --git a/Aquaria/Shot.h b/Aquaria/Shot.h index d35e65e..157be1f 100644 --- a/Aquaria/Shot.h +++ b/Aquaria/Shot.h @@ -69,15 +69,15 @@ struct ShotData Vector gravity; void bankLoad(const std::string &file, const std::string &path); - + }; class Shot : public Quad, public Segmented { public: - //Shot(DamageType damageType, Entity *firer, Vector pos, Entity *target, std::string tex="", float homingness=1000, int maxSpeed=400, int segments=10, float segMin=0.1, float segMax=5, float damage = 1, float lifeTime = 0); + Shot(); - //void destroy(); + void reflectFromEntity(Entity *e); void setParticleEffect(const std::string &particleEffect); typedef std::vector Shots; @@ -95,7 +95,7 @@ public: void fire(bool playSfx = true); void hitEntity(Entity *e, Bone *b); - + void noSegs(); void rotateToVec(Vector addVec, float time, int offsetAngle); @@ -156,7 +156,7 @@ public: Beam(Vector pos, float angle); typedef std::list Beams; static Beams beams; - //static void targetDied(Entity *t); + static void killAllBeams(); float angle; diff --git a/Aquaria/Spore.cpp b/Aquaria/Spore.cpp index 1cb8630..8ccff6a 100644 --- a/Aquaria/Spore.cpp +++ b/Aquaria/Spore.cpp @@ -49,7 +49,7 @@ bool Spore::isPositionClear(const Vector &position) { if (dsq->game->isObstructed(TileVector(position))) return false; - for (Spores::iterator i = spores.begin(); i != spores.end(); i++) + for (Spores::iterator i = spores.begin(); i != spores.end(); i++) { Spore *s = *i; if (s->position == position) @@ -68,7 +68,7 @@ void Spore::destroy() void Spore::onEndOfLife() { - //::onEndLife(); + spores.remove(this); } @@ -84,9 +84,9 @@ void Spore::onEnterState(int state) } void Spore::killAllSpores() -{ +{ std::queuesporeDeleteQueue; - for (Spores::iterator i = spores.begin(); i != spores.end(); i++) + for (Spores::iterator i = spores.begin(); i != spores.end(); i++) { sporeDeleteQueue.push(*i); } @@ -104,8 +104,8 @@ void Spore::killAllSpores() } void Spore::onUpdate(float dt) -{ - +{ + CollideEntity::onUpdate(dt); if (life < 1) return; @@ -118,7 +118,7 @@ void Spore::onUpdate(float dt) int sporeCr = 48; collideRadius = scale.x * sporeCr; - + if (touchAvatarDamage(collideRadius, 1, Vector(-1,-1,-1), 500)) { // YAY! diff --git a/Aquaria/States.cpp b/Aquaria/States.cpp index f9a93ef..071e791 100644 --- a/Aquaria/States.cpp +++ b/Aquaria/States.cpp @@ -28,15 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Bubble::Bubble() : Quad() { setTexture("particles/bubble"); - /* - this->life = 10; - this->decayRate = 1; - */ + this->alpha = 0.5f; this->speed = rand()%10+20; this->width = 32; this->height = 32; - //this->scale = Vector(0.5f, 0.5f, 0.5f); + } void Bubble::onUpdate(float dt) @@ -64,12 +61,12 @@ void Intro2::applyState() ActionMapper::clearActions(); - //addAction(MakeFunctionEvent(Intro2, skipIntro), KEY_ESCAPE, 0); + dsq->subtitlePlayer.show(0.5f); core->resetCamera(); - + dsq->jiggleCursor(); dsq->setCutscene(1,1); @@ -78,8 +75,7 @@ void Intro2::applyState() dsq->overlay->alpha.interpolateTo(0, 40); dsq->toggleCursor(0); - // OLD WAY of skipping - //dsq->user.control.actionSet.importAction(this, "Escape", ACTION_ESC); + Quad *frame4 = new Quad; { @@ -110,96 +106,11 @@ void Intro2::applyState() dsq->voice("Naija_Intro-music"); - + while (dsq->sound->isPlayingVoice()) dsq->main(FRAME_TIME); - /* - while (dsq->sound->isPlayingVoice()) - { - if (isActing(ACTION_ESC)) - { - while (isActing(ACTION_ESC) && dsq->sound->isPlayingVoice()) - { - core->main(FRAME_TIME); - } - dsq->overlay->alpha.interpolateTo(1, 1); - dsq->stopVoice(); - dsq->main(1); - dsq->newGame(); - return; - } - core->main(FRAME_TIME); - } - */ - /* - Quad *frame3 = new Quad; - { - frame3->setTexture("gameover-0002"); - frame3->position = Vector(400,300); - frame3->width = 600; - frame3->height = 600; - } - addRenderObject(frame3, LR_BACKGROUND); - - Quad *frame2 = new Quad; - { - frame2->setTexture("gameover-0003"); - frame2->position = Vector(400,300); - frame2->width = 600; - frame2->height = 600; - } - addRenderObject(frame2, LR_BACKGROUND); - - Quad *frame1 = new Quad; - { - frame1->setTexture("gameover-0004"); - frame1->position = Vector(400,300); - frame1->width = 600; - frame1->height = 600; - } - addRenderObject(frame1, LR_BACKGROUND); - */ - - /* - dsq->voice("Naija_Intro1"); - while (dsq->isStreamingVoice()) core->main(1); - */ - - /* - frame1->alpha.interpolateTo(0, 1); - core->main(1); - */ - - /* - dsq->voice("Naija_Intro2"); - while (dsq->isStreamingVoice()) core->main(1); - */ - - //frame2->alpha.interpolateTo(0, 1); - - /* - dsq->voice("Naija_Intro3"); - while (dsq->isStreamingVoice()) core->main(1); - */ - - /* - frame3->alpha.interpolateTo(0, 1); - core->main(1); - */ - - /* - dsq->voice("Naija_Intro3"); - while (dsq->isStreamingVoice()) core->main(1); - */ - - //frame4->alpha.interpolateTo(0, 1); - - /* - dsq->voice("Naija_Intro4"); - while (dsq->isStreamingVoice()) core->main(1); - */ emitter->stop(); emitter2->start(); @@ -245,8 +156,8 @@ void GameOver::applyState() const bool frameOutputGameOver = false; core->sound->fadeMusic(SFT_OUT, 1); - //float transTime = 0.01; - //core->sound->fadeOut(transTime); + + StateObject::applyState(); core->globalScale = Vector(1,1); core->globalScaleChanged(); @@ -268,18 +179,6 @@ void GameOver::applyState() } addRenderObject(q); - /* - BitmapText *b = new BitmapText(&dsq->font); - { - int sz = 64; - b->setFontSize(sz); - b->setText("GAME OVER"); - b->position = Vector(400+sz/2,300-sz/2); - } - addRenderObject(b); - */ - //core->main(transTime); - frame1 = new Quad; @@ -331,11 +230,10 @@ void GameOver::applyState() core->afterEffectManager->addEffect(new ShockEffect(Vector(core->width/2, core->height/2),core->screenCenter, 0.07,0.03,30,0.2f, 1.1)); } - //dsq->screenTransition->transition(0); + dsq->overlay->alpha = 0; - //core->main(0.1); - //frame3->alpha.interpolateTo(0, GO_ANIM_TIME); + core->main(GO_ANIM_TIME); frame4->alpha.interpolateTo(0, GO_ANIM_TIME); @@ -351,24 +249,18 @@ void GameOver::applyState() core->main(GO_ANIM_TIME); core->main(1.5); - //core->sound->streamMusic("Requiem", 0); + if (dsq->recentSaveSlot != -1) { - // game over recent save load + dsq->sound->stopMusic(); float transferSeconds = dsq->continuity.seconds; dsq->continuity.loadFile(dsq->recentSaveSlot); - - /* - //float lastLoadSeconds = dsq->continuity.seconds; - // time spent on a session that ended with death is the - // difference between the current total time and the last save time? - // nope. - // ignore doing the above for now! - */ - + + + dsq->continuity.seconds = transferSeconds; dsq->game->transitionToScene(dsq->game->sceneToLoad); } @@ -376,20 +268,16 @@ void GameOver::applyState() dsq->title(); - //core->main(transTime); if (frameOutputGameOver) core->frameOutputMode = false; - /* - addAction(MakeFunctionEvent(GameOver, onClick), ActionMapper::MOUSE_BUTTON_LEFT, 0); - timer = 1; - */ + } void GameOver::removeState() { - //dsq->screenTransition->capture(); + StateObject::removeState(); frame3 = frame2 = frame1 = 0; } @@ -410,30 +298,7 @@ void GameOver::update(float dt) timer = 0; } - /* - if (frame1 && frame2 && frame3) - { - if (frame3->alpha.x == 0 && !frame3->alpha.isInterpolating()) - { - if (frame2->alpha.x == 0 && !frame2->alpha.isInterpolating()) - { - if (frame1->alpha.x == 0 && !frame1->alpha.isInterpolating()) - { - frame1=frame2=frame3=0; - } - else if (!frame1->alpha.isInterpolating()) - { - frame1->alpha.interpolateTo(0, 0.8); - } - } - else if (!frame2->alpha.isInterpolating()) - { - frame2->alpha.interpolateTo(0, GO_ANIM_TIME); - } - } - } - */ } namespace NagStuff @@ -442,10 +307,7 @@ namespace NagStuff int ic=0; const int numScreens = 11; float screenTimer = 0; - /* - const float screenTime = 7; - const float nagFadeTime = 3; - */ + const float screenTime = 3; const float nagFadeTime = 1; }; @@ -477,7 +339,7 @@ void Nag::applyState() core->setInputGrab(false); grab = false; - + dsq->overlay2->alpha = 0; dsq->stopVoice(); @@ -489,8 +351,8 @@ void Nag::applyState() AquariaMenuItem *buy = new AquariaMenuItem(); buy->followCamera = 1; - buy->position = Vector(630, 400); //300, 540); - //buy->setLabel("Buy"); + buy->position = Vector(630, 400); + buy->useGlow("particles/glow", 480, 128); buy->event.set(MakeFunctionEvent(Nag, onBuy)); buy->setDirMove(DIR_LEFT, buy); @@ -501,7 +363,7 @@ void Nag::applyState() AquariaMenuItem *exit = new AquariaMenuItem(); exit->followCamera = 1; exit->position = Vector(732, 543); - //exit->setLabel("Exit"); + exit->useGlow("particles/glow", 128, 64); exit->event.set(MakeFunctionEvent(Nag, onExit)); exit->setDirMove(DIR_LEFT, exit); @@ -518,7 +380,7 @@ void Nag::applyState() ic = 0; irot.clear(); - //Vector framePos(235, 405); + Vector framePos(240, 400); Vector frameScale(0.98, 0.98); diff --git a/Aquaria/States.h b/Aquaria/States.h index 1216a19..144c7b9 100644 --- a/Aquaria/States.h +++ b/Aquaria/States.h @@ -68,7 +68,7 @@ protected: bool done; Precacher cachy; - //void update(float dt); + }; class Intro2 : public StateObject @@ -88,11 +88,11 @@ public: void applyState(); void removeState(); void update(float dt); - + void doShortBitBlot(); void getOut(); void skipLogo(); - + bool watchQuit(float time); protected: int quitFlag; diff --git a/Aquaria/StatsAndAchievements.cpp b/Aquaria/StatsAndAchievements.cpp index 67bb01e..c133243 100644 --- a/Aquaria/StatsAndAchievements.cpp +++ b/Aquaria/StatsAndAchievements.cpp @@ -122,15 +122,11 @@ const int FLAG_MINIBOSS_END = 720; #pragma warning( push ) // warning C4355: 'this' : used in base member initializer list // This is OK because it's warning on setting up the Steam callbacks, they won't use this until after construction is done -#pragma warning( disable : 4355 ) +#pragma warning( disable : 4355 ) #endif StatsAndAchievements::StatsAndAchievements() { - /* - std::ostringstream os; - os << "app_id: " << SteamUtils()->GetAppID(); - debugLog(os.str()); - */ + #ifdef BBGE_BUILD_ACHIEVEMENTS_INTERNAL unlockedDisplayTimestamp = -1.0f; @@ -140,21 +136,7 @@ StatsAndAchievements::StatsAndAchievements() statsValid = false; storeStats = false; - /* - m_flGameFeetTraveled = 0; - m_nTotalGamesPlayed = 0; - m_nTotalNumWins = 0; - m_nTotalNumLosses = 0; - m_flTotalFeetTraveled = 0; - m_flMaxFeetTraveled = 0; - - m_flAverageSpeed = 0; - - m_hDisplayFont = pGameEngine->HCreateFont( ACHDISP_FONT_HEIGHT, FW_MEDIUM, false, "Arial" ); - if ( !m_hDisplayFont ) - OutputDebugString( "Stats font was not created properly, text won't draw\n" ); - */ } #ifdef _MSC_VER #pragma warning( pop ) @@ -343,7 +325,7 @@ void StatsAndAchievements::OnGameStateChange( EClientGameState eNewState ) m_ulTickCountGameStart = m_pGameEngine->GetGameTickCount(); break; case k_EClientFindInternetServers: - break; + break; case k_EClientGameWinner: if ( SpaceWarClient()->BLocalPlayerWonLastGame() ) m_nTotalNumWins++; @@ -379,11 +361,11 @@ void StatsAndAchievements::OnGameStateChange( EClientGameState eNewState ) //----------------------------------------------------------------------------- void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) { - //debugLog("Eval..."); + // Already have it? if ( achievement.achieved ) { - //debugLog(std::string(achievement.chAchievementID) + " was already achieved"); + return; } @@ -423,11 +405,7 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) || (dsq->continuity.recipes[i].result == "VeggieSoup" && didVeggieSoup)) {} else { - /* - std::ostringstream os; - os << "doesn't know recipe: " << dsq->continuity.recipes[i].result; - debugLog(os.str()); - */ + knowAll = false; } } @@ -442,20 +420,7 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) case ACH_MASS_TRANSIT: { - /* - debugLog("eval ACH_MASS_TRANSIT"); - std::ostringstream os; - os << "FLAG_TRANSTURTLE_VEIL01: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_VEIL01) << "\n"; - os << "FLAG_TRANSTURTLE_VEIL02: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_VEIL02) << "\n"; - os << "FLAG_TRANSTURTLE_OPENWATER03: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_OPENWATER03) << "\n"; - os << "FLAG_TRANSTURTLE_FOREST04: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_FOREST04) << "\n"; - os << "FLAG_TRANSTURTLE_FOREST05: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_FOREST05) << "\n"; - os << "FLAG_TRANSTURTLE_MAINAREA: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_MAINAREA) << "\n"; - os << "FLAG_TRANSTURTLE_SEAHORSE: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_SEAHORSE) << "\n"; - os << "FLAG_TRANSTURTLE_ABYSS03: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_ABYSS03) << "\n"; - os << "FLAG_TRANSTURTLE_FINALBOSS: " << dsq->continuity.getFlag(FLAG_TRANSTURTLE_FINALBOSS) << "\n"; - debugLog(os.str()); - */ + if (dsq->continuity.getFlag(FLAG_TRANSTURTLE_VEIL01) > 0 && dsq->continuity.getFlag(FLAG_TRANSTURTLE_VEIL02) > 0 @@ -481,11 +446,7 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) { WorldMapTile *tile = dsq->continuity.worldMap.getWorldMapTile(i); if (!tile->revealed && (nocasecmp(tile->name, "thirteenlair") != 0)) { - /* - std::ostringstream os; - os << "does not have: " << tile->name; - debugLog(os.str()); - */ + hasAllMap = false; break; } @@ -506,7 +467,7 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) break; case ACH_AQUIRE_ALL_SONGS: - //debugLog("eval ACH_AQUIRE_ALL_SONGS"); + if (dsq->continuity.hasSong(SONG_BIND) && dsq->continuity.hasSong(SONG_SHIELDAURA) && dsq->continuity.hasSong(SONG_LI) @@ -518,14 +479,14 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) && dsq->continuity.hasSong(SONG_FISHFORM) && dsq->continuity.hasSong(SONG_SPIRITFORM)) { - //errorLog("ACH_AQUIRE_ALL_SONGS!"); + UnlockAchievement(achievement); } break; // gameplay case ACH_DEFEAT_PRIESTS: - //if (dsq->continuity.getFlag(FLAG_MINIBOSS_PRIESTS) > 0) + if (dsq->continuity.hasSong(SONG_SPIRITFORM)) { UnlockAchievement(achievement); @@ -609,7 +570,7 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) UnlockAchievement(achievement); } break; - + case ACH_THE_FROZEN_VEIL: if (dsq->game->sceneName == "frozenveil") { @@ -618,8 +579,8 @@ void StatsAndAchievements::EvaluateAchievement( Achievement &achievement ) break; case ACH_MOMMY_AND_DADDY: - //if (dsq->continuity.getFlag(SUNKENCITY_BOSSDONE) > 0) - //setFlag(FLAG_SUNKENCITY_PUZZLE, SUNKENCITY_BOSSDONE) + + if (dsq->continuity.getFlag(FLAG_SUNKENCITY_PUZZLE) >= SUNKENCITY_BOSSDONE) { UnlockAchievement(achievement); @@ -723,16 +684,8 @@ void StatsAndAchievements::entityDied(Entity *eDead) biteDeathComboCounter = 0; } - /* - eDead->getState() == - if (eDead->name == "monkey") { - // we killed a monkey, but how? - if (eDead->lastDamage.damageType == DT_AVATAR_VINE) { - // with a nature form vine - flungMonkey = true; - } - } - */ + + } void StatsAndAchievements::update(float dt) @@ -748,15 +701,11 @@ void StatsAndAchievements::update(float dt) if (!rodeEkkritToTheStars) { if (!dsq->game->isPaused() && b->on) { - //debugLog("boneLock->entity->name: " + b->entity->name); + if (b->entity->name == "ekkrit") { ridingEkkritTime += dt; - /* - std::ostringstream os; - os << "ridingEkkritTime: " << ridingEkkritTime; - debugLog(os.str()); - */ + if (ridingEkkritTime >= ridingEkkritTimeMax) { rodeEkkritToTheStars = true; @@ -864,7 +813,7 @@ void StatsAndAchievements::StoreStatsIfNecessary() const size_t max_achievements = ARRAYSIZE(g_rgAchievements); unsigned char *buf = new unsigned char[max_achievements]; - + for (size_t i = 0; i < max_achievements; i++) { int val = g_rgAchievements[i].achieved ? 1 : 0; diff --git a/Aquaria/StatsAndAchievements.h b/Aquaria/StatsAndAchievements.h index 5087d11..8c37fc6 100644 --- a/Aquaria/StatsAndAchievements.h +++ b/Aquaria/StatsAndAchievements.h @@ -99,13 +99,13 @@ struct PlayStats // maybe int timesPlayed; // # of times the game started int timesPoisoned; // # of times the poison applied gets called on Naija - + int timesUsedTurtle; // # of times trans turtle is used (how to check?) int timesRideSeahorse; // # of times ride seahorse int timesLeptOutOfWater; // # of times Naija goes not underwater after being underwater int timesBackflipped; // # of times Naija does a backflip, check in Avatar.cpp float highestDive; // ...? - + int creaturesConsumed; // # of times swallow creatures, check in Avatar.cpp int sealoafsConsumed; // # of sealoafs eaten int creaturesKilled; // diff --git a/Aquaria/SteamRender.cpp b/Aquaria/SteamRender.cpp index 7273ede..40bf2f7 100644 --- a/Aquaria/SteamRender.cpp +++ b/Aquaria/SteamRender.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. SteamRender::SteamRender() : RenderObject() { cull = false; - //alpha = 0.1f; + alpha = 0.7; setTexture("Particles/Steam"); texture->repeat = true; @@ -40,9 +40,8 @@ void SteamRender::onUpdate(float dt) void SteamRender::onRender() { -#ifdef BBGE_BUILD_OPENGL - //glDisable(GL_CULL_FACE); - //int qs = 0; + + for (Path *p = dsq->game->getFirstPathOfType(PATH_STEAM); p; p = p->nextOfType) { @@ -84,7 +83,7 @@ void SteamRender::onRender() const float len = diff.getLength2D(); const float texScale = len/256.0f; - //qs++; + glBegin(GL_QUAD_STRIP); glColor4f(1,1,1,0); glTexCoord2f((0)*texScale+p->animOffset, 0); @@ -121,7 +120,6 @@ void SteamRender::onRender() } } - //glEnable(GL_CULL_FACE); -#endif + } diff --git a/Aquaria/Strand.cpp b/Aquaria/Strand.cpp index 429cd18..5047146 100644 --- a/Aquaria/Strand.cpp +++ b/Aquaria/Strand.cpp @@ -50,7 +50,6 @@ void Strand::onUpdate(float dt) void Strand::onRender() { -#ifdef BBGE_BUILD_OPENGL const int numSegments = segments.size(); if (numSegments == 0) return; @@ -59,8 +58,8 @@ void Strand::onRender() glLineWidth(1); glBegin(GL_LINE_STRIP); - //glColor4f(0.25,0.25,0.5,1); - // Use fixed-point math to speed things up. --achurch + + unsigned int r = (unsigned int)(color.x * (255<<8)); unsigned int g = (unsigned int)(color.y * (255<<8)); unsigned int b = (unsigned int)(color.z * (255<<8)); @@ -90,5 +89,4 @@ void Strand::onRender() glVertex2f(segments[i]->position.x, segments[i]->position.y); } glEnd(); -#endif } diff --git a/Aquaria/StringBank.cpp b/Aquaria/StringBank.cpp index abdbb8d..f106f94 100644 --- a/Aquaria/StringBank.cpp +++ b/Aquaria/StringBank.cpp @@ -48,7 +48,7 @@ void StringBank::load() void StringBank::_load(const std::string &file) { - //debugLog("StringBank::load("+file+")"); + InStream in(file.c_str()); @@ -59,9 +59,7 @@ void StringBank::_load(const std::string &file) { std::getline(in, line); - //std::ostringstream os; - //os << idx << ": StringBank Read Line: " << line; - //debugLog(os.str()); + if (!line.empty() && line[0] == ' ') line = line.substr(1, line.size()); diff --git a/Aquaria/SubtitlePlayer.cpp b/Aquaria/SubtitlePlayer.cpp index 6a5f89e..3af76a7 100644 --- a/Aquaria/SubtitlePlayer.cpp +++ b/Aquaria/SubtitlePlayer.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../BBGE/DebugFont.h" #include "../BBGE/BitmapFont.h" -//#define DISABLE_SUBS + SubtitlePlayer::SubtitlePlayer() { @@ -130,7 +130,7 @@ void SubtitlePlayer::update(float dt) // set text debugLog(subLines[curLine].line); dsq->subtext->scrollText(subLines[curLine].line, 0.02); - //dsq->subtext->scrollText(subLines[curLine].line, 0.1); + // advance curLine++; } diff --git a/Aquaria/ToolTip.cpp b/Aquaria/ToolTip.cpp index a892eb1..fe90bac 100644 --- a/Aquaria/ToolTip.cpp +++ b/Aquaria/ToolTip.cpp @@ -54,7 +54,7 @@ void ToolTip::setText(const std::string &t, const Vector ¢er, int width) int height = 0; back->position = center; - + text->setWidth(width - 40); text->setText(t); @@ -62,7 +62,7 @@ void ToolTip::setText(const std::string &t, const Vector ¢er, int width) back->setWidthHeight(width, height); - text->position = center - Vector(width,height)*0.5f + Vector(5, 5); + text->position = center - Vector(width,height)*0.5f + Vector(5, 5); } void ToolTip::setArea(const Vector &p1, const Vector &p2) @@ -114,7 +114,7 @@ void ToolTip::onUpdate(float dt) break; } - const float t = 0.0;//0.4;//0.05; + const float t = 0.0; if (in && (required || dsq->user.control.toolTipsOn)) { back->alpha.interpolateTo(1, t); diff --git a/Aquaria/UserSettings.cpp b/Aquaria/UserSettings.cpp index 90a3caa..bb7a6ab 100644 --- a/Aquaria/UserSettings.cpp +++ b/Aquaria/UserSettings.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void UserSettings::save() { - //initInputCodeMap(); + XMLDocument doc; { @@ -268,7 +268,7 @@ void UserSettings::save() doc.SaveFile(userSettingsFilename.c_str()); #endif - //clearInputCodeMap(); + } static void readInt(XMLElement *xml, const char *elem, const char *att, int *toChange) @@ -328,7 +328,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile) } control.actionSet.clearActions(); - //initInputCodeMap(); + control.actionSet.addActionInput("lmb"); control.actionSet.addActionInput("rmb"); @@ -419,9 +419,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile) readInt(xml_video, "FpsSmoothing", "v", &video.fpsSmoothing); - /* - readInt(xml_video, "Parallax", "on", &video.parallaxOn); - */ + XMLElement *xml_parallax = xml_video->FirstChildElement("Parallax"); if (xml_parallax) { @@ -534,7 +532,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile) network.masterServer = serv; } - //clearInputCodeMap(); + if (system.locale.empty()) { diff --git a/Aquaria/WaterSurfaceRender.cpp b/Aquaria/WaterSurfaceRender.cpp index f02d43b..6ad27c5 100644 --- a/Aquaria/WaterSurfaceRender.cpp +++ b/Aquaria/WaterSurfaceRender.cpp @@ -1,37 +1,10 @@ -/* -Copyright (C) 2007, 2010 - Bit-Blot -This file is part of Aquaria. - -Aquaria is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ #include "WaterSurfaceRender.h" #include "DSQ.h" #include "Game.h" #include "Avatar.h" -/* -{ -public: - WaterSurfaceRender(); - void render(); -protected: - void onRender(); -}; -*/ + namespace WaterSurfaceRenderStuff { @@ -44,7 +17,7 @@ WaterSurfaceRender::WaterSurfaceRender() : Quad() { color = baseColor; cull = false; - //alpha = 0.98; + alpha = 0.75; if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) @@ -54,33 +27,17 @@ WaterSurfaceRender::WaterSurfaceRender() : Quad() - //addChild(qSurface); - //qSurface->renderBeforeParent = 1; - - /* - qLine = new Quad("water/water-line", Vector(0,50)); - qLine->repeatTextureToFill(1); - addChild(qLine); - */ - qLine = new Quad("water/water-line", Vector(0,0)); qLine->repeatTextureToFill(1); qLine->cull = false; dsq->game->addRenderObject(qLine, LR_WATERSURFACE2); qLine2 = 0; - /* - qLine2 = new Quad("water/water-line", Vector(0,0)); - qLine2->repeatTextureToFill(1); - qLine2->cull = false; - //qLine2->flipVertical(); - dsq->game->addRenderObject(qLine2, LR_ELEMENTS3); - */ - //water/water-surface + qSurface = new Quad("missingimage", Vector(0,0)); - //qSurface->parentManagedPointer = 1; + qSurface->cull = false; qSurface->repeatTextureToFill(1); dsq->game->addRenderObject(qSurface, LR_WATERSURFACE2); @@ -90,22 +47,22 @@ WaterSurfaceRender::WaterSurfaceRender() : Quad() } void WaterSurfaceRender::render() -{ - //if (dsq->frameBuffer.isInited()) +{ + if (dsq->game->waterLevel.x > 0) - { + { qLine->alpha = qSurface->alpha = 1; - //qSurface->alpha = 0; + position.x = core->screenCenter.x; position.y = dsq->game->waterLevel.x; width = core->getVirtualWidth()*core->invGlobalScale; height = 100; - + float dist = (core->screenCenter.y - position.y); if (dist > 0) @@ -117,7 +74,7 @@ void WaterSurfaceRender::render() } offset.y = (height*scale.y); - //offset.y += 10; + offset.y -= 40*scale.y; @@ -125,11 +82,7 @@ void WaterSurfaceRender::render() qLine->alphaMod = 0.5; qLine->setWidth(width); - /* - qLine2->position = position + offset; - qLine2->alphaMod = 0.5; - qLine2->width = this->width; - */ + qSurface->position = position+offset; qSurface->scale = scale.y; @@ -137,48 +90,35 @@ void WaterSurfaceRender::render() qSurface->setWidthHeight(width, height); float bit = core->cameraPos.x/300.0f; - //qSurface->texOff.x = bit; + qLine->texOff.x = bit; - //qSurface->refreshRepeatTextureToFill(); + qLine->refreshRepeatTextureToFill(); - /* - qLine2->texOff.x = bit; - qLine2->refreshRepeatTextureToFill(); - */ if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) { qSurface->alphaMod = 0.5; Quad::render(); - //qLine->alpha = qSurface->alpha = 0; + } else { - //color = baseColor; + Quad::render(); - //qSurface->alphaMod = 0.6; - //deleteGrid(); - //color = Vector(1,1,1); + + + } - - /* - //core->setupRenderPositionAndScale(); - glClear(GL_DEPTH_BUFFER_BIT); - core->currentLayerPass = 0; - dsq->game->avatar->color = Vector(1,0,0); - dsq->game->avatar->render(); - dsq->game->avatar->color = Vector(1,1,1); - //glBindTexture(GL_TEXTURE_2D, 0); - */ + } else { qLine->alpha = qSurface->alpha = 0; - + if (qLine2) { qLine2->alpha = 0; @@ -188,7 +128,6 @@ void WaterSurfaceRender::render() void WaterSurfaceRender::onRender() { -#ifdef BBGE_BUILD_OPENGL if (dsq->game->waterLevel == 0) return; if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) { @@ -218,22 +157,13 @@ void WaterSurfaceRender::onRender() Quad::onRender(); - /* - glTranslatef(0, -height - 20); - height = 40; - Quad::onRender(); - */ - glBindTexture(GL_TEXTURE_2D, 0); } else { - /* - upperLeftTextureCoordinates.x = 0; - lowerRightTextureCoordinates.x = core->frameBuffer.getWidthP(); - */ + glColor4f(0.4, 0.7, 0.8, 0.2); Quad::onRender(); @@ -242,19 +172,6 @@ void WaterSurfaceRender::onRender() RenderObject::lastTextureApplied = 0; - //dsq->game->avatar->setRenderPass(0); - - /* - glEnable(GL_SCISSOR_TEST); - float realSz2 = sz2*scale.x; - float factor = float(core->getWindowWidth()) / 800.0f; - glScissor(dsq->game->waterLevel.x*factor - realSz2 * factor, 600*factor-(position.y+realSz2)*factor, realSz2*2*factor, realSz2*2*factor); - - */ - - - //glDisable(GL_SCISSOR_TEST); -#endif } diff --git a/Aquaria/Web.cpp b/Aquaria/Web.cpp index ae8c8e7..8512f31 100644 --- a/Aquaria/Web.cpp +++ b/Aquaria/Web.cpp @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "Web.h" +#include "Web.h" #include "DSQ.h" #include "Game.h" #include "Avatar.h" @@ -40,9 +40,9 @@ void Web::setParentEntity(Entity *e) } void Web::killAllWebs() -{ +{ std::queueshotDeleteQueue; - for (Webs::iterator i = webs.begin(); i != webs.end(); i++) + for (Webs::iterator i = webs.begin(); i != webs.end(); i++) { shotDeleteQueue.push(*i); } @@ -136,14 +136,7 @@ void Web::onUpdate(float dt) } if (hit) { - /* - if (!e->vel.isZero()) - { - Vector n = e->vel; - n.setLength2D(e->getv(EV_WEBSLOW)*dt); - e->vel -= n; - } - */ + e->vel /= float(e->getv(EV_WEBSLOW)) * dt; } } @@ -153,24 +146,22 @@ void Web::onUpdate(float dt) void Web::onRender() { -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, 0); - //glDisable(GL_BLEND); - + + glLineWidth(4); - //glDisable(GL_CULL_FACE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_LINES); for (int i = 0; i < points.size()-1; i++) - { - + { + glColor4f(1, 1, 1, 0.5f*alpha.x); glVertex3f(points[i].x, points[i].y, 0); glColor4f(1, 1, 1, 0.5f*alpha.x); glVertex3f(points[i+1].x, points[i+1].y, 0); - + } glEnd(); -#endif } diff --git a/Aquaria/WorldMapRender.cpp b/Aquaria/WorldMapRender.cpp index 37363c2..2c1a9f1 100644 --- a/Aquaria/WorldMapRender.cpp +++ b/Aquaria/WorldMapRender.cpp @@ -67,7 +67,7 @@ namespace WorldMapRenderNamespace bool editorActive=false; Quad *tophud=0; - + Gradient *underlay = 0; } @@ -157,44 +157,35 @@ public: BeaconRender(BeaconData *beaconData) : Quad(), beaconData(beaconData) { renderQuad = false; - setTexture("gui/minimap/ripple"); //"particles/softring"); // or whatever + setTexture("gui/minimap/ripple"); position = beaconData->pos; truePosition = beaconData->pos; followCamera = 1; - /* - scale = Vector(0.2, 0.2); - scale.interpolateTo(Vector(0.5, 0.5), 0.75, -1, 1, 1); - */ + alpha = 0.5; color = beaconData->color; - /* - pe = new ParticleEffect(); - pe->load("sparkle"); - pe->followCamera = 1; - pe->start(); - core->addRenderObject(pe, LR_PARTICLES); - */ + spawnBitTimer = 0; } - - //float spawnBitTimer; + + Vector truePosition; ParticleEffect *pe; - + float spawnBitTimer; - - + + void render() { - //setProperPosition(); + Quad::render(); } - + protected: BeaconData *beaconData; - + void setProperPosition() { Vector wp = parent->getWorldCollidePosition(truePosition); @@ -215,13 +206,13 @@ protected: Vector move = wp - getWorldPosition(); position += move; } - - + + void onUpdate(float dt) { Quad::onUpdate(dt); - - //setProperPosition(); + + if (!dsq->game->worldMapRender->isOn()) return; @@ -244,7 +235,7 @@ protected: int x = sinf(radius)*len; int y = cosf(radius)*len; - //truePosition + + float t = 0.75; WorldMapBoundQuad *q = new WorldMapBoundQuad(Vector(x, y, 0)); q->setTexture("particles/glow"); @@ -257,16 +248,15 @@ protected: q->color = color; q->scale = Vector(pscale, pscale); - //q->fadeAlphaWithLife = 1; + q->setLife(1); q->setDecayRate(1.0f/t); - + q->setBlendType(BLEND_ADD); addChild(q, PM_POINTER); - //std::ostringstream os; - //os << "children: " << children.size(); - //debugLog(os.str()); + + } else { @@ -276,9 +266,6 @@ protected: - /* - - */ } }; @@ -295,41 +282,26 @@ public: blinkTimer = 0; alphaMod = 0.66; canMove = gemData->canMove; - //canMove = true; - //gemData->userString = "HI THERE!"; + + std::string useString = gemData->userString; - /* - if (gemData->userString.empty()) - { - if (gemData->name == "savepoint") - useString = "Memory Crystal"; - if (gemData->name == "cook") - useString = "Kitchen"; - } - */ - /* - text = new BitmapText(&dsq->smallFont); - text->position = Vector(0, -20); - text->setText(gemData->userString); - addChild(text, PM_POINTER); - */ - text = new TTFText(&dsq->fontArialSmall);//new DebugFont(10, useString); - text->offset = Vector(0, 4); //Vector(0,5); + text = new TTFText(&dsq->fontArialSmall); + text->offset = Vector(0, 4); text->setText(useString); text->setAlign(ALIGN_CENTER); textBG = new RoundedRect(); - textBG->setWidthHeight(text->getActualWidth() + 20, 25, 10); // 30 + textBG->setWidthHeight(text->getActualWidth() + 20, 25, 10); textBG->alpha = 0; textBG->followCamera = 1; game->addRenderObject(textBG, LR_WORLDMAPHUD); textBG->addChild(text, PM_POINTER); - //game->addRenderObject(text, LR_WORLDMAPHUD); + } void destroy() @@ -348,32 +320,16 @@ public: { this->blink = blink; - //if (blink) - //{ - // scale = Vector(0.5, 0.5); - // scale.interpolateTo(Vector(1,1), 0.5, -1, 1); - // /* - // alpha = 0.5; - // alpha.interpolateTo(1, 0.5, -1, 1); - // */ - //} - //else - //{ - // scale.stop(); - // scale = Vector(1,1); - // /* - // alpha.stop(); - // alpha = 1; - // */ - //} + + } bool canMove; protected: - + float blinkTimer; bool blink; GemData *gemData; - //BitmapText *text; + TTFText *text; RoundedRect *textBG; void onUpdate(float dt) @@ -386,7 +342,7 @@ protected: sz.x = sz.y = zoomMin; if (sz.x > zoomMax) sz.x = sz.y = zoomMax; - + if (sz.x > 1.0f) { scale.x = (1.0f/sz.x); @@ -421,22 +377,22 @@ protected: { core->sound->playSfx("Gem-Move"); mover = this; - //offset = Vector(position - core->mouse.position); - //position += core->mouse.position - wp; - //offset = Vector(0, 4); + + + } } else if (mover == this) { - //position = core->mouse.position; + position += (core->mouse.position - wp)/parent->scale.x; if (!core->mouse.buttons.left) { mover = 0; core->sound->playSfx("Gem-Place"); - //position += offset; - //offset = Vector(0,0); - //offset = Vector(0,0); + + + gemData->pos = position; } } @@ -450,20 +406,14 @@ protected: if ((core->mouse.position - wp).isLength2DIn(GEM_GRAB)) { - //text->alpha.interpolateTo(1, 0.1); - /* - if (!gemData->userString.empty()) - textBG->alpha.interpolateTo(1, 0.1); - */ + + if (!gemData->userString.empty()) textBG->show(); } else { - /* - text->alpha.interpolateTo(0, 0.1); - textBG->alpha.interpolateTo(0, 0.1); - */ + if (textBG->alpha == 1) textBG->hide(); } @@ -502,7 +452,6 @@ void WorldMapRender::setProperTileColor(WorldMapTile *tile) } } -#ifdef AQUARIA_BUILD_MAPVIS static void tileDataToVis(WorldMapTile *tile, Vector **vis) { @@ -615,24 +564,16 @@ static void resetTileAlpha(WorldMapTile *tile, const unsigned char *savedTexData tile->q->texture->write(0, 0, tile->q->texture->width, tile->q->texture->height, savedTexData); } -#endif // AQUARIA_BUILD_MAPVIS void WorldMapRender::setVis(WorldMapTile *tile) { if (!tile) return; -#ifdef AQUARIA_BUILD_MAPVIS - /* - if (lastVisQuad) - { - lastVisQuad->alphaMod = 0.5; - lastVisQuad->color = Vector(0.7, 0.8, 1); - } - */ + tile->q->color = Vector(1,1,1); tile->q->alphaMod = 1; - + if (visMethod == VIS_VERTEX) { tile->q->setSegs(MAPVIS_SUBDIV, MAPVIS_SUBDIV, 0, 0, 0, 0, 2.0, 1); @@ -645,13 +586,11 @@ void WorldMapRender::setVis(WorldMapTile *tile) lastVisQuad = tile->q; lastVisTile = tile; -#endif } void WorldMapRender::clearVis(WorldMapTile *tile) { if (!tile) return; -#ifdef AQUARIA_BUILD_MAPVIS if (visMethod == VIS_VERTEX) { if (tile->q) @@ -666,7 +605,6 @@ void WorldMapRender::clearVis(WorldMapTile *tile) savedTexData = 0; } } -#endif } @@ -704,19 +642,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() savedTexData = 0; - /* - bg = new Quad("", Vector(400,300)); - bg->setWidthHeight(810, 610); - bg->setSegs(32, 32, 0.5, 0.5, 0.008, 0.008, 2.0, 1); - bg->alphaMod = 0.5; - bg->alpha = 0; - bg->followCamera = 1; - bg->repeatTextureToFill(true); - //bg->parentManagedPointer = 1; - dsq->game->addRenderObject(bg, LR_MESSAGEBOX); - bg->renderQuad = false; - */ int num = dsq->continuity.worldMap.getNumWorldMapTiles(); std::string n = dsq->game->sceneName; @@ -750,7 +676,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() q->alphaMod = 0; tile->q = q; - + q->setWidthHeight(q->getWidth()*tile->scale, q->getHeight()*tile->scale); q->scale = Vector(0.25f*tile->scale2, 0.25f*tile->scale2); @@ -769,7 +695,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() activeTile->q->color = Vector(1,1,1); activeTile->q->alphaMod = 1; } - + addChild(q, PM_POINTER); tiles.push_back(q); @@ -789,14 +715,14 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() tophud->alpha = 0; dsq->game->addRenderObject(tophud, LR_WORLDMAPHUD); - //int fontSize = 6; + float aly = 26, aly2 = 18; float sz = 0.6; //hover areaLabel = new BitmapText(&dsq->smallFont); areaLabel->scale = Vector(sz,sz); - //areaLabel->setFontSize(fontSize); + areaLabel->setAlign(ALIGN_CENTER); areaLabel->followCamera = 1; areaLabel->position = Vector(150,aly); @@ -805,7 +731,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() //in areaLabel2 = new BitmapText(&dsq->smallFont); - //areaLabel2->setFontSize(fontSize); + areaLabel2->scale = Vector(sz,sz); areaLabel2->followCamera = 1; areaLabel2->setAlign(ALIGN_CENTER); @@ -816,7 +742,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() //select areaLabel3 = new BitmapText(&dsq->smallFont); areaLabel3->scale = Vector(sz,sz); - //areaLabel3->setFontSize(fontSize); + areaLabel3->followCamera = 1; areaLabel3->setAlign(ALIGN_CENTER); areaLabel3->position = Vector(650, aly); @@ -831,9 +757,9 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() originalActiveTile = activeTile; bindInput(); - + underlay = new Gradient; - //underlay->makeVertical(Vector(0.5,0.5,1), Vector(0,0,0.5)); + underlay->makeVertical(Vector(0.25,0.25,0.5), Vector(0,0,0.25)); underlay->position = Vector(400,300); underlay->autoWidth = AUTO_VIRTUALWIDTH; @@ -852,14 +778,14 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() addHintQuad2->alpha = 0; dsq->game->addRenderObject(addHintQuad2, LR_WORLDMAPHUD); - //helpButton->event.set(MakeFunctionEvent(WorldMapRender, onToggleHelpScreen)); + helpButton = new AquariaMenuItem; helpButton->event.setActionMapperCallback(this, ACTION_TOGGLEHELPSCREEN, 0); helpButton->useQuad("gui/icon-help"); helpButton->useGlow("particles/glow", 40, 40); helpButton->useSound("Click"); helpButton->alpha = 0; - //helpButton->position = Vector(800-20, 20); + dsq->game->addRenderObject(helpButton, LR_WORLDMAPHUD); } @@ -886,7 +812,7 @@ void WorldMapRender::bindInput() void WorldMapRender::destroy() { - //clearVis(activeTile); + for (int i = 0; i < dsq->continuity.worldMap.getNumWorldMapTiles(); i++) { WorldMapTile *tile = dsq->continuity.worldMap.getWorldMapTile(i); @@ -939,7 +865,7 @@ void WorldMapRender::onUpdate(float dt) if (alpha.x > 0) { - //if (activeTile && activeTile==originalActiveTile && !gemMovers.empty()) + if (originalActiveTile && !gemMovers.empty()) { gemMovers.back()->position = getAvatarWorldMapPosition(); @@ -975,7 +901,7 @@ void WorldMapRender::onUpdate(float dt) if (q) { d = (q->getWorldPosition() - core->mouse.position).getSquaredLength2D(); - + if (q->isCoordinateInsideWorld(core->mouse.position) && (sd == -1 || d < sd)) { sd = d; @@ -993,7 +919,7 @@ void WorldMapRender::onUpdate(float dt) { areaLabel3->setText(dsq->continuity.stringBank.get(activeTile->stringIndex)); } - + if (selectedTile) { areaLabel->setText(dsq->continuity.stringBank.get(selectedTile->stringIndex)); @@ -1009,7 +935,7 @@ void WorldMapRender::onUpdate(float dt) activeTile = selectedTile; activeQuad = activeTile->q; - //activeTile->gridPos = activeTile->q->position; + if (activeQuad) { dsq->clickRingEffect(activeQuad->getWorldPosition(), 0); @@ -1126,7 +1052,7 @@ void WorldMapRender::onUpdate(float dt) zoomMax = exteriorZoomMax; } - float scrollAmount = 0.2;//0.25; + float scrollAmount = 0.2; if (core->mouse.scrollWheelChange) { @@ -1219,7 +1145,6 @@ void WorldMapRender::onUpdate(float dt) } else { -#ifdef AQUARIA_BUILD_MAPVIS if (!dsq->isInCutscene() && dsq->game->avatar && activeTile #ifdef AQUARIA_BUILD_SCENEEDITOR && !dsq->game->sceneEditor.isOn() @@ -1261,7 +1186,6 @@ void WorldMapRender::onUpdate(float dt) } } } -#endif } lastMousePosition = core->mouse.position; @@ -1357,7 +1281,7 @@ void WorldMapRender::toggle(bool turnON) if (alpha.isInterpolating()) return; if (dsq->mod.isActive() && !dsq->mod.hasWorldMap()) return; - + if (dsq->isNested()) return; if (!dsq->game->avatar) return; @@ -1367,7 +1291,7 @@ void WorldMapRender::toggle(bool turnON) if (dsq->game->isInGameMenu()) return; if (!dsq->game->isActive()) return; - + if (turnON && dsq->game->isPaused()) return; if (!this->on && !dsq->game->avatar->isInputEnabled()) return; @@ -1387,7 +1311,7 @@ void WorldMapRender::toggle(bool turnON) { restoreVel = dsq->game->avatar->vel; dsq->game->avatar->vel = Vector(0,0,0); - //dsq->game->avatar->idle(); + dsq->game->togglePause(true); core->sound->playSfx("menu-open"); @@ -1435,23 +1359,23 @@ void WorldMapRender::toggle(bool turnON) alpha.interpolateTo(1, 0.2); - - //dsq->game->hudUnderlay->alpha.interpolateTo(WORLDMAP_UNDERLAY_ALPHA, 0.2); + + underlay->alpha.interpolateTo(WORLDMAP_UNDERLAY_ALPHA, 0.2); addHintQuad1->alpha.interpolateTo(1.0, 0.2); addHintQuad2->alpha.interpolateTo(1.0, 0.2); helpButton->alpha.interpolateTo(1.0, 0.2); - + addAllGems(); - + for (Continuity::Beacons::reverse_iterator i = dsq->continuity.beacons.rbegin(); i != dsq->continuity.beacons.rend(); i++) { if ((*i).on) { BeaconRender *b = new BeaconRender(&(*i)); - //b->position = (*i).pos; - //game->addRenderObject(b, layer+1); + + addChild(b, PM_POINTER); beaconRenders.push_back(b); } @@ -1496,14 +1420,6 @@ void WorldMapRender::toggle(bool turnON) } - //setVis(activeTile); - /* - for (int i = 0; i < LR_MENU; i++) - { - RenderObjectLayer *rl = dsq->getRenderObjectLayer(i); - rl->visible = true; - } - */ core->sound->playSfx("Menu-Close"); @@ -1513,7 +1429,7 @@ void WorldMapRender::toggle(bool turnON) alpha.interpolateTo(0, 0.2); dsq->game->togglePause(false); - //dsq->game->hudUnderlay->alpha.interpolateTo(0, 0.2); + underlay->alpha.interpolateTo(0, 0.2); addHintQuad1->alpha.interpolateTo(0, 0.2); addHintQuad2->alpha.interpolateTo(0, 0.2); @@ -1522,14 +1438,14 @@ void WorldMapRender::toggle(bool turnON) for (GemMovers::iterator i = gemMovers.begin(); i != gemMovers.end(); i++) { - //removeChild(*i); + (*i)->safeKill(); } gemMovers.clear(); - + for (BeaconRenders::iterator i = beaconRenders.begin(); i != beaconRenders.end(); i++) { - //removeChild(*i); + (*i)->safeKill(); } beaconRenders.clear(); @@ -1546,7 +1462,7 @@ void WorldMapRender::createGemHint(const std::string &gfx) doubleClickTimer = 0; GemData *g = dsq->continuity.pickupGem(gfx, false); g->canMove = 1; - g->pos = getAvatarWorldMapPosition();// + Vector(0, -20); + g->pos = getAvatarWorldMapPosition(); g->userString = useString; addGem(g); fixGems(); @@ -1614,25 +1530,6 @@ void WorldMapRender::action (int id, int state) } - /* - if (id == ACTION_PRIMARY && state) - { - if (doubleClickTimer > 0) - { - doubleClickTimer = 0; - GemData *g = dsq->continuity.pickupGem("pyramidyellow", false); - g->canMove = 1; - g->userString = dsq->getUserInputString("Enter Map Hint Name:", ""); - addGem(g); - } - else - { - if (doubleClickTimer == 0) - { - doubleClickTimer = DOUBLE_CLICK_DELAY; - } - } - } - */ + } } diff --git a/Aquaria/WorldMapTiles.cpp b/Aquaria/WorldMapTiles.cpp index 71f30a8..1eab978 100644 --- a/Aquaria/WorldMapTiles.cpp +++ b/Aquaria/WorldMapTiles.cpp @@ -255,7 +255,7 @@ void WorldMap::_load(const std::string &file) std::string line; InStream in(file.c_str()); - + while (std::getline(in, line)) { WorldMapTile t; @@ -337,18 +337,8 @@ WorldMapTile *WorldMap::getWorldMapTileByIndex(int index) return 0; } -/* - -void WorldMap::revealMapIndex(int index) -{ - if (index < 0 || index >= worldMapTiles.size()) return; - - worldMapTiles[index].revealed = true; -} -*/ - void WorldMap::hideMap() { for (int i = 0; i < worldMapTiles.size(); i++) diff --git a/BBGE/ActionMapper.cpp b/BBGE/ActionMapper.cpp index 559fc5d..27974ed 100644 --- a/BBGE/ActionMapper.cpp +++ b/BBGE/ActionMapper.cpp @@ -13,53 +13,11 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "ActionMapper.h" #include "Core.h" -//bool ActionMapper::isActing(const std::string &action) -//{ -// ButtonList::iterator i = actionMap[action].begin(); -// for (; i != actionMap[action].end(); i++) -// { -// if (keyDownMap[(*i)]) -// return true; -// } -// return false; -// //return keyDownMap[actionMap[action]]; -//} - -//bool ActionMapper::isActing(int actionID) -//{ -// std::string action = "A"; -// action[0] = char(actionID); -// ButtonList::iterator i = actionMap[action].begin(); -// for (; i != actionMap[action].end(); i++) -// { -// if (keyDownMap[(*i)]) -// return true; -// } -// return false; -// //return keyDownMap[actionMap[action]]; -//} - -//void ActionMapper::addAction (const std::string &action, int k) -//{ -// actionMap[action].push_back(k); -// keyDownMap[k] = core->getKeyState(k); -//} -// -//void ActionMapper::addAction (int actionID, int k) -//{ -// std::string action = "A"; -// action[0] = char(actionID); -// actionMap[action].push_back(k); -// keyDownMap[k] = core->getKeyState(k); -//} ActionMapper::ActionMapper() { @@ -104,11 +62,7 @@ void ActionMapper::addAction (int actionID, int k) if (ad) { - /* - std::ostringstream os; - os << "Action ID [" << actionID << "] already exists!"; - debugLog(os.str()); - */ + } else { @@ -166,55 +120,7 @@ void ActionMapper::clearCreatedEvents() createdEvents.clear(); } -/* -void ActionMapper::addMouseButtonAction (const std::string &action, int b) -{ - actionMap[action].push_back (0-b); - keyDownMap[0-b] = mouse_b & b; -} -void ActionMapper::addJoystickButtonAction (const std::string &action, int b) -{ - if (num_joysticks) - { - actionMap[action].push_back (b+9000); - keyDownMap[b+9000] = joy[0].button[b].b; - } -} - -int ActionMapper::getDPad(int dir) -{ -// for (int = 0; i < joy[0].num_sticks; i++) - //int s = 4; - int s = 0; - switch (dir) - { - case 0: - return (joy[0].stick[s].axis[0].d1); - break; - case 1: - return (joy[0].stick[s].axis[0].d2); - break; - case 2: - return (joy[0].stick[s].axis[1].d1); - break; - case 3: - return (joy[0].stick[s].axis[1].d2); - break; - } - return 0; -} - - -void ActionMapper::addJoystickDPadAction (const std::string &action, int dir) -{ - if (num_joysticks) - { - actionMap[action].push_back (dir+8000); - keyDownMap[dir+8000] = getDPad(dir); - } -} -*/ void ActionMapper::enableInput() { @@ -235,7 +141,7 @@ void ActionMapper::removeAction(int actionID) for (; i != ad->buttonList.end(); i++) { int k = (*i); - cleared = true; // it's a hack, but it works + cleared = true; // it's a hack, but it works keyDownMap.erase(k); } for (ActionDataSet::iterator i = actionData.begin(); i != actionData.end();) @@ -248,19 +154,7 @@ void ActionMapper::removeAction(int actionID) } } -//int ActionMapper::getKeyForAction (std::string action) -//{ -// ButtonList b = actionMap[action]; -// if (!b.empty()) -// { -// return b[0]; -// } -// else -// { -// debugLog ("no action: " +action); -// return -1; -// } -//} + bool ActionMapper::pollAction(int actionID) { @@ -272,7 +166,7 @@ bool ActionMapper::pollAction(int actionID) ButtonList *blist = &ad->buttonList; ButtonList::iterator j; j = blist->begin(); - + for (; j != blist->end(); j++) { if (getKeyState((*j))) @@ -316,11 +210,11 @@ bool ActionMapper::getKeyState(int k) else if (k == MOUSE_BUTTON_MIDDLE) { keyState = (core->mouse.buttons.middle == DOWN); - } + } else if (k >= JOY1_BUTTON_0 && k <= JOY1_BUTTON_16) { int v = k - JOY1_BUTTON_0; - + if (core->joystickEnabled) keyState = core->joystick.buttons[v]; } @@ -369,13 +263,10 @@ bool ActionMapper::getKeyState(int k) } void ActionMapper::onUpdate (float dt) -{ +{ if (inUpdate) return; inUpdate = true; - /* - if (num_joysticks) - poll_joystick(); - */ + if (cleared) cleared = false; ActionDataSet::iterator i; KeyDownMap oldKeyDownMap = keyDownMap; @@ -392,7 +283,7 @@ void ActionMapper::onUpdate (float dt) keyState = getKeyState(k); if (keyState != oldKeyDownMap[k]) - { + { keyDownMap[k] = keyState; if (inputEnabled) { @@ -417,7 +308,7 @@ void ActionMapper::onUpdate (float dt) out: inUpdate = false; -// keyDownMap[k] = ; + } void ActionMapper::clearActions() diff --git a/BBGE/ActionMapper.h b/BBGE/ActionMapper.h index 73aa2e0..99b8335 100644 --- a/BBGE/ActionMapper.h +++ b/BBGE/ActionMapper.h @@ -44,45 +44,37 @@ struct ActionData class ActionMapper { public: - + // funcs ActionMapper(); virtual ~ActionMapper(); - //void addAction (const std::string &action, int k); + void addAction(Event *event, int k, int state=-1); void addAction(int actionID, int k); - /* - void addMouseButtonAction (const std::string &action, int b); - void addJoystickButtonAction (const std::string &action, int b); - void addJoystickDPadAction (const std::string &action, int dir); - int getDPad(int dir); - */ + void removeAction(int actionID); void removeAllActions(); bool isActing(int actionID); virtual void action(int actionID, int state){} - + void clearActions(); bool isInputEnabled() { return inputEnabled; } - + // vars - + typedef std::list ActionDataSet; ActionDataSet actionData; typedef std::map KeyDownMap; KeyDownMap keyDownMap; - + bool cleared; - //typedef std::map StringIntMap; - //StringIntMap stateCheckMap; - enum { MOUSE_BUTTON_LEFT = 999, MOUSE_BUTTON_RIGHT = 1000, @@ -106,7 +98,7 @@ public: JOY1_BUTTON_15 = 2015, JOY1_BUTTON_16 = 2016, - //JOY1_BUTTON_X360_START=2011, + X360_BTN_START = 3016, X360_BTN_BACK = 3017, @@ -122,13 +114,13 @@ public: enum { DPAD_LEFT = 0, DPAD_RIGHT, DPAD_UP, DPAD_DOWN }; - //int getKeyForAction(std::string action); + virtual void enableInput(); virtual void disableInput(); - /*void loadActionSet(const std::string &fn);*/ - //nasty hack - //void forceUpdate(float dt); + + + Event *addCreatedEvent(Event *event); void clearCreatedEvents(); @@ -149,4 +141,3 @@ protected: - diff --git a/BBGE/ActionSet.cpp b/BBGE/ActionSet.cpp index 47b83fa..53a0593 100644 --- a/BBGE/ActionSet.cpp +++ b/BBGE/ActionSet.cpp @@ -38,68 +38,7 @@ ActionInput *ActionSet::getActionInputByName(const std::string &name) return 0; } -//void ActionSet::loadAction(const std::string &name, int inputCode, InputSetType set) -//{ -// ActionInput *a = getActionInputByName(name); -// if (!a) -// { -// ActionInput newa; -// newa.name = name; -// inputSet.push_back(newa); -// a = getActionInputByName(name); -// -// if (!a) return; -// } -// -// switch(set) -// { -// case INPUTSET_KEY: -// a->keyCodes.push_back(inputCode); -// break; -// case INPUTSET_JOY: -// a->joyCodes.push_back(inputCode); -// break; -// case INPUTSET_MOUSE: -// a->mouseCodes.push_back(inputCode); -// break; -// case INPUTSET_GENERAL: -// default: -// a->inputCodes.push_back(inputCode); -// break; -// } -//} -// -//void ActionSet::loadAction(const std::string &name, const std::vector &inputCodes, InputSetType set) -//{ -// -// ActionInput *a = getActionInputByName(name); -// if (!a) -// { -// ActionInput newa; -// newa.name = name; -// inputSet.push_back(newa); -// a = getActionInputByName(name); -// -// if (!a) return; -// } -// -// switch(set) -// { -// case INPUTSET_KEY: -// a->keyCodes = inputCodes; -// break; -// case INPUTSET_JOY: -// a->joyCodes = inputCodes; -// break; -// case INPUTSET_MOUSE: -// a->mouseCodes = inputCodes; -// break; -// case INPUTSET_GENERAL: -// default: -// a->inputCodes = inputCodes; -// break; -// } -//} + void ActionSet::importAction(ActionMapper *mapper, const std::string &name, int actionID) { @@ -168,7 +107,7 @@ ActionInput *ActionSet::addActionInput(const std::string &name) std::string ActionSet::insertInputIntoString(const std::string &string) { std::string str = string; - + int start = str.find('{'); int end = str.find('}'); if (start == std::string::npos || end == std::string::npos) @@ -177,18 +116,18 @@ std::string ActionSet::insertInputIntoString(const std::string &string) stringToLower(code); std::string part1 = str.substr(0, start); std::string part3 = str.substr(end+1, str.size()); - - //{ToggleHelp:k0} + + int thing = code.find(':'); std::string input = code.substr(0, thing); std::string button = code.substr(thing+1, code.size()); - + char buttonType; int buttonNum; - + std::istringstream is(button); is >> buttonType >> buttonNum; - + ActionInput *actionInput=0; actionInput = getActionInputByName(input); if (!actionInput) @@ -209,7 +148,7 @@ std::string ActionSet::insertInputIntoString(const std::string &string) inputCode = actionInput->mse[buttonNum]; break; } - + std::string part2 = getInputCodeToUserString(inputCode); return part1 + part2 + part3; } diff --git a/BBGE/ActionSet.h b/BBGE/ActionSet.h index 3d9b9a4..6f6b98f 100644 --- a/BBGE/ActionSet.h +++ b/BBGE/ActionSet.h @@ -39,13 +39,12 @@ public: ActionInput *addActionInput(const std::string &name); - //void loadAction(const std::string &name, int inputCode, InputSetType set); - //void loadAction(const std::string &name, const std::vector &inputCodes, InputSetType set=INPUTSET_GENERAL); + ActionInput *getActionInputByName(const std::string &name); ActionInputSet inputSet; - + std::string insertInputIntoString(const std::string &string); }; diff --git a/BBGE/AfterEffect.cpp b/BBGE/AfterEffect.cpp index 6b6b92c..3eaef3f 100644 --- a/BBGE/AfterEffect.cpp +++ b/BBGE/AfterEffect.cpp @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "AfterEffect.h" -//#include "math.h" + #include @@ -76,7 +76,7 @@ AfterEffectManager::~AfterEffectManager() for (i = 0; i < xDivs; i++) { delete[] drawGrid[i]; - } + } delete[] drawGrid; } deleteEffects(); @@ -128,7 +128,7 @@ void AfterEffectManager::clear() void AfterEffectManager::update(float dt) { - if (core->particlesPaused) return; + if (core->particlesPaused) return; resetGrid(); @@ -138,7 +138,7 @@ void AfterEffectManager::update(float dt) active = false; for (int i = 0; i < effects.size(); i++) - { + { Effect *e = effects[i]; if (e) { @@ -177,7 +177,6 @@ void AfterEffectManager::render() { assert(core->frameBuffer.isInited()); -#ifdef BBGE_BUILD_OPENGL glPushMatrix(); glDisable (GL_ALPHA_TEST); @@ -189,14 +188,12 @@ void AfterEffectManager::render() glColor4f(1,1,1,1); renderGrid(); - //renderGridPoints(); + glPopMatrix(); -#endif } void AfterEffectManager::renderGrid() { -#ifdef BBGE_BUILD_OPENGL int firstShader = -1; int lastShader = -1; @@ -237,29 +234,29 @@ void AfterEffectManager::renderGrid() backupBuffer.startCapture(); } - //float div = xDivs; + for (int i = 0; i < (xDivs-1); i++) { for (int j = 0; j < (yDivs-1); j++) - { - glBegin(GL_QUADS); - //glColor3f(i/div, i/div, i/div); + { + glBegin(GL_QUADS); + glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0); + + glVertex2f(offx + vw*drawGrid[i][j].x, offy + vh*drawGrid[i][j].y); glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16); + + glVertex2f(offx + vw*drawGrid[i][j+1].x, offy + vh*drawGrid[i][j+1].y); - glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16); + glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); + + glVertex2f(offx + vw*drawGrid[i+1][j+1].x, offy + vh*drawGrid[i+1][j+1].y); - glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0); - glVertex2f(offx + vw*drawGrid[i+1][j].x, offy + vh*drawGrid[i+1][j].y); + glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); + + + glVertex2f(offx + vw*drawGrid[i+1][j].x, offy + vh*drawGrid[i+1][j].y); glEnd(); } } @@ -296,7 +293,7 @@ void AfterEffectManager::renderGrid() activeShader->bind(); activeShader->setInt("tex", 0); - + // note that offx, offy are negative here! glBegin(GL_QUADS); glTexCoord2d(0.0f, 0.0f); @@ -308,7 +305,7 @@ void AfterEffectManager::renderGrid() glTexCoord2d(0.0f, percentY); glVertex3f(offx, offy, 0.0f); glEnd(); - + activeShader->unbind(); } } @@ -322,8 +319,8 @@ void AfterEffectManager::renderGrid() for (int i = 0; i < (xDivs-1); i++) { for (int j = 0; j < (yDivs-1); j++) - { - glBegin(GL_POINTS); + { + glBegin(GL_POINTS); //glColor3f(i/div, i/div, i/div); glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); @@ -333,17 +330,17 @@ void AfterEffectManager::renderGrid() //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16); glVertex2f(800*drawGrid[i][j+1].x, 600*drawGrid[i][j+1].y); - glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16); + glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); + //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); + //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16); glVertex2f(800*drawGrid[i+1][j+1].x, 600*drawGrid[i+1][j+1].y); - glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0); - glVertex2f(800*drawGrid[i+1][j].x, 600*drawGrid[i+1][j].y); + glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); + //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); + //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0); + glVertex2f(800*drawGrid[i+1][j].x, 600*drawGrid[i+1][j].y); glEnd(); } - } + } */ //glDisable(GL_TEXTURE_2D); @@ -352,15 +349,13 @@ void AfterEffectManager::renderGrid() //bwShader.unbind(); //glActiveTextureARB(GL_TEXTURE0_ARB); - //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //if (bRenderGridPoints) // renderGridPoints(); -#endif } void AfterEffectManager::renderGridPoints() { -#ifdef BBGE_BUILD_OPENGL glColor4f(0.0f,0.0f,0.0f,1.0f); for (int i = 0; i < (xDivs); i++) { @@ -374,7 +369,6 @@ void AfterEffectManager::renderGridPoints() glEnd(); } } -#endif } void AfterEffectManager::unloadDevice() @@ -438,31 +432,15 @@ void AfterEffectManager::addEffect(Effect *e) effects.push_back(e); } numEffects++; - //float lowest = 9999; - Vector base(0,0,0); - //Vector *newPos = &base; - //Vector *v; - e->position.x /= screenWidth; - //e->position.x *= xDivs; - e->position.y /= screenHeight; - //e->position.y *= yDivs; - /* - for (int x = 1; x < xDivs-1; x++) - { - for (int y = 1; y < yDivs-1; y++) - { - v = &drawGrid[x][y]; - float dist = (v->x - e->position.x)*(v->x - e->position.x)+(v->y - e->position.y)*(v->y - e->position.y); - if (dist < lowest) - { - lowest = dist; - newPos = &drawGrid[x][y]; - } - } - } - e->position = Vector(newPos->x, newPos->y, newPos->z); - */ + Vector base(0,0,0); + + + e->position.x /= screenWidth; + + e->position.y /= screenHeight; + + } @@ -471,18 +449,13 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs) { dt *= timeMultiplier; Effect::update(dt, drawGrid, xDivs, yDivs); - //GLdouble sx, sy,sz; - /* - gluProject(position.x,position.y,position.z, - nCameraPointer->modelMatrix,nCameraPointer->projMatrix,nCameraPointer->viewport, - &sx,&sy,&sz); // Find out where the light is on the screen. - centerPoint.Set(sx/(float)nCameraPointer->viewport[2],1-sy/(float)nCameraPointer->viewport[3],sz); - */ + + centerPoint = position; centerPoint -= ((core->screenCenter-originalCenter)*core->globalScale.x)/core->width; - //centerPoint = position/xDivs; - //centerPoint = drawGrid[xDivs/2][yDivs/2]; + + float xDist,yDist,tDist; @@ -490,8 +463,7 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs) currentDistance+=dt*frequency; - //float distFromCamp =(core->cameraPos - position).getLength2D();//v3dDist(nCameraPointer->pos, position); - //if (distFromCamp < 4) + float distFromCamp = 4; float adjWaveLength = waveLength/distFromCamp; @@ -504,33 +476,21 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs) { for (int j = 1; j < (yDivs-1); j++) { - /* - Vector p = getNearestPointOnLine(centerPoint, centerPoint + Vector(-200, -200), Vector(drawGrid[i][j].x*core->width, drawGrid[i][j].y*core->height)); - - p.x /= core->width; - p.y /= core->height; - */ - + + xDist = (centerPoint.x - drawGrid[i][j].x)/.75; yDist = centerPoint.y - drawGrid[i][j].y; - - /* - xDist = (p.x - drawGrid[i][j].x)/.75; - yDist = p.y - drawGrid[i][j].y; - */ - //xDist = 1; - //yDist = 2; + + tDist = sqrtf(xDist*xDist+yDist*yDist); - //drawGrid[i][j].x += (rand()%100)/10000.0f; - //drawGrid[i][j].y += (rand()%100)/10000.0f; if (tDist < currentDistance*adjWaveLength) { - //drawGrid[i][j].x += rand()%50; - //drawGrid[i][j].y += rand()%50; + + drawGrid[i][j].x += adjAmplitude*sinf(-tDist/adjWaveLength+currentDistance)*.75f; drawGrid[i][j].y += adjAmplitude*cosf(-tDist/adjWaveLength+currentDistance); } @@ -546,20 +506,9 @@ RippleEffect::RippleEffect() : Effect() void RippleEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs) { - /* - // whole screen roll - time += dt; - float amp = 0.01; - for (int i = 0; i < (xDivs-1); i++) - { - for (int j = 0; j < (yDivs-1); j++) - { - float offset = +i/float(xDivs) +j/float(xDivs); - //drawGrid[i][j].x += sinf(time+offset)*amp; - drawGrid[i][j].y += cosf((time+offset)*2.5f)*amp; - } - } - */ + + + time += dt*0.5f; float amp = 0.002; for (int i = 0; i < (xDivs-1); i++) @@ -567,7 +516,7 @@ void RippleEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs) for (int j = 0; j < (yDivs-1); j++) { float offset = i/float(xDivs) + (core->screenCenter.x/float(core->width)/2) +j/float(xDivs) + (core->screenCenter.y/float(core->height)/2); - //drawGrid[i][j].x += sinf(time+offset)*amp; + drawGrid[i][j].x += sinf((time+offset)*7.5f)*(amp*0.5f); drawGrid[i][j].y += cosf((time+offset)*7.5f)*amp; } diff --git a/BBGE/AfterEffect.h b/BBGE/AfterEffect.h index 251635f..d28ec8a 100644 --- a/BBGE/AfterEffect.h +++ b/BBGE/AfterEffect.h @@ -51,7 +51,7 @@ public: this->timeMultiplier = timeMultiplier; } float timeMultiplier; - //void go(); + void update(float dt, Vector ** drawGrid, int xDivs, int yDivs); float waveLength; diff --git a/BBGE/Base.cpp b/BBGE/Base.cpp index 785e3fb..d8731be 100644 --- a/BBGE/Base.cpp +++ b/BBGE/Base.cpp @@ -160,7 +160,6 @@ unsigned hash(const std::string &string) return hash; } -/* hash * 33 + c */ static unsigned char lowerToUpperTable[256]; @@ -351,8 +350,7 @@ bool exists(const std::string &f, bool makeFatal, bool skipVFS) void drawCircle(float radius, int stepSize) { -#ifdef BBGE_BUILD_OPENGL - //glDisable(GL_CULL_FACE); + glBegin(GL_POLYGON); { @@ -363,8 +361,7 @@ void drawCircle(float radius, int stepSize) } glEnd(); - //glEnable(GL_CULL_FACE); -#endif + } void exit_error(const std::string &message) @@ -385,9 +382,7 @@ std::string parseCommand(const std::string &line, const std::string &command) void glColor3_256(int r, int g, int b) { -#ifdef BBGE_BUILD_OPENGL glColor4f(float(r)/256.0f, float(g)/256.0f, float(b)/256.0f, 1.0f); -#endif } bool chance(int perc) @@ -404,68 +399,7 @@ bool chancef(float p) return ((rand()%100) <= p*100); } -/* -PHYSFS_file *openRead(const std::string &f) -{ - PHYSFS_file *file = PHYSFS_openRead(f.c_str()); - if (!file) - { - errorLog ("Could not open [" + f + "]"); - exit(0); - } - - return file; -} - - -void pfread(void *buffer, PHYSFS_uint32 size, PHYSFS_uint32 objs, PHYSFS_file *handle) -{ - PHYSFS_read(handle, buffer, size, objs); -} - -void pfseek(PHYSFS_file *handle,PHYSFS_uint64 byte,int origin) -{ - if (origin == SEEK_CUR) - { - byte += PHYSFS_tell(handle); - } - PHYSFS_seek(handle,byte); -} - -void pfclose(PHYSFS_file *handle) -{ - PHYSFS_close(handle); -} - -std::string pLoadStream(const std::string &filename) -{ - PHYSFS_file *f = openRead(filename.c_str()); - int len = PHYSFS_fileLength(f); - std::string s; - for (int i = 0; i < len; i++) - { - char p; - PHYSFS_read(f, &p, sizeof(char), 1); - s += p; - } - //std::istringstream is(s); - - PHYSFS_close(f); - return s; - -} - - -void pSaveStream(const std::string &filename, std::ostringstream &os) -{ - PHYSFS_file *f = PHYSFS_openWrite(filename.c_str()); - //int size = os.str().size(); - //PHYSFS_write(f, (void*)size, sizeof(int), 1); - PHYSFS_write(f, (void*)os.str().c_str(), sizeof(char)*os.str().size(), 1); - PHYSFS_close(f); -} -*/ void errorLog(const std::string &s) { @@ -561,29 +495,7 @@ tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr / return doc; } -/* -void pForEachFile(std::string path, std::string type, void callback(const std::string &filename, int param), int param) -{ - char **rc = PHYSFS_enumerateFiles(path.c_str()); - char **i; - for (i = rc; *i != NULL; i++) - { - std::string s(*i); - int p=0; - if ((p=s.find('.'))!=std::string::npos) - { - std::string ext = s.susbtr(p, s.getLength2D()); - if (ext == type) - { - callback(fielnameafhghaha - } - } - } - - PHYSFS_freeList(rc); -} -*/ void doSingleFile(const std::string &path, const std::string &type, std::string filename, void callback(const std::string &filename, int param), int param) { @@ -592,9 +504,9 @@ void doSingleFile(const std::string &path, const std::string &type, std::string std::string search = filename; stringToLower(search); std::string filetype = filename.substr(search.size()-4, search.size()); - //stringToUpper(filetype); - //debugLog("comparing: " + filetype + " and: " + type); - //if (filetype==type) + + + debugLog("checking:" + search + " for type:" + type); if (search.find(type)!=std::string::npos) { @@ -725,9 +637,7 @@ void forEachFile(std::string path, std::string type, void callback(const std::st } - //std::string add = "%s*" + type; - //sprintf(szDir, "%s*", path.c_str()); sprintf(szDir, "%s\\*", path.c_str()); stringToUpper(type); @@ -736,7 +646,7 @@ void forEachFile(std::string path, std::string type, void callback(const std::st hList = FindFirstFile(szDir, &FileData); if (hList == INVALID_HANDLE_VALUE) { - //printf("No files found\n\n"); + debugLog("No files of type " + type + " found in path " + path); } else @@ -748,13 +658,13 @@ void forEachFile(std::string path, std::string type, void callback(const std::st // Check the object is a directory or not //printf("%*s%s\n", indent, "", FileData.cFileName); std::string filename = FileData.cFileName; - //debugLog("found: " + filename); + if (filename.size()>4) { std::string filetype = filename.substr(filename.size()-4, filename.size()); stringToUpper(filetype); - //debugLog("comparing: " + filetype + " and: " + type); + if (filetype==type) { callback(path+filename, param); @@ -764,12 +674,7 @@ void forEachFile(std::string path, std::string type, void callback(const std::st if (!FindNextFile(hList, &FileData)) { - /* - if (GetLastError() == ERROR_NO_MORE_FILES) - { - fFinished = TRUE; - } - */ + fFinished = TRUE; } } @@ -810,19 +715,14 @@ std::vector getFileList(std::string path, std::string type, int par std::string filename = FileData.cFileName; if (filename.size()>4 && filename.substr(filename.size()-4, filename.size())==type) { - //callback(path+filename, param); + list.push_back (filename); } if (!FindNextFile(hList, &FileData)) { - /* - if (GetLastError() == ERROR_NO_MORE_FILES) - { - fFinished = TRUE; - } - */ + fFinished = TRUE; } } @@ -883,18 +783,7 @@ Vector getNearestPointOnLine(Vector a, Vector b, Vector c) return nearest; } -/* -bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius) -{ - Vector p = getNearestPointOnLine(lineStart, lineEnd, point); - Vector diff = p - point; - std::ostringstream os; - os << "s(" << lineStart.x << ", " << lineStart.y << ") e("; - os << lineEnd.x << ", " << lineEnd.y << ") - p(" << point.x << ", " << point.y << ")"; - debugLog(os.str()); - return (diff.getSquaredLength2D() < sqr(radius)); -} -*/ + bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius, Vector *closestP) { @@ -930,14 +819,12 @@ GLuint generateEmptyTexture(int quality) // Create An Empty Texture memset(data, 0, size); // Clear Storage Memory -#ifdef BBGE_BUILD_OPENGL glGenTextures(1, &txtnumber); // Create 1 Texture glBindTexture(GL_TEXTURE_2D, txtnumber); // Bind The Texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, quality, quality, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); // Build Texture Using Information In data -#endif delete [] data; // Release data diff --git a/BBGE/Base.h b/BBGE/Base.h index 1f650e3..2a4a404 100644 --- a/BBGE/Base.h +++ b/BBGE/Base.h @@ -39,67 +39,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef BBGE_BUILD_WINDOWS - //#include "iprof/prof.h" - //#define BBGE_PROF(x) Prof(x) + #define BBGE_PROF(x) -/* - //#ifdef BBGE_BUILD_DIRECTX - #define DIRECTINPUT_VERSION 0x0800 - #include - //#endif -*/ + #else #define BBGE_PROF(x) #endif -#ifdef BBGE_BUILD_GLFW - #include - #include "glext.h" - //#include "glext.h" -#elif BBGE_BUILD_DIRECTX - #if defined(BBGE_BUILD_X360) && !defined(BBGE_BUILD_WINDOWS) - - #include - #include - - #endif // _XBOX - - #if defined(BBGE_BUILD_X360) && defined(BBGE_BUILD_WINDOWS) - // Using the win32\ path prefix on the D3D include files makes sure that the Xbox 360 - // version of D3D is used, not the DirectX SDK version. - #include - #include - #pragma warning(disable:4100) - - #include "XTLOnPC.h" - - #endif // _PC - - #if defined(BBGE_BUILD_X360) - #include - #include - #include - #include - #include - #endif -#endif - -#ifdef BBGE_BUILD_SDL #include "SDL.h" -#endif -#if defined(BBGE_BUILD_OPENGL) #define GL_GLEXT_LEGACY 1 #include "gl.h" #include "glext.h" -#endif #define compile_assert(pred) switch(0){case 0:case (pred):;} @@ -136,7 +94,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -//#include + #include "Rect.h" @@ -233,23 +191,9 @@ Direction getOppositeDir(Direction dir); Direction getNextDirClockwise(Direction dir); Vector colorRGB(int r, int g, int b); -#ifdef BBGE_BUILD_DIRECTX - typedef unsigned int GLuint; -#endif GLuint generateEmptyTexture(int res); -//void pForEachFile(std::string path, std::string type, void callback(const std::string &filename, int param), int param); -/* -void pfread(void *buffer, PHYSFS_uint32 size, PHYSFS_uint32 objs, PHYSFS_file *handle); -void pfseek(PHYSFS_file *handle,PHYSFS_uint64 byte,int origin); -void pfclose(PHYSFS_file *handle); - - -PHYSFS_file *openRead(const std::string &f); -std::string pLoadStream(const std::string &filename); -void pSaveStream(const std::string &filename, std::ostringstream &os); -*/ void drawCircle(float radius, int steps=1); bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord2); @@ -287,8 +231,7 @@ enum LerpType float lerp(const float &v1, const float &v2, float dt, int lerpType); -//int packFile(const std::string &sourcef, const std::string &destf, int level); -//int unpackFile(const std::string &sourcef, const std::string &destf); + void openURL(const std::string &url); diff --git a/BBGE/BitmapFont.cpp b/BBGE/BitmapFont.cpp index 51efc2b..4770dbe 100644 --- a/BBGE/BitmapFont.cpp +++ b/BBGE/BitmapFont.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "BitmapFont.h" #include "Core.h" -//#include "DSQ.h" + using namespace glfont; @@ -56,14 +56,12 @@ void BmpFont::load(const std::string &file, float scale, bool loadTexture) this->scale = scale; -#ifdef BBGE_BUILD_OPENGL GLuint id=0; glGenTextures(1, &id); if (!font.Create(file.c_str(), id, loadTexture)) return; -#endif loaded = true; } @@ -81,13 +79,13 @@ BitmapText::BitmapText(BmpFont *bmpFont) align = ALIGN_CENTER; textWidth = 600; this->fontDrawSize = 24; - //color = Vector(0.5,0.5,1); + cull = false; - //setTexture(font); + alignWidth = 0; - //fontTextureTest = core->addTexture("font"); + } void BitmapText::autoKern() @@ -164,8 +162,8 @@ void BitmapText::formatText() alignWidth = 0; maxW = 0; for (int i = 0; i < text.size(); i++) - { - //currentWidth += spacingMap[text[i]]*fontDrawSize; + { + float sz = bmpFont->font.GetCharWidth(text[i])*bmpFont->scale; currentWidth += sz; @@ -218,24 +216,7 @@ void BitmapText::updateWordColoring() } } - /* - for (int i = 0; i < lines.size(); i++) - { - int c = 0; - for (int t = 0; t < dsq->continuity.wordColoring.size(); t++) - { - WordColoring *w = &dsq->continuity.wordColoring[t]; - if ((c = lines[i].find(w->word)) != std::string::npos) - { - for (int j = c; j < c + w->word.size(); j++) - { - colorIndices[i][j] = w->color; - } - } - } - } - */ - //lines.push_back(text); + } @@ -316,15 +297,9 @@ void BitmapText::onRender() float top_color[3] = {bmpFont->fontTopColor.x*color.x, bmpFont->fontTopColor.y*color.y, bmpFont->fontTopColor.z*color.z}; float bottom_color[3] = {bmpFont->fontBtmColor.x*color.x, bmpFont->fontBtmColor.y*color.y, bmpFont->fontBtmColor.z*color.z}; -#ifdef BBGE_BUILD_OPENGL glEnable(GL_TEXTURE_2D); - /* - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - */ - //glDisable(GL_CULL_FACE); - //glScalef(1, -1, 0); + bmpFont->font.Begin(); @@ -353,11 +328,7 @@ void BitmapText::onRender() x = -sz.first*0.5f*bmpFont->scale; } float la = 1.0f-(scrollDelay/scrollSpeed); - /* - std::ostringstream os; - os << "la: " << la; - debugLog(os.str()); - */ + bmpFont->font.DrawString(theLine, bmpFont->scale, x, y, top_color, bottom_color, alpha.x, la); y += adj; @@ -378,11 +349,10 @@ void BitmapText::onRender() y += adj; } } - - //glEnable(GL_CULL_FACE); + + glBindTexture(GL_TEXTURE_2D, 0); -#endif } void BitmapText::unloadDevice() @@ -454,33 +424,4 @@ float BitmapText::getStringWidth(const std::string& text) return maxsize * bmpFont->scale; } -/* -BitmapText::BitmapText() : RenderObject() -{ - cull = false; - followCamera = 1; - scrollSpeed = 0.1f; -} -void BitmapText::scrollText(const std::string &text, float scrollSpeed) -{ - setText(text); - this->scrollSpeed = scrollSpeed; -} - -void BitmapText::setText(const std::string &text) -{ - this->text = text; -} - -std::string BitmapText::getText() -{ - return text; -} - -void BitmapText::onRender() -{ - CTextDrawer::GetSingleton().SetColor(color.x, color.y, color.z, alpha.getValue()); - dsq->print(position.x, 600 - (position.y + 16*2), text); -} -*/ diff --git a/BBGE/BitmapFont.h b/BBGE/BitmapFont.h index 5ba302f..e764320 100644 --- a/BBGE/BitmapFont.h +++ b/BBGE/BitmapFont.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef BITMAPFONT_H #define BITMAPFONT_H -//#include "DrawText.h" + #include "RenderObject.h" #include "BaseText.h" diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 8de7fff..d312772 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -44,7 +44,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif -#ifdef BBGE_BUILD_SDL #include "SDL_syswm.h" #ifdef BBGE_BUILD_SDL2 static SDL_Window *gScreen=0; @@ -55,7 +54,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. bool ignoreNextMouse=false; Vector unchange; -#endif #ifdef BBGE_BUILD_VFS #include "ttvfs.h" @@ -75,8 +73,8 @@ void Core::initIcon() { #ifdef BBGE_BUILD_WINDOWS HINSTANCE handle = ::GetModuleHandle(NULL); - //if (icon_windows) - // ::DestroyIcon(icon_windows); + + icon_windows = ::LoadIcon(handle, "icon"); @@ -84,8 +82,8 @@ void Core::initIcon() SDL_VERSION(&wminfo.version) if (SDL_GetWindowWMInfo(gScreen, &wminfo) != 1) { - //errorLog("wrong SDL version"); - // error: wrong SDL version + + } HWND hwnd = wminfo.info.win.window; @@ -171,7 +169,7 @@ void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp) shutdownGraphicsLibrary(); initGraphicsLibrary(w, h, fullscreen, vsync, bpp); - + enable2DWide(w, h); reloadResources(); @@ -183,46 +181,29 @@ void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp) void Core::toggleScreenMode(int t) { -#ifdef BBGE_BUILD_GLFW -/* - glfwCloseWindow(); - - createWindow(800,600,32,false,""); - initGraphicsLibrary(false, true); - enable2D(800); - //reloadResources(); - */ -#endif -#ifdef BBGE_BUILD_SDL sound->pause(); resetGraphics(-1, -1, t); cacheRender(); resetTimer(); sound->resume(); -#endif } void Core::updateCursorFromJoystick(float dt, int spd) { - //debugLog("updating mouse from joystick"); + core->mouse.position += joystick.position*dt*spd; -/* - if (!joystick.position.isZero()) - setMousePosition(core->mouse.position); - */ + doMouseConstraint(); } void Core::setWindowCaption(const std::string &caption, const std::string &icon) { -#ifdef BBGE_BUILD_SDL #ifndef BBGE_BUILD_SDL2 SDL_WM_SetCaption(caption.c_str(), icon.c_str()); #endif -#endif } RenderObjectLayer *Core::getRenderObjectLayer(int i) @@ -232,584 +213,40 @@ RenderObjectLayer *Core::getRenderObjectLayer(int i) return &renderObjectLayers[i]; } -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) - LPDIRECTINPUT8 g_pDI = NULL; // The DirectInput object - LPDIRECTINPUTDEVICE8 g_pKeyboard = NULL; // The keyboard device - LPDIRECTINPUTDEVICE8 g_pMouse = NULL; - - D3DCOLOR d3dColor =0xFFFFFFFF; -#endif - -#ifdef BBGE_BUILD_DIRECTX - - __int64 timerStart=0, timerEnd=0, timerFreq=0; - //Direct3D 9 interface - IDirect3D9* d3d = NULL; - //Capabilities of graphics adapter - D3DCAPS9 d3dCaps; - - //Direct3D present parameters - D3DPRESENT_PARAMETERS d3dPresent; - LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device - LPD3DXSPRITE d3dSprite = NULL; - LPD3DXMATRIXSTACK d3dMatrixStack = NULL; - IDirect3DVertexBuffer9* vertexBuffer = NULL; - IDirect3DVertexBuffer9* preTransVertexBuffer = NULL; - - //Custom vertex - struct TLVERTEX - { - float x; - float y; - float z; - //float rhw; - D3DCOLOR colour; - float u; - float v; - }; - const DWORD D3DFVF_TLVERTEX = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1; - struct PTLVERTEX - { - float x; - float y; - float z; - float rhw; - D3DCOLOR colour; - float u; - float v; - }; - - const DWORD D3DFVF_PTLVERTEX = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1; -#endif - - - - #ifdef BBGE_BUILD_DIRECTX - /* - LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; // Buffer to hold vertices - LPDIRECT3DTEXTURE9 g_pTexture = NULL; // Our texture - */ - // A structure for our custom vertex type - struct CUSTOMVERTEX - { - FLOAT x, y, z, rhw; // The transformed position for the vertex - DWORD color; // The vertex color - }; - - // Our custom FVF, which describes our custom vertex structure - #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE) - - LPD3DXMATRIXSTACK Core::getD3DMatrixStack() - { - return d3dMatrixStack; - } - - LPDIRECT3DDEVICE9 Core::getD3DDevice() - { - return g_pd3dDevice; - } - - LPD3DXSPRITE Core::getD3DSprite() - { - return d3dSprite; - } - - LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) - { - switch( msg ) - { - case WM_DESTROY: - //Cleanup(); - PostQuitMessage( 0 ); - return 0; - } - - return DefWindowProc( hWnd, msg, wParam, lParam ); -} - void Core::blitD3DVerts(IDirect3DTexture9 *texture, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y, float v4x, float v4y) - { - TLVERTEX* vertices; - - //Lock the vertex buffer - vertexBuffer->Lock(0, 0, (void**)&vertices, NULL); - - vertices[0].colour = d3dColor; - vertices[0].x = v1x; - vertices[0].y = v1y; - vertices[0].z = 1.0f; - vertices[0].u = 0.0f; - vertices[0].v = 1.0f-1.0f; - - vertices[1].colour = d3dColor; - vertices[1].x = v2x; - vertices[1].y = v2y; - vertices[1].z = 1.0f; - vertices[1].u = 1.0f; - vertices[1].v = 1.0f-1.0f; - - vertices[2].colour = d3dColor; - vertices[2].x = v3x; - vertices[2].y = v3y; - vertices[2].z = 1.0f; - vertices[2].u = 1.0f; - vertices[2].v = 1.0f-0.0f; - - vertices[3].colour = d3dColor; - vertices[3].x = v4x; - vertices[3].y = v4y; - vertices[3].z = 1.0f; - vertices[3].u = 0.0f; - vertices[3].v = 1.0f-0.0f; - //Unlock the vertex buffer - vertexBuffer->Unlock(); - - //Set texture - g_pd3dDevice->SetTexture (0, texture); - - //Draw image - g_pd3dDevice->DrawPrimitive (D3DPT_TRIANGLEFAN, 0, 2); - } - - void Core::blitD3DEx (IDirect3DTexture9 *texture, int w2, int h2, float u1, float v1, float u2, float v2) - { - TLVERTEX* vertices; - - /* - int w2=width/2; - int h2=height/2; - */ - //Lock the vertex buffer - vertexBuffer->Lock(0, 0, (void**)&vertices, NULL); - - //Setup vertices - //A -0.5f modifier is applied to vertex coordinates to match texture - //and screen coords. Some drivers may compensate for this - //automatically, but on others texture alignment errors are introduced - //More information on this can be found in the Direct3D 9 documentation - vertices[0].colour = d3dColor; - vertices[0].x = -0.5f*w2; - vertices[0].y = -0.5f*h2; - vertices[0].z = 1.0f; - //vertices[0].rhw = 1.0f; - vertices[0].u = u1; - vertices[0].v = 1.0f-v2; - - vertices[1].colour = d3dColor; - vertices[1].x = 0.5f*w2; - vertices[1].y = -0.5f*h2; - vertices[1].z = 1.0f; - //vertices[1].rhw = 1.0f; - vertices[1].u = u2; - vertices[1].v = 1.0f-v2; - - vertices[2].colour = d3dColor; - vertices[2].x = 0.5f*w2; - vertices[2].y = 0.5f*h2; - vertices[2].z = 1.0f; - //vertices[2].rhw = 1.0f; - vertices[2].u = u2; - vertices[2].v = 1.0f-v1; - - vertices[3].colour = d3dColor; - vertices[3].x = -0.5f*w2; - vertices[3].y = 0.5f*h2; - vertices[3].z = 1.0f; - //vertices[3].rhw = 1.0f; - vertices[3].u = u1; - vertices[3].v = 1.0f-v1; - //Unlock the vertex buffer - vertexBuffer->Unlock(); - - //Set texture - g_pd3dDevice->SetTexture (0, texture); - - //Draw image - g_pd3dDevice->DrawPrimitive (D3DPT_TRIANGLEFAN, 0, 2); - } - - void Core::blitD3DGradient(D3DCOLOR ulc0, D3DCOLOR ulc1, D3DCOLOR ulc2, D3DCOLOR ulc3) - { - TLVERTEX* vertices; - - //Lock the vertex buffer - vertexBuffer->Lock(0, 0, (void**)&vertices, NULL); - vertices[0].colour = ulc0; - vertices[0].x = -0.5f; - vertices[0].y = -0.5f; - vertices[0].z = 1.0f; - //vertices[0].rhw = 1.0f; - vertices[0].u = 0.0f; - vertices[0].v = 1.0f-1.0f; - - vertices[1].colour = ulc1; - vertices[1].x = 0.5f; - vertices[1].y = -0.5f; - vertices[1].z = 1.0f; - //vertices[1].rhw = 1.0f; - vertices[1].u = 1.0f; - vertices[1].v = 1.0f-1.0f; - - vertices[2].colour = ulc2; - vertices[2].x = 0.5f; - vertices[2].y = 0.5f; - vertices[2].z = 1.0f; - //vertices[2].rhw = 1.0f; - vertices[2].u = 1.0f; - vertices[2].v = 1.0f-0.0f; - - vertices[3].colour = ulc3; - vertices[3].x = -0.5f; - vertices[3].y = 0.5f; - vertices[3].z = 1.0f; - //vertices[3].rhw = 1.0f; - vertices[3].u = 0.0f; - vertices[3].v = 1.0f-0.0f; - //Unlock the vertex buffer - vertexBuffer->Unlock(); - - //Set texture - //g_pd3dDevice->SetTexture (0, texture); - g_pd3dDevice->SetTexture (0, 0); - - //Draw image - g_pd3dDevice->DrawPrimitive (D3DPT_TRIANGLEFAN, 0, 2); - } - - void Core::blitD3DPreTrans(IDirect3DTexture9 *texture, float x, float y, int w2, int h2) - { - /* - PTLVERTEX* vertices; - //Lock the vertex buffer - preTransVertexBuffer->Lock(0, 0, (void**)&vertices, NULL); - */ - TLVERTEX* vertices; - //Lock the vertex buffer - vertexBuffer->Lock(0, 0, (void**)&vertices, NULL); - - - //Setup vertices - //A -0.5f modifier is applied to vertex coordinates to match texture - //and screen coords. Some drivers may compensate for this - //automatically, but on others texture alignment errors are introduced - //More information on this can be found in the Direct3D 9 documentation - vertices[0].colour = d3dColor; - vertices[0].x = x-0.5f*w2; - vertices[0].y = y-0.5f*h2; - vertices[0].z = 1.0f; - //vertices[0].rhw = 1.0f; - vertices[0].u = 0.0f; - vertices[0].v = 1.0f-1.0f; - - vertices[1].colour = d3dColor; - vertices[1].x = x+0.5f*w2; - vertices[1].y = y-0.5f*h2; - vertices[1].z = 1.0f; - //vertices[1].rhw = 1.0f; - vertices[1].u = 1.0f; - vertices[1].v = 1.0f-1.0f; - - vertices[2].colour = d3dColor; - vertices[2].x = x+0.5f*w2; - vertices[2].y = y+0.5f*h2; - vertices[2].z = 1.0f; - //vertices[2].rhw = 1.0f; - vertices[2].u = 1.0f; - vertices[2].v = 1.0f-0.0f; - - vertices[3].colour = d3dColor; - vertices[3].x = x-0.5f*w2; - vertices[3].y = y+0.5f*h2; - vertices[3].z = 1.0f; - //vertices[3].rhw = 1.0f; - vertices[3].u = 0.0f; - vertices[3].v = 1.0f-0.0f; - /* - //Unlock the vertex buffer - preTransVertexBuffer->Unlock(); - */ - vertexBuffer->Unlock(); - - - //Set texture - g_pd3dDevice->SetTexture (0, texture); - - //Draw image - g_pd3dDevice->DrawPrimitive (D3DPT_TRIANGLEFAN, 0, 2); - } - void Core::blitD3D (IDirect3DTexture9 *texture, int w2, int h2) - { - TLVERTEX* vertices; - //D3DCOLOR d3dColor = 0xFFFFFFFF; - - /* - int w2=width/2; - int h2=height/2; - */ - //Lock the vertex buffer - vertexBuffer->Lock(0, 0, (void**)&vertices, NULL); - - //Setup verticeserr - //A -0.5f modifier is applied to vertex coordinates to match texture - //and screen coords. Some drivers may compensate for this - //automatically, but on others texture alignment ors are introduced - //More information on this can be found in the Direct3D 9 documentation - vertices[0].colour = d3dColor; - vertices[0].x = -0.5f*w2; - vertices[0].y = -0.5f*h2; - vertices[0].z = 1.0f; - //vertices[0].rhw = 1.0f; - vertices[0].u = 0.0f; - vertices[0].v = 1.0f-1.0f; - - vertices[1].colour = d3dColor; - vertices[1].x = 0.5f*w2; - vertices[1].y = -0.5f*h2; - vertices[1].z = 1.0f; - //vertices[1].rhw = 1.0f; - vertices[1].u = 1.0f; - vertices[1].v = 1.0f-1.0f; - - vertices[2].colour = d3dColor; - vertices[2].x = 0.5f*w2; - vertices[2].y = 0.5f*h2; - vertices[2].z = 1.0f; - //vertices[2].rhw = 1.0f; - vertices[2].u = 1.0f; - vertices[2].v = 1.0f-0.0f; - - vertices[3].colour = d3dColor; - vertices[3].x = -0.5f*w2; - vertices[3].y = 0.5f*h2; - vertices[3].z = 1.0f; - //vertices[3].rhw = 1.0f; - vertices[3].u = 0.0f; - vertices[3].v = 1.0f-0.0f; - //Unlock the vertex buffer - vertexBuffer->Unlock(); - - //Set texture - g_pd3dDevice->SetTexture (0, texture); - - //Draw image - g_pd3dDevice->DrawPrimitive (D3DPT_TRIANGLEFAN, 0, 2); - } - - HRESULT InitD3D( HWND hWnd, bool fullscreen, int vsync) - { - // Create the D3D object. - HRESULT hr; - - //Make Direct3D object - d3d = Direct3DCreate9(D3D_SDK_VERSION); - - //Make sure NULL pointer was not returned - if (!d3d) - return FALSE; - - //Get device capabilities - ZeroMemory (&d3dCaps, sizeof(d3dCaps)); - if (FAILED(d3d->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps))) - return FALSE; - - //Setup present parameters - ZeroMemory(&d3dPresent,sizeof(d3dPresent)); - d3dPresent.hDeviceWindow = hWnd; - - //Check if windowed - if (!fullscreen) - { - D3DDISPLAYMODE d3ddm; - RECT rWindow; - - //Get display mode - d3d->GetAdapterDisplayMode (D3DADAPTER_DEFAULT, &d3ddm); - - //Get window bounds - GetClientRect (hWnd, &rWindow); - - //Setup screen dimensions - core->width = rWindow.right - rWindow.left; - core->height = rWindow.bottom - rWindow.top; - - //Setup backbuffer - d3dPresent.Windowed = true; - d3dPresent.BackBufferWidth = rWindow.right - rWindow.left; - d3dPresent.BackBufferHeight = rWindow.bottom - rWindow.top; - } - else - { - d3dPresent.Windowed = false; - d3dPresent.BackBufferWidth = core->width; - d3dPresent.BackBufferHeight = core->height; - } - d3dPresent.BackBufferFormat = D3DFMT_A8R8G8B8; - d3dPresent.BackBufferCount = 1; - d3dPresent.SwapEffect = D3DSWAPEFFECT_DISCARD; - - if (vsync>0) - d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - else - d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - - //Check if hardware vertex processing is available - if (d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) - { - debugLog("hardware T&L!"); - //Create device with hardware vertex processing - hr = d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL, hWnd, - D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dPresent, &g_pd3dDevice); - } - else - { - debugLog("no hardware T&L."); - //Create device with software vertex processing - hr = d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL, hWnd, - D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dPresent, &g_pd3dDevice); - } - - //Make sure device was created - if (FAILED(hr)) - { - errorLog ("directx init failed"); - return false; - } - - g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); - g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - // Turn off culling - g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - /* - D3DCULL_NONE = 1, - D3DCULL_CW = 2, - D3DCULL_CCW = 3, - */ - // Turn off D3D lighting - g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); - // Turn on the zbuffer - g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE); - - D3DXCreateSprite(core->getD3DDevice(), &d3dSprite); - D3DXCreateMatrixStack(0, &d3dMatrixStack); - - //Set vertex shader - g_pd3dDevice->SetVertexShader(NULL); - g_pd3dDevice->SetFVF(D3DFVF_TLVERTEX); - - //Create vertex buffer - g_pd3dDevice->CreateVertexBuffer(sizeof(TLVERTEX) * 4, NULL, D3DFVF_TLVERTEX, D3DPOOL_MANAGED, &vertexBuffer, NULL); - g_pd3dDevice->SetStreamSource(0, vertexBuffer, 0, sizeof(TLVERTEX)); - - /* - g_pd3dDevice->CreateVertexBuffer(sizeof(PTLVERTEX) * 4, NULL, D3DFVF_TLVERTEX, D3DPOOL_MANAGED, &preTransVertexBuffer, NULL); - g_pd3dDevice->SetStreamSource(0, preTransVertexBuffer, 0, sizeof(PTLVERTEX)); - */ - - g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); - - g_pd3dDevice->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1); - g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); - g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); - g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); - - return S_OK; - } -#endif void Core::setColor(float r, float g, float b, float a) { -#ifdef BBGE_BUILD_OPENGL glColor4f(r, g, b, a); -#endif -#ifdef BBGE_BUILD_DIRECTX - d3dColor = D3DCOLOR_RGBA(int(r*255), int(g*255), int(b*255), int(a*255)); -#endif } void Core::bindTexture(int stage, unsigned int handle) { -#ifdef BBGE_BUILD_DIRECTX - getD3DDevice()->SetTexture(stage, (IDirect3DBaseTexture9*)handle); -#endif -#ifdef BBGE_BUILD_OPENGL - //glBindTexture(GL_TEXTURE_2D, handle); -#endif + } void Core::translateMatrixStack(float x, float y, float z) { -#ifdef BBGE_BUILD_OPENGL glTranslatef(x, y, z); -#endif -#ifdef BBGE_BUILD_DIRECTX - /* - D3DXMATRIX matTranslation; - D3DXMatrixTranslation (&matTranslation, x, y, 0); - */ - /* - float usex, usey; - usex = x - (float)core->getWindowWidth() / 2; - usey = -y + (float)core->getWindowHeight() / 2; - */ - //core->getD3DMatrixStack()->MultMatrixLocal(&matTranslation); - core->getD3DMatrixStack()->TranslateLocal(x, y, z); -#endif } void Core::scaleMatrixStack(float x, float y, float z) { -#ifdef BBGE_BUILD_OPENGL glScalef(x, y, z); -#endif -#ifdef BBGE_BUILD_DIRECTX - if (x != 1 || y != 1) - core->getD3DMatrixStack()->ScaleLocal(x, y, 1); -#endif } void Core::rotateMatrixStack(float x, float y, float z) { -#ifdef BBGE_BUILD_OPENGL glRotatef(0, 0, 1, z); -#endif -#ifdef BBGE_BUILD_DIRECTX - if (z != 0) - { - D3DXVECTOR3 axis(0,0,1); - core->getD3DMatrixStack()->RotateAxisLocal(&axis,D3DXToRadian(z)); - } -#endif } void Core::applyMatrixStackToWorld() { -#ifdef BBGE_BUILD_DIRECTX - g_pd3dDevice->SetTransform(D3DTS_WORLD, core->getD3DMatrixStack()->GetTop()); -#endif } void Core::rotateMatrixStack(float z) { -#ifdef BBGE_BUILD_OPENGL glRotatef(0, 0, 1, z); -#endif -#ifdef BBGE_BUILD_DIRECTX - //core->getD3DMatrixStack()->RotateAxis(0, 0, z); - /* - D3DXVECTOR3 axis(0,0,1); - float angle = D3DXToRadian(z); - if (angle == D3DX_PI) - angle += 0.001f; - core->getD3DMatrixStack()->RotateAxisLocal(&axis,angle); - */ - if (z != 0) - { - D3DXMATRIX mat; - D3DXMatrixRotationZ(&mat,D3DXToRadian(z)); - core->getD3DMatrixStack()->MultMatrixLocal(&mat); - } -#endif } bool Core::getShiftState() @@ -900,7 +337,7 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n if (userDataSubFolder.empty()) userDataSubFolder = appName; - + #if defined(BBGE_BUILD_UNIX) const char *envr = getenv("HOME"); if (envr == NULL) @@ -965,7 +402,7 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n debugLogActive = true; debugLogTextures = true; - + grabInputOnReentry = -1; srand(time(NULL)); @@ -981,15 +418,10 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n viewOffX = viewOffY = 0; - /* - aspectX = 1440; //4.0f; - aspectY = 900; //3.0f; - */ + particleManager = new ParticleManager(particleSize); -#ifdef BBGE_BUILD_SDL nowTicks = thenTicks = 0; -#endif _hasFocus = false; lib_graphics = lib_sound = lib_input = false; clearColor = Vector(0,0,0); @@ -1038,8 +470,8 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n keys[i] = 0; } - aspect = (aspectX/aspectY);//320.0f/240.0f; - //1.3333334f; + aspect = (aspectX/aspectY); + globalResolutionScale = globalScale = Vector(1,1,1); @@ -1053,7 +485,7 @@ void Core::initPlatform(const std::string &filesystem) #if defined(BBGE_BUILD_MACOSX) && !defined(BBGE_BUILD_MACOSX_NOBUNDLEPATH) // FIXME: filesystem not handled CFBundleRef mainBundle = CFBundleGetMainBundle(); - //CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); + CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) @@ -1236,13 +668,11 @@ void Core::setInputGrab(bool on) { if (isWindowFocus()) { -#ifdef BBGE_BUILD_SDL #ifdef BBGE_BUILD_SDL2 SDL_SetWindowGrab(gScreen, on ? SDL_TRUE : SDL_FALSE); #else SDL_WM_GrabInput(on?SDL_GRAB_ON:SDL_GRAB_OFF); #endif -#endif } } @@ -1273,11 +703,6 @@ void Core::init() setupFileAccess(); quitNestedMainFlag = false; -#ifdef BBGE_BUILD_GLFW - if (!glfwInit()) - exit(0); -#endif -#ifdef BBGE_BUILD_SDL #ifndef BBGE_BUILD_SDL2 // Disable relative mouse motion at the edges of the screen, which breaks // mouse control for absolute input devices like Wacom tablets and touchscreens. @@ -1288,14 +713,8 @@ void Core::init() { exit_error("Failed to init SDL"); } - -#endif - /* -#ifdef BBGE_BUILD_DIRECTX - if (!glfwInit()) - exit(0); -#endif - */ + + loopDone = false; clearedGarbageFlag = false; @@ -1303,7 +722,7 @@ void Core::init() initLocalization(); - //glfwSetWindowSizeCallback(lockWindowSize); + } void Core::initRenderObjectLayers(int num) @@ -1336,7 +755,6 @@ Vector Core::getGamePosition(const Vector &v) bool Core::getMouseButtonState(int m) { -#ifdef BBGE_BUILD_SDL int mcode=m; switch(m) @@ -1349,23 +767,17 @@ bool Core::getMouseButtonState(int m) Uint8 mousestate = SDL_GetMouseState(0,0); return mousestate & SDL_BUTTON(mcode); -#endif return false; } bool Core::getKeyState(int k) { -#ifdef BBGE_BUILD_GLFW - return glfwGetKey(k)==GLFW_PRESS; -#endif -#ifdef BBGE_BUILD_SDL if (k >= KEY_MAXARRAY || k < 0) { return 0; } return keys[k]; -#endif #ifdef BBGE_BUILD_WINDOWS if (k >= KEY_MAXARRAY || k < 0) @@ -1378,225 +790,44 @@ bool Core::getKeyState(int k) return 0; } -//#ifdef BBGE_BUILD_DIRECTX -//float sensitivity = 1.0; Vector joychange; Vector lastjoy; void readJoystickData() { - /* - if (core->joystickEnabled && core->numJoysticks > 0) - { - //DIJOYSTATE2 js; - core->joysticks[0]->poll(&core->joystate); - Vector joy = Vector(core->joystate.lX, core->joystate.lY); - joychange = joy-lastjoy; - lastjoy = joy; - core->joystickPosition = Vector(core->joystate.lX - (65536/2), core->joystate.lY - (65536/2)); - core->joystickPosition /= (65536/2); - // HACK: super hacky!! - core->mouse.buttons.left = (core->joystate.rgbButtons[0] & 0x80) ? Buttons::DOWN : Buttons::UP; - core->mouse.buttons.right = (core->joystate.rgbButtons[1] & 0x80) ? Buttons::DOWN : Buttons::UP; - } - */ + } void readMouseData() { -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) - if (!core->updateMouse) return; - HRESULT hr; - DIMOUSESTATE2 dims2; // DirectInput Mouse state structure - if( NULL == g_pMouse ) - return; - - // Get the input's device state, and put the state in dims - ZeroMemory( &dims2, sizeof(dims2) ); - hr = g_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &dims2 ); - if( FAILED(hr) ) - { - // DirectInput may be telling us that the input stream has been - // interrupted. We aren't tracking any state between polls, so - // we don't have any special reset that needs to be done. - // We just re-acquire and try again. - - // If input is lost then acquire and keep trying - hr = g_pMouse->Acquire(); - while( hr == DIERR_INPUTLOST ) - hr = g_pMouse->Acquire(); - - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This - // may occur when the app is minimized or in the process of - // switching, so just try again later - return; - } - - //float sensitivity = float(core->width) / float(core->getVirtualWidth()); - float sensitivity = 1; - core->mouse.position.x += dims2.lX*sensitivity; - core->mouse.position.y += dims2.lY*sensitivity; - core->mouse.position.z += dims2.lZ; - core->mouse.change.x = dims2.lX*sensitivity; - core->mouse.change.y = dims2.lY*sensitivity; - core->mouse.change.z = dims2.lZ; - core->mouse.scrollWheelChange = dims2.lZ; - if (!core->flipMouseButtons) - { - core->mouse.buttons.left = (dims2.rgbButtons[0] & 0x80) ? DOWN : UP; - core->mouse.buttons.right = (dims2.rgbButtons[1] & 0x80) ? DOWN : UP; - } - else - { - core->mouse.buttons.left = (dims2.rgbButtons[1] & 0x80) ? DOWN : UP; - core->mouse.buttons.right = (dims2.rgbButtons[0] & 0x80) ? DOWN : UP; - } - core->mouse.buttons.middle = (dims2.rgbButtons[2] & 0x80) ? DOWN : UP; - -#elif defined(BBGE_BUILD_SDL) - //core->mouse.position += dMouse; -#elif defined(BBGE_BUILD_GLFW) - //HACK: may not always want 800x600 virtual - /* - static int lastx=400, lasty=300; - int x, y; - glfwGetMousePos(&x,&y); - int mickeyx,mickeyy; - mickeyx = x - lastx; - mickeyy = y - lasty; - lastx = x; - lasty = y; - core->mouse.position.x += mickeyx; - core->mouse.position.y += mickeyy; - */ - - int x,y; - glfwGetMousePos(&x,&y); - core->mouse.position = Vector(x, y); - - -/* - int mid_x = core->width / 2; - int mid_y = core->height / 2; - int dx=0,dy=0; - int x,y; - glfwGetMousePos(&x, &y); - // Don't do anything if mouse hasn't moved - if (x == mid_x && y == mid_y) - { - } - else - { - dx = x - mid_x; - dy = y - mid_y; - } - - std::ostringstream os; - os << "d(" << dx << ", " << dy <<")"; - debugLog(os.str()); - - core->mouse.position += Vector(dx, dy); - - - // Now move the mouse back to the middle, because - // we don't care where it really is, just how much - // it moves. - glfwSetMousePos(mid_x, mid_y); - */ - - - - core->mouse.buttons.left = glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT) ? DOWN : UP; - core->mouse.buttons.right = glfwGetMouseButton(GLFW_MOUSE_BUTTON_RIGHT) ? DOWN : UP; - core->mouse.buttons.middle = glfwGetMouseButton(GLFW_MOUSE_BUTTON_MIDDLE) ? DOWN : UP; - core->mouse.scrollWheel = glfwGetMouseWheel(); -#endif } void readKeyData() { -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) - if( NULL == g_pKeyboard ) - return; - HRESULT hr; - BYTE diks[256]; - // Get the input's device state, and put the state in dims - ZeroMemory( diks, sizeof(diks) ); - hr = g_pKeyboard->GetDeviceState( sizeof(diks), diks ); - if( FAILED(hr) ) - { - // DirectInput may be telling us that the input stream has been - // interrupted. We aren't tracking any state between polls, so - // we don't have any special reset that needs to be done. - // We just re-acquire and try again. - - // If input is lost then acquire and keep trying - hr = g_pKeyboard->Acquire(); - while( hr == DIERR_INPUTLOST ) - hr = g_pKeyboard->Acquire(); - - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This - // may occur when the app is minimized or in the process of - // switching, so just try again later - return; - } - - // Make a string of the index values of the keys that are down - for(int i = 0; i < 256; i++ ) - { - core->keys[i] = ( diks[i] & 0x80 ); - } -#endif } -//#endif + bool Core::initJoystickLibrary(int numSticks) { - //joystickEnabled = false; -#ifdef BBGE_BUILD_SDL + #ifdef BBGE_BUILD_SDL2 SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER); #else SDL_InitSubSystem(SDL_INIT_JOYSTICK); -#endif #endif if (numSticks > 0) joystick.init(0); joystickEnabled = true; - /* - numJoysticks = Joystick::deviceCount(); - std::ostringstream os; - os << "Found " << numJoysticks << " joysticks"; - debugLog(os.str()); - if (numJoysticks > 0) - { - if (numJoysticks > 4) - numJoysticks = 4; - // HACK: memory leak... add code to clean this up! - for (int i = 0; i < numJoysticks; i++) { - joysticks[i] = new Joystick(i); - joysticks[i]->open(); - // Print the name of the joystick. - char name[MAX_PATH]; - joysticks[i]->deviceName(name); - std::ostringstream os; - os << " Joystick " << i << ": " << name; - debugLog(os.str()); - } - joystickEnabled = true; - return true; - } - */ return true; } @@ -1605,127 +836,13 @@ bool Core::initInputLibrary() { core->mouse.position = Vector(getWindowWidth()/2, getWindowHeight()/2); -#ifdef BBGE_BUILD_GFLW - glfwDisable(GLFW_MOUSE_CURSOR); - //glfwEnable( GLFW_SYSTEM_KEYS ); -#endif for (int i = 0; i < KEY_MAXARRAY; i++) { keys[i] = 0; } -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) - - HRESULT hr; - BOOL bExclusive = true; - BOOL bForeground = true; - //BOOL bImmediate = true; - BOOL bDisableWindowsKey = false; - DWORD dwCoopFlags; - - if( bExclusive ) - dwCoopFlags = DISCL_EXCLUSIVE; - else - dwCoopFlags = DISCL_NONEXCLUSIVE; - - if( bForeground ) - dwCoopFlags |= DISCL_FOREGROUND; - else - dwCoopFlags |= DISCL_BACKGROUND; - - // Disabling the windows key is only allowed only if we are in foreground nonexclusive - if( bDisableWindowsKey && !bExclusive && bForeground ) - dwCoopFlags |= DISCL_NOWINKEY; - - // Create a DInput object - if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, - IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) ) - return false; - - // Obtain an interface to the system keyboard device. - if( FAILED( hr = g_pDI->CreateDevice( GUID_SysKeyboard, &g_pKeyboard, NULL ) ) ) - return false; - - // Set the data format to "Keyboard format" - a predefined data format - // - // A data format specifies which controls on a device we - // are interested in, and how they should be reported. - // - // This tells DirectInput that we will be passing an array - // of 256 bytes to IDirectInputDevice::GetDeviceState. - if( FAILED( hr = g_pKeyboard->SetDataFormat( &c_dfDIKeyboard ) ) ) - return false; - - // Set the cooperativity level to let DirectInput know how - // this device should interact with the system and with other - // DirectInput applications. - hr = g_pKeyboard->SetCooperativeLevel( this->hWnd, dwCoopFlags ); - if( hr == DIERR_UNSUPPORTED && !bForeground && bExclusive ) - { - debugLog("could not set cooperative level"); - //FreeDirectInput(); - //errorLog ("failed to init input"); - /* - MessageBox( hDlg, _T("SetCooperativeLevel() returned DIERR_UNSUPPORTED.\n") - _T("For security reasons, background exclusive Keyboard\n") - _T("access is not allowed."), _T("Keyboard"), MB_OK ); - */ - //return false;; - } - - /* - if( FAILED(hr) ) - { - errorLog("failed to init input"); - return false; - } - */ - - - // Acquire the newly created device - g_pKeyboard->Acquire(); - - -//#ifdef BBGE_BUILD_DIRECTX - - if( FAILED( hr = g_pDI->CreateDevice( GUID_SysMouse, &g_pMouse, NULL ) ) ) - return false; - - // Set the data format to "Mouse format" - a predefined data format - // - // A data format specifies which controls on a device we - // are interested in, and how they should be reported. - // - // This tells DirectInput that we will be passing a - // DIMOUSESTATE2 structure to IDirectInputDevice::GetDeviceState. - if( FAILED( hr = g_pMouse->SetDataFormat( &c_dfDIMouse2 ) ) ) - return false; - - // Set the cooperativity level to let DirectInput know how - // this device should interact with the system and with other - // DirectInput applications. - hr = g_pMouse->SetCooperativeLevel( this->hWnd, dwCoopFlags ); - if( hr == DIERR_UNSUPPORTED && !bForeground && bExclusive ) - { - //FreeDirectInput(); - //errorLog ("mouse failed"); - debugLog("could not set cooperative level"); - //return false; - } - - /* - if( FAILED(hr) ) - return false; - */ - - // Acquire the newly created device - g_pMouse->Acquire(); - -#endif - // joystick init -//#endif return true; } @@ -1747,60 +864,9 @@ void Core::onUpdate(float dt) - - - - /* - std::ostringstream os; - os << "x: " << joystate.lX << " y: " << joystate.lY; - os << " frx: " << joystate.lFRx << " fry: " << joystate.lFRy; - debugLog(os.str()); - */ - - /* - if (joystickOverrideMouse && !joychange.isZero()) - { - Vector joy(joystate.lX, joystate.lY); - //core->mouse.position += joychange * 0.001f; - core->mouse.position = Vector(400,300) + ((joy * 600) / (65536/2))-300; - } - */ - - - /* - - */ - - - /* - if (mouse.position.x < 0) - mouse.position.x = 0; - if (mouse.position.x > core->getVirtualWidth()) - mouse.position.x = core->getVirtualWidth(); - if (mouse.position.y < 0) - mouse.position.y = 0; - if (mouse.position.y > core->getVirtualHeight()) - mouse.position.y = core->getVirtualHeight(); - */ - onMouseInput(); - /* -#ifdef BBGE_BUILD_GLFW - glfwSetMousePos(mouse.position.x, mouse.position.y); -#endif - */ -#ifdef BBGE_BUILD_DIRECTX -#endif - //core->mouse.change = core->mouse.position - core->mouse.lastPosition; - //core->mouse.scrollWheelChange = core->mouse.scrollWheel - core->mouse.lastScrollWheel; - - - - - - //script.update(dt); globalScale.update(dt); core->globalScaleChanged(); @@ -1839,13 +905,8 @@ void Core::setClearColor(const Vector &c) { clearColor = c; -#ifdef BBGE_BUILD_OPENGL glClearColor(c.x, c.y, c.z, 0.0); -#endif -#ifdef BBGE_BUILD_DIRECTX - -#endif } void Core::setSDLGLAttributes() @@ -1854,13 +915,11 @@ void Core::setSDLGLAttributes() os << "setting vsync: " << _vsync; debugLog(os.str()); -#ifdef BBGE_BUILD_SDL #ifndef BBGE_BUILD_SDL2 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, _vsync); #endif SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); -#endif } @@ -1911,15 +970,15 @@ static bool lookup_all_glsyms(void) bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync, int bpp, bool recreate) -{ +{ static bool didOnce = false; - + aspectX = width; aspectY = height; aspect = (aspectX/aspectY); - + this->width = width; this->height = height; @@ -1929,10 +988,7 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync _hasFocus = false; -#if defined(BBGE_BUILD_SDL) - //setenv("SDL_VIDEO_CENTERED", "1", 1); - //SDL_putenv("SDL_VIDEO_WINDOW_POS=400,300"); #ifndef BBGE_BUILD_SDL2 #if !defined(BBGE_BUILD_MACOSX) @@ -1942,7 +998,7 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync SDL_putenv((char *) "SDL_VIDEO_CENTERED=1"); #endif #endif - //SDL_putenv((char *) "LIBGL_DEBUG=verbose"); // temp, to track errors on linux with nouveau drivers. + if (recreate) { @@ -1968,7 +1024,7 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync setSDLGLAttributes(); - //if (!didOnce) + { #ifdef BBGE_BUILD_SDL2 Uint32 flags = 0; @@ -2053,57 +1109,23 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync keys[i] = 0; } -/* -#ifdef BBGE_BUILD_WINDOWS - SDL_SysWMinfo wmInfo; - SDL_GetWMInfo(&wmInfo); - hWnd = wmInfo.window; -#endif -*/ -#endif -#if defined(BBGE_BUILD_OPENGL) glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background glClearDepth(1.0); // Depth Buffer Setup glDisable(GL_CULL_FACE); - - //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + glLoadIdentity(); - + glFinish(); -#ifdef BBGE_BUILD_GLFW - glfwSwapInterval(vsync); -#endif -#endif - - - -#if defined(BBGE_BUILD_DIRECTX) - - // Initialize Direct3D - if( SUCCEEDED( InitD3D( this->hWnd, fullscreen, vsync ) ) ) - { - // Show the window - ShowWindow( this->hWnd, SW_SHOWDEFAULT ); - UpdateWindow( this->hWnd ); - //initPipeline(PT_NORMAL); - } - else - { - errorLog("Could not init D3D"); - exit(-1); - } - -#endif setClearColor(clearColor); - + clearBuffers(); showBuffer(); @@ -2124,7 +1146,6 @@ void Core::enumerateScreenModes() { screenModes.clear(); -#ifdef BBGE_BUILD_SDL #ifdef BBGE_BUILD_SDL2 SDL_DisplayMode mode; const int modecount = SDL_GetNumDisplayModes(0); @@ -2132,7 +1153,7 @@ void Core::enumerateScreenModes() debugLog("No modes available!"); return; } - + for (int i = 0; i < modecount; i++) { SDL_GetDisplayMode(0, i, &mode); if (mode.w && mode.h && (mode.w > mode.h)) @@ -2169,7 +1190,6 @@ void Core::enumerateScreenModes() } } #endif -#endif } void Core::shutdownSoundLibrary() @@ -2178,7 +1198,6 @@ void Core::shutdownSoundLibrary() void Core::shutdownGraphicsLibrary(bool killVideo) { -#ifdef BBGE_BUILD_SDL glFinish(); if (killVideo) { #ifdef BBGE_BUILD_SDL2 @@ -2206,7 +1225,6 @@ void Core::shutdownGraphicsLibrary(bool killVideo) #undef GL_FUNC #endif } -#endif _hasFocus = false; @@ -2225,8 +1243,8 @@ void Core::shutdownGraphicsLibrary(bool killVideo) void Core::quit() { enqueueJumpState("STATE_QUIT"); - //loopDone = true; - //popAllStates(); + + } void Core::applyState(const std::string &state) @@ -2238,21 +1256,6 @@ void Core::applyState(const std::string &state) StateManager::applyState(state); } -#ifdef BBGE_BUILD_GLFW -void GLFWCALL windowResize(int w, int h) -{ - // this gets called on minimize + restore? - if (w == 0 && h == 0) - { - core->minimized = true; - return; - } - else - core->minimized = false; - if (w != core->width || h != core->height) - glfwSetWindowSize(core->width,core->height); -} -#endif #ifdef BBGE_BUILD_WINDOWS @@ -2274,22 +1277,11 @@ void centerWindow(HWND hwnd) y -= (rcWnd.bottom - rcWnd.top)/2; // Set top and left to center main window on desktop ::SetWindowPos(hwnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE); -// ::ShowWindow(hwnd, 1); + } #endif -/* -void Core::adjustWindowPosition(int x, int y) -{ -#ifdef BBGE_BUILD_WINDOWS - RECT rcWnd; - ::GetWindowRect(hWnd, &rcWnd); - rcWnd.left += x; - rcWnd.top += y; - ::SetWindowPos(hWnd, HWND_TOP, rcWnd.left, rcWnd.top, 0, 0, SWP_NOSIZE); -#endif -} -*/ + bool Core::createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle) { @@ -2297,89 +1289,9 @@ bool Core::createWindow(int width, int height, int bits, bool fullscreen, std::s this->height = height; redBits = greenBits = blueBits = alphaBits = 0; -#ifdef BBGE_BUILD_SDL return true; -#endif - -#ifdef BBGE_BUILD_GLFW - int redbits, greenbits, bluebits, alphabits; - redbits = greenbits = bluebits = 8; - alphabits = 0; - switch(bits) - { - case 16: - redbits = 5; - greenbits = 6; - bluebits = 5; - break; - case 24: - redbits = 8; - bluebits = 8; - greenbits = 8; - alphabits = 0; - break; - case 32: - redbits = 8; - greenbits = 8; - bluebits = 8; - alphabits = 8; - break; - case 8: - redbits = 2; - greenbits = 2; - bluebits = 2; - break; - } - if (glfwOpenWindow(width, height, redbits, greenbits, bluebits, 0, 0, 0, fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW) == GL_TRUE) - { - glfwSetWindowTitle(windowTitle.c_str()); - resize(width,height); -#ifdef BBGE_BUILD_WINDOWS - this->hWnd = (HWND)glfwGetWindowHandle(); - - if (!fullscreen) centerWindow(hWnd); -#endif - - glfwSetWindowSizeCallback(windowResize); - - redBits = glfwGetWindowParam(GLFW_RED_BITS); - blueBits = glfwGetWindowParam(GLFW_BLUE_BITS); - greenBits = glfwGetWindowParam(GLFW_GREEN_BITS); - alphaBits = glfwGetWindowParam(GLFW_ALPHA_BITS); - - if (redBits < 8 && (bits == 32 || bits == 24)) - { - int sayBits = 32; - std::ostringstream os; - os << "(" << width << ", " << height << ") " << sayBits << "-bit mode could not be enabled. Please try setting your desktop to " << sayBits << "-bit color depth"; - if (!fullscreen) - os << ", or try running in fullscreen."; - else - os << "."; - os << " This resolution may not be supported on your machine."; - errorLog(os.str()); - exit(0); return false; - } - return true; - } - else - return false; -#endif - -#ifdef BBGE_BUILD_DIRECTX - // Register the window class - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, - GetModuleHandle(NULL), NULL, NULL, NULL, NULL, - windowTitle.c_str(), NULL }; - RegisterClassEx( &wc ); - - this->hWnd = CreateWindow( windowTitle.c_str(), windowTitle.c_str(), - WS_OVERLAPPEDWINDOW, 100, 100, width, height+10, - GetDesktopWindow(), NULL, wc.hInstance, NULL ); - return true; -#endif } // No longer part of C/C++ standard @@ -2418,19 +1330,15 @@ bbgePerspective(float fovy, float aspect, float zNear, float zFar) void Core::setPixelScale(int pixelScaleX, int pixelScaleY) { - /* - piScaleX = pixelScaleX; - piScaleY = pixelScaleY; - */ + virtualWidth = pixelScaleX; - //MAX(virtualWidth, 800); - virtualHeight = pixelScaleY;//int((pixelScale*aspectY)/aspectX); //assumes 4:3 aspect ratio + virtualHeight = pixelScaleY; //assumes 4:3 aspect ratio this->baseCullRadius = 1.1f * sqrtf(sqr(getVirtualWidth()/2) + sqr(getVirtualHeight()/2)); std::ostringstream os; os << "virtual(" << virtualWidth << ", " << virtualHeight << ")"; debugLog(os.str()); - + vw2 = virtualWidth/2; vh2 = virtualHeight/2; @@ -2464,13 +1372,13 @@ void Core::enable2DWide(int rx, int ry) if (aspect >= 1.3f) { int vw = int(float(baseVirtualHeight) * (float(rx)/float(ry))); - //vw = MAX(vw, baseVirtualWidth); + core->enable2D(vw, baseVirtualHeight, 1); } else { int vh = int(float(baseVirtualWidth) * (float(ry)/float(rx))); - //vh = MAX(vh, baseVirtualHeight); + core->enable2D(baseVirtualWidth, vh, 1); } } @@ -2482,34 +1390,14 @@ static void bbgeOrtho2D(float left, float right, float bottom, float top) void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale) { - // why do this again? don't really get it - /* - if (mode == MODE_2D) - { - if (forcePixelScale || (pixelScaleX!=0 && core->width!=pixelScaleX) || (pixelScaleY!=0 && core->height!=pixelScaleY)) - { - float widthFactor = core->width/float(pixelScaleX); - float heightFactor = core->height/float(pixelScaleY); - core->globalResolutionScale = Vector(widthFactor,heightFactor,1.0f); - setPixelScale(pixelScaleX, pixelScaleY); - std::ostringstream os; - os << "top of call: "; - os << "widthFactor: " << widthFactor; - os << "heightFactor: " << heightFactor; - debugLog(os.str()); - } - return; - } - */ - -#ifdef BBGE_BUILD_OPENGL + GLint viewPort[4]; glGetIntegerv(GL_VIEWPORT, viewPort); glMatrixMode(GL_PROJECTION); - //glPushMatrix(); + glLoadIdentity(); float vw=0,vh=0; @@ -2533,168 +1421,34 @@ void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale) - /* - vh = float(baseVirtualHeight * viewPort[2]) / float(baseVirtualWidth); - - viewOffY = (viewPort[3] - vh) * 0.5f; - */ - - - /* - std::ostringstream os; - os << "vw: " << vw << " OFFX: " << viewOffX << " "; - os << "vh: " << vh << " OFFY: " << viewOffY; - debugLog(os.str()); - */ - - - /* - float aspect = float(width) / float (height); - - if (aspect < 1.3f) - { - viewOffX *= 0.5f; - } - */ - - -//#else -// int offx=0,offy=0; -//#endif - - //+offx - //-offx - //glOrtho(0.0f,viewPort[2],viewPort[3],0.0f,-1000.0f,1000.0f); - //glOrtho(0.0f+offx,viewPort[2]+offx,viewPort[3]+offy,0.0f+offy,-1.0f,1.0f); bbgeOrtho2D(0.0f-viewOffX,viewPort[2]-viewOffX,viewPort[3]-viewOffY,0.0f-viewOffY); - /* - static bool doOnce = false; - if (!doOnce) - { - glOrtho(0.0f,viewPort[2],viewPort[3],0.0f,-10.0f,10.0f); - doOnce = true; - } - */ - //glOrtho(-viewPort[2]/2,viewPort[2]/2,viewPort[3]/2,-viewPort[3]/2,-10.0f,10.0f); - //glOrtho(0, viewPort[2], 0, viewPort[3], -100, 100); + + glMatrixMode(GL_MODELVIEW); - //glPushMatrix(); + glLoadIdentity(); setupRenderPositionAndScale(); -#endif -#ifdef BBGE_BUILD_DIRECTX - D3DXMATRIX matOrtho; - D3DXMATRIX matIdentity; - - //Setup orthographic projection matrix - - D3DXMatrixOrthoOffCenterLH(&matOrtho, 0, getWindowWidth(), getWindowHeight(), 0, 1, 10); - //D3DXMatrixOrthoLH (&matOrtho, getWindowWidth(), getWindowHeight(), 1.0f, 10.0f); - D3DXMatrixIdentity (&matIdentity); - g_pd3dDevice->SetTransform (D3DTS_PROJECTION, &matOrtho); - g_pd3dDevice->SetTransform (D3DTS_WORLD, &matIdentity); - g_pd3dDevice->SetTransform (D3DTS_VIEW, &matIdentity); - // For our world matrix, we will just leave it as the identity - /* - D3DXMATRIXA16 matWorld; - D3DXMatrixIdentity( &matWorld ); - //D3DXMatrixRotationX( &matWorld, 0/1000.0f ); - g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); - - // Set up our view matrix. A view matrix can be defined given an eye point, - // a point to lookat, and a direction for which way is up. Here, we set the - // eye five units back along the z-axis and up three units, look at the - // origin, and define "up" to be in the y-direction. - D3DXVECTOR3 vEyePt( 0.0f, 0.0f,0.0f ); - D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f ); - D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); - D3DXMATRIXA16 matView; - D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); - g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); - - // For the projection matrix, we set up a perspective transform (which - // transforms geometry from 3D view space to 2D viewport space, with - // a perspective divide making objects smaller in the distance). To build - // a perpsective transform, we need the field of view (1/4 pi is common), - // the aspect ratio, and the near and far clipping planes (which define at - // what distances geometry should be no longer be rendered). - ///LPDIRECT3DVIEWPORT3 Viewport; - - D3DVIEWPORT9 viewport; - viewport.Width = core->getWindowWidth(); - viewport.Height = core->getWindowHeight(); - viewport.MaxZ = 5; - viewport.MinZ = -5; - viewport.X = 0; - viewport.Y = 0; - - g_pd3dDevice->SetViewport( &viewport ); - - D3DXMATRIXA16 matProj; - D3DXMatrixOrthoLH(&matProj, 800, 600, -5, 5); - g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); - */ - - // Create the viewport - /* - if (FAILED(g_pd3dDevice->CreateViewport(&Viewport,NULL))) - { errorLog("Failed to create a viewport"); }; - if (FAILED(g_pd3dDevice->AddViewport(Viewport))) - { errorLog("Failed to add a viewport"); }; - if (FAILED(g_pd3dDevice->SetViewport2(&Viewdata))) - { errorLog("Failed to set Viewport data"); }; - g_pd3dDevice->SetCurrentViewport(Viewport); - */ - - /* - D3DXMATRIXA16 matProj; - D3DXMatrixOrthoLH(&matProj, 4, 3, -5, 5); - g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); - */ - - /* - D3DVIEWPORT9 viewport; - g_pd3dDevice->GetViewport(&viewport); - D3DXMATRIX matProj; - D3DXMatrixOrthoLH(&matProj, viewport.Width, viewport.Height, -10, 10); - g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); - */ - - -#endif if (forcePixelScale || (pixelScaleX!=0 && core->width!=pixelScaleX) || (pixelScaleY!=0 && core->height!=pixelScaleY)) { - /* - float f = core->width/float(pixelScale); - core->globalResolutionScale = Vector(f,f,1.0f); - */ - //debugLog("HEEEREEE"); + + float widthFactor = core->width/float(pixelScaleX); float heightFactor = core->height/float(pixelScaleY); - //float heightFactor = + core->globalResolutionScale = Vector(widthFactor,heightFactor,1.0f); setPixelScale(pixelScaleX, pixelScaleY); - //core->globalResolutionScale = Vector(1.5,1.5,1); - /* - std::ostringstream os; - os << "bottom of call: "; - os << "widthFactor: " << widthFactor; - os << " heightFactor: " << heightFactor; - debugLog(os.str()); - */ + + } setPixelScale(pixelScaleX, pixelScaleY); - //core->globalResolutionScale.x = 1.6; - //setupRenderPositionAndScale(); - } void Core::quitNestedMain() @@ -2707,16 +1461,7 @@ void Core::quitNestedMain() void Core::resetTimer() { -#ifdef BBGE_BUILD_GLFW - glfwSetTime(0); -#endif -#ifdef BBGE_BUILD_SDL nowTicks = thenTicks = SDL_GetTicks(); -#endif -#ifdef BBGE_BUILD_DIRECTX - QueryPerformanceCounter((LARGE_INTEGER*)&timerEnd); - timerStart = timerEnd; -#endif for (int i = 0; i < avgFPS.size(); i++) { @@ -2733,12 +1478,8 @@ void Core::setMousePosition(const Vector &p) Vector lp = core->mouse.position; core->mouse.position = p; -#if !defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_GLFW) - glfwSetMousePos(p.x,p.y); -#endif -#ifdef BBGE_BUILD_SDL float px = p.x + virtualOffX; - float py = p.y;// + virtualOffY; + float py = p.y; #ifdef BBGE_BUILD_SDL2 SDL_WarpMouseInWindow(gScreen, px * (float(width)/float(virtualWidth)), py * (float(height)/float(virtualHeight))); @@ -2746,17 +1487,8 @@ void Core::setMousePosition(const Vector &p) SDL_WarpMouse( px * (float(width)/float(virtualWidth)), py * (float(height)/float(virtualHeight))); #endif - /* - ignoreNextMouse = true; - unchange = core->mouse.position - lp; - */ -#endif - /* - std::ostringstream os; - os << "setting position (" << p.x << ", " << p.y << ")"; - debugLog(os.str()); - */ + } // used to update all render objects either uniformly or as part of a time sliced update process @@ -2806,9 +1538,7 @@ std::string getScreenshotFilename() unsigned Core::getTicks() { -#ifdef BBGE_BUILD_SDL return SDL_GetTicks(); -#endif return 0; } @@ -2829,21 +1559,17 @@ float Core::stopWatch(int d) bool Core::isWindowFocus() { -#ifdef BBGE_BUILD_SDL #ifdef BBGE_BUILD_SDL2 return ((SDL_GetWindowFlags(gScreen) & SDL_WINDOW_INPUT_FOCUS) != 0); #else return ((SDL_GetAppState() & SDL_APPINPUTFOCUS) != 0); #endif -#endif return true; } void Core::onBackgroundUpdate() { -#if BBGE_BUILD_SDL SDL_Delay(200); -#endif } void Core::main(float runTime) @@ -2853,117 +1579,46 @@ void Core::main(float runTime) // cannot nest loops when the game is over if (loopDone) return; - //QueryPerformanceCounter((LARGE_INTEGER*)&lastTime); - //QueryPerformanceFrequency((LARGE_INTEGER*)&freq); + + float dt; float counter = 0; int frames = 0; float real_dt = 0; - //std::ofstream out("debug.log"); + #if (!defined(_DEBUG) || defined(BBGE_BUILD_UNIX)) && defined(BBGE_BUILD_SDL) bool wasInactive = false; #endif -#ifdef BBGE_BUILD_GLFW - if (runTime == -1) - glfwSetTime(0); -#endif -#ifdef BBGE_BUILD_DIRECTX - // HACK: find out how to use performance counter again Query - - if (verbose) debugLog("Performance Counter"); - - if (!QueryPerformanceFrequency((LARGE_INTEGER*)&freq)) - { - errorLog ("could not get clock freq"); - return; - } - QueryPerformanceCounter((LARGE_INTEGER*)&timerStart); - /* - DWORD ticks = GetTickCount(); - DWORD newTicks; - */ -#endif - -#ifdef BBGE_BUILD_SDL nowTicks = thenTicks = SDL_GetTicks(); -#endif - //int i; + nestedMains++; - // HACK: Why block this? - /* - if (nestedMains > 1 && runTime <= 0) - return; - */ -#ifdef BBGE_BUILD_DIRECTX - MSG msg; - ZeroMemory( &msg, sizeof(msg) ); -#endif - while((runTime == -1 && !loopDone) || (runTime >0)) // Loop That Runs While done=FALSE + + while((runTime == -1 && !loopDone) || (runTime >0)) { BBGE_PROF(Core_main); -#ifdef BBGE_BUILD_DIRECTX - if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } -#endif -#ifdef BBGE_BUILD_GLFW - if (verbose) debugLog("glfwSetTime"); - dt = glfwGetTime(); - glfwSetTime(0); -#endif -#ifdef BBGE_BUILD_DIRECTX - /* - newTicks = GetTickCount(); - */ - QueryPerformanceCounter((LARGE_INTEGER*)&timerEnd); - dt = (float(timerEnd-timerStart)/float(freq)); - timerStart = timerEnd; -// dt = float(newTicks)/1000.0f; - //dt = float(newTicks - ticks)/1000.0f; - //ticks = newTicks; -#endif - -#ifdef BBGE_BUILD_SDL if (timeUpdateType == TIMEUPDATE_DYNAMIC) { nowTicks = SDL_GetTicks(); } - /* - else - { - if (nowTicks == 0) - { - nowTicks = SDL_GetTicks(); - } - } - */ + dt = (nowTicks-thenTicks)/1000.0; thenTicks = nowTicks; - //thenTicks = SDL_GetTicks(); -#endif + if (verbose) debugLog("avgFPS"); if (!avgFPS.empty()) { - /* - if (avgFPS[0] <= 0) - { - for (int i = 0; i < avgFPS.size(); i++) - avgFPS[i] = dt; - } - */ + int i = 0; for (i = avgFPS.size()-1; i > 0; i--) { @@ -2981,16 +1636,12 @@ void Core::main(float runTime) n ++; } } - if (n > 0) // && n == avgFPS.size() ?? + if (n > 0) { c /= n; dt = c; } - /* - std::ostringstream os; - os << dt; - debugLog(os.str()); - */ + } #if !defined(_DEBUG) && defined(BBGE_BUILD_SDL) @@ -3004,7 +1655,7 @@ void Core::main(float runTime) if (wasInactive) { debugLog("WINDOW ACTIVE"); - + setReentryInputGrab(1); wasInactive = false; @@ -3029,7 +1680,7 @@ void Core::main(float runTime) while (!isWindowFocus()) { pollEvents(); - //debugLog("app not in input focus"); + onBackgroundUpdate(); resetTimer(); @@ -3052,7 +1703,7 @@ void Core::main(float runTime) sound->resume(); resetTimer(); - + SDL_ShowCursor(SDL_DISABLE); continue; @@ -3163,7 +1814,7 @@ void Core::main(float runTime) saveScreenshotTGA(getScreenshotFilename()); prepScreen(0); } - + // wait if (timeUpdateType == TIMEUPDATE_FIXED) { @@ -3174,34 +1825,28 @@ void Core::main(float runTime) avg_diff_count++; avg_diff += diff; - + char buf[256]; sprintf(buf, "real_dt: %5.4f \n realFPS: %5.4f \n fixedFPS: %5.4f \n diff: %5.4f \n delay: %5.4f \n avgdiff: %5.8f", float(real_dt), float(real_dt>0?(1.0f/real_dt):0.0f), float(fixedFPS), float(diff), float(diff*1000), float(avg_diff/(float)avg_diff_count)); fpsDebugString = buf; - /* - std::ostringstream os; - os << "real_dt: " << real_dt << "\n realFPS: " << (1.0/real_dt) << "\n fixedFPS: " << fixedFPS << "\n diff: " << diff << "\n delay: " << diff*1000; - fpsDebugString = os.str(); - */ -#ifdef BBGE_BUILD_SDL + nowTicks = SDL_GetTicks(); - + if (diff > 0) { - //Sleep(diff*1000); - //SDL_Delay(diff*1000); + + while ((SDL_GetTicks() - nowTicks) < (diff*1000)) { - //wend, bitch + } } - //nowTicks = SDL_GetTicks(); -#endif - } + + } } if (verbose) debugLog("bottom of function"); quitNestedMainFlag = false; @@ -3231,33 +1876,8 @@ void Core::sortLayer(int layer) void Core::sort() { - /* - if (sortEnabled) - renderObjects.sort(RenderObject_lt); - */ - // sort layeres independantly - /* - for (int i = renderObjects.size()-1; i >= 0; i--) - { - bool flipped = false; - for (int j = 0; j < i; j++) - { - //position.z - //position.z - //!renderObjects[j]->parent && !renderObjects[j+1]->parent && - if (renderObjects[j]->getSortDepth() > renderObjects[j+1]->getSortDepth()) - { - RenderObject *temp; - temp = renderObjects[j]; - renderObjects[j] = renderObjects[j+1]; - renderObjects[j+1] = temp; - flipped = true; - } - } - if (!flipped) break; - } - */ + } @@ -3268,10 +1888,8 @@ void Core::clearBuffers() void Core::setupRenderPositionAndScale() { -#ifdef BBGE_BUILD_OPENGL glScalef(globalScale.x*globalResolutionScale.x*screenCapScale.x, globalScale.y*globalResolutionScale.y*screenCapScale.y, globalScale.z*globalResolutionScale.z); glTranslatef(-(cameraPos.x+cameraOffset.x), -(cameraPos.y+cameraOffset.y), -(cameraPos.z+cameraOffset.z)); -#endif } void Core::setupGlobalResolutionScale() @@ -3286,12 +1904,7 @@ void Core::initFrameBuffer() void Core::setMouseConstraint(bool on) { -/* - if (mouseConstraint && !on) - { - setMousePosition(mouse.position); - } - */ + mouseConstraint = on; } @@ -3303,15 +1916,7 @@ void Core::setMouseConstraintCircle(const Vector& pos, float circle) mouseConstraintCenter.z = 0; } -/* -void Core::clearKeys() -{ - for (int i = 0; i < KEY_MAXARRAY; i++) - { - keys[i] = 0; - } -} -*/ + int Core::getVirtualOffX() { @@ -3332,22 +1937,21 @@ bool Core::doMouseConstraint() { if (mouseConstraint) { - //- core->getVirtualOffX() - //- virtualOffX + + Vector h = mouseConstraintCenter; Vector d = mouse.position - h; if (!d.isLength2DIn(mouseCircle)) { d.setLength2D(mouseCircle); mouse.position = h+d; - //warpMouse = true; + return true; } } return false; } -#if defined(BBGE_BUILD_SDL) #if defined(BBGE_BUILD_SDL2) typedef std::map sdlKeyMap; @@ -3398,8 +2002,8 @@ static sdlKeyMap *initSDLKeymap(void) SETKEYMAP(KEY_BACKSPACE, SDLK_BACKSPACE); - //SETKEYMAP(KEY_CAPSLOCK, DIK_CAPSLOCK); - //SETKEYMAP(KEY_CIRCUMFLEX, DIK_CIRCUMFLEX); + + SETKEYMAP(KEY_LALT, SDLK_LALT); SETKEYMAP(KEY_RALT, SDLK_RALT); SETKEYMAP(KEY_LSHIFT, SDLK_LSHIFT); @@ -3418,7 +2022,7 @@ static sdlKeyMap *initSDLKeymap(void) SETKEYMAP(KEY_SEMICOLON, SDLK_SEMICOLON); SETKEYMAP(KEY_LBRACKET, SDLK_LEFTBRACKET); SETKEYMAP(KEY_RBRACKET, SDLK_RIGHTBRACKET); - //SETKEYMAP(KEY_RALT, GLFW_SETKEYMAP(KEY_RALT); + SETKEYMAP(KEY_TILDE, SDLK_BACKQUOTE); SETKEYMAP(KEY_0, SDLK_0); SETKEYMAP(KEY_1, SDLK_1); @@ -3492,8 +2096,8 @@ static sdlKeyMap *initSDLKeymap(void) SETKEYMAP(KEY_F15, SDLK_F15); SETKEYMAP(KEY_ESCAPE, SDLK_ESCAPE); - //SETKEYMAP(KEY_ANYKEY, 4059); - //SETKEYMAP(KEY_MAXARRAY, SDLK_LAST+1 + + #undef SETKEYMAP @@ -3512,21 +2116,13 @@ static int mapSDLKeyToGameKey(const SDLKey val) return (*keymap)[val]; } -#endif void Core::pollEvents() { -#if defined(BBGE_BUILD_SDL) bool warpMouse=false; - /* - Uint8 *keystate = SDL_GetKeyState(NULL); - for (int i = 0; i < KEY_MAXARRAY; i++) - { - keys[i] = keystate[i]; - } - */ + if (updateMouse) { @@ -3557,11 +2153,9 @@ void Core::pollEvents() - - SDL_Event event; - + while ( SDL_PollEvent (&event) ) { switch (event.type) { @@ -3583,7 +2177,7 @@ void Core::pollEvents() if ((event.key.keysym.sym == SDLK_g) && (event.key.keysym.mod & KMOD_CTRL)) { - // toggle mouse grab with the magic hotkey. + grabInputOnReentry = (grabInputOnReentry)?0:-1; setReentryInputGrab(1); } @@ -3626,8 +2220,8 @@ void Core::pollEvents() { SDL_Quit(); _exit(0); - //loopDone = true; - //quit(); + + } } break; @@ -3682,26 +2276,13 @@ void Core::pollEvents() case SDL_QUIT: SDL_Quit(); _exit(0); - //loopDone = true; - //quit(); + + break; case SDL_SYSWMEVENT: { - /* - debugLog("SYSWM!"); - if (event.syswm.type == WM_ACTIVATE) - { - debugLog("ACTIVE"); - this->unloadDevice(); - this->reloadDevice(); - } - else - { - debugLog("NOT ACTIVE"); - this->unloadDevice(); - } - */ + } break; @@ -3720,26 +2301,20 @@ void Core::pollEvents() } } -#endif } #define _VLN(x, y, x2, y2) glVertex2f(x, y); glVertex2f(x2, y2); void Core::print(int x, int y, const char *str, float sz) { - //Prof(Core_print); - /* - glLoadIdentity(); - core->setupRenderPositionAndScale(); - */ - ///glPushAttrib(GL_ALL_ATTRIB_BITS); -#ifdef BBGE_BUILD_OPENGL + + glBindTexture(GL_TEXTURE_2D, 0); glPushMatrix(); - //sz *= 8; - //float osz = sz; + + float xx = x; float yy = y; glTranslatef(x, y-0.5f*sz, 0); @@ -3748,13 +2323,7 @@ void Core::print(int x, int y, const char *str, float sz) bool isLower = false, wasLower = false; int c=0; - /* - if (a == 1) - glDisable(GL_BLEND); - else - glEnable(GL_BLEND); - glColor4f(r,g,b,a); - */ + glLineWidth(1); glScalef(sz*0.75f, sz, 1); @@ -3767,15 +2336,7 @@ void Core::print(int x, int y, const char *str, float sz) else isLower = false; - /* - if (isLower) - glScalef(sz*0.5f, sz*0.5f, 1); - else if (wasLower) - { - glScalef(sz, sz, 1); - wasLower = false; - } - */ + switch(toupper(str[c])) { @@ -4024,11 +2585,7 @@ void Core::print(int x, int y, const char *str, float sz) _VLN(xx, y+1, xx+1, y); break; default: - /* - std::ostringstream os; - os << "Core::print doesn't know char: " << str[c]; - debugLog(os.str()); - */ + break; } if (isLower) @@ -4042,9 +2599,8 @@ void Core::print(int x, int y, const char *str, float sz) glEnd(); glPopMatrix(); - //glPopAttrib(); -#endif + } void Core::cacheRender() @@ -4067,7 +2623,7 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail) { BBGE_PROF(Core_render); - //HWND hwnd = _glfwWin.Wnd; + if (startLayer == -1 && endLayer == -1 && overrideStartLayer != 0) { @@ -4091,7 +2647,6 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail) totalRenderObjectCount = 0; -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, 0); glLoadIdentity(); // Reset The View clearBuffers(); @@ -4102,42 +2657,13 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail) } setupRenderPositionAndScale(); -#endif - -#ifdef BBGE_BUILD_DIRECTX - bool doRender = false; - - core->getD3DMatrixStack()->LoadIdentity(); - core->scaleMatrixStack(globalScale.x*globalResolutionScale.x, globalScale.y*globalResolutionScale.y); - core->translateMatrixStack(-(cameraPos.x+cameraOffset.x), -(cameraPos.y+cameraOffset.y)); - clearBuffers(); - if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) - { - doRender = true; - //d3dSprite->Begin(D3DXSPRITE_BILLBOARD | D3DXSPRITE_ALPHABLEND); - } - -#endif - - - /* - //default - if (renderObjectLayerOrder.empty()) - { - renderObjectLayerOrder.resize(renderObjectLayers.size()); - for (int i = 0; i < renderObjectLayerOrder.size(); i++) - { - renderObjectLayerOrder[i] = i; - } - } - */ RenderObject::rlayer = 0; for (int c = 0; c < renderObjectLayerOrder.size(); c++) - //for (int i = 0; i < renderObjectLayers.size(); i++) + { int i = renderObjectLayerOrder[c]; if (i == -1) continue; @@ -4154,12 +2680,7 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail) if (darkLayer.isUsed() ) { - /* - if (i == darkLayer.getLayer()) - { - darkLayer.preRender(); - } - */ + if (i == darkLayer.getRenderLayer()) { darkLayer.render(); @@ -4194,15 +2715,6 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail) } } -#ifdef BBGE_BUILD_DIRECTX - if (doRender) - { - // End the scene - //d3dSprite->End(); - //core->getD3DMatrixStack()->Pop(); - g_pd3dDevice->EndScene(); - } -#endif } @@ -4211,19 +2723,11 @@ void Core::showBuffer() BBGE_PROF(Core_showBuffer); #ifdef BBGE_BUILD_SDL2 SDL_GL_SwapWindow(gScreen); -#elif BBGE_BUILD_SDL +#else SDL_GL_SwapBuffers(); - //glFlush(); + #endif -#ifdef BBGE_BUILD_GLFW - glfwSwapBuffers(); - //_glfwPlatSwapBuffers(); -#endif -#ifdef BBGE_BUILD_DIRECTX - // Present the backbuffer contents to the display - g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); -#endif } // WARNING: only for use during shutdown @@ -4242,23 +2746,13 @@ void Core::clearResources() void Core::shutdownInputLibrary() { -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) - g_pKeyboard->Unacquire(); - g_pKeyboard->Release(); - g_pKeyboard = 0; - g_pMouse->Unacquire(); - g_pMouse->Release(); - g_pMouse = 0; -#endif } void Core::shutdownJoystickLibrary() { if (joystickEnabled) { joystick.shutdown(); -#ifdef BBGE_BUIDL_SDL SDL_QuitSubSystem(SDL_INIT_JOYSTICK); -#endif joystickEnabled = false; } } @@ -4267,11 +2761,7 @@ void Core::clearRenderObjects() { for (int i = 0; i < renderObjectLayers.size(); i++) { - /* - for (int j = 0; j < renderObjectLayers[i].renderObjects.size(); j++) - { - RenderObject *r = renderObjectLayers[i].renderObjects[j]; - */ + RenderObject *r = renderObjectLayers[i].getFirst(); while (r) { @@ -4349,13 +2839,6 @@ void Core::shutdown() -#ifdef BBGE_BUILD_GLFW - debugLog("Terminate GLFW..."); - //killGlWindow(); - glfwTerminate(); - debugLog("OK"); -#endif - #ifdef BBGE_BUILD_VFS debugLog("Unload VFS..."); vfs.Clear(); @@ -4363,22 +2846,18 @@ void Core::shutdown() #endif -#ifdef BBGE_BUILD_SDL debugLog("SDL Quit..."); SDL_Quit(); debugLog("OK"); -#endif } //util funcs void Core::instantQuit() { -#ifdef BBGE_BUILD_SDL SDL_Event event; event.type = SDL_QUIT; SDL_PushEvent(&event); -#endif } bool Core::exists(const std::string &filename) @@ -4388,8 +2867,8 @@ bool Core::exists(const std::string &filename) CountedPtr Core::findTexture(const std::string &name) { - //stringToUpper(name); - //std::ofstream out("texturefind.log"); + + int sz = resources.size(); for (int i = 0; i < sz; i++) { @@ -4580,7 +3059,7 @@ void Core::removeTexture(Texture *res) void Core::deleteRenderObjectMemory(RenderObject *r) { - //if (!r->allocStatic) + delete r; } @@ -4604,7 +3083,7 @@ void Core::removeRenderObject(RenderObject *r, RemoveRenderObjectFlag flag) void Core::enqueueRenderObjectDeletion(RenderObject *object) { - if (!object->_dead) // && !object->staticallyAllocated) + if (!object->_dead) { garbage.push_back (object); object->_dead = true; @@ -4636,24 +3115,13 @@ bool Core::canChangeState() return (nestedMains<=1); } -/* -int Core::getVirtualWidth() -{ - return virtualWidth; -} -int Core::getVirtualHeight() -{ - return virtualHeight; -} -*/ // Take a screenshot of the specified region of the screen and store it // in a 32bpp pixel buffer. delete[] the returned buffer when it's no // longer needed. unsigned char *Core::grabScreenshot(int x, int y, int w, int h) { -#ifdef BBGE_BUILD_OPENGL unsigned char *imageData; @@ -4687,13 +3155,6 @@ unsigned char *Core::grabScreenshot(int x, int y, int w, int h) return imageData; -#else - - #warning FIXME: Need to implement non-GL grabScreenshot(). - // Avoid crashing, at least. - return new unsigned char[sizeof(unsigned char) * w * h * 4]; - -#endif } // Like grabScreenshot(), but grab from the center of the screen. @@ -4740,7 +3201,7 @@ void Core::saveSizedScreenshotTGA(const std::string &filename, int sz, int crop3 unsigned int size = sizeof(unsigned char) * w * h * 3; imageData = (unsigned char *)malloc(size); - float wbit = fsz;//+1; + float wbit = fsz; float hbit = ((fsz)*(3.0f/4.0f)); int width = core->width-1; @@ -4771,25 +3232,8 @@ void Core::saveSizedScreenshotTGA(const std::string &filename, int sz, int crop3 debugLog(os.str()); glRasterPos2i(0, 0); - - /* - glPushAttrib(GL_ALL_ATTRIB_BITS); - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); glDisable(GL_DITHER); glDisable(GL_FOG); - glDisable(GL_LIGHTING); glDisable(GL_LOGIC_OP); - glDisable(GL_STENCIL_TEST); glDisable(GL_TEXTURE_1D); - glDisable(GL_TEXTURE_2D); glPixelTransferi(GL_MAP_COLOR, - GL_FALSE); glPixelTransferi(GL_RED_SCALE, 1); - glPixelTransferi(GL_RED_BIAS, 0); glPixelTransferi(GL_GREEN_SCALE, 1); - glPixelTransferi(GL_GREEN_BIAS, 0); glPixelTransferi(GL_BLUE_SCALE, 1); - glPixelTransferi(GL_BLUE_BIAS, 0); glPixelTransferi(GL_ALPHA_SCALE, 1); - glPixelTransferi(GL_ALPHA_BIAS, 0); - */ - - //glPixelStorei(GL_PACK_ALIGNMENT, 1); debugLog("pixel zoom"); glPixelZoom(zx,zy); @@ -4809,14 +3253,13 @@ void Core::saveSizedScreenshotTGA(const std::string &filename, int sz, int crop3 tgaSave(filename.c_str(),w,h,savebits,imageData); debugLog("pop"); - //glPopAttrib(); + debugLog("done"); } void Core::save64x64ScreenshotTGA(const std::string &filename) { -#ifdef BBGE_BUILD_OPENGL int w, h; unsigned char *imageData; @@ -4853,16 +3296,13 @@ void Core::save64x64ScreenshotTGA(const std::string &filename) // save the image tgaSave(filename.c_str(),64,64,32,imageData); glPixelZoom(1,1); -#endif - // do NOT free imageData here - // it IS freed in tgaSave - //free(imageData); + + } - // saves an array of pixels as a TGA image (frees the image data passed in) int Core::tgaSave( const char *filename, short int width, @@ -4960,7 +3400,7 @@ int Core::tgaSaveSeries(char *filename, void Core::screenshot() { doScreenshot = true; -// ilutGLScreenie(); + } diff --git a/BBGE/Core.h b/BBGE/Core.h index c3e2d7b..8f99f44 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -40,11 +40,7 @@ BUILD_LINUX #include "DarkLayer.h" -/* -#ifdef BBGE_BUILD_WINDOWS - #include "Joystick.h" -#endif -*/ + #include "FrameBuffer.h" #include "Shader.h" @@ -102,183 +98,10 @@ class Texture; const int baseVirtualWidth = 800; const int baseVirtualHeight = 600; -#if (defined(BBGE_BUILD_WINDOWS)) && !defined(BBGE_BUILD_SDL) enum GameKeys { - KEY_BACKSPACE = DIK_BACKSPACE, - KEY_CAPSLOCK = DIK_CAPSLOCK, - KEY_CIRCUMFLEX = DIK_CIRCUMFLEX, - KEY_DOWNARROW = DIK_DOWNARROW, - KEY_LALT = DIK_LALT, - KEY_LEFTARROW = DIK_LEFTARROW, - KEY_NUMPADMINUS = DIK_NUMPADMINUS, - KEY_NUMPADPERIOD = DIK_NUMPADPERIOD, - KEY_NUMPADPLUS = DIK_NUMPADPLUS, - KEY_NUMPADSLASH = DIK_NUMPADSLASH, - KEY_NUMPADSTAR = DIK_NUMPADSTAR, - KEY_PGDN = DIK_PGDN, - KEY_PGUP = DIK_PGUP, - KEY_RALT = DIK_RALT, - KEY_RIGHTARROW = DIK_RIGHTARROW, - KEY_UPARROW = DIK_UPARROW, - KEY_TILDE = DIK_GRAVE, - KEY_0 = DIK_0, - KEY_1 = DIK_1, - KEY_2 = DIK_2, - KEY_3 = DIK_3, - KEY_4 = DIK_4, - KEY_5 = DIK_5, - KEY_6 = DIK_6, - KEY_7 = DIK_7, - KEY_8 = DIK_8, - KEY_9 = DIK_9, - KEY_A = DIK_A, - KEY_ABNT_C1 = DIK_ABNT_C1, - KEY_ABNT_C2 = DIK_ABNT_C2, - KEY_ADD = DIK_ADD, - KEY_APOSTROPHE = DIK_APOSTROPHE, - KEY_APPS = DIK_APPS, - KEY_AT = DIK_AT, - KEY_AX = DIK_AX, - KEY_B = DIK_B, - KEY_BACK = DIK_BACK, - KEY_BACKSLASH = DIK_BACKSLASH, - KEY_C = DIK_C, - KEY_CALCULATOR = DIK_CALCULATOR, - KEY_CAPITAL = DIK_CAPITAL, - KEY_COLON = DIK_COLON, - KEY_COMMA = DIK_COMMA, - KEY_CONVERT = DIK_CONVERT, - KEY_D = DIK_D, - KEY_DECIMAL = DIK_DECIMAL, - KEY_DELETE = DIK_DELETE, - KEY_DIVIDE = DIK_DIVIDE, - KEY_DOWN = DIK_DOWN, - KEY_E = DIK_E, - KEY_END = DIK_END, - KEY_EQUALS = DIK_EQUALS, - KEY_ESCAPE = DIK_ESCAPE, - KEY_F = DIK_F, - KEY_F1 = DIK_F1, - KEY_F2 = DIK_F2, - KEY_F3 = DIK_F3, - KEY_F4 = DIK_F4, - KEY_F5 = DIK_F5, - KEY_F6 = DIK_F6, - KEY_F7 = DIK_F7, - KEY_F8 = DIK_F8, - KEY_F9 = DIK_F9, - KEY_F10 = DIK_F10, - KEY_F11 = DIK_F11, - KEY_F12 = DIK_F12, - KEY_F13 = DIK_F13, - KEY_F14 = DIK_F14, - KEY_F15 = DIK_F15, - KEY_G = DIK_G, - KEY_GRAVE = DIK_GRAVE, - KEY_H = DIK_H, - KEY_HOME = DIK_HOME, - KEY_I = DIK_I, - KEY_INSERT = DIK_INSERT, - KEY_J = DIK_J, - KEY_K = DIK_K, - KEY_KANA = DIK_KANA, - KEY_KANJI = DIK_KANJI, - KEY_L = DIK_L, - KEY_LBRACKET = DIK_LBRACKET, - KEY_LCONTROL = DIK_LCONTROL, - KEY_LEFT = DIK_LEFT, - KEY_LMENU = DIK_LMENU, - KEY_LSHIFT = DIK_LSHIFT, - KEY_LMETA = DIK_LWIN, - KEY_M = DIK_M, - KEY_MAIL = DIK_MAIL, - KEY_MEDIASELECT = DIK_MEDIASELECT, - KEY_MEDIASTOP = DIK_MEDIASTOP, - KEY_MINUS = DIK_MINUS, - KEY_MULTIPLY = DIK_MULTIPLY, - KEY_MUTE = DIK_MUTE, - KEY_MYCOMPUTER = DIK_MYCOMPUTER, - KEY_N = DIK_N, - KEY_NEXT = DIK_NEXT, - KEY_NEXTTRACK = DIK_NEXTTRACK, - KEY_NOCONVERT = DIK_NOCONVERT, - KEY_NUMLOCK = DIK_NUMLOCK, - KEY_NUMPAD0 = DIK_NUMPAD0, - KEY_NUMPAD1 = DIK_NUMPAD1, - KEY_NUMPAD2 = DIK_NUMPAD2, - KEY_NUMPAD3 = DIK_NUMPAD3, - KEY_NUMPAD4 = DIK_NUMPAD4, - KEY_NUMPAD5 = DIK_NUMPAD5, - KEY_NUMPAD6 = DIK_NUMPAD6, - KEY_NUMPAD7 = DIK_NUMPAD7, - KEY_NUMPAD8 = DIK_NUMPAD8, - KEY_NUMPAD9 = DIK_NUMPAD9, - KEY_NUMPADCOMMA = DIK_NUMPADCOMMA, - KEY_NUMPADENTER = DIK_NUMPADENTER, - KEY_NUMPADEQUALS = DIK_NUMPADEQUALS, - KEY_O = DIK_O, - KEY_OEM_102 = DIK_OEM_102, - KEY_P = DIK_P, - KEY_PAUSE = DIK_PAUSE, - KEY_PERIOD = DIK_PERIOD, - KEY_PLAYPAUSE = DIK_PLAYPAUSE, - KEY_POWER = DIK_POWER, - KEY_PREVTRACK = DIK_PREVTRACK, - KEY_PRIOR = DIK_PRIOR, - KEY_Q = DIK_Q, - KEY_R = DIK_R, - KEY_RBRACKET = DIK_RBRACKET, - KEY_RCONTROL = DIK_RCONTROL, - KEY_RETURN = DIK_RETURN, - KEY_RIGHT = DIK_RIGHT, - KEY_RMENU = DIK_RMENU, - KEY_RSHIFT = DIK_RSHIFT, - KEY_RMETA = DIK_RWIN, - KEY_S = DIK_S, - KEY_SCROLL = DIK_SCROLL, - KEY_SEMICOLON = DIK_SEMICOLON, - KEY_SLASH = DIK_SLASH, - KEY_SLEEP = DIK_SLEEP, - KEY_SPACE = DIK_SPACE, - KEY_STOP = DIK_STOP, - KEY_SUBTRACT = DIK_SUBTRACT, - KEY_SYSRQ = DIK_SYSRQ, - KEY_T = DIK_T, - KEY_TAB = DIK_TAB, - KEY_U = DIK_U, - KEY_UNDERLINE = DIK_UNDERLINE, - KEY_UNLABELED = DIK_UNLABELED, - KEY_UP = DIK_UP, - KEY_V = DIK_V, - KEY_VOLUMEDOWN = DIK_VOLUMEDOWN, - KEY_VOLUMEUP = DIK_VOLUMEUP, - KEY_W = DIK_W, - KEY_WAKE = DIK_WAKE, - KEY_WEBBACK = DIK_WEBBACK, - KEY_WEBFAVORITES = DIK_WEBFAVORITES, - KEY_WEBFORWARD = DIK_WEBFORWARD, - KEY_WEBHOME = DIK_WEBHOME, - KEY_WEBREFRESH = DIK_WEBREFRESH, - KEY_WEBSEARCH = DIK_WEBSEARCH, - KEY_WEBSTOP = DIK_WEBSTOP, - KEY_X = DIK_X, - KEY_Y = DIK_Y, - KEY_YEN = DIK_YEN, - KEY_Z = DIK_Z, - KEY_ANYKEY = 4059, - KEY_MAXARRAY = 256 -}; -#elif defined(BBGE_BUILD_SDL) -enum GameKeys -{ - // replace with GLFW equivalent - /* - KEY_DOWNARROW = GLFW_KEY_DOWN, - KEY_RIGHTARROW = GLFW_KEY_RIGHT, - KEY_UPARROW = GLFW_KEY_UP, - KEY_LEFTARROW = GLFW_KEY_LEFT, - */ + + KEY_LSUPER, KEY_RSUPER, @@ -287,8 +110,8 @@ enum GameKeys KEY_BACKSPACE, KEY_PRINTSCREEN, - //KEY_CAPSLOCK, - //KEY_CIRCUMFLEX, + + KEY_LALT, KEY_RALT, KEY_LSHIFT, @@ -307,7 +130,7 @@ enum GameKeys KEY_SEMICOLON, KEY_LBRACKET, KEY_RBRACKET, - //KEY_RALT, + KEY_TILDE, KEY_0, KEY_1, @@ -390,353 +213,6 @@ enum GameKeys KEY_ANYKEY, KEY_MAXARRAY }; -#elif defined(BBGE_BUILD_XINPUT) -enum GameKeys -{ - KEY_LSUPER = 0, - KEY_RSUPER = 0, - KEY_LMETA = 0, - KEY_RMETA = 0, - KEY_BACKSPACE = 0, - KEY_PRINTSCREEN = 0, - KEY_LALT = 0, - KEY_RALT = 0, - KEY_LSHIFT = 0, - KEY_RSHIFT = 0, - KEY_LCONTROL = 0, - KEY_RCONTROL = 0, - KEY_NUMPADMINUS = 0, - KEY_NUMPADPERIOD = 0, - KEY_NUMPADPLUS = 0, - KEY_NUMPADSLASH = 0, - KEY_NUMPADSTAR = 0, - KEY_PGDN = 0, - KEY_PGUP = 0, - KEY_TILDE = 0, - KEY_0 = 0, - KEY_1 = 0, - KEY_2 = 0, - KEY_3 = 0, - KEY_4 = 0, - KEY_5 = 0, - KEY_6 = 0, - KEY_7 = 0, - KEY_8 = 0, - KEY_9 = 0, - KEY_A = 0, - KEY_B = 0, - KEY_C = 0, - KEY_D = 0, - KEY_E = 0, - KEY_F = 0, - KEY_G = 0, - KEY_H = 0, - KEY_I = 0, - KEY_J = 0, - KEY_K = 0, - KEY_L = 0, - KEY_M = 0, - KEY_N = 0, - KEY_O = 0, - KEY_P = 0, - KEY_Q = 0, - KEY_R = 0, - KEY_S = 0, - KEY_T = 0, - KEY_U = 0, - KEY_V = 0, - KEY_W = 0, - KEY_X = 0, - KEY_Y = 0, - KEY_Z = 0, - - KEY_LEFT = 0, - KEY_RIGHT = 0, - KEY_UP = 0, - KEY_DOWN = 0, - - KEY_NUMPAD1 = 0, - KEY_NUMPAD2 = 0, - KEY_NUMPAD3 = 0, - KEY_NUMPAD4 = 0, - KEY_NUMPAD5 = 0, - KEY_NUMPAD6 = 0, - KEY_NUMPAD7 = 0, - KEY_NUMPAD8 = 0, - KEY_NUMPAD9 = 0, - KEY_NUMPAD0 = 0, - - KEY_DELETE = 0, - KEY_SPACE = 0, - KEY_RETURN = 0, - KEY_PERIOD = 0, - KEY_MINUS = 0, - KEY_CAPSLOCK = 0, - KEY_SYSRQ = 0, - KEY_TAB = 0, - KEY_HOME = 0, - KEY_END = 0, - KEY_COMMA = 0, - KEY_SLASH = 0, - - KEY_F1 = 0, - KEY_F2 = 0, - KEY_F3 = 0, - KEY_F4 = 0, - KEY_F5 = 0, - KEY_F6 = 0, - KEY_F7 = 0, - KEY_F8 = 0, - KEY_F9 = 0, - KEY_F10 = 0, - KEY_F11 = 0, - KEY_F12 = 0, - KEY_F13 = 0, - KEY_F14 = 0, - KEY_F15 = 0, - - KEY_ESCAPE = 0, - KEY_ANYKEY = 4059, - KEY_MAXARRAY = 256 -}; -#elif defined(BBGE_BUILD_GLFW) -enum GameKeys -{ - // replace with GLFW equivalent - /* - KEY_DOWNARROW = GLFW_KEY_DOWN, - KEY_RIGHTARROW = GLFW_KEY_RIGHT, - KEY_UPARROW = GLFW_KEY_UP, - KEY_LEFTARROW = GLFW_KEY_LEFT, - */ - - - KEY_BACKSPACE = GLFW_KEY_BACKSPACE, - //KEY_CAPSLOCK = DIK_CAPSLOCK, - //KEY_CIRCUMFLEX = DIK_CIRCUMFLEX, - KEY_LALT = GLFW_KEY_LALT, - KEY_RALT = GLFW_KEY_RALT, - KEY_LSHIFT = GLFW_KEY_LSHIFT, - KEY_RSHIFT = GLFW_KEY_RSHIFT, - KEY_LCONTROL = GLFW_KEY_LCTRL, - KEY_RCONTROL = GLFW_KEY_RCTRL, - KEY_NUMPADMINUS = GLFW_KEY_KP_SUBTRACT, - KEY_NUMPADPERIOD = GLFW_KEY_KP_DECIMAL, - KEY_NUMPADPLUS = GLFW_KEY_KP_ADD, - KEY_NUMPADSLASH = GLFW_KEY_KP_DIVIDE, - KEY_NUMPADSTAR = GLFW_KEY_KP_MULTIPLY, - KEY_PGDN = GLFW_KEY_PAGEDOWN, - KEY_PGUP = GLFW_KEY_PAGEUP, - //KEY_RALT = GLFW_KEY_RALT, - KEY_TILDE = '`', - KEY_0 = '0', - KEY_1 = '1', - KEY_2 = '2', - KEY_3 = '3', - KEY_4 = '4', - KEY_5 = '5', - KEY_6 = '6', - KEY_7 = '7', - KEY_8 = '8', - KEY_9 = '9', - KEY_A = 'A', - KEY_B = 'B', - KEY_C = 'C', - KEY_D = 'D', - KEY_E = 'E', - KEY_F = 'F', - KEY_G = 'G', - KEY_H = 'H', - KEY_I = 'I', - KEY_J = 'J', - KEY_K = 'K', - KEY_L = 'L', - KEY_M = 'M', - KEY_N = 'N', - KEY_O = 'O', - KEY_P = 'P', - KEY_Q = 'Q', - KEY_R = 'R', - KEY_S = 'S', - KEY_T = 'T', - KEY_U = 'U', - KEY_V = 'V', - KEY_W = 'W', - KEY_X = 'X', - KEY_Y = 'Y', - KEY_Z = 'Z', - - KEY_LEFT = GLFW_KEY_LEFT, - KEY_RIGHT = GLFW_KEY_RIGHT, - KEY_UP = GLFW_KEY_UP, - KEY_DOWN = GLFW_KEY_DOWN, - - KEY_NUMPAD1 = GLFW_KEY_KP_1, - KEY_NUMPAD2 = GLFW_KEY_KP_2, - KEY_NUMPAD3 = GLFW_KEY_KP_3, - KEY_NUMPAD4 = GLFW_KEY_KP_4, - KEY_NUMPAD5 = GLFW_KEY_KP_5, - KEY_NUMPAD6 = GLFW_KEY_KP_6, - KEY_NUMPAD7 = GLFW_KEY_KP_7, - KEY_NUMPAD8 = GLFW_KEY_KP_8, - KEY_NUMPAD9 = GLFW_KEY_KP_9, - KEY_NUMPAD0 = GLFW_KEY_KP_0, - - KEY_DELETE = GLFW_KEY_DEL, - KEY_SPACE = GLFW_KEY_SPACE, - // mac os x - KEY_RETURN = 13, - KEY_PERIOD = '.', - KEY_MINUS = '-', - KEY_CAPSLOCK = -1, - KEY_SYSRQ = '`', - KEY_TAB = GLFW_KEY_TAB, - KEY_HOME = GLFW_KEY_HOME, - KEY_END = GLFW_KEY_END, - KEY_COMMA = ',', - KEY_SLASH = '/', - //KEY_ABNT_C1 = DIK_ABNT_C1, - //KEY_ABNT_C2 = DIK_ABNT_C2, - /* - KEY_ADD = DIK_ADD, - KEY_APOSTROPHE = DIK_APOSTROPHE, - KEY_APPS = DIK_APPS, - KEY_AT = DIK_AT, - KEY_AX = DIK_AX, - */ - /* - KEY_B = 'B', - KEY_BACK = DIK_BACK, - KEY_BACKSLASH = DIK_BACKSLASH, - KEY_C = DIK_C, - KEY_CALCULATOR = DIK_CALCULATOR, - KEY_CAPITAL = DIK_CAPITAL, - KEY_COLON = DIK_COLON, - KEY_COMMA = DIK_COMMA, - KEY_CONVERT = DIK_CONVERT, - KEY_D = DIK_D, - KEY_DECIMAL = DIK_DECIMAL, - KEY_DELETE = DIK_DELETE, - KEY_DIVIDE = DIK_DIVIDE, - KEY_DOWN = DIK_DOWN, - KEY_E = DIK_E, - KEY_END = DIK_END, - KEY_EQUALS = DIK_EQUALS, - KEY_ESCAPE = DIK_ESCAPE, - KEY_F = DIK_F, - */ - KEY_F1 = GLFW_KEY_F1, - KEY_F2 = GLFW_KEY_F2, - KEY_F3 = GLFW_KEY_F3, - KEY_F4 = GLFW_KEY_F4, - KEY_F5 = GLFW_KEY_F5, - KEY_F6 = GLFW_KEY_F6, - KEY_F7 = GLFW_KEY_F7, - KEY_F8 = GLFW_KEY_F8, - KEY_F9 = GLFW_KEY_F9, - KEY_F10 = GLFW_KEY_F10, - KEY_F11 = GLFW_KEY_F11, - KEY_F12 = GLFW_KEY_F12, - KEY_F13 = GLFW_KEY_F13, - KEY_F14 = GLFW_KEY_F14, - KEY_F15 = GLFW_KEY_F15, - /* - KEY_G = DIK_G, - KEY_GRAVE = DIK_GRAVE, - KEY_H = DIK_H, - KEY_HOME = DIK_HOME, - KEY_I = DIK_I, - KEY_INSERT = DIK_INSERT, - KEY_J = DIK_J, - KEY_K = DIK_K, - KEY_KANA = DIK_KANA, - KEY_KANJI = DIK_KANJI, - KEY_L = DIK_L, - KEY_LBRACKET = DIK_LBRACKET, - KEY_LCONTROL = DIK_LCONTROL, - KEY_LEFT = DIK_LEFT, - KEY_LMENU = DIK_LMENU, - KEY_LWIN = DIK_LWIN, - KEY_M = DIK_M, - KEY_MAIL = DIK_MAIL, - KEY_MEDIASELECT = DIK_MEDIASELECT, - KEY_MEDIASTOP = DIK_MEDIASTOP, - KEY_MINUS = DIK_MINUS, - KEY_MULTIPLY = DIK_MULTIPLY, - KEY_MUTE = DIK_MUTE, - KEY_MYCOMPUTER = DIK_MYCOMPUTER, - KEY_N = DIK_N, - KEY_NEXT = DIK_NEXT, - KEY_NEXTTRACK = DIK_NEXTTRACK, - KEY_NOCONVERT = DIK_NOCONVERT, - KEY_NUMLOCK = DIK_NUMLOCK, - KEY_NUMPAD0 = DIK_NUMPAD0, - KEY_NUMPAD1 = DIK_NUMPAD1, - KEY_NUMPAD2 = DIK_NUMPAD2, - KEY_NUMPAD3 = DIK_NUMPAD3, - KEY_NUMPAD4 = DIK_NUMPAD4, - KEY_NUMPAD5 = DIK_NUMPAD5, - KEY_NUMPAD6 = DIK_NUMPAD6, - KEY_NUMPAD7 = DIK_NUMPAD7, - KEY_NUMPAD8 = DIK_NUMPAD8, - KEY_NUMPAD9 = DIK_NUMPAD9, - KEY_NUMPADCOMMA = DIK_NUMPADCOMMA, - KEY_NUMPADENTER = DIK_NUMPADENTER, - KEY_NUMPADEQUALS = DIK_NUMPADEQUALS, - KEY_O = DIK_O, - KEY_OEM_102 = DIK_OEM_102, - KEY_P = DIK_P, - KEY_PAUSE = DIK_PAUSE, - KEY_PERIOD = DIK_PERIOD, - KEY_PLAYPAUSE = DIK_PLAYPAUSE, - KEY_POWER = DIK_POWER, - KEY_PREVTRACK = DIK_PREVTRACK, - KEY_PRIOR = DIK_PRIOR, - KEY_Q = DIK_Q, - KEY_R = DIK_R, - KEY_RBRACKET = DIK_RBRACKET, - KEY_RCONTROL = DIK_RCONTROL, - KEY_RETURN = DIK_RETURN, - KEY_RIGHT = DIK_RIGHT, - KEY_RMENU = DIK_RMENU, - - KEY_RWIN = DIK_RWIN, - KEY_S = DIK_S, - KEY_SCROLL = DIK_SCROLL, - KEY_SEMICOLON = DIK_SEMICOLON, - KEY_SLASH = DIK_SLASH, - KEY_SLEEP = DIK_SLEEP, - KEY_SPACE = DIK_SPACE, - KEY_STOP = DIK_STOP, - KEY_SUBTRACT = DIK_SUBTRACT, - KEY_SYSRQ = DIK_SYSRQ, - KEY_T = DIK_T, - KEY_TAB = DIK_TAB, - KEY_U = DIK_U, - KEY_UNDERLINE = DIK_UNDERLINE, - KEY_UNLABELED = DIK_UNLABELED, - KEY_UP = DIK_UP, - KEY_V = DIK_V, - KEY_VOLUMEDOWN = DIK_VOLUMEDOWN, - KEY_VOLUMEUP = DIK_VOLUMEUP, - KEY_W = DIK_W, - KEY_WAKE = DIK_WAKE, - KEY_WEBBACK = DIK_WEBBACK, - KEY_WEBFAVORITES = DIK_WEBFAVORITES, - KEY_WEBFORWARD = DIK_WEBFORWARD, - KEY_WEBHOME = DIK_WEBHOME, - KEY_WEBREFRESH = DIK_WEBREFRESH, - KEY_WEBSEARCH = DIK_WEBSEARCH, - KEY_WEBSTOP = DIK_WEBSTOP, - KEY_X = DIK_X, - KEY_Y = DIK_Y, - KEY_YEN = DIK_YEN, - KEY_Z = DIK_Z, - */ - KEY_ESCAPE = GLFW_KEY_ESC, - KEY_ANYKEY = 4059 -}; -#endif enum ButtonState { UP = 0, DOWN }; @@ -749,7 +225,7 @@ struct MouseButtons right = UP; middle = UP; } - + ButtonState left, right, middle; }; @@ -797,13 +273,11 @@ public: Vector rightStick; bool inited, xinited; bool anyButton(); -#ifdef BBGE_BUILD_SDL # ifdef BBGE_BUILD_SDL2 SDL_GameController *sdl_controller; SDL_Haptic *sdl_haptic; # endif SDL_Joystick *sdl_joy; -#endif #if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) int eventfd; int16_t effectid; @@ -820,10 +294,10 @@ enum FollowCameraLock FCL_VERT = 2 }; -//RenderObject Layer Type (enable only one) -//#define RLT_DYNAMIC // Dynamic list -#define RLT_FIXED // Static array -//#define RLT_MAP // Mapping + + +#define RLT_FIXED + typedef std::vector RenderObjects; typedef std::list RenderObjectList; @@ -846,48 +320,17 @@ public: inline bool empty() { - #ifdef RLT_FIXED return objectCount == 0; - #endif - #ifdef RLT_DYNAMIC - return renderObjectList.empty(); - #endif - return false; } inline RenderObject *getFirst() { - #ifdef RLT_DYNAMIC - if (renderObjectList.empty()) return 0; - iter = renderObjectList.begin(); - return *iter; - #endif - #ifdef RLT_MAP - if (renderObjectMap.empty()) return 0; - iter = renderObjectMap.begin(); - return (*iter).second; - #endif - #ifdef RLT_FIXED iter = 0; return getNext(); - #endif } RenderObject *getNext() { - #ifdef RLT_DYNAMIC - if (iter == renderObjectList.end()) return 0; - iter++; - if (iter == renderObjectList.end()) return 0; - return *iter; - #endif - #ifdef RLT_MAP - if (iter == renderObjectMap.end()) return 0; - iter++; - if (iter == renderObjectMap.end()) return 0; - return (*iter).second; - #endif - #ifdef RLT_FIXED const int size = renderObjects.size(); int i; for (i = iter; i < size; i++) @@ -905,7 +348,6 @@ public: iter = i; return 0; } - #endif return 0; } @@ -941,20 +383,10 @@ protected: }; std::vector displayList; -#ifdef RLT_DYNAMIC - RenderObjectList renderObjectList; - RenderObjectList::iterator iter; -#endif -#ifdef RLT_MAP - RenderObjectMap renderObjectMap; - RenderObjectMap::iterator iter; -#endif -#ifdef RLT_FIXED RenderObjects renderObjects; int objectCount; int firstFreeIdx; int iter; -#endif }; class Core : public ActionMapper, public StateManager @@ -971,10 +403,10 @@ public: void initRenderObjectLayers(int num); void applyState(const std::string &state); - //bool createGlWindow(char* title, int width, int height, int bits, bool fullscreenflag); + bool createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle=""); - //void setWindowTitle(const std::string &title); // func not yet written - void clearBuffers(); + + void clearBuffers(); void render(int startLayer=-1, int endLayer=-1, bool useFrameBufferIfAvail=true); void showBuffer(); void quit(); @@ -989,7 +421,7 @@ public: void reloadResources(); void unloadResources(); - + std::string getPreferencesFolder(); std::string getUserDataFolder(); @@ -1000,9 +432,9 @@ public: virtual void shutdown(); - void main(float runTime = -1); // can use main + void main(float runTime = -1); // can use main + - //void adjustWindowPosition(int x, int y); // state functions @@ -1029,9 +461,9 @@ public: void setMouseConstraint(bool on); void setMouseConstraintCircle(const Vector& pos, float mouseCircle); - + void setReentryInputGrab(int on); - + void action(int id, int state){} bool exists(const std::string &file); @@ -1059,15 +491,7 @@ public: void resetGraphics(int w, int h, int fullscreen=-1, int vsync=-1, int bpp=-1); -/* -#ifdef BBGE_BUILD_OPENGL - void getWindowHeight(int *height) - {glfwGetWindowSize(0, height);} - void getWindowWidth(int *width) - {glfwGetWindowSize(width, 0);} -#endif -*/ void setDockIcon(const std::string &ident); @@ -1097,7 +521,7 @@ public: RenderObjectLayer *getRenderObjectLayer(int i); std::vector renderObjectLayerOrder; - //typedef std::list RenderObjects; + typedef std::vector RenderObjectLayers; RenderObjectLayers renderObjectLayers; @@ -1130,7 +554,6 @@ public: ParticleManager *particleManager; - //Scripting::Script script; void setBaseTextureDirectory(const std::string &baseTextureDirectory) @@ -1177,29 +600,18 @@ public: void applyMatrixStackToWorld(); void translateMatrixStack(float x, float y, float z=0); - //void translateMatrixStackRelative(float x, float y, float z=0); + void rotateMatrixStack(float x, float y, float z); void scaleMatrixStack(float x, float y, float z=1); void rotateMatrixStack(float z); void setColor(float r, float g, float b, float a); void bindTexture(int stage, unsigned int handle); - -#ifdef BBGE_BUILD_DIRECTX - - void blitD3DVerts(IDirect3DTexture9 *texture, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y, float v4x, float v4y); - void blitD3D (IDirect3DTexture9 *texture, int width, int height); - void blitD3DPreTrans (IDirect3DTexture9 *texture, float x, float y, int absWidth, int absHeight); - void blitD3DEx (IDirect3DTexture9 *texture, int width, int height, float u1=0, float v1=0, float u2=1, float v2=1); - void blitD3DGradient(D3DCOLOR ulc0, D3DCOLOR ulc1, D3DCOLOR ulc2, D3DCOLOR ulc3); - LPDIRECT3DDEVICE9 getD3DDevice(); - LPD3DXSPRITE getD3DSprite(); - LPD3DXMATRIXSTACK getD3DMatrixStack(); -#endif + bool getKeyState(int k); bool getMouseButtonState(int m); - + int currentLayerPass; int keys[KEY_MAXARRAY]; virtual void debugLog(const std::string &s); @@ -1219,20 +631,16 @@ public: void setupRenderPositionAndScale(); void setupGlobalResolutionScale(); - + int particlesPaused; - //JoystickData joystickData[4]; + bool joystickEnabled; bool joystickOverrideMouse; - /* - int numJoysticks; - DIJOYSTATE2 joystate; - Joystick* joysticks[4]; - */ + bool debugLogTextures; - + Joystick joystick; void setClearColor(const Vector &c); @@ -1248,7 +656,7 @@ public: bool frameOutputMode; int overrideStartLayer, overrideEndLayer; - + void setWindowCaption(const std::string &caption, const std::string &icon); ParticleEffect* createParticleEffect(const std::string &name, const Vector &position, int layer, float rotz=0); @@ -1281,7 +689,7 @@ public: Vector center; void enable2DWide(int rx, int ry); - + void enumerateScreenModes(); std::vector screenModes; @@ -1319,13 +727,13 @@ protected: float old_dt; float current_dt; - + std::string debugLogPath; virtual void onReloadResources(); CountedPtr doTextureAdd(const std::string &texture, const std::string &name, std::string internalTextureName); - + void deleteRenderObjectMemory(RenderObject *r); bool _hasFocus; bool lib_graphics, lib_sound, lib_input; @@ -1338,9 +746,9 @@ protected: bool mouseConstraint; float mouseCircle; Vector mouseConstraintCenter; - + bool doMouseConstraint(); - + virtual void onMouseInput(){} bool doScreenshot; float baseCullRadius; @@ -1361,10 +769,10 @@ protected: bool sortFlag; virtual void modifyDt(float &dt){} void setPixelScale(int pixelScaleX, int pixelScaleY); - + int virtualHeight, virtualWidth; - + bool shuttingDown; bool quitNestedMainFlag; bool clearedGarbageFlag; @@ -1376,10 +784,8 @@ protected: std::ofstream _logOut; -#ifdef BBGE_BUILD_SDL int nowTicks, thenTicks; -#endif - + int _vsync, _bpp; bool _fullscreen; @@ -1387,9 +793,8 @@ protected: CountedPtr texError; - //unsigned int windowWidth, windowHeight; - + int tgaSaveSeries(char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData); virtual void onUpdate(float dt); virtual void onRender(){} diff --git a/BBGE/DarkLayer.cpp b/BBGE/DarkLayer.cpp index a55937b..a8747d2 100644 --- a/BBGE/DarkLayer.cpp +++ b/BBGE/DarkLayer.cpp @@ -40,10 +40,8 @@ void DarkLayer::unloadDevice() frameBuffer.unloadDevice(); else { -#ifdef BBGE_BUILD_OPENGL if (texture) glDeleteTextures(1, &texture); -#endif } } @@ -65,7 +63,7 @@ bool DarkLayer::isUsed() //HACK: disabling dark layer for temporary testing build // MAKE SURE TO RESTORE THIS CODE TO THE WAY IT WAS return layer > -1 && active; - //return false; + } void DarkLayer::setLayers(int layer, int rl) @@ -81,7 +79,7 @@ void DarkLayer::init(int quality, bool useFrameBufferParam) this->quality = quality; if (useFrameBuffer) - { + { if (!frameBuffer.init(quality, quality)) useFrameBuffer = false; else @@ -106,33 +104,31 @@ void DarkLayer::toggle(bool on) void DarkLayer::preRender() { -#ifdef BBGE_BUILD_OPENGL bool verbose = core->coreVerboseDebug; if (layer != -1) { if (verbose) debugLog("viewport"); glViewport(0,0,quality,quality); - //core->clearBuffers(); - - //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - + + + if (verbose) debugLog("startCapture"); if (useFrameBuffer) frameBuffer.startCapture(); if (verbose) debugLog("clearColor"); - + glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT); if (verbose) debugLog("render"); - - core->render(layer, layer, false); + + core->render(layer, layer, false); if (verbose) debugLog("endCapture"); - + if (useFrameBuffer) frameBuffer.endCapture(); else @@ -143,44 +139,36 @@ void DarkLayer::preRender() } if (verbose) debugLog("viewport"); - + glViewport(0, 0, core->width, core->height); glClearColor(0,0,0,0); - + if (verbose) debugLog("done"); - /* - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - */ - //glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, quality, quality, 0); + + } -#endif } void DarkLayer::render() { -#ifdef BBGE_BUILD_OPENGL if (renderLayer != -1) { glPushMatrix(); glLoadIdentity(); - //float percentX = (float)core->width/(float)quality; - //float percentY = (float)core->height/(float)quality; - + + + glEnable(GL_TEXTURE_2D); if (useFrameBuffer) frameBuffer.bindTexture(); else glBindTexture(GL_TEXTURE_2D,texture); - - //glDisable(GL_BLEND); - - glEnable(GL_BLEND); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //glBlendFunc(GL_ZERO, GL_SRC_COLOR); - //glBlendEquation(GL_FUNC_SUBTRACT); + + + glEnable(GL_BLEND); + + // subtractive blend! (using color) glBlendFunc(GL_ZERO, GL_SRC_COLOR); @@ -194,9 +182,9 @@ void DarkLayer::render() { debugLog("darkLayer: invalid operation"); } - - //glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); - //glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA); + + + glColor4f(1,1,1,1); float width = core->getWindowWidth(); @@ -221,10 +209,9 @@ void DarkLayer::render() glEnd(); glPopMatrix(); - + RenderObject::lastTextureApplied = 0; glBindTexture(GL_TEXTURE_2D, 0); } -#endif } diff --git a/BBGE/DarkLayer.h b/BBGE/DarkLayer.h index a571ea7..08ce3bf 100644 --- a/BBGE/DarkLayer.h +++ b/BBGE/DarkLayer.h @@ -36,7 +36,7 @@ public: int getLayer(); int getRenderLayer(); bool isUsed(); - + void unloadDevice(); void reloadDevice(); @@ -47,8 +47,8 @@ protected: int quality; bool active; int layer, renderLayer; - - + + GLuint texture; GLuint format; }; diff --git a/BBGE/DebugFont.cpp b/BBGE/DebugFont.cpp index d2699b5..f593bf9 100644 --- a/BBGE/DebugFont.cpp +++ b/BBGE/DebugFont.cpp @@ -132,10 +132,9 @@ void DebugFont::onRender() { const float vspc = 1.5; -#ifdef BBGE_BUILD_OPENGL for (int i = 0; i < lines.size(); i++) { - //float width = (lines[i].size()-1) * fontDrawSize * 1.4f * 0.75f; + float width = (lines[i].size()) * fontDrawSize * 1.4f * 0.75f; if (align == ALIGN_CENTER) { @@ -152,7 +151,6 @@ void DebugFont::onRender() glTranslatef(width*0.5f, 0, 0); } } -#endif } void DebugFont::setAlign(Align align) diff --git a/BBGE/DebugFont.h b/BBGE/DebugFont.h index a7d0b07..2464567 100644 --- a/BBGE/DebugFont.h +++ b/BBGE/DebugFont.h @@ -58,7 +58,7 @@ public: EventPtr event; bool quitMain; int buttonID; - + protected: void onUpdate(float dt); Quad *highlight; diff --git a/BBGE/Effects.cpp b/BBGE/Effects.cpp index 2103701..eed10fe 100644 --- a/BBGE/Effects.cpp +++ b/BBGE/Effects.cpp @@ -76,7 +76,6 @@ void PostProcessingFX::render() { if (enabled[i]) { -#ifdef BBGE_BUILD_OPENGL glPushMatrix(); FXTypes type = (FXTypes)i; switch(type) @@ -153,97 +152,9 @@ void PostProcessingFX::render() } glPopMatrix(); -#endif } } } -/* -GLuint blurTexture; -GLuint emptyTexture() // Create An Empty Texture -{ - GLuint txtnumber; // Texture ID - unsigned int* data; // Stored Data - // Create Storage Space For Texture Data (128x128x4) - data = (unsigned int*)new GLuint[((128 * 128)* 4 * sizeof(unsigned int))]; - ZeroMemory(data,((128 * 128)* 4 * sizeof(unsigned int))); // Clear Storage Memory - glGenTextures(1, &txtnumber); // Create 1 Texture - glBindTexture(GL_TEXTURE_2D, txtnumber); // Bind The Texture - glTexImage2D(GL_TEXTURE_2D, 0, 4, 128, 128, 0, - GL_RGBA, GL_UNSIGNED_BYTE, data); // Build Texture Using Information In data - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - - delete [] data; // Release data - - return txtnumber; // Return The Texture ID -} - -PostProcessingFX::PostProcessingFX() -{ - -} - -void PostProcessingFX::init(FXTypes type) -{ - if (type == FXT_RADIALBLUR) - { - blurTexture = emptyTexture(); - } - enabled[(int)type] = true; -} - -void PostProcessingFX::shutdown(FXTypes type) -{ - enabled[int(type)] = false; -} - -void PostProcessingFX::preRender() -{ - for (int i = 0; i < FXT_MAX; i++) - { - if (enabled[i]) - { - FXTType type = (FXType)i; - switch(type) - { - case FXT_RADIALBLUR: - glViewport(0,0,128,128); // Set Our Viewport (Match Texture Size; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And Depth Buffer - core->render(); - glBindTexture(GL_TEXTURE_2D,BlurTexture); // Bind To The Blur Texture - - // Copy Our ViewPort To The Blur Texture (From 0,0 To 128,128... No Border) - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0); - - glClearColor(0.0f, 0.0f, 0.5f, 0.5); // Set The Clear Color To Medium Blue - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And Depth Buffer - - glViewport(0, 0, 800, 600); - break; - } - } - } -} - -void PostProcessingFX::render() -{ - for (int i = 0; i < FXT_MAX; i++) - { - if (enabled[i]) - { - FXTType type = (FXType)i; - switch(type) - { - case FXT_RADIALBLUR: - glBegin(GL_QUADS); - - glEnd(); - break; - } - } - } -} -*/ diff --git a/BBGE/Emitter.cpp b/BBGE/Emitter.cpp index dc855cf..d111942 100644 --- a/BBGE/Emitter.cpp +++ b/BBGE/Emitter.cpp @@ -37,7 +37,7 @@ void Emitter::destroy() } particles.clear(); Quad::destroy(); - //particleManager->setFree(firstFree); + } void Emitter::spawnParticle(float perc) @@ -46,7 +46,7 @@ void Emitter::spawnParticle(float perc) Particle *p = particleManager->getFreeParticle(this); p->active = true; - + p->life = data.life; setBlendType(data.blendType); @@ -105,14 +105,7 @@ void Emitter::spawnParticle(float perc) p->rot.data->target.z += p->rot.z; } - /* - if (data.calculateVelocityToCenter) - { - Vector pos = p->position - this->position; - pos.setLength2D(1); - quad->velocity = -p*particles[i].velocityMagnitude.x; - } - */ + if (data.randomVelocityMagnitude > 0) { @@ -137,13 +130,8 @@ Vector Emitter::getSpawnPosition() void Emitter::onUpdate(float dt) { Quad::onUpdate(dt); - - /* - for (Particles::iterator i = particles.begin(); i != particles.end(); i++) - { - particleManager->updateParticle(*i, dt); - } - */ + + if (pe->isRunning() && core->particlesPaused <= data.pauseLevel) { @@ -232,16 +220,7 @@ void Emitter::removeParticle(Particle *p) } else particles.remove(p); - /* - for (Particles::reverse_iterator i = particles.rbegin(); i != particles.rend(); i++) - { - if (*i == p) - { - particles.erase(i); - return; - } - } - */ + } void Emitter::render() @@ -257,20 +236,8 @@ void Emitter::onRender() if (!data.spawnLocal) { -#ifdef BBGE_BUILD_OPENGL glLoadIdentity(); -#endif - /* - if (pe && pe->followCamera) - { - glLoadIdentity(); - glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0); - } - else - { - core->setupRenderPositionAndScale(); - } - */ + core->setupRenderPositionAndScale(); } @@ -294,32 +261,26 @@ void Emitter::onRender() const float dx = w2 * p->scale.x; const float dy = h2 * p->scale.y; -#ifdef BBGE_BUILD_OPENGL Vector col = p->color * colorMult; glColor4f(col.x, col.y, col.z, p->alpha.x * alphaMult); - + if (p->rot.z != 0 || p->rot.isInterpolating()) { glPushMatrix(); - + glTranslatef(p->pos.x, p->pos.y,0); glRotatef(p->rot.z, 0, 0, 1); if (data.flipH || (data.copyParentFlip && (pe->isfh() || (pe->getParent() && pe->getParent()->isfh())))) { - //glDisable(GL_CULL_FACE); + glRotatef(180, 0, 1, 0); } - /* - if (data.flipV || (data.copyParentFlip && (this->isfv() || (parent && parent->isfv())))) - { - glDisable(GL_CULL_FACE); - } - */ - + + glBegin(GL_QUADS); glTexCoord2f(0,1); glVertex2f(-dx, +dy); @@ -329,7 +290,7 @@ void Emitter::onRender() glTexCoord2f(1,0); glVertex2f(+dx, -dy); - + glTexCoord2f(0,0); glVertex2f(-dx, -dy); glEnd(); @@ -350,18 +311,16 @@ void Emitter::onRender() glTexCoord2f(1,0); glVertex2f(x+dx, y-dy); - + glTexCoord2f(0,0); glVertex2f(x-dx, y-dy); glEnd(); } -#endif } } } else { -#ifdef BBGE_BUILD_OPENGL glBegin(GL_QUADS); for (Particles::iterator i = particles.begin(); i != particles.end(); i++) { @@ -374,7 +333,7 @@ void Emitter::onRender() const float dy = h2 * p->scale.y; glColor4f(p->color.x, p->color.y, p->color.z, p->alpha.x); - + glTexCoord2f(0,1); glVertex2f(x-dx, y+dy); @@ -383,34 +342,14 @@ void Emitter::onRender() glTexCoord2f(1,0); glVertex2f(x+dx, y-dy); - + glTexCoord2f(0,0); glVertex2f(x-dx, y-dy); } } glEnd(); -#endif } - /* - glDisable(GL_TEXTURE_2D); - glPointSize(4); - glBegin(GL_POINTS); - - for (Particles::iterator i = particles.begin(); i != particles.end(); i++) - { - Particle *p = *i; - if (p->active) - { - glColor4f(1, 0, 0, 1); - x = p->pos.x; - y = p->pos.y; - glVertex2f(x, y); - } - } - glEnd(); - glEnable(GL_TEXTURE_2D); - */ } diff --git a/BBGE/Event.cpp b/BBGE/Event.cpp index 3c0cd61..556e37a 100644 --- a/BBGE/Event.cpp +++ b/BBGE/Event.cpp @@ -221,7 +221,7 @@ void Timer::update(float dt) } break; case 2: - timer += dt; + timer += dt; break; } } @@ -239,5 +239,5 @@ float Timer::getValue() { return timer; } -//EventPtr endEvent, startEvent; + diff --git a/BBGE/Event.h b/BBGE/Event.h index 90f4251..070c152 100644 --- a/BBGE/Event.h +++ b/BBGE/Event.h @@ -80,7 +80,7 @@ enum EventManage { EVM_NONE = 0, EVM_CLEANUP = 1, - EVM_MAX + EVM_MAX }; class ActionMapper; diff --git a/BBGE/FmodOpenALBridge.cpp b/BBGE/FmodOpenALBridge.cpp index aad7b3c..ddba21e 100644 --- a/BBGE/FmodOpenALBridge.cpp +++ b/BBGE/FmodOpenALBridge.cpp @@ -139,17 +139,11 @@ private: bool stopped; // true if enqueued deletion unsigned int samples_done; // Number of samples played and dequeued -#ifdef BBGE_BUILD_SDL static SDL_Thread *decoderThread; static LockedQueue decoderQ; static volatile bool stop_thread; static std::list decoderList; // used by decoder thread only -#else -#warning Threads not supported, music may cut out on area changes! -// ... because the stream runs out of decoded data while the area is -// still loading, so OpenAL aborts playback. -#endif static void detachDecoder(OggDecoder *); }; @@ -181,16 +175,13 @@ static const ov_callbacks ogg_memory_callbacks = { OggDecoder::mem_tell }; -#ifdef BBGE_BUILD_SDL SDL_Thread *OggDecoder::decoderThread = NULL; LockedQueue OggDecoder::decoderQ; volatile bool OggDecoder::stop_thread; std::list OggDecoder::decoderList; -#endif void OggDecoder::startDecoderThread() { -#ifdef BBGE_BUILD_SDL stop_thread = false; #ifdef BBGE_BUILD_SDL2 decoderThread = SDL_CreateThread((int (*)(void *))decode_loop, "OggDecoder", NULL); @@ -202,12 +193,10 @@ void OggDecoder::startDecoderThread() debugLog("Failed to create Ogg Vorbis decode thread: " + std::string(SDL_GetError())); } -#endif } void OggDecoder::stopDecoderThread() { -#ifdef BBGE_BUILD_SDL if (decoderThread) { stop_thread = true; @@ -215,27 +204,22 @@ void OggDecoder::stopDecoderThread() SDL_WaitThread(decoderThread, NULL); decoderThread = NULL; } -#endif } void OggDecoder::detachDecoder(OggDecoder *ogg) { -#ifdef BBGE_BUILD_SDL if(decoderThread) { ogg->thread = true; decoderQ.push(ogg); } -#endif } void OggDecoder::decode_loop(OggDecoder *this_) { while (!this_->stop_thread) { -#ifdef BBGE_BUILD_SDL SDL_Delay(10); -#endif // Transfer decoder to this background thread OggDecoder *ogg; while(decoderQ.pop(ogg)) @@ -371,7 +355,7 @@ bool OggDecoder::preStart(ALuint source) /* NOTE: The failure to use alGetError() here and elsewhere is * intentional -- since alGetError() writes to a global buffer and * is thus not thread-safe, we can't use it either in the decoding - * threads _or_ here in the main thread. In this case, we rely on + * threads _or_ here in the main thread. In this case, we rely on * the specification that failing OpenAL calls do not modify return * parameters to detect failure; for functions that do not return * values, we have no choice but to hope for the best. (From a @@ -1298,7 +1282,6 @@ void OpenALChannel::setSound(OpenALSound *_sound) - // FMOD::System implementation ... class OpenALSystem diff --git a/BBGE/FrameBuffer.cpp b/BBGE/FrameBuffer.cpp index 44794aa..d291e41 100644 --- a/BBGE/FrameBuffer.cpp +++ b/BBGE/FrameBuffer.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //WARNING: FrameBuffer objects have to have reloadDevice/unloadDevice called manually! #ifdef BBGE_BUILD_FRAMEBUFFER -#if defined(BBGE_BUILD_OPENGL) PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL; PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL; PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL; @@ -43,7 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL; PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL; #endif -#endif FrameBuffer::FrameBuffer() { @@ -85,7 +83,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter) std::ostringstream oss; oss << "Vendor: [" << glGetString(GL_VENDOR) << "] Renderer: [" << glGetString(GL_RENDERER) << "]"; debugLog(oss.str()); - + std::string renderer = (const char*)glGetString(GL_RENDERER); if (renderer.find("Intel GMA 950") != std::string::npos) { @@ -94,7 +92,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter) } #endif - + #ifdef BBGE_BUILD_FRAMEBUFFER _w = width; @@ -115,15 +113,11 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter) _fitToScreen = fitToScreen; if (width == 0 || height == 0) return false; - /* - if (width > height) - height = width; - */ + w=width; h=height; -#ifdef BBGE_BUILD_OPENGL char *ext = (char*)glGetString( GL_EXTENSIONS ); std::ostringstream os; @@ -137,7 +131,6 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter) } else { -#if defined(BBGE_BUILD_SDL) if (!glIsRenderbufferEXT) { glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glIsRenderbufferEXT"); @@ -158,7 +151,6 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter) glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)SDL_GL_GetProcAddress("glGenerateMipmapEXT"); } -#endif if( !glIsRenderbufferEXT || !glBindRenderbufferEXT || !glDeleteRenderbuffersEXT || !glGenRenderbuffersEXT || !glRenderbufferStorageEXT || !glGetRenderbufferParameterivEXT || @@ -218,8 +210,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter) } glBindTexture(GL_TEXTURE_2D, 0); - -#endif + debugLog("Done"); inited = true; enabled = true; @@ -237,7 +228,6 @@ void FrameBuffer::unloadDevice() #ifdef BBGE_BUILD_FRAMEBUFFER -#ifdef BBGE_BUILD_OPENGL if (glDeleteFramebuffersEXT == NULL) { @@ -274,13 +264,11 @@ void FrameBuffer::unloadDevice() glDeleteRenderbuffersEXT(1, &g_depthRenderBuffer); g_depthRenderBuffer = 0; } -#endif #endif debugLog("done"); } -#if defined(BBGE_BUILD_SDL) void FrameBuffer::resetOpenGL() { #if defined(BBGE_BUILD_FRAMEBUFFER) @@ -305,7 +293,6 @@ void FrameBuffer::resetOpenGL() glGenerateMipmapEXT = NULL; #endif } -#endif void FrameBuffer::reloadDevice() { @@ -317,15 +304,13 @@ void FrameBuffer::startCapture() { #ifdef BBGE_BUILD_FRAMEBUFFER -#ifdef BBGE_BUILD_OPENGL glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, g_frameBuffer ); - //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, g_depthRenderBuffer ); + glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, g_dynamicTextureID, 0 ); glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, g_depthRenderBuffer ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); -#endif #endif } @@ -334,9 +319,7 @@ void FrameBuffer::endCapture() { #ifdef BBGE_BUILD_FRAMEBUFFER -#ifdef BBGE_BUILD_OPENGL glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); -#endif #endif } @@ -345,9 +328,7 @@ void FrameBuffer::bindTexture() { #ifdef BBGE_BUILD_FRAMEBUFFER -#ifdef BBGE_BUILD_OPENGL glBindTexture( GL_TEXTURE_2D, g_dynamicTextureID ); -#endif #endif } diff --git a/BBGE/FrameBuffer.h b/BBGE/FrameBuffer.h index 105b290..30f2a5b 100644 --- a/BBGE/FrameBuffer.h +++ b/BBGE/FrameBuffer.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class FrameBuffer { public: - FrameBuffer(); + FrameBuffer(); ~FrameBuffer(); bool init(int width, int height, bool fitToScreen=false, GLint filter=GL_LINEAR); bool isInited() { return inited; } @@ -40,13 +40,11 @@ public: int getHeight() { return h; } float getWidthP(); float getHeightP(); - + void unloadDevice(); void reloadDevice(); -#if defined(BBGE_BUILD_SDL) static void resetOpenGL(); -#endif protected: int _w, _h; diff --git a/BBGE/GL/gl.h b/BBGE/GL/gl.h index 336937b..a4614ed 100644 --- a/BBGE/GL/gl.h +++ b/BBGE/GL/gl.h @@ -8,20 +8,20 @@ extern "C" { /* ** Copyright 1998-2002, NVIDIA Corporation. ** All Rights Reserved. -** +** ** THE INFORMATION CONTAINED HEREIN IS PROPRIETARY AND CONFIDENTIAL TO ** NVIDIA, CORPORATION. USE, REPRODUCTION OR DISCLOSURE TO ANY THIRD PARTY ** IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORPORATION. -** -** +** +** ** Copyright 1992-1999, Silicon Graphics, Inc. ** All Rights Reserved. -** +** ** Portions of this file are UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon ** Graphics, Inc.; the contents of this file may not be disclosed to third ** parties, copied or duplicated in any form, in whole or in part, without ** the prior written permission of Silicon Graphics, Inc. -** +** ** RESTRICTED RIGHTS LEGEND: ** Use, duplication or disclosure by the Government is subject to ** restrictions as set forth in subdivision (c)(1)(ii) of the Rights in @@ -44,9 +44,7 @@ extern "C" { #undef WINGDIAPI #define WINGDIAPI extern -/*#ifndef WIN32 -#define WINGDIAPI -#endif*/ + #ifndef GLAPI # ifdef _WIN32 @@ -104,13 +102,13 @@ typedef void GLvoid; #define GL_SCISSOR_BIT 0x00080000 #define GL_ALL_ATTRIB_BITS 0xFFFFFFFF -/* ClearBufferMask */ -/* GL_COLOR_BUFFER_BIT */ -/* GL_ACCUM_BUFFER_BIT */ -/* GL_STENCIL_BUFFER_BIT */ -/* GL_DEPTH_BUFFER_BIT */ -/* ClientAttribMask */ + + + + + + #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 #define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF @@ -158,55 +156,55 @@ typedef void GLvoid; #define GL_DST_ALPHA 0x0304 #define GL_ONE_MINUS_DST_ALPHA 0x0305 -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ + + + #define GL_DST_COLOR 0x0306 #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ -/* ColorMaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ -/* ColorMaterialParameter */ -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ -/* GL_EMISSION */ -/* GL_AMBIENT_AND_DIFFUSE */ -/* ColorPointerType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ -/* CullFaceMode */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ -/* DrawBufferMode */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #define GL_NONE 0 #define GL_FRONT_LEFT 0x0400 #define GL_FRONT_RIGHT 0x0401 @@ -222,75 +220,75 @@ typedef void GLvoid; #define GL_AUX2 0x040B #define GL_AUX3 0x040C -/* EnableCap */ -/* GL_FOG */ -/* GL_LIGHTING */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -/* GL_LINE_STIPPLE */ -/* GL_POLYGON_STIPPLE */ -/* GL_CULL_FACE */ -/* GL_ALPHA_TEST */ -/* GL_BLEND */ -/* GL_INDEX_LOGIC_OP */ -/* GL_COLOR_LOGIC_OP */ -/* GL_DITHER */ -/* GL_STENCIL_TEST */ -/* GL_DEPTH_TEST */ -/* GL_CLIP_PLANE0 */ -/* GL_CLIP_PLANE1 */ -/* GL_CLIP_PLANE2 */ -/* GL_CLIP_PLANE3 */ -/* GL_CLIP_PLANE4 */ -/* GL_CLIP_PLANE5 */ -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -/* GL_TEXTURE_GEN_S */ -/* GL_TEXTURE_GEN_T */ -/* GL_TEXTURE_GEN_R */ -/* GL_TEXTURE_GEN_Q */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_POINT_SMOOTH */ -/* GL_LINE_SMOOTH */ -/* GL_POLYGON_SMOOTH */ -/* GL_SCISSOR_TEST */ -/* GL_COLOR_MATERIAL */ -/* GL_NORMALIZE */ -/* GL_AUTO_NORMAL */ -/* GL_POLYGON_OFFSET_POINT */ -/* GL_POLYGON_OFFSET_LINE */ -/* GL_POLYGON_OFFSET_FILL */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ -/* ErrorCode */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #define GL_NO_ERROR 0 #define GL_INVALID_ENUM 0x0500 #define GL_INVALID_VALUE 0x0501 @@ -317,8 +315,8 @@ typedef void GLvoid; #define GL_COPY_PIXEL_TOKEN 0x0706 #define GL_LINE_RESET_TOKEN 0x0707 -/* FogMode */ -/* GL_LINEAR */ + + #define GL_EXP 0x0800 #define GL_EXP2 0x0801 @@ -1635,9 +1633,6 @@ WINGDIAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei hei # undef __DEFINED_GLAPI #endif -#ifndef GL_GLEXT_LEGACY -#include -#endif #ifdef __cplusplus } diff --git a/BBGE/GL/glext.h b/BBGE/GL/glext.h index 7372c86..83c7b59 100644 --- a/BBGE/GL/glext.h +++ b/BBGE/GL/glext.h @@ -11,13 +11,13 @@ extern "C" { TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS - OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL - NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR - CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR - LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, - OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE - THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL + NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR + CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR + LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, + OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE + THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ******************************************************************************/ @@ -30,21 +30,21 @@ extern "C" { ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** +** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: This software was created using the ** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has ** not been independently verified as being compliant with the OpenGL(R) @@ -3335,7 +3335,7 @@ extern "C" { #define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA #endif -#ifndef GL_EXT_texture_compression_rgtc +#ifndef GL_EXT_texture_compression_rgtc #define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC #define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD diff --git a/BBGE/Gradient.cpp b/BBGE/Gradient.cpp index a825671..1301daa 100644 --- a/BBGE/Gradient.cpp +++ b/BBGE/Gradient.cpp @@ -59,47 +59,26 @@ void Gradient::makeHorizontal(Vector c1, Vector c2) void Gradient::onRender() { -#ifdef BBGE_BUILD_DIRECTX - core->blitD3DGradient - ( ulc0.getD3DColor(alpha.x), - ulc1.getD3DColor(alpha.x), - ulc2.getD3DColor(alpha.x), - ulc3.getD3DColor(alpha.x)); -#endif -#ifdef BBGE_BUILD_OPENGL - //glNormal3f(0, 0, 1); + glBegin(GL_QUADS); - //glNormal3f(0, 0, 1); + glColor4f(ulc2.x*color.x, ulc2.y*color.y, ulc2.z*color.z, alpha.x); glVertex3f(-0.5, 0.5, 0.0f); - // 2 + glColor4f(ulc3.x*color.x, ulc3.y*color.y, ulc3.z*color.z, alpha.x); glVertex3f( 0.5, 0.5, 0.0f); - // 3 + glColor4f(ulc0.x*color.x, ulc0.y*color.y, ulc0.z*color.z, alpha.x); glVertex3f( 0.5, -0.5, 0.0f); - // 4 - glColor4f(ulc1.x*color.x, ulc1.y*color.y, ulc1.z*color.z, alpha.x); + + glColor4f(ulc1.x*color.x, ulc1.y*color.y, ulc1.z*color.z, alpha.x); glVertex3f(-0.5, -0.5, 0.0f); - /* - glColor3f(ulc0.x, ulc0.y, ulc0.z); - glVertex3f(-0.5, -0.5, 0); - glColor3f(ulc1.x, ulc1.y, ulc1.z); - glVertex3f(0.5, -0.5, 0); - - glColor3f(ulc2.x, ulc2.y, ulc2.z); - glVertex3f(0.5, 0.5, 0); - - glColor3f(ulc3.x, ulc3.y, ulc3.z); - glVertex3f(-0.5, 0.5, 0); - */ glEnd(); -#endif } diff --git a/BBGE/Joystick.cpp b/BBGE/Joystick.cpp index 57f316e..9380cca 100644 --- a/BBGE/Joystick.cpp +++ b/BBGE/Joystick.cpp @@ -21,51 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core.h" -#if defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_XINPUT) - #include "Xinput.h" - -#if defined(BBGE_BUILD_DELAYXINPUT) - #include -#endif - -/* - HRESULT (WINAPI *XInputGetState)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter) = 0; - -if ( (winp.hInstDI = LoadLibrary( "dinput.dll" )) == 0 ) - - -if (!pDirectInput8Create) { - pDirectInput8Create = (HRESULT (__stdcall *)(HINSTANCE, DWORD ,REFIID, LPVOID *, LPUNKNOWN)) GetProcAddress(winp.hInstDI,"DirectInput8Create"); - - if (!pDirectInput8Create) { - error(L"Couldn't get DI proc addr\n"); - } -} - - bool importXInput() - { - - } -*/ - - - - -bool tryXInput() -{ - __try - { - XINPUT_STATE xinp; - XInputGetState(0, &xinp); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - return false; - } - return true; -} - -#endif #ifdef __LINUX__ #include @@ -89,13 +44,11 @@ Joystick::Joystick() { xinited = false; stickIndex = -1; -#ifdef BBGE_BUILD_SDL # ifdef BBGE_BUILD_SDL2 sdl_controller = NULL; sdl_haptic = NULL; # endif sdl_joy = NULL; -#endif #if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) eventfd = -1; effectid = -1; @@ -124,11 +77,8 @@ Joystick::Joystick() void Joystick::init(int stick) { -#if defined(BBGE_BUILD_SDL) || defined(__LINUX__) std::ostringstream os; -#endif -#ifdef BBGE_BUILD_SDL stickIndex = stick; const int numJoy = SDL_NumJoysticks(); os << "Found [" << numJoy << "] joysticks"; @@ -184,8 +134,7 @@ void Joystick::init(int stick) { debugLog("Not enough Joystick(s) found"); } -#endif - + #if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) os.seekp(0); os << "AQUARIA_EVENT_JOYSTICK" << stick; @@ -223,20 +172,6 @@ void Joystick::init(int stick) } #endif -#ifdef BBGE_BUILD_XINPUT - debugLog("about to init xinput"); - - xinited = tryXInput(); - - if (!xinited) - debugLog("XInput not found, not installed?"); - - debugLog("after catch"); - -#if !defined(BBGE_BUILD_SDL) - inited = xinited; -#endif -#endif } void Joystick::shutdown() @@ -250,7 +185,6 @@ void Joystick::shutdown() eventfd = -1; } #endif -#ifdef BBGE_BUILD_SDL #ifdef BBGE_BUILD_SDL2 if (sdl_haptic) { @@ -269,7 +203,6 @@ void Joystick::shutdown() SDL_JoystickClose(sdl_joy); sdl_joy = 0; } -#endif } void Joystick::rumble(float leftMotor, float rightMotor, float time) @@ -292,25 +225,6 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time) } } -#elif defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_XINPUT) - XINPUT_VIBRATION vib; - vib.wLeftMotorSpeed = WORD(leftMotor*65535); - vib.wRightMotorSpeed = WORD(rightMotor*65535); - - clearRumbleTime = time; - DWORD d = XInputSetState(0, &vib); - if (d == ERROR_SUCCESS) - { - //debugLog("success"); - } - else if (d == ERROR_DEVICE_NOT_CONNECTED) - { - //debugLog("joystick not connected"); - } - else - { - //unknown error - } #elif defined(__LINUX__) if (eventfd >= 0) { struct ff_effect effect; @@ -331,24 +245,24 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time) effect.u.rumble.strong_magnitude = (uint16_t) (rightMotor * 0xffff); effect.u.rumble.weak_magnitude = (uint16_t) (leftMotor * 0xffff); } - + if (ioctl(eventfd, EVIOCSFF, &effect) == -1) { debugLog(std::string("Upload rumble effect: ") + strerror(errno)); return; } - + event.time.tv_sec = 0; event.time.tv_usec = 0; event.type = EV_FF; event.code = effectid = effect.id; - + if (leftMotor == 0 && rightMotor == 0) { event.value = 0; } else { event.value = 1; } - + if (write(eventfd, (const void*) &event, sizeof(event)) == -1) { debugLog(std::string("Play rumble effect: ") + strerror(errno)); } @@ -359,7 +273,7 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time) void Joystick::callibrate(Vector &calvec, float deadZone) { - //float len = position.getLength2D(); + if (calvec.isLength2DIn(deadZone)) { calvec = Vector(0,0,0); @@ -367,7 +281,7 @@ void Joystick::callibrate(Vector &calvec, float deadZone) else { if (!calvec.isZero()) - { + { Vector pos2 = calvec; pos2.setLength2D(deadZone); calvec -= pos2; @@ -389,7 +303,6 @@ void Joystick::callibrate(Vector &calvec, float deadZone) void Joystick::update(float dt) { -#ifdef BBGE_BUILD_SDL if (core->joystickEnabled && inited && sdl_joy && stickIndex != -1) { #ifdef BBGE_BUILD_SDL2 @@ -451,23 +364,14 @@ void Joystick::update(float dt) rightStick.y = yaxis2/32768.0f; #endif - /* - std::ostringstream os; - os << "joy(" << position.x << ", " << position.y << ")"; - debugLog(os.str()); - */ callibrate(position, deadZone1); callibrate(rightStick, deadZone2); - - /* - std::ostringstream os2; - os2 << "joy2(" << position.x << ", " << position.y << ")"; - debugLog(os2.str()); - */ + + #ifdef BBGE_BUILD_SDL2 if (sdl_controller) { @@ -485,21 +389,10 @@ void Joystick::update(float dt) for (int i = 0; i < maxJoyBtns; i++) buttons[i] = SDL_JoystickGetButton(sdl_joy, i)?DOWN:UP; #endif - /* - unsigned char btns[maxJoyBtns]; - glfwGetJoystickButtons(GLFW_JOYSTICK_1, btns, maxJoyBtns); - for (int i = 0; i < maxJoyBtns; i++) - { - if (btns[i] == GLFW_PRESS) - buttons[i] = DOWN; - else - buttons[i] = UP; - } - */ + } -#endif if (clearRumbleTime >= 0) { @@ -510,59 +403,8 @@ void Joystick::update(float dt) } } -#if defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_XINPUT) - if (inited && xinited) - { - XINPUT_STATE xinp; - XInputGetState(0, &xinp); - - leftTrigger = float(xinp.Gamepad.bLeftTrigger)/255.0f; - rightTrigger = float(xinp.Gamepad.bRightTrigger)/255.0f; - leftShoulder = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER; - rightShoulder = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER; - leftThumb = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB; - rightThumb = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB; - - dpadUp = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP; - dpadDown = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN; - dpadLeft = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT; - dpadRight = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT; - - - - -#if !defined(BBGE_BUILD_SDL) - - buttons[0] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_A?DOWN:UP; - buttons[1] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_B?DOWN:UP; - buttons[2] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_X?DOWN:UP; - buttons[3] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_Y?DOWN:UP; - - position = Vector(xinp.Gamepad.sThumbLX, xinp.Gamepad.sThumbLY)/32768.0f; - position.y = -rightStick.y; - - rightStick = Vector(xinp.Gamepad.sThumbRX, xinp.Gamepad.sThumbRY)/32768.0f; - rightStick.y = -rightStick.y; - - callibrate(position, deadZone1); - - callibrate(rightStick, deadZone2); - -#endif - - btnStart = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_START; - btnSelect = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_BACK; - } -#endif - - - /* - std::ostringstream os; - os << "j-pos(" << position.x << ", " << position.y << " - b0[" << buttons[0] << "]) - len[" << len << "]"; - debugLog(os.str()); - */ } bool Joystick::anyButton() diff --git a/BBGE/LensFlare.cpp b/BBGE/LensFlare.cpp index 6570150..daec1f2 100644 --- a/BBGE/LensFlare.cpp +++ b/BBGE/LensFlare.cpp @@ -43,7 +43,7 @@ void LensFlare::addFlare(const std::string &tex, Vector color, int w, int h) void LensFlare::onUpdate(float dt) { - //const int maxLen = 1500; + RenderObject::onUpdate(dt); Vector v = core->screenCenter - this->position; if (v.getSquaredLength2D() > sqr(maxLen)) @@ -53,7 +53,7 @@ void LensFlare::onUpdate(float dt) float l = v.getLength2D(); float a = 1.0f-(l/(float)maxLen); a*=0.8f; - //Vector vbit = v*(1.0f/flares.size()); + Vector vbit = v; vbit *= inc; for (int i = 0; i < flares.size(); i++) diff --git a/BBGE/MT.cpp b/BBGE/MT.cpp index da2e766..66a223f 100644 --- a/BBGE/MT.cpp +++ b/BBGE/MT.cpp @@ -1,37 +1,28 @@ #include "MT.h" #include "Base.h" -#ifdef BBGE_BUILD_SDL // --------- Lockable ---------- Lockable::Lockable() : _mtx(NULL) { -#ifdef BBGE_BUILD_SDL _mtx = SDL_CreateMutex(); -#endif } Lockable::~Lockable() { -#ifdef BBGE_BUILD_SDL SDL_DestroyMutex((SDL_mutex*)_mtx); -#endif } void Lockable::lock() { -#ifdef BBGE_BUILD_SDL SDL_LockMutex((SDL_mutex*)_mtx); -#endif } void Lockable::unlock() { -#ifdef BBGE_BUILD_SDL SDL_UnlockMutex((SDL_mutex*)_mtx); -#endif } // --------- Waitable ---------- @@ -39,37 +30,26 @@ void Lockable::unlock() Waitable::Waitable() : _cond(NULL) { -#ifdef BBGE_BUILD_SDL _cond = SDL_CreateCond(); -#endif } Waitable::~Waitable() { -#ifdef BBGE_BUILD_SDL SDL_DestroyCond((SDL_cond*)_cond); -#endif } void Waitable::wait() { -#ifdef BBGE_BUILD_SDL SDL_CondWait((SDL_cond*)_cond, (SDL_mutex*)mutex()); -#endif } void Waitable::signal() { -#ifdef BBGE_BUILD_SDL SDL_CondSignal((SDL_cond*)_cond); -#endif } void Waitable::broadcast() { -#ifdef BBGE_BUILD_SDL SDL_CondBroadcast((SDL_cond*)_cond); -#endif } -#endif // BBGE_BUILD_SDL diff --git a/BBGE/MemoryAllocatorSmallBlock.cpp b/BBGE/MemoryAllocatorSmallBlock.cpp index c51f964..4907058 100644 --- a/BBGE/MemoryAllocatorSmallBlock.cpp +++ b/BBGE/MemoryAllocatorSmallBlock.cpp @@ -9,7 +9,7 @@ #include -//#define DD(...) fprintf(stderr, __VA_ARGS__) + #define DD(...) #define logdev(...) #define logerror(...) diff --git a/BBGE/MemoryAllocatorSmallBlock.h b/BBGE/MemoryAllocatorSmallBlock.h index 5dd9c52..0c31475 100644 --- a/BBGE/MemoryAllocatorSmallBlock.h +++ b/BBGE/MemoryAllocatorSmallBlock.h @@ -79,8 +79,8 @@ private: inline unsigned int GetIndexForElemSize(unsigned int elemSize) { - //ASSERT(elemSize); - //ASSERT(elemSize <= _blockSizeMax); + + return ((elemSize + (_blockSizeIncr - 1)) / _blockSizeIncr) - 1; } diff --git a/BBGE/ParticleEffect.cpp b/BBGE/ParticleEffect.cpp index 7209a0c..2f59bac 100644 --- a/BBGE/ParticleEffect.cpp +++ b/BBGE/ParticleEffect.cpp @@ -54,18 +54,7 @@ void ParticleEffect::transfer(ParticleEffect *pe) Emitter *e = pe->addNewEmitter(); e->data = (*i)->data; e->setTexture(e->data.texture); - /* - if (e->data.flipH) - { - if (!e->isfh()) - e->flipHorizontal(); - } - else - { - if (e->isfh()) - e->flipHorizontal(); - } - */ + } } @@ -112,7 +101,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path) Emitter *currentEmitter = 0; while (inf >> token) { - //debugLog("Token: " + token); + if (token == "[Emitter]") { state = 1; @@ -156,11 +145,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path) currentEmitter->data.color.data->path.addPathNode(Vector(x,y,z), t); currentEmitter->data.color.startPath(currentEmitter->data.life); - /* - std::ostringstream os; - os << "colorNode: " << t << ", " << x << ", " << y << ", " << z; - debugLog(os.str()); - */ + } if (state == 3 && currentEmitter) { @@ -172,11 +157,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path) currentEmitter->data.number.data->path.addPathNode(num, t); currentEmitter->data.number.startPath(currentEmitter->data.life); - /* - std::ostringstream os; - os << "numberNode: " << t << ", " << num; - debugLog(os.str()); - */ + } if (state == 4 && currentEmitter) { @@ -188,11 +169,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path) currentEmitter->data.alpha.data->path.addPathNode(num, t); currentEmitter->data.alpha.startPath(currentEmitter->data.life); - /* - std::ostringstream os; - os << "alphaNode: " << t << ", " << num; - debugLog(os.str()); - */ + } if (state == 5 && currentEmitter) { @@ -204,11 +181,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path) currentEmitter->data.rotation.data->path.addPathNode(Vector(0,0,num), t); currentEmitter->data.rotation.startPath(currentEmitter->data.life); - /* - std::ostringstream os; - os << "rotationNode: " << t << ", " << num; - debugLog(os.str()); - */ + } if (state == 6 && currentEmitter) { @@ -220,11 +193,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path) currentEmitter->data.scale.data->path.addPathNode(Vector(sx, sy), t); currentEmitter->data.scale.startPath(currentEmitter->data.life); - /* - std::ostringstream os; - os << "scaleNode: " << t << ", " << sx << ", " << sy; - debugLog(os.str()); - */ + } @@ -422,12 +391,7 @@ void ParticleEffect::onUpdate(float dt) { RenderObject::onUpdate(dt); - /* - for (Emitters::iterator i = emitters.begin(); i != emitters.end(); i++) - { - (*i)->update(dt); - } - */ + if (effectLifeCounter == 0) { diff --git a/BBGE/ParticleManager.cpp b/BBGE/ParticleManager.cpp index 030c064..39fab8a 100644 --- a/BBGE/ParticleManager.cpp +++ b/BBGE/ParticleManager.cpp @@ -191,34 +191,9 @@ void ParticleManager::endParticle(Particle *p) } if (p->index != -1) { - /* - // set free if the neighbours are also free - int backupFree = free; - int oldFree = p->index; - free = oldFree; - nextFree(); - if (!particles[free].active) - { - free = oldFree; - prevFree(); - if (!particles[free].active) - { - // good to go! - } - else - { - free = backupFree; - } - } - else - { - free = backupFree; - } - */ - //if (p->index > free) - //{ - //free = p->index; - //} + + + } p->reset(); } @@ -273,67 +248,11 @@ Particle *ParticleManager::stomp() } while (p->active); - /* - int nFree = free; - int pFree = free; - nextFree(); - nFree = free; - - free = bFree; - prevFree(); - pFree = free; - - do - { - free = nFree; - p = &particles[free]; - idx = free; - nextFree(); - nFree = free; - - if (p->active) - { - free = pFree; - p = &particles[free]; - idx = free; - prevFree(); - pFree = free; - } - c++; - if (c >= spreadCheck) - { - exceed = true; - break; - } - } - while (p->active); - */ - /* - if (p->active) - { - c = 0; - free = backupFree; - nextFree(); - do - { - p = &particles[free]; - idx = free; - nextFree(); - c++; - if (c >= 8) - { - exceed = true; - break; - } - } - while (p->active); - } - */ if (exceed) { - //debugLog("EXCEEDED"); + } endParticle(p); @@ -341,27 +260,7 @@ Particle *ParticleManager::stomp() return p; } -/* -const int FREELISTSIZE = 32; -void ParticleManager::getFreeList(int list) -{ - for (int i = 0; i < FREELISTSIZE; i++) - { - if (freeList[curList] != -1) - { - Particle *p = &particles[freeList[curList]]; - freeList[curList] = -1; - return p; - } - } - return 0; -} - -void ParticleManager::addFreeList() -{ -} -*/ Particle *ParticleManager::getFreeParticle(Emitter *emitter) { @@ -383,21 +282,6 @@ Particle *ParticleManager::getFreeParticle(Emitter *emitter) nextFree(spread); } - /* - static int lpstep = 0; - if (c > lpstep) - lpstep = c; - std::ostringstream os; - os << "psteps: " << c << " largest: " << lpstep; - debugLog(os.str()); - */ - - - /* - p = &particles[free]; - nextFree(); - */ - if (emitter) diff --git a/BBGE/Particles.h b/BBGE/Particles.h index 95b458d..3ed6239 100644 --- a/BBGE/Particles.h +++ b/BBGE/Particles.h @@ -231,7 +231,7 @@ public: protected: - + std::vector suckPositions; int numActive; diff --git a/BBGE/Precacher.cpp b/BBGE/Precacher.cpp index 3d604b8..84c46a3 100644 --- a/BBGE/Precacher.cpp +++ b/BBGE/Precacher.cpp @@ -82,7 +82,7 @@ void precacherCallback(const std::string &file, intptr_t param) } // precacheTex -// caches one texture +// caches one texture // also support simple wildcard to cache multiple textures // e.g. naija/*.png void Precacher::precacheTex(const std::string &tex) @@ -97,12 +97,12 @@ void Precacher::precacheTex(const std::string &tex) if (core->debugLogTextures) debugLog("PRECACHING: " + tex); - + if (tex.find('*')!=std::string::npos) { if (core->debugLogTextures) debugLog("searching directory"); - + int loc = tex.find('*'); std::string path = tex.substr(0, loc); std::string type = tex.substr(loc+1, tex.size()); @@ -137,7 +137,7 @@ void Precacher::precacheList(const std::string &list, void progressCallback()) if (!t.empty()) { #if defined(BBGE_BUILD_UNIX) - //debugLog("precache["+t+"]"); + t = t.substr(0,t.size()-1); debugLog("precache["+t+"]"); #endif diff --git a/BBGE/ProfRender.cpp b/BBGE/ProfRender.cpp index 0c2cada..6837fde 100644 --- a/BBGE/ProfRender.cpp +++ b/BBGE/ProfRender.cpp @@ -51,22 +51,14 @@ ProfRender::ProfRender() : RenderObject() cull = false; alpha = 0.5; - //Prof_set_report_mode(Prof_CALL_GRAPH); + } void ProfRender::onRender() { - /* - for (int i = 0; i < 20; i++) - { - core->print(10, 10+i*10, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz"); - } - */ + #ifdef BBGE_BUILD_WINDOWS - /* - Prof_draw_gl(20, 50, 400, 400, 20, 2, prof_print, prof_width); - Prof_draw_graph_gl(430, 50, 2, 8); - */ + #endif } diff --git a/BBGE/Quad.cpp b/BBGE/Quad.cpp index 82b73ab..f008534 100644 --- a/BBGE/Quad.cpp +++ b/BBGE/Quad.cpp @@ -33,15 +33,7 @@ Quad::Quad(const std::string &tex, const Vector &pos) setTexture(tex); } -/* -void Quad::initDefaultVBO() -{ -} -void Quad::shutdownDefaultVBO() -{ -} -*/ void Quad::setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo) { @@ -67,7 +59,7 @@ void Quad::setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, createGrid(x, y); gridTimer = 0; - + doUpdateGrid = true; } } @@ -95,10 +87,10 @@ void Quad::setStrip(const std::vector &st) void Quad::createGrid(int xd, int yd) { deleteGrid(); - + xDivs = xd; yDivs = yd; - + drawGrid = new Vector * [xDivs]; for (int i = 0; i < xDivs; i++) { @@ -108,7 +100,7 @@ void Quad::createGrid(int xd, int yd) drawGrid[i][j].z = 1; } } - + resetGrid(); } @@ -166,7 +158,7 @@ void Quad::resetStrip() { for (int i = 0; i < strip.size(); i++) { - //float v = (i/(float)(strip.size()-1))-0.5f; + float v = (i/(float(strip.size()))); strip[i].x = v; strip[i].y = 0; @@ -197,39 +189,37 @@ void Quad::initQuad() gridTimer = 0; xDivs = 0; yDivs = 0; - + doUpdateGrid = false; autoWidth = autoHeight = 0; - //debugLog("Quad::initQuad()"); + repeatingTextureToFill = false; - + drawGrid = 0; renderBorder = false; renderCenter = true; width = 2; height = 2; - //llalpha = Vector(1); - //lralpha = Vector(1); - //ulalpha = Vector(1); - //uralpha = Vector(1); - //oriented = false; + + + upperLeftTextureCoordinates = Vector(0,0); lowerRightTextureCoordinates = Vector(1,1); renderQuad = true; - //debugLog("End Quad::initQuad()"); + } Quad::Quad() : RenderObject() { addType(SCO_QUAD); borderAlpha = 0.5; - //debugLog("Quad::Quad()"); + initQuad(); - //debugLog("End Quad::Quad()"); - //textureSize = Vector(1,1); + + } void Quad::deleteGrid() @@ -311,7 +301,7 @@ bool Quad::isCoordinateInsideWorldRect(const Vector &coord, int w, int h) void Quad::updateGrid(float dt) { - //if (xDivs == 0 && yDivs == 0) return; + if (!doUpdateGrid) return; if (gridType == GRID_WAVY) @@ -347,7 +337,6 @@ void Quad::renderGrid() if (xDivs < 2 || yDivs < 2) return; -#ifdef BBGE_BUILD_OPENGL const float percentX = fabsf(this->lowerRightTextureCoordinates.x - this->upperLeftTextureCoordinates.x); const float percentY = fabsf(this->upperLeftTextureCoordinates.y - this->lowerRightTextureCoordinates.y); @@ -373,10 +362,7 @@ void Quad::renderGrid() const float blue = this->color.z; const float alpha = this->alpha.x * this->alphaMod; - /* - glDisable(GL_BLEND); - glDisable(GL_CULL_FACE); - */ + glBegin(GL_QUADS); float u0 = baseX; float u1 = u0 + incX; @@ -391,26 +377,26 @@ void Quad::renderGrid() glColor4f(red, green, blue, alpha*drawGrid[i][j].z); glTexCoord2f(u0, v0); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v0-baseY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0); + + glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y); - // + glColor4f(red, green, blue, alpha*drawGrid[i][j+1].z); glTexCoord2f(u0, v1); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v1-baseY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16); + + glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y); - // + glColor4f(red, green, blue, alpha*drawGrid[i+1][j+1].z); glTexCoord2f(u1, v1); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v1-baseY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16); + + glVertex2f(w*drawGrid[i+1][j+1].x, h*drawGrid[i+1][j+1].y); - // + glColor4f(red, green, blue, alpha*drawGrid[i+1][j].z); glTexCoord2f(u1, v0); - //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v0-baseY); - //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0); + + glVertex2f(w*drawGrid[i+1][j].x, h*drawGrid[i+1][j].y); } } @@ -438,7 +424,6 @@ void Quad::renderGrid() if (texture) glBindTexture(GL_TEXTURE_2D, texture->textures[0]); } -#endif } void Quad::repeatTextureToFill(bool on) @@ -453,15 +438,14 @@ void Quad::onRender() { if (!renderQuad) return; -#ifdef BBGE_BUILD_OPENGL float _w2 = width/2.0f; float _h2 = height/2.0f; if (!strip.empty()) { - //glDisable(GL_BLEND);gggg - //glDisable(GL_CULL_FACE); + + const float texBits = 1.0f / (strip.size()-1); @@ -479,7 +463,7 @@ void Quad::onRender() } glEnd(); - //glEnable(GL_CULL_FACE); + glBindTexture( GL_TEXTURE_2D, 0 ); glColor4f(1,0,0,1); glPointSize(64); @@ -547,123 +531,6 @@ void Quad::onRender() RenderObject::lastTextureApplied = 0; } -#endif -#ifdef BBGE_BUILD_DIRECTX - //core->setColor(color.x, color.y, color.z, alpha.x); - //if (!children.empty() || useDXTransform) - if (true) - { - if (this->texture) - { - if (upperLeftTextureCoordinates.x != 0 || upperLeftTextureCoordinates.y != 0 - || lowerRightTextureCoordinates.x != 1 || lowerRightTextureCoordinates.y != 1) - { - //core->blitD3DEx(this->texture->d3dTexture, fontDrawSize/2, fontDrawSize/2, u, v-ybit, u+xbit, v+ybit-ybit); - core->blitD3DEx(this->texture->d3dTexture, width, height, upperLeftTextureCoordinates.x, upperLeftTextureCoordinates.y, lowerRightTextureCoordinates.x, lowerRightTextureCoordinates.y); - } - else - core->blitD3D(this->texture->d3dTexture, width, height); - } - else - { - core->blitD3D(0, width, height); - } - } - else - { - if (this->texture) - core->blitD3DPreTrans(this->texture->d3dTexture, position.x+offset.x, position.y+offset.y, width*scale.x, width.y*scale.y); - else - core->blitD3DPreTrans(0, position.x+offset.x, position.y+offset.y, width*scale.x, width.y*scale.y); - } - - /* - if (this->texture) - { - core->getD3DSprite()->Begin(D3DXSPRITE_ALPHABLEND); - D3DXVECTOR2 scaling((1.0f/float(this->texture->width))*width*scale.x, - (1.0f/float(this->texture->height))*height*scale.y); - if (isfh()) - scaling.x = -scaling.x; - D3DXVECTOR2 spriteCentre=D3DXVECTOR2((this->texture->width/2), (this->texture->height/2)); - ///scale.x - //D3DXVECTOR2 trans=D3DXVECTOR2(position.x, position.y); - - - if (blendType == BLEND_DEFAULT) - { - core->getD3DDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); - core->getD3DDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - core->getD3DDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); - core->getD3DDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - - D3DXVECTOR2 rotationCentre = spriteCentre; - D3DXVECTOR2 trans=D3DXVECTOR2(position.x,position.y) - spriteCentre; - if (followCamera != 1) - { - trans.x -= core->cameraPos.x; - trans.y -= core->cameraPos.y; - } - D3DXMATRIX mat, scale, final; - //D3DXVECTOR2 centre = trans + spriteCentre; - float rotation = (this->rotation.z*PI)/180.0f; - //D3DXVECTOR2 scaling((1.0f/float(this->texture->width))*width*scale.x,(1.0f/float(this->texture->height))*height*scale.y); - - //D3DXVECTOR2 scaling(1,1); - const D3DCOLOR d3dColor=D3DCOLOR_ARGB(int(alpha.x*255), int(color.x*255), int(color.y*255), int(color.z*255)); - //const D3DCOLOR d3dColor=D3DCOLOR_ARGB(int(alpha.x*255), int(color.x*255), int(color.y*255), int(color.z*255)); - FLOAT scalingRotation = 0; - //D3DXMatrixTransformation2D(&mat,NULL,0.0,&scaling,&spriteCentre,rotation,&trans); - D3DXMatrixTransformation2D(&mat, - &spriteCentre, - scalingRotation, - &scaling, - &spriteCentre, - rotation, - &trans - ); - - if (followCamera != 1) - { - D3DXMatrixScaling(&scale,core->globalScale.x*core->globalResolutionScale.x,core->globalScale.y*core->globalResolutionScale.y,1); - D3DXMatrixMultiply(&final, &mat, &scale); - - core->getD3DSprite()->SetTransform(&final); - } - else - { - D3DXMatrixScaling(&scale,core->globalResolutionScale.x,core->globalResolutionScale.y,1); - D3DXMatrixMultiply(&final, &mat, &scale); - core->getD3DSprite()->SetTransform(&final); - } - - - //mat = scale * mat; - - if (this->texture) - { - core->getD3DSprite()->Draw(this->texture->d3dTexture,NULL,NULL,NULL,d3dColor);//0xFFFFFFFF);//d3dColor); - core->getD3DSprite()->End(); - } - else - { - core->getD3DSprite()->End(); - D3DRECT rect; - rect.x1 = trans.x - this->width/2; - rect.x2 = trans.x + this->width/2; - rect.y1 = trans.y - this->height/2; - rect.y2 = trans.y + this->height/2; - core->getD3DDevice()->Clear(1,&rect,D3DCLEAR_TARGET,d3dColor,0,0); - } - //core->getD3DSprite()->End(); - } - */ - -#endif } diff --git a/BBGE/Quad.h b/BBGE/Quad.h index ec35ba6..861cd88 100644 --- a/BBGE/Quad.h +++ b/BBGE/Quad.h @@ -32,7 +32,7 @@ public: bool renderCenter; protected: - + int w, h, w2, h2; int lineSize; @@ -43,7 +43,7 @@ class Quad : public RenderObject { public: Quad(const std::string &tex, const Vector &pos); - Quad(); + Quad(); void createGrid(int x, int y); void destroy(); bool isCoordinateInside(Vector coord, int minSize=0); @@ -57,8 +57,8 @@ public: void setHeight(float h); int getWidth() const {return int(width);} int getHeight() const {return int(height);} - - void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo); + + void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo); void setDrawGridAlpha(int x, int y, float alpha); void repeatTextureToFill(bool on); void refreshRepeatTextureToFill(); @@ -69,16 +69,15 @@ public: float getStripSegmentSize(); void resetStrip(); Vector ** getDrawGrid() { return drawGrid; } - + void reloadDevice(); void deleteGrid(); InterpolatedVector upperLeftTextureCoordinates, lowerRightTextureCoordinates; - //InterpolatedVector upperLeftColor, upperRightColor, lowerLeftColor, lowerRightColor; - //InterpolatedVector llalpha, lralpha, ulalpha, uralpha; - //bool oriented; + + enum GridType { @@ -88,7 +87,7 @@ public: unsigned char gridType; // unsigned char to save space char autoWidth, autoHeight; // char to save space - + bool renderQuad, renderBorder, renderCenter; bool stripVert; std::vectorstrip; @@ -106,7 +105,7 @@ protected: void resetGrid(); void updateGrid(float dt); void renderGrid(); - + float drawGridOffsetX; float drawGridOffsetY; @@ -114,9 +113,9 @@ protected: float drawGridModY; float drawGridTimeMultiplier; bool drawGridOut; - + static Vector renderBorderColor; - + void onSetTexture(); void onRender(); void onUpdate(float dt); @@ -131,7 +130,7 @@ public: PauseQuad(); int pauseLevel; protected: - + void onUpdate(float dt); }; diff --git a/BBGE/QuadTrail.cpp b/BBGE/QuadTrail.cpp index a299b4e..c6b06fc 100644 --- a/BBGE/QuadTrail.cpp +++ b/BBGE/QuadTrail.cpp @@ -58,8 +58,7 @@ void QuadTrail::onRender() { if (numPoints < 2) return; -#ifdef BBGE_BUILD_OPENGL - //glDisable(GL_CULL_FACE); + int c = 0; Vector p, diff, dl, dr; Vector lastPoint; @@ -114,7 +113,6 @@ void QuadTrail::onRender() glVertex2f((*i).point.x, (*i).point.y); } glEnd(); -#endif } void QuadTrail::onUpdate(float dt) diff --git a/BBGE/QuadTrail.h b/BBGE/QuadTrail.h index 9f21c6b..4effc05 100644 --- a/BBGE/QuadTrail.h +++ b/BBGE/QuadTrail.h @@ -50,7 +50,7 @@ public: float lifeRate; protected: - + Vector backOffset; int numPoints; int maxPoints; diff --git a/BBGE/Rect.h b/BBGE/Rect.h index 8b3b67b..19d72cc 100644 --- a/BBGE/Rect.h +++ b/BBGE/Rect.h @@ -45,8 +45,8 @@ public: } void setCWH(int x, int y, int w, int h) { - //int w2 = w*0.5f; - //int h2 = h*0.5f; + + const int w2 = w / 2; const int h2 = h / 2; x1 = x - w2; diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index 7dcbf6a..79960c1 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -59,7 +59,6 @@ int RenderObject::getTopLayer() void RenderObject::applyBlendType() { -#ifdef BBGE_BUILD_OPENGL if (blendEnabled) { glEnable(GL_BLEND); @@ -84,42 +83,6 @@ void RenderObject::applyBlendType() glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); } -#endif -#ifdef BBGE_BUILD_DIRECTX - if (blendEnabled) - { - core->getD3DDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - switch (blendType) - { - case BLEND_DEFAULT: - core->getD3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - core->getD3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - break; - case BLEND_ADD: - core->getD3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - core->getD3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); - //glBlendFunc(GL_SRC_ALPHA,GL_ONE); - break; - case BLEND_SUB: - core->getD3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO); - core->getD3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); - //glBlendFunc(GL_ZERO, GL_SRC_ALPHA); - break; - } - - core->getD3DDevice()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - core->getD3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); - } - else - { - core->getD3DDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - /* - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - */ - } -#endif } void RenderObject::setColorMult(const Vector &color, const float alpha) @@ -179,13 +142,10 @@ RenderObject::RenderObject() motionBlurFrameOffset = 0; motionBlur = false; idx = -1; -#ifdef BBGE_BUILD_DIRECTX - useDXTransform = false; -#endif _fv = false; _fh = false; updateCull = -1; - //rotateFirst = true; + layer = LR_NONE; cull = true; @@ -193,7 +153,7 @@ RenderObject::RenderObject() positionSnapTo = 0; - //updateMultiplier = 1; + blendEnabled = true; texture = 0; width = 0; @@ -201,7 +161,7 @@ RenderObject::RenderObject() scale = Vector(1,1,1); color = Vector(1,1,1); alpha.x = 1; - //mode = 0; + life = maxLife = 1; decayRate = 0; _dead = false; @@ -209,14 +169,14 @@ RenderObject::RenderObject() _static = false; fadeAlphaWithLife = false; blendType = BLEND_DEFAULT; - //lifeAlphaFadeMultiplier = 1; + followCamera = 0; stateData = 0; parent = 0; - //useColor = true; + renderBeforeParent = false; - //followXOnly = false; - //renderOrigin = false; + + colorIsSaved = false; shareAlphaWithChildren = false; shareColorWithChildren = false; @@ -255,7 +215,6 @@ bool RenderObject::isPieceFlippedHorizontal() Vector RenderObject::getInvRotPosition(const Vector &vec) { -#ifdef BBGE_BUILD_OPENGL glPushMatrix(); glLoadIdentity(); @@ -266,21 +225,21 @@ Vector RenderObject::getInvRotPosition(const Vector &vec) chain.push_back(p); p = p->parent; } - + for (int i = chain.size()-1; i >= 0; i--) { glRotatef(-(chain[i]->rotation.z+chain[i]->rotationOffset.z), 0, 0, 1); - + if (chain[i]->isfh()) { - //glDisable(GL_CULL_FACE); + glRotatef(180, 0, 1, 0); } } if (vec.x != 0 || vec.y != 0) { - //glRotatef(this->rotation.z, 0,0,1,this->rotation.z); + glTranslatef(vec.x, vec.y, 0); } @@ -292,9 +251,6 @@ Vector RenderObject::getInvRotPosition(const Vector &vec) glPopMatrix(); return Vector(x,y,z); -#elif BBGE_BUILD_DIRECTX - return vec; -#endif } #ifdef BBGE_USE_GLM @@ -326,19 +282,17 @@ static void matrixChain(RenderObject *ro) { if (RenderObject *parent = ro->getParent()) matrixChain(parent); - -#ifdef BBGE_BUILD_OPENGL + glTranslatef(ro->position.x+ro->offset.x, ro->position.y+ro->offset.y, 0); glRotatef(ro->rotation.z+ro->rotationOffset.z, 0, 0, 1); glTranslatef(ro->beforeScaleOffset.x, ro->beforeScaleOffset.y, 0); glScalef(ro->scale.x, ro->scale.y, 0); if (ro->isfh()) { - //glDisable(GL_CULL_FACE); + glRotatef(180, 0, 1, 0); } glTranslatef(ro->internalOffset.x, ro->internalOffset.y, 0); -#endif } #endif @@ -369,7 +323,6 @@ Vector RenderObject::getWorldCollidePosition(const Vector &vec) return Vector(transformMatrix[3][0], transformMatrix[3][1], 0); #else -#ifdef BBGE_BUILD_OPENGL glPushMatrix(); glLoadIdentity(); @@ -383,9 +336,6 @@ Vector RenderObject::getWorldCollidePosition(const Vector &vec) glPopMatrix(); return Vector(x,y,0); -#elif BBGE_BUILD_DIRECTX - return vec; -#endif #endif } @@ -407,28 +357,14 @@ void RenderObject::flipHorizontal() { onFH(); } - /* - if (wasFlippedHorizontal && !_fh) - for (int i = 0; i < this->collisionMask.size(); i++) - collisionMask[i].x = -collisionMask[i].x; - else if (!wasFlippedHorizontal && _fh) - for (int i = 0; i < this->collisionMask.size(); i++) - collisionMask[i].x = -collisionMask[i].x; - */ + } void RenderObject::flipVertical() { - //bool wasFlippedVertical = _fv; + _fv = !_fv; - /* - if (wasFlippedVertical && !_fv) - for (int i = 0; i < this->collisionMask.size(); i++) - collisionMask[i].y = -collisionMask[i].y; - else if (!wasFlippedVertical && _fv) - for (int i = 0; i < this->collisionMask.size(); i++) - collisionMask[i].y = -collisionMask[i].y; - */ + } void RenderObject::destroy() @@ -618,7 +554,7 @@ void RenderObject::render() return; } } - + if (motionBlur || motionBlurTransition) { Vector oldPos = position; @@ -635,7 +571,7 @@ void RenderObject::render() alpha *= motionBlurTransitionTimer; } renderCall(); - } + } position = oldPos; alpha.x = oldAlpha; rotation.z = oldRotZ; @@ -649,26 +585,20 @@ void RenderObject::render() void RenderObject::renderCall() { - //RenderObjectLayer *rlayer = core->getRenderObjectLayer(getTopLayer()); + if (positionSnapTo) this->position = *positionSnapTo; position += offset; -#ifdef BBGE_BUILD_DIRECTX - if (!RENDEROBJECT_FASTTRANSFORM) - core->getD3DMatrixStack()->Push(); -#endif -#ifdef BBGE_BUILD_OPENGL if (!RENDEROBJECT_FASTTRANSFORM) glPushMatrix(); if (!RENDEROBJECT_SHAREATTRIBUTES) { glPushAttrib(GL_ALL_ATTRIB_BITS); } -#endif if (!RENDEROBJECT_FASTTRANSFORM) @@ -685,70 +615,40 @@ void RenderObject::renderCall() { if (followCamera == 1) { -#ifdef BBGE_BUILD_OPENGL glLoadIdentity(); glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0); glTranslatef(position.x, position.y, position.z); if (isfh()) { - //glDisable(GL_CULL_FACE); + glRotatef(180, 0, 1, 0); } glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->getD3DMatrixStack()->LoadIdentity(); - core->scaleMatrixStack(core->globalResolutionScale.x, core->globalResolutionScale.y,0); - core->translateMatrixStack(position.x, position.y, 0); - if (isfh()) - { - //HACK: disable cull -> - core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180)); - } - core->rotateMatrixStack(rotation.z + rotationOffset.z); -#endif } else { Vector pos = getFollowCameraPosition(); -#ifdef BBGE_BUILD_OPENGL glTranslatef(pos.x, pos.y, pos.z); if (isfh()) { - //glDisable(GL_CULL_FACE); + glRotatef(180, 0, 1, 0); } glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->translateMatrixStack(pos.x, pos.y, 0); - if (isfh()) - { - //HACK: disable cull -> - core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180)); - } - core->rotateMatrixStack(rotation.z + rotationOffset.z); -#endif } } else { -#ifdef BBGE_BUILD_OPENGL glTranslatef(position.x, position.y, position.z); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->translateMatrixStack(position.x, position.y, 0); -#endif -#ifdef BBGE_BUILD_OPENGL if (RenderObject::renderPaths && position.data && position.data->path.getNumPathNodes() > 0) { glLineWidth(4); glEnable(GL_BLEND); - + int i = 0; glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBindTexture(GL_TEXTURE_2D, 0); @@ -770,69 +670,21 @@ void RenderObject::renderCall() } glEnd(); } -#endif -#ifdef BBGE_BUILD_OPENGL - glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); + glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); if (isfh()) { - //glDisable(GL_CULL_FACE); + glRotatef(180, 0, 1, 0); } -#endif -#ifdef BBGE_BUILD_DIRECTX - //core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 0, 1), rotation.z+rotationOffset.z); - core->rotateMatrixStack(rotation.z + rotationOffset.z); - if (isfh()) - { - //HACK: disable cull - core->getD3DDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); - //core->getD3DMatrixStack()->Scale(-1, 1, 1); - //core->applyMatrixStackToWorld(); - core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180)); - //core->applyMatrixStackToWorld(); - } -#endif } - -#ifdef BBGE_BUILD_OPENGL + glTranslatef(beforeScaleOffset.x, beforeScaleOffset.y, beforeScaleOffset.z); glScalef(scale.x, scale.y, 1); glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->translateMatrixStack(beforeScaleOffset.x, beforeScaleOffset.y, 0); - core->scaleMatrixStack(scale.x, scale.y, 1); - core->translateMatrixStack(internalOffset.x, internalOffset.y, 0); - - core->applyMatrixStackToWorld(); -#endif - //glDisable(GL_CULL_FACE); - /* Never set anywhere. --achurch - if (renderOrigin) - { -#ifdef BBGE_BUILD_OPENGL - glBegin(GL_TRIANGLES); - glColor4f(1.0f, 0.0f, 0.0f, 1.0f); - glVertex3f(0.0f, 5.0f, 0.0f); - glVertex3f(50.0f, 0.0f, 0.0f); - glVertex3f(0.0f, -5.0f, 0.0f); - glColor4f(0.0f, 1.0f, 0.0f, 1.0f); - glVertex3f(0.0f, 0.0f, 5.0f); - glVertex3f(0.0f, 50.0f, 0.0f); - glVertex3f(0.0f, 0.0f, -5.0f); - - glColor4f(0.0f, 0.0f, 1.0f, 1.0f); - glVertex3f(5.0f, 0.0f, 0.0f); - glVertex3f(0.0f, 0.0f, 50.0f); - glVertex3f(-5.0f, 0.0f, 0.0f); - glEnd(); -#endif - } - */ } for (Children::iterator i = children.begin(); i != children.end(); i++) @@ -842,48 +694,34 @@ void RenderObject::renderCall() } - //if (useColor) + { -#ifdef BBGE_BUILD_OPENGL if (rlayer) glColor4f(color.x * rlayer->color.x, color.y * rlayer->color.y, color.z * rlayer->color.z, alpha.x*alphaMod); else glColor4f(color.x, color.y, color.z, alpha.x*alphaMod); -#elif defined(BBGE_BUILD_DIRECTX) - core->setColor(color.x, color.y, color.z, alpha.x*alphaMod); -#endif } - + if (texture) { -#ifdef BBGE_BUILD_OPENGL if (texture->textures[0] != lastTextureApplied || repeatTexture != lastTextureRepeat) { texture->apply(repeatTexture); lastTextureRepeat = repeatTexture; lastTextureApplied = texture->textures[0]; } -#endif -#ifdef BBGE_BUILD_DIRECTX - texture->apply(repeatTexture); -#endif } else { if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat) { -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, 0); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->bindTexture(0, 0); -#endif lastTextureApplied = 0; lastTextureRepeat = repeatTexture; } } - + applyBlendType(); @@ -907,7 +745,7 @@ void RenderObject::renderCall() if (doRender) onRender(); - //collisionShape.render(); + if (!RENDEROBJECT_SHAREATTRIBUTES) { glPopAttrib(); @@ -922,13 +760,7 @@ void RenderObject::renderCall() if (!RENDEROBJECT_FASTTRANSFORM) { -#ifdef BBGE_BUILD_OPENGL glPopMatrix(); -#endif -#ifdef BBGE_BUILD_DIRECTX - core->getD3DMatrixStack()->Pop(); - core->applyMatrixStackToWorld(); -#endif } @@ -939,20 +771,15 @@ void RenderObject::renderCollision() { if (!collisionMask.empty()) { -#ifdef BBGE_BUILD_OPENGL glPushAttrib(GL_ALL_ATTRIB_BITS); glPushMatrix(); glBindTexture(GL_TEXTURE_2D, 0); - - /* - glTranslatef(-offset.x, -offset.y,0); - glTranslatef(collidePosition.x, collidePosition.y,0); - */ - - + + + glLoadIdentity(); core->setupRenderPositionAndScale(); - + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -962,28 +789,22 @@ void RenderObject::renderCollision() for (int i = 0; i < transformedCollisionMask.size(); i++) { Vector collide = this->transformedCollisionMask[i]; - //Vector collide = getWorldCollidePosition(collisionMask[i]); - //Vector collide = collisionMask[i]; - /* - if (isPieceFlippedHorizontal()) - { - collide.x = -collide.x; - } - */ + + + glTranslatef(collide.x, collide.y, 0); RenderObject *parent = this->getTopParent(); if (parent) drawCircle(collideRadius*parent->scale.x, 45); glTranslatef(-collide.x, -collide.y, 0); } - - //glTranslatef(-collidePosition.x, -collidePosition.y,0); + + glDisable(GL_BLEND); glPopMatrix(); glPopAttrib(); - //glTranslatef(offset.x, offset.y,0); -#endif + } else if (collideRadius > 0) { @@ -992,12 +813,12 @@ void RenderObject::renderCollision() core->setupRenderPositionAndScale(); glBindTexture(GL_TEXTURE_2D, 0); glTranslatef(position.x+offset.x, position.y+offset.y, 0); - //glScalef(scale.x, scale.y, 0); + glTranslatef(internalOffset.x, internalOffset.y, 0); glEnable(GL_BLEND); - //glTranslatef(collidePosition.x, collidePosition.y,0); - //glEnable(GL_ALPHA_TEST); - //glAlphaFunc(GL_GREATER, 0); + + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,0,0,0.5); drawCircle(collideRadius, 8); @@ -1037,14 +858,10 @@ Vector RenderObject::getCollisionMaskNormal(int index) if (!sum.isZero()) { sum /= num; - + sum.normalize2D(); - /* - std::ostringstream os; - os << "found [" << num << "] circles, got normal [" << sum.x << ", " << sum.y << "]"; - debugLog(os.str()); - */ + } return sum; @@ -1054,12 +871,12 @@ void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxA { Vector myPos = this->getWorldPosition(); float angle = 0; - + if (myPos.x == pos.x && myPos.y == pos.y) { return; } - MathFunctions::calculateAngleBetweenVectorsInDegrees(myPos, pos, angle); + MathFunctions::calculateAngleBetweenVectorsInDegrees(myPos, pos, angle); RenderObject *p = parent; while (p) @@ -1071,21 +888,9 @@ void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxA if (isPieceFlippedHorizontal()) { angle = 180-angle; - - /* - minAngle = -minAngle; - maxAngle = -maxAngle; - std::swap(minAngle, maxAngle); - */ - //std::swap(minAngle, maxAngle); - /* - minAngle = -(180+minAngle); - maxAngle = -(180+maxAngle); - */ - /* - if (minAngle > maxAngle) - std::swap(minAngle, maxAngle); - */ + + + offset = -offset; } angle += offset; @@ -1125,7 +930,7 @@ void RenderObject::update(float dt) } if (!isDead()) { - //dt *= updateMultiplier; + onUpdate(dt); if (isHidden()) @@ -1171,19 +976,16 @@ void RenderObject::safeKill() alpha = 0; life = 0; onEndOfLife(); - //deathEvent.call(); + for (RenderObjectList::iterator i = deathNotifications.begin(); i != deathNotifications.end(); i++) { (*i)->deathNotify(this); } - //dead = true; + if (this->parent) { parent->enqueueChildDeletion(this); - /* - parent->removeChild(this); - core->enqueueRenderObjectDeletion(this); - */ + } else { @@ -1207,12 +1009,7 @@ Vector RenderObject::getForward() Vector r = v - getWorldCollidePosition(); r.normalize2D(); - /* - std::ostringstream os; - os << "forward v(" << v.x << ", " << v.y << ") "; - os << "r(" << r.x << ", " << r.y << ") "; - debugLog(os.str()); - */ + return r; } @@ -1229,7 +1026,7 @@ Vector RenderObject::getAbsoluteRotation() void RenderObject::onUpdate(float dt) { if (isDead()) return; - //collisionShape.updatePosition(position); + updateLife(dt); // FIXME: We might not need to do lifetime checks either; I just @@ -1261,7 +1058,7 @@ void RenderObject::onUpdate(float dt) (*i)->update(dt); } } - + if (!childGarbage.empty()) { for (Children::iterator i = childGarbage.begin(); i != childGarbage.end(); i++) @@ -1298,7 +1095,7 @@ void RenderObject::onUpdate(float dt) } } -// updateCullVariables(); + } void RenderObject::unloadDevice() @@ -1323,7 +1120,10 @@ bool RenderObject::setTexture(const std::string &n) stringToLowerUserData(name); if (name.empty()) + { + setTexturePointer(NULL); return false; + } if(texture && texture->getLoadResult() == TEX_SUCCESS && name == texture->name) return true; // no texture change @@ -1384,6 +1184,6 @@ void RenderObject::setOverrideCullRadius(float ovr) bool RenderObject::isCoordinateInRadius(const Vector &pos, float r) { Vector d = pos-getRealPosition(); - + return (d.getSquaredLength2D() < r*r); } diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 3fac577..104fa82 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -120,7 +120,7 @@ public: blendType = bt; } - //enum DestroyType { RANDOM=0, REMOVE_STATE }; + virtual void destroy(); virtual void flipHorizontal(); @@ -180,7 +180,7 @@ public: const RenderObject &operator=(const RenderObject &r); void toggleCull(bool value); - + void safeKill(); void enqueueChildDeletion(RenderObject *r); @@ -242,18 +242,14 @@ public: unsigned char blendType; float life; - //float lifeAlphaFadeMultiplier; + float followCamera; - //bool useColor; + bool renderBeforeParent; bool updateAfterParent; - //bool followXOnly; - //bool renderOrigin; - //float updateMultiplier; - //EventPtr deathEvent; bool colorIsSaved; // Used for both color and alpha Vector savedColor; // Saved values from setColorMult() @@ -268,16 +264,11 @@ public: InterpolatedVector *positionSnapTo; - //DestroyType destroyType; + typedef std::vector Children; Children children, childGarbage; - //Flags flags; -#ifdef BBGE_BUILD_DIRECTX - bool useDXTransform; - //D3DXMATRIX matrix; -#endif float collideRadius; std::vector collisionMask; @@ -289,7 +280,7 @@ public: bool ignoreUpdate; bool useOldDT; - + protected: virtual void onFH(){} virtual void onFV(){} @@ -312,7 +303,7 @@ protected: } if (fadeAlphaWithLife && !alpha.isInterpolating()) { - //alpha = ((life*lifeAlphaFadeMultiplier)/maxLife); + alpha = life/maxLife; } } @@ -324,7 +315,6 @@ protected: void renderCollision(); bool repeatTexture; - //ParentManaged pm; unsigned char pm; // unsigned char to save space typedef std::list RenderObjectList; RenderObjectList deathNotifications; @@ -340,7 +330,7 @@ protected: bool _hidden; bool _static; bool _fv, _fh; - //bool rotateFirst; + int idx; RenderObject *parent; StateData *stateData; diff --git a/BBGE/RenderObjectLayer.cpp b/BBGE/RenderObjectLayer.cpp index cd63ae8..5faf03c 100644 --- a/BBGE/RenderObjectLayer.cpp +++ b/BBGE/RenderObjectLayer.cpp @@ -20,15 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "Core.h" -#ifdef RLT_FIXED #define BASE_ARRAY_SIZE 100 // Size of an object array in a new layer -#endif RenderObjectLayer::RenderObjectLayer() -#ifdef RLT_FIXED : renderObjects(BASE_ARRAY_SIZE) -#endif -{ +{ followCamera = NO_FOLLOW_CAMERA; visible = true; startPass = endPass = 0; @@ -42,14 +38,12 @@ RenderObjectLayer::RenderObjectLayer() color = Vector(1,1,1); displayListValid = false; - -#ifdef RLT_FIXED + const int size = renderObjects.size(); for (int i = 0; i < size; i++) renderObjects[i] = 0; objectCount = 0; firstFreeIdx = 0; -#endif } RenderObjectLayer::~RenderObjectLayer() @@ -68,19 +62,12 @@ void RenderObjectLayer::setOptimizeStatic(bool opt) clearDisplayList(); } -#ifdef RLT_DYNAMIC -bool sortRenderObjectsByDepth(RenderObject *r1, RenderObject *r2) -{ - return r1->getSortDepth() < r2->getSortDepth(); -} -#endif void RenderObjectLayer::sort() { if (optimizeStatic && displayListValid) return; // Assume the order hasn't changed -#ifdef RLT_FIXED // Compress the list before sorting to boost speed. const int size = renderObjects.size(); int from, to; @@ -141,15 +128,10 @@ void RenderObjectLayer::sort() sortDepths[best] = d; } } -#endif -#ifdef RLT_DYNAMIC - renderObjectList.sort(sortRenderObjectsByDepth); -#endif } void RenderObjectLayer::add(RenderObject* r) { -#ifdef RLT_FIXED int size = renderObjects.size(); if (firstFreeIdx >= size) { @@ -166,20 +148,12 @@ void RenderObjectLayer::add(RenderObject* r) if (!renderObjects[firstFreeIdx]) break; } -#endif -#ifdef RLT_DYNAMIC - renderObjectList.push_back(r); -#endif -#ifdef RLT_MAP - renderObjectMap[intptr_t(r)] = r; -#endif clearDisplayList(); } void RenderObjectLayer::remove(RenderObject* r) { -#ifdef RLT_FIXED const int idx = r->getIdx(); if (idx < 0 || idx >= renderObjects.size()) { @@ -196,20 +170,12 @@ void RenderObjectLayer::remove(RenderObject* r) if (idx < firstFreeIdx) firstFreeIdx = idx; r->setIdx(-1); -#endif -#ifdef RLT_DYNAMIC - renderObjectList.remove(r); -#endif -#ifdef RLT_MAP - renderObjectMap[intptr_t(r)] = 0; -#endif clearDisplayList(); } void RenderObjectLayer::moveToFront(RenderObject *r) { -#ifdef RLT_FIXED const int size = renderObjects.size(); const int curIdx = r->getIdx(); int lastUsed; @@ -267,18 +233,12 @@ void RenderObjectLayer::moveToFront(RenderObject *r) while (renderObjects[firstFreeIdx]) firstFreeIdx++; } -#endif // RLT_FIXED -#ifdef RLT_DYNAMIC - renderObjectList.remove(r); - renderObjectList.push_back(r); -#endif clearDisplayList(); } void RenderObjectLayer::moveToBack(RenderObject *r) { -#ifdef RLT_FIXED const int size = renderObjects.size(); const int curIdx = r->getIdx(); int firstUsed; @@ -341,11 +301,6 @@ void RenderObjectLayer::moveToBack(RenderObject *r) break; } } -#endif // RLT_FIXED -#ifdef RLT_DYNAMIC - renderObjectList.remove(r); - renderObjectList.push_front(r); -#endif clearDisplayList(); } @@ -364,9 +319,7 @@ void RenderObjectLayer::renderPass(int pass) { if (displayList[i].isList) { -#ifdef BBGE_BUILD_OPENGL glCallList(displayList[i].u.listID); -#endif RenderObject::lastTextureApplied = 0; } else @@ -430,7 +383,6 @@ void RenderObjectLayer::generateDisplayList() } else { -#ifdef BBGE_BUILD_OPENGL int listID = glGenLists(1); if (listID != 0) { @@ -450,16 +402,13 @@ void RenderObjectLayer::generateDisplayList() } else debugLog("glGenLists failed"); -#endif } } else { if (lastWasStatic) { -#ifdef BBGE_BUILD_OPENGL glEndList(); -#endif lastWasStatic = false; } } @@ -477,9 +426,7 @@ void RenderObjectLayer::generateDisplayList() if (lastWasStatic) { -#ifdef BBGE_BUILD_OPENGL glEndList(); -#endif } displayList.resize(listLength); diff --git a/BBGE/RenderObject_inline.h b/BBGE/RenderObject_inline.h index 2e7af29..5e18199 100644 --- a/BBGE/RenderObject_inline.h +++ b/BBGE/RenderObject_inline.h @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. inline bool RenderObject::isOnScreen() { if (followCamera == 1) return true; - //if (followCamera != 0) return true; + // note: radii are sqr-ed for speed const float cullRadiusSqr = (getCullRadiusSqr() * core->invGlobalScaleSqr) + core->cullRadiusSqr; diff --git a/BBGE/RenderRect.cpp b/BBGE/RenderRect.cpp index 37de382..dd2c0cb 100644 --- a/BBGE/RenderRect.cpp +++ b/BBGE/RenderRect.cpp @@ -42,7 +42,6 @@ void OutlineRect::setLineSize(int ls) void OutlineRect::onRender() { -#ifdef BBGE_BUILD_OPENGL glLineWidth(lineSize); glBegin(GL_LINES); // l @@ -71,7 +70,6 @@ void OutlineRect::onRender() glVertex2f(0,h2); glEnd(); } -#endif } diff --git a/BBGE/RoundedRect.cpp b/BBGE/RoundedRect.cpp index 4eb86dc..700fdbb 100644 --- a/BBGE/RoundedRect.cpp +++ b/BBGE/RoundedRect.cpp @@ -35,7 +35,7 @@ RoundedRect::RoundedRect() : RenderObject() height = 100; radius = 20; - + cull = false; canMove = false; @@ -91,21 +91,21 @@ void RoundedRect::onUpdate(float dt) { if (moving == this) { - // do stuff + moving = 0; } - + } } } void RoundedRect::onRender() { - //glBindTexture(GL_TEXTURE_2D, 0); + int w2 = width/2; int h2 = height/2; - //glDisable(GL_CULL_FACE); + float iter = 0.1f; glBegin(GL_QUADS); @@ -146,20 +146,20 @@ void RoundedRect::onRender() glVertex3f(-w2 + x1, h2 + 0, 0); } } - + //middle, top, btm glVertex3f(-w2, -h2 - radius, 0); glVertex3f(w2, -h2 - radius, 0); glVertex3f(w2, h2 + radius, 0); glVertex3f(-w2, h2 + radius, 0); - // left + // left glVertex3f(-w2 - radius, -h2, 0); glVertex3f(-w2, -h2, 0); glVertex3f(-w2, h2, 0); glVertex3f(-w2 - radius, h2, 0); - // right + // right glVertex3f(w2 + radius, -h2, 0); glVertex3f(w2, -h2, 0); glVertex3f(w2, h2, 0); @@ -167,7 +167,7 @@ void RoundedRect::onRender() glEnd(); - //glEnable(GL_CULL_FACE); + } void RoundedRect::show() @@ -195,7 +195,7 @@ void RoundedRect::hide() RoundButton::RoundButton(const std::string &labelText, TTFFont *font) : RenderObject() { - //label = new + label = new TTFText(font); label->setAlign(ALIGN_CENTER); label->offset += Vector(0, 3); @@ -214,7 +214,7 @@ void RoundButton::setWidthHeight(int w, int h, int radius) width = w; height = h; } - + void RoundButton::onUpdate(float dt) { if (noNested && core->isNested()) return; diff --git a/BBGE/RoundedRect.h b/BBGE/RoundedRect.h index 5a4309b..cff355a 100644 --- a/BBGE/RoundedRect.h +++ b/BBGE/RoundedRect.h @@ -40,7 +40,7 @@ public: int getHeight() { return height; } int getRadius() { return radius; } - + protected: void onUpdate(float dt); void onRender(); diff --git a/BBGE/ScreenTransition.cpp b/BBGE/ScreenTransition.cpp index e0d3270..508490f 100644 --- a/BBGE/ScreenTransition.cpp +++ b/BBGE/ScreenTransition.cpp @@ -34,7 +34,7 @@ void ScreenTransition::createTexture() { width = core->getVirtualWidth(); height = core->getVirtualHeight(); - + windowWidth = core->getWindowWidth(); windowHeight = core->getWindowHeight(); @@ -44,15 +44,8 @@ void ScreenTransition::createTexture() sizePowerOf2Texture(textureWidth); sizePowerOf2Texture(textureHeight); - /* - if (windowWidth>1024) - { - textureWidth = 2048; - textureHeight = 1024; - } - */ -#ifdef BBGE_BUILD_OPENGL + //create our texture glGenTextures(1,&screen_texture); glBindTexture(GL_TEXTURE_2D, screen_texture); @@ -63,23 +56,17 @@ void ScreenTransition::createTexture() glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_NEAREST); //GL_NEAREST); glTexImage2D(GL_TEXTURE_2D,0,3, textureWidth, textureHeight, 0 , GL_RGB, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D,0); -#endif -/* - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -*/ + } void ScreenTransition::destroyTexture() { -#ifdef BBGE_BUILD_OPENGL if (screen_texture) { glDeleteTextures(1, &screen_texture); screen_texture = 0; } -#endif } void ScreenTransition::unloadDevice() @@ -95,23 +82,17 @@ void ScreenTransition::reloadDevice() } void ScreenTransition::capture() -{ +{ core->render(); - /* - std::ostringstream os; - os << "windowWidth [" << windowWidth << "] windowHeight [" << windowHeight << "]"; - errorLog(os.str()); - */ - -#ifdef BBGE_BUILD_OPENGL + + if (screen_texture) { glBindTexture(GL_TEXTURE_2D,screen_texture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, windowWidth, windowHeight); glBindTexture(GL_TEXTURE_2D, 0); } -#endif core->showBuffer(); } @@ -137,28 +118,18 @@ bool ScreenTransition::isGoing() void ScreenTransition::onRender() { if (alpha.x == 0) return; - -#ifdef BBGE_BUILD_OPENGL + float width2 = float(width)/2; float height2 = float(height)/2; - + const float pw = float(windowWidth)/float(textureWidth); const float ph = float(windowHeight)/float(textureHeight); - - /* - std::ostringstream os; - os << "wh(" << width2 << ", " << height2 << ") p(" << pw << ", " << ph << ")"; - debugLog(os.str()); - */ - + + + glBindTexture(GL_TEXTURE_2D, screen_texture); - //glBindTexture(GL_TEXTURE_2D, 0); - // 16/10 = 1.6 - // 16/9 = 1.77777 - // 4/3 = 1.33333 - - // fix slight offset in 16/10 resolution - // only on mac? + + #if 0 //def BBGE_BUILD_MACOSX float aspect = float(core->width) / float(core->height); @@ -170,8 +141,8 @@ void ScreenTransition::onRender() #endif glBegin(GL_QUADS); - //glNormal3f( 0.0f, 0.0f, 1.0f); - //glColor4f(color.x, color.y, color.z, alpha.getValue()); + + glTexCoord2d(0, 0); glVertex3f(-width2, height2, 0.0); glTexCoord2d(pw, 0); @@ -183,8 +154,7 @@ void ScreenTransition::onRender() glEnd(); glBindTexture(GL_TEXTURE_2D, 0); - + RenderObject::lastTextureApplied = 0; -#endif } diff --git a/BBGE/ScreenTransition.h b/BBGE/ScreenTransition.h index c4adc14..5a59a03 100644 --- a/BBGE/ScreenTransition.h +++ b/BBGE/ScreenTransition.h @@ -40,11 +40,9 @@ protected: int windowWidth, windowHeight; void onRender(); float width, height; - //void onUpdate(float dt); -#ifdef BBGE_BUILD_OPENGL + GLuint screen_texture; -#endif }; #endif diff --git a/BBGE/Shader.cpp b/BBGE/Shader.cpp index af5e882..d73b0d9 100644 --- a/BBGE/Shader.cpp +++ b/BBGE/Shader.cpp @@ -66,10 +66,7 @@ void Shader::staticInit() //This extension string indicates that the OpenGL Shading Language, // version 1.00, is supported. debugLog("GL_ARB_shading_language_100 extension was not found"); - /* - MessageBox(NULL,"GL_ARB_shading_language_100 extension was not found", - "ERROR",MB_OK|MB_ICONEXCLAMATION); - */ + goto end; } @@ -80,7 +77,6 @@ void Shader::staticInit() } else { -#ifdef BBGE_BUILD_SDL glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB"); glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB"); glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB"); @@ -101,11 +97,10 @@ void Shader::staticInit() glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)SDL_GL_GetProcAddress("glUniform2ivARB"); glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)SDL_GL_GetProcAddress("glUniform3ivARB"); glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)SDL_GL_GetProcAddress("glUniform4ivARB"); -#endif if( !glCreateProgramObjectARB || !glDeleteObjectARB || !glUseProgramObjectARB || - !glCreateShaderObjectARB || !glCreateShaderObjectARB || !glCompileShaderARB || - !glGetObjectParameterivARB || !glAttachObjectARB || !glGetInfoLogARB || + !glCreateShaderObjectARB || !glCreateShaderObjectARB || !glCompileShaderARB || + !glGetObjectParameterivARB || !glAttachObjectARB || !glGetInfoLogARB || !glLinkProgramARB || !glGetUniformLocationARB || !glGetActiveUniformARB || !glUniform1fvARB || !glUniform2fvARB || !glUniform3fvARB || !glUniform4fvARB || !glUniform1ivARB || !glUniform2ivARB || !glUniform3ivARB || !glUniform4ivARB) @@ -134,9 +129,7 @@ Shader::Shader() numUniforms = -1; uniformsDirty = false; -#ifdef BBGE_BUILD_OPENGL g_programObj = 0; -#endif } Shader::~Shader() @@ -403,7 +396,7 @@ void Shader::_queryUniforms() memset(&u.data, 0, sizeof(u.data)); u.dirty = true; u.type = type; - + if(add) uniforms.push_back(u); else diff --git a/BBGE/Shader.h b/BBGE/Shader.h index 30b8ba0..762a794 100644 --- a/BBGE/Shader.h +++ b/BBGE/Shader.h @@ -45,10 +45,8 @@ public: protected: std::string vertFile, fragFile; std::string vertSrc, fragSrc; -#ifdef BBGE_BUILD_OPENGL GLuint g_programObj; int numUniforms; -#endif private: static void staticInit(); diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 52350c2..ce39dcb 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -81,13 +81,7 @@ Bone::Bone() : Quad() selectable = true; originalRenderPass = 0; } -/* -void Bone::createStrip(bool vert, int num) -{ - Quad::createStrip(vert, num); - changeStrip.resize(num); -} -*/ + void Bone::destroy() { @@ -143,7 +137,7 @@ Quad* Bone::addFrame(const std::string &gfx) void Bone::showFrame(int idx) { - //float t = 0.1; + int c = 0; for (Children::iterator i = children.begin(); i != children.end(); i++) { @@ -181,11 +175,7 @@ void Bone::showFrame(int idx) void Bone::setAnimated(int b) { - /* - std::ostringstream os; - os << "setting animated: " << b; - debugLog(os.str()); - */ + animated = b; } @@ -200,10 +190,7 @@ void Bone::setSegmentProps(int minDist, int maxDist, bool reverse) void Bone::updateSegment(Bone *b, const Vector &diff) { - /* - int maxDist, minDist; - maxDist = minDist = 128; - */ + float angle = -1; if (diff.getSquaredLength2D() > sqr(maxDist)) @@ -215,21 +202,17 @@ void Bone::updateSegment(Bone *b, const Vector &diff) MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), diff, angle); } - else if (diff.getSquaredLength2D() > sqr(minDist)) // 6.3 + else if (diff.getSquaredLength2D() > sqr(minDist)) { b->position += diff*0.05f; MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), diff, angle); - //b->rotation.interpolateTo(Vector(0,0,angle),0.2); + } if (angle != -1) { - /* - std::ostringstream os; - os << "rotz: " << b->rotation.z << " angle: " << angle; - debugLog(os.str()); - */ + if (b->rotation.z >= 270 && angle < 90) { @@ -246,35 +229,15 @@ void Bone::updateSegment(Bone *b, const Vector &diff) b->rotation.interpolateTo(Vector(0,0,angle),0.2); } - /* - else - { - float angle; - MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), diff, angle); - b->rotation.interpolateTo(Vector(0,0,angle),0); - } - */ + } void Bone::updateSegments() { if (segmentChain>0 && !segments.empty()) { - //bool reverse = true; - /* - std::vector segments; - Bone *child = (Bone*)(this->children.front()); - while (child) - { - segments.push_back(child); - if (child->children.empty()) - child = 0; - else - child = (Bone*)(child->children.front()); - } - */ if (!reverse) { @@ -336,25 +299,13 @@ bool BoneCommand::parse(Bone *b, SimpleIStringStream &is) { command = AC_PRT_START; is >> slot; - /* - Emitter *e = b->emitters[slot]; - if (e) - { - e->start(); - } - */ + } else if (type=="AC_PRT_STOP") { command = AC_PRT_STOP; is >> slot; - /* - Emitter *e = b->emitters[slot]; - if (e) - { - e->stop(); - } - */ + } else if (type=="AC_SEGS_START") command = AC_SEGS_START; @@ -379,7 +330,7 @@ bool BoneCommand::parse(Bone *b, SimpleIStringStream &is) void BoneCommand::run() { - //debugLog("running CMD"); + switch(command) { case AC_SND_PLAY: @@ -429,7 +380,7 @@ AnimationLayer::AnimationLayer() { lastNewKey = 0; fallThru= 0; - //index = -1; + timer = 0; loop = 0; enqueuedAnimationLoop = 0; @@ -482,7 +433,7 @@ void AnimationLayer::playAnimation(int idx, int loop) fallThruSpeed = 10; } timeMultiplier = 1; - //currentKeyframe = 0; + currentAnimation = idx; timer = 0; animating = true; @@ -490,7 +441,7 @@ void AnimationLayer::playAnimation(int idx, int loop) this->loop = loop; animationLength = getCurrentAnimation()->getAnimationLength(); - //doNextKeyframe(); + } void AnimationLayer::enqueueAnimation(const std::string& anim, int loop) @@ -547,7 +498,7 @@ Animation* AnimationLayer::getCurrentAnimation() bool AnimationLayer::createTransitionAnimation(const std::string& anim, float time) { - //Animation *a = getCurrentAnimation(); + Animation *to = s->getAnimation(anim); if (!to) return false; blendAnimation.keyframes.clear(); @@ -653,10 +604,7 @@ SkeletalKeyframe *Animation::getFirstKeyframe() void Animation::reorderKeyframes() { - /* - std::vector copy = this->keyframes; - keyframes.clear(); - */ + for (int i = 0; i < keyframes.size(); i++) { for (int j = 0; j < keyframes.size()-1; j++) @@ -747,7 +695,7 @@ SkeletalKeyframe *Animation::getNextKeyframe(float t) break; } } -// kf++; + if (kf == -1) return 0; if (kf >= keyframes.size()) @@ -831,17 +779,12 @@ void SkeletalSprite::onUpdate(float dt) } } - /* - for (int i = 0; i < bones.size(); i++) - { - bones[i]->update(dt); - } - */ + for (i = 0; i < animLayers.size(); i++) { animLayers[i].update(dt); } - //updateBones(); + } void AnimationLayer::update(float dt) @@ -988,14 +931,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn) os << this->bones[i]->originalScale.x << " " << this->bones[i]->originalScale.y; bone->SetAttribute("sz", os.str().c_str()); } - /* - if (this->bones[i]->color.x != 1 || this->bones[i]->color.y != 1 || this->bones[i]->color.z != 1) - { - std::ostringstream os; - os << this->bones[i]->color.x << " " << this->bones[i]->color.y << " " << this->bones[i]->color.z; - bone->SetAttribute("color", os.str().c_str()); - } - */ + for (Children::iterator j = this->bones[i]->children.begin(); j != this->bones[i]->children.end(); j++) { @@ -1125,7 +1061,7 @@ Bone *SkeletalSprite::initBone(int idx, std::string gfx, int pidx, int rbp, std: b->pidx = pidx; b->collideRadius = cr; b->name = name; - //core->generateCollisionMask(b); + if (fh) b->flipHorizontal(); if (fv) @@ -1256,25 +1192,8 @@ void SkeletalSprite::loadSkin(const std::string &fn) b->flipVertical(); } - /* - if (boneXml->Attribute("a")) - { - float alpha = 0; - boneXml->Attribute("a", &alpha); - b->alpha = alpha; - } - */ - /* - // this is for SKINS - if (boneXml->Attribute("sz")) - { - float v1, v2; - SimpleIStringStream is(boneXml->Attribute("sz")); - is >> v1 >> v2; - b->scale = Vector(v1,v2); - b->originalScale = b->scale; - } - */ + + } else { @@ -1617,7 +1536,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn) for (int i = 0; i < b.strip.size(); i++) { is >> b.strip[i].x >> b.strip[i].y; - //b.strip[i].y *= 10; + } } if (key->Attribute("sz")) @@ -1760,10 +1679,7 @@ void AnimationLayer::updateBones() float t1 = key1->t; float t2 = key2->t; - /* - if (key1 == key2) - stopAnimation(); - */ + float diff = t2-t1; float dt; @@ -1871,16 +1787,7 @@ void SkeletalSprite::updateBones() animLayers[i].updateBones(); } } - /* - for (int i = animLayers.size()-1; i >= 0; i--) - { - if (animLayers[i].animating) - { - animLayers[i].updateBones(); - return; - } - } - */ + } diff --git a/BBGE/SkeletalSprite.h b/BBGE/SkeletalSprite.h index 8a59887..6e86a23 100644 --- a/BBGE/SkeletalSprite.h +++ b/BBGE/SkeletalSprite.h @@ -63,7 +63,7 @@ public: std::map emitters; std::string prt; std::vector changeStrip; - + bool generateCollisionMask; int animated; Vector originalScale; @@ -77,7 +77,7 @@ public: SkeletalSprite *skeleton; - + void setSegmentProps(int minDist, int maxDist, bool reverse); Vector segmentOffset; @@ -142,7 +142,7 @@ public: SkeletalKeyframe *getLastKeyframe(); SkeletalKeyframe *getFirstKeyframe(); SkeletalKeyframe *getPrevKeyframe(float t); - SkeletalKeyframe *getNextKeyframe(float t); + SkeletalKeyframe *getNextKeyframe(float t); void cloneKey(int key, float toffset); void deleteKey(int key); void reorderKeyframes(); @@ -158,10 +158,10 @@ class SkeletalSprite; class AnimationLayer { public: - + //---- AnimationLayer(); - void setSkeletalSprite(SkeletalSprite *s); + void setSkeletalSprite(SkeletalSprite *s); Animation *getCurrentAnimation(); void animate(const std::string &animation, int loop); void update(float dt); @@ -177,8 +177,7 @@ public: bool isAnimating(); bool contains(const Bone *b) const; void resetPass(); - //float lerp(float v1, float v2, float dt, int lerpType); - + //---- float fallThru; float fallThruSpeed; @@ -188,7 +187,7 @@ public: SkeletalSprite *s; SkeletalKeyframe *lastNewKey; - //int index; + float timer; int loop; Animation blendAnimation; @@ -201,13 +200,13 @@ public: int currentAnimation; bool animating; - + }; class SkeletalSprite : public RenderObject { public: - + SkeletalSprite(); void loadSkeletal(const std::string &fn); bool saveSkeletal(const std::string &fn); @@ -216,9 +215,9 @@ public: Bone *getBoneByIdx(int idx); Bone *getBoneByName(const std::string &name); void animate(const std::string &animation, int loop = 0, int layer=0); - - + + void setTime(float time, int layer=0); void updateBones(); @@ -230,12 +229,12 @@ public: bool isAnimating(int layer=0); - void setTimeMultiplier(float t, int layer=0); + void setTimeMultiplier(float t, int layer=0); Bone* getSelectedBone(bool mouseBased = true); Animation *getCurrentAnimation(int layer=0); - + void nextAnimation(); void prevAnimation(); void lastAnimation(); @@ -244,9 +243,9 @@ public: void setFreeze(bool f); - - - + + + Animation *getAnimation(const std::string& anim); std::vector animations; @@ -270,7 +269,7 @@ public: static std::string animationPath, skinPath, secondaryAnimationPath; static void clearCache(); - + protected: bool frozen; RenderObject *animKeyNotify; diff --git a/BBGE/Slider.cpp b/BBGE/Slider.cpp index cdd7d43..176b7b9 100644 --- a/BBGE/Slider.cpp +++ b/BBGE/Slider.cpp @@ -69,8 +69,8 @@ void Slider::onUpdate(float dt) { RenderObject::onUpdate(dt); - if (alpha.x != 1) return; - + if (alpha.x != 1) return; + bool b = (core->mouse.buttons.left || core->mouse.buttons.right) && fabsf(core->mouse.position.y-position.y) < grabRadius; if (!b && inSlider) inSlider = false; @@ -111,7 +111,7 @@ void Slider::onUpdate(float dt) if (inSlider) { slider.position.x = core->mouse.position.x - position.x + off; - //slider.position.interpolateTo(Vector(core->mouse.position.x - position.x), dt*2); + int w2 = sliderLength/2; if (slider.position.x > w2) { @@ -177,7 +177,7 @@ void CheckBox::onUpdate(float dt) { if (!wasDown) { - //debugLog("setting wasDown"); + wasDown = true; } } @@ -185,9 +185,9 @@ void CheckBox::onUpdate(float dt) { if (wasDown) { - //debugLog("changing value"); + wasDown = false; - if (value !=0) + if (value !=0) { value = 0; } else { value= 1; } diff --git a/BBGE/SoundManager.cpp b/BBGE/SoundManager.cpp index e113ca6..88dd011 100644 --- a/BBGE/SoundManager.cpp +++ b/BBGE/SoundManager.cpp @@ -23,20 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "SoundManager.h" #include "Base.h" -#if defined(BBGE_BUILD_FMODEX) - #ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE - #include "FmodOpenALBridge.h" - #else - #include - #include - #ifdef BBGE_BUILD_WINDOWS - #pragma comment(lib, "fmodex_vc.lib") - #endif - #endif +#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE + #include "FmodOpenALBridge.h" +#else + #include + #include + #ifdef BBGE_BUILD_WINDOWS + #pragma comment(lib, "fmodex_vc.lib") + #endif #endif -#ifdef BBGE_BUILD_FMODEX -#endif SoundManager *sound = 0; @@ -48,7 +44,6 @@ std::string fileType = ".ogg"; namespace SoundCore { -#ifdef BBGE_BUILD_FMODEX typedef std::map SoundMap; SoundMap soundMap; @@ -110,7 +105,6 @@ namespace SoundCore } fadeChs.push_back(fadeCh); } -#endif } using namespace SoundCore; @@ -121,12 +115,12 @@ using namespace SoundCore; 1. use F_CALLBACK. Do NOT force cast your own function to fmod's callback type. 2. return FMOD_ERR_FILE_NOTFOUND in open as required. - 3. return number of bytes read in read callback. Do not get the size and count + 3. return number of bytes read in read callback. Do not get the size and count around the wrong way in fread for example, this would return 1 instead of the number of bytes read. QUESTIONS: - 1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags. + 1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags. Use FMOD_IGNORETAGS in System::createSound / System::createStream if you don't like this behaviour. */ @@ -200,7 +194,6 @@ FMOD_RESULT F_CALLBACK myseek(void *handle, unsigned int pos, void *userdata) void SoundManager::pause() { -#ifdef BBGE_BUILD_FMODEX debugLog("SoundManager::pause"); debugLog("mus"); @@ -222,14 +215,12 @@ void SoundManager::pause() debugLog("update"); result = SoundCore::system->update(); checkError(); - + debugLog("done"); -#endif } void SoundManager::resume() { -#ifdef BBGE_BUILD_FMODEX debugLog("SoundManager::resume"); debugLog("mus"); @@ -253,7 +244,6 @@ void SoundManager::resume() checkError(); debugLog("done"); -#endif } Buffer SoundManager::getBuffer(const std::string &name) @@ -285,7 +275,6 @@ SoundManager::SoundManager(const std::string &defaultDevice) loadProgressCallback = NULL; -#ifdef BBGE_BUILD_FMODEX int channels = 128; @@ -296,7 +285,7 @@ SoundManager::SoundManager(const std::string &defaultDevice) debugLog("system::create"); result = FMOD::System_Create(&SoundCore::system); if (checkError()) goto get_out; - + debugLog("getVersion"); result = SoundCore::system->getVersion(&version); if (checkError()) goto get_out; @@ -332,7 +321,7 @@ SoundManager::SoundManager(const std::string &defaultDevice) debugLog("err_output_createbuffer, speaker mode"); result = SoundCore::system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO); if (checkError()) goto get_out; - + debugLog("init 2"); result = SoundCore::system->init(channels, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */ if (checkError()) goto get_out; @@ -342,30 +331,7 @@ SoundManager::SoundManager(const std::string &defaultDevice) SoundCore::system->getNumChannels(&channels); #endif - //FMOD::Debug_SetLevel(FMOD_DEBUG_LEVEL_ALL); - /* - result = FMOD::System_Create(&SoundCore::system); // Create the main system object. - if (checkError()) - { - exit(-1); - } - - result = SoundCore::system->init(64, FMOD_INIT_NORMAL, 0); // Initialize FMOD. - if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) - { - debugLog("FMOD_ERR_OUTPUT_CREATEBUFFER, setting stereo speaker mode"); - SoundCore::system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO); - result = SoundCore::system->init(64, FMOD_INIT_NORMAL, 0); - if (checkError()) - exit(-1); - } - else - { - if (checkError()) - exit(-1); - } - */ debugLog("set file system"); result = SoundCore::system->setFileSystem(myopen, myclose, myread, myseek, 2048); @@ -396,12 +362,6 @@ SoundManager::SoundManager(const std::string &defaultDevice) if (checkError()) { dspReverb = 0; } - //dspReverb->setParameter(FMOD_DSP_REVERB_ROOMSIZE, 0.5); - //dspReverb->setParameter(FMOD_DSP_REVERB_DAMP, 0.5); - //dspReverb->setParameter(FMOD_DSP_REVERB_WETMIX, 0.33); - //dspReverb->setParameter(FMOD_DSP_REVERB_DRYMIX, 0.66); - //dspReverb->setParameter(FMOD_DSP_REVERB_WIDTH, 1.0); - //dspReverb->setParameter(FMOD_DSP_REVERB_MODE, 0); // 0 or 1 if (dspReverb) { @@ -414,7 +374,6 @@ SoundManager::SoundManager(const std::string &defaultDevice) } -#endif enabled = true; @@ -438,7 +397,6 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on) { if (!enabled) return; -#ifdef BBGE_BUILD_FMODEX bool active = false; @@ -454,7 +412,6 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on) break; } -#endif } @@ -508,25 +465,14 @@ void SoundManager::setMusicFader(float v, float t) return; } - /* - std::ostringstream os; - os << "musicFader " << v << " over " << t; - debugLog(os.str()); - */ + musVol.interpolateTo(Vector(musVol.x, v, musVol.z), t); - -#ifdef BBGE_BUILD_FMODEX - /* - result = group_mus->setVolume(musVol.x*musVol.y*v); - checkError(); - */ -#endif } void SoundManager::error(const std::string &errMsg) { - //std::cout << errMsg << std::endl; + errorLog(errMsg); } @@ -549,17 +495,13 @@ SoundManager::~SoundManager() } soundMap.clear(); -#ifdef BBGE_BUILD_FMODEX SoundCore::system->release(); -#endif } void SoundManager::stopAllSfx() { -#ifdef BBGE_BUILD_FMODEX if (group_sfx) group_sfx->stop(); -#endif } void SoundManager::stopAll() @@ -568,36 +510,35 @@ void SoundManager::stopAll() void SoundManager::onVoiceEnded() { - //debugLog("Voice Ended!"); + event_stopVoice.call(); - //debugLog("checking vox queue"); + if (dspReverb) dspReverb->remove(); if (!voxQueue.empty()) { - //debugLog("calling playVoice"); - + + std::string vox = voxQueue.front(); - - //debugLog("popping voxQueue"); + + if (!voxQueue.empty()) voxQueue.pop(); - - //debugLog("calling playVoice"); + + playVoice(vox, SVT_INTERRUPT); } else { - //debugLog("setting music fader"); + setMusicFader(1, 1); sfxFader = 1; } - //debugLog("done onVoiceEnded"); } @@ -607,19 +548,16 @@ bool SoundManager::isPaused() if (!enabled) return paused; -#ifdef BBGE_BUILD_FMODEX result = masterChannelGroup->getPaused(&paused); checkError(); -#endif return paused; } void SoundManager::clearFadingSfx() { -#ifdef BBGE_BUILD_FMODEX SoundCore::FadeChs::iterator i = fadeChs.begin(); for (; i != fadeChs.end(); i++) @@ -633,7 +571,6 @@ void SoundManager::clearFadingSfx() } SoundCore::fadeChs.clear(); -#endif } @@ -647,7 +584,6 @@ void SoundManager::update(float dt) musVol.update(dt); -#ifdef BBGE_BUILD_FMODEX if (musicChannel) { @@ -668,10 +604,10 @@ void SoundManager::update(float dt) if (musicChannel) { // fader value - + result = musicChannel->setVolume(musVol.y*1.0f); checkError(); - + if (musVol.y <= 0 && stopMusicOnFadeOut) { @@ -740,7 +676,7 @@ void SoundManager::update(float dt) continue; } } - + if (f->c) { f->c->setVolume(f->v); @@ -753,15 +689,12 @@ void SoundManager::update(float dt) SoundCore::system->update(); -#endif -#if defined(BBGE_BUILD_BASS20) || defined(BBGE_BUILD_FMODEX) || defined(BBGE_BUILD_SDLMIXER) if (wasPlayingVoice && !isPlayingVoice()) { wasPlayingVoice = false; onVoiceEnded(); } -#endif } void SoundManager::fadeMusic(SoundFadeType sft, float t) @@ -770,7 +703,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t) { case SFT_CROSS: { -#ifdef BBGE_BUILD_FMODEX if (musicChannel2) { musicChannel2->stop(); @@ -789,16 +721,13 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t) musicFader2Volume = musVol.y; musicFader2Time = musicFader2Timer = t; -#endif } break; case SFT_OUT: setMusicFader(0, t); -#ifdef BBGE_BUILD_FMODEX stopMusicOnFadeOut = true; -#endif break; default: //setMusMul(0, t); @@ -808,7 +737,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t) bool SoundManager::isPlayingMusic() { -#ifdef BBGE_BUILD_FMODEX if (musicChannel) { @@ -817,13 +745,7 @@ bool SoundManager::isPlayingMusic() return b; } -#endif -#ifdef BBGE_BUILD_BASS20 - - return musicStream != 0; - -#endif return false; } @@ -832,12 +754,10 @@ void SoundManager::setMusicVolume(float v) { musVol.x = v; -#ifdef BBGE_BUILD_FMODEX result = group_mus->setVolume(v); checkError(); -#endif } void SoundManager::setSfxVolume(float v) @@ -854,15 +774,12 @@ void SoundManager::setVoiceVolume(float v) { voxVol.x = v; -#ifdef BBGE_BUILD_FMODEX result = group_vox->setVolume(v); checkError(); -#endif } bool SoundManager::isPlayingVoice() { -#ifdef BBGE_BUILD_FMODEX if (voiceChannel) { @@ -882,7 +799,6 @@ bool SoundManager::isPlayingVoice() return b; } -#endif return false; } @@ -893,7 +809,7 @@ void SoundManager::setSfxChannelsVolume(float v) bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float vmod) { - //debugLog("playVoice, masterSoundLock: " + name); + if (!enabled) return false; @@ -902,7 +818,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float n = name; stringToLower(n); - + if (!voicePath2.empty()) { fn = voicePath2 + name + fileType; @@ -953,12 +869,10 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float if (playNow) { -#ifdef BBGE_BUILD_FMODEX if (voiceStream) { stopVoice(); } -#endif debugLog("play now"); @@ -979,7 +893,6 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float } } -#ifdef BBGE_BUILD_FMODEX // FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE. @@ -994,7 +907,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float } if (voiceStream) - { + { if (!reverbKeyword.empty()) { @@ -1003,7 +916,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float if (dspReverb) { bool active = false; - + result = dspReverb->getActive(&active); checkError(); @@ -1033,7 +946,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float result = voiceChannel->setChannelGroup(group_vox); checkError(); - + if (vmod != -1) { result = voiceChannel->setVolume(vmod); @@ -1043,10 +956,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float result = voiceChannel->setPriority(1); checkError(); - /* - result = dspReverb->remove(); - checkError(); - */ + voiceChannel->setFrequency(1); voiceChannel->setCallback(NULL); @@ -1061,7 +971,6 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float wasPlayingVoice = true; } -#endif lastVoice = n; event_playVoice.call(); @@ -1077,7 +986,6 @@ void SoundManager::updateChannelVolume(void *ch, float v) float SoundManager::getVoiceTime() { -#ifdef BBGE_BUILD_FMODEX if (isPlayingVoice()) { @@ -1086,7 +994,6 @@ float SoundManager::getVoiceTime() return float(position) * 0.001f; } -#endif return 0; } @@ -1095,11 +1002,10 @@ void *SoundManager::playSfx(const PlaySfx &play) { if (!enabled) return 0; -#ifdef BBGE_BUILD_FMODEX FMOD::Channel *channel = 0; FMOD::Sound *sound = 0; - + if (play.handle) sound = (FMOD::Sound*)play.handle; @@ -1168,7 +1074,6 @@ void *SoundManager::playSfx(const PlaySfx &play) checkError(); return channel; -#endif return 0; @@ -1194,11 +1099,7 @@ bool SoundManager::isPlayingMusic(const std::string &name) std::string test = name; stringToLower(test); - /* - std::ostringstream os; - os << "checking lastMusic: " << lastMusic << " test: " << test; - debugLog(os.str()); - */ + if (test == lastMusic) return true; @@ -1218,9 +1119,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa { if (isPlayingMusic(name)) { - #ifdef BBGE_BUILD_OPENALOGG - if (masterSoundLock) SDL_mutexV(masterSoundLock); - #endif return false; } } @@ -1251,7 +1149,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa lastMusic = name; stringToLower(lastMusic); -#ifdef BBGE_BUILD_FMODEX if (sft == SFT_CROSS) { @@ -1303,7 +1200,7 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa if (musicStream) { - + result = SoundCore::system->playSound(FMOD_CHANNEL_FREE, musicStream, true, &musicChannel); checkError(); @@ -1345,7 +1242,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa { debugLog("Failed to create music stream: " + fn); } -#endif return true; } @@ -1353,7 +1249,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa void SoundManager::stopMusic() { -#ifdef BBGE_BUILD_FMODEX if (musicChannel) { musicChannel->stop(); @@ -1366,14 +1261,12 @@ void SoundManager::stopMusic() musicStream = 0; musicChannel = 0; } -#endif playingMusicOnce = false; lastMusic = ""; } void SoundManager::stopSfx(void *channel) { -#ifdef BBGE_BUILD_FMODEX if (!channel) return; FMOD::Channel *ch = (FMOD::Channel*)channel; if (ch) @@ -1382,12 +1275,10 @@ void SoundManager::stopSfx(void *channel) checkError(); ch = 0; } -#endif } void SoundManager::fadeSfx(void *channel, SoundFadeType sft, float t) { -#ifdef BBGE_BUILD_FMODEX if (!channel) return; if (sft == SFT_OUT) { @@ -1403,13 +1294,11 @@ void SoundManager::fadeSfx(void *channel, SoundFadeType sft, float t) SoundCore::addFadeCh(f); } } -#endif } void SoundManager::stopVoice() { -#ifdef BBGE_BUILD_FMODEX if (voiceChannel) { bool playing = false; @@ -1430,7 +1319,6 @@ void SoundManager::stopVoice() voiceStream = 0; } onVoiceEnded(); -#endif } @@ -1446,7 +1334,7 @@ void loadCacheSoundsCallback (const std::string &filename, intptr_t param) sm = (SoundManager*)param; if (!sm->enabled) { - //sm->erorr(); + debugLog("Disabled: Won't Load Sample ["+filename+"]"); return; } @@ -1513,7 +1401,6 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s stringToLower(name); -#ifdef BBGE_BUILD_FMODEX FMOD::Sound * sound = SoundCore::soundMap[name]; @@ -1540,11 +1427,8 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s } return sound; -#endif -#ifdef BBGE_BUILD_FMODEX -#endif return Buffer(); } @@ -1553,24 +1437,14 @@ Buffer SoundManager::loadLocalSound(const std::string &filename) { Buffer b = loadSoundIntoBank(filename, localSoundPath, fileType, SFXLOAD_LOCAL); -#ifdef BBGE_BUILD_FMODEX return b; -#endif return BBGE_AUDIO_NOCHANNEL; } void SoundManager::setMusicSpeed(float speed) { - /* - FMOD_CAPS caps; - FMOD_SPEAKERMODE speakerMode; - int minf, maxf; - SoundCore::system->getDriverCaps(0, &caps, &minf, &maxf, &speakerMode); - std::ostringstream os; - os << "minf: " << minf << " maxf: " << maxf; - debugLog(os.str()); - */ + musicChannel->setFrequency(speed); } @@ -1583,7 +1457,6 @@ void SoundManager::setModSpeed(float speed) void SoundManager::clearLocalSounds() { -#ifdef BBGE_BUILD_FMODEX for (LocalSounds::iterator i = localSounds.begin(); i != localSounds.end(); i++) { std::string snd = (*i); @@ -1593,12 +1466,10 @@ void SoundManager::clearLocalSounds() soundMap[snd] = 0; } localSounds.clear(); -#endif } bool SoundManager::checkError() { -#ifdef BBGE_BUILD_FMODEX if (result != FMOD_OK) { std::ostringstream os; @@ -1640,7 +1511,6 @@ bool SoundManager::checkError() debugLog(os.str()); return true; } -#endif return false; } diff --git a/BBGE/SoundManager.h b/BBGE/SoundManager.h index 245388a..bb63061 100644 --- a/BBGE/SoundManager.h +++ b/BBGE/SoundManager.h @@ -27,36 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Vector.h" -// if using SDL_MIXER -//const int BBGE_AUDIO_NOCHANNEL = -1; - - - #define BBGE_BUILD_FMODEX -//#define BBGE_BUILD_BASS20 -//#define BBGE_BUILD_SDLMIXER -//#define BBGE_BUILD_IRRKLANG -//#define BBGE_BUILD_OPENALOGG - - - -#ifdef BBGE_BUILD_OPENALOGG - const int BBGE_AUDIO_NOCHANNEL = -1; -#elif defined(BBGE_BUILD_FMODEX) - const int BBGE_AUDIO_NOCHANNEL = 0; -#endif - +const int BBGE_AUDIO_NOCHANNEL = 0; const int BBGE_AUDIO_LOOPINFINITE = -1; const int BBGE_AUDIO_LOOPNONE = 0; namespace SoundCore { -#if defined(BBGE_BUILD_OPENALOGG) - //struct Buffer; -#elif defined(BBGE_BUILD_FMODEX) typedef void *Buffer; -#endif } enum SoundEffectType @@ -204,19 +183,6 @@ public: void pause(); void resume(); - /* - void setMusVol(float v, float t=0); - void setSfxVol(float v, float t=0); - void setVoxVol(float v, float t=0); - - void setMusMul(float v, float t=0); - void setSfxMul(float v, float t=0); - void setVoxMul(float v, float t=0); - - float getTotalSfxVol(); - float getTotalMusVol(); - float getTotalVoxVol(); - */ float getVoiceTime(); @@ -280,6 +246,4 @@ extern SoundManager *sound; - - #endif diff --git a/BBGE/SpawnParticleData.cpp b/BBGE/SpawnParticleData.cpp index f6f89cd..e38ef2b 100644 --- a/BBGE/SpawnParticleData.cpp +++ b/BBGE/SpawnParticleData.cpp @@ -62,7 +62,7 @@ SpawnParticleData::SpawnParticleData() spawnArea = SPAWN_CIRCLE; randomVelocityMagnitude = 0; randomVelocityRange = 360; - //updateMultiplier = 1; + copyParentRotation = 0; justOne = didOne = false; flipH = flipV = 0; diff --git a/BBGE/StateMachine.cpp b/BBGE/StateMachine.cpp index 88895ff..46789ee 100644 --- a/BBGE/StateMachine.cpp +++ b/BBGE/StateMachine.cpp @@ -44,7 +44,7 @@ int StateMachine::getPrevState() { return prevState; } - + void StateMachine::perform(int state, float time) { //debugLog("in perform"); @@ -52,7 +52,7 @@ void StateMachine::perform(int state, float time) prevState = currentState; nextState = state; //debugLog("onExitState"); - + // do this to prevent scripts from repeating endlessly when running main loops enqueuedState = STATE_NONE; @@ -63,9 +63,9 @@ void StateMachine::perform(int state, float time) nextState = STATE_NONE; //debugLog("onActionInit"); onEnterState(currentState); - + //debugLog("done"); -} +} void StateMachine::setState(int state, float time, bool force) { @@ -95,7 +95,7 @@ void StateMachine::onEnterState(int state) void StateMachine::onExitState(int state) { } - + void StateMachine::stopState(int state) { onExitState(state); diff --git a/BBGE/StateMachine.h b/BBGE/StateMachine.h index b86ba93..86387ad 100644 --- a/BBGE/StateMachine.h +++ b/BBGE/StateMachine.h @@ -28,7 +28,7 @@ class StateMachine public: StateMachine (); virtual ~StateMachine() {} - + void setState(int state, float time = -1, bool force = false); void stopState(int state); bool isState(int state); @@ -41,7 +41,7 @@ public: enum { STATE_NONE = -1 - }; + }; virtual bool canSetState(int state); protected: @@ -51,14 +51,14 @@ protected: int currentState, nextState, prevState, enqueuedState; float stateTime, enqueuedTime, stateExtraDT; - + void onUpdate (float dt); void resetStateCounter() { stateCounter = 0; } private: float stateCounter; - + }; #endif diff --git a/BBGE/StateManager.cpp b/BBGE/StateManager.cpp index f0a81ad..987b3c1 100644 --- a/BBGE/StateManager.cpp +++ b/BBGE/StateManager.cpp @@ -41,7 +41,7 @@ void StateObject::removeState() { clearActions(); clearCreatedEvents(); - //stateManager->getState(name)->eraseRenderObjects(); + } void StateObject::addRenderObject(RenderObject *renderObject, int layer) @@ -71,11 +71,7 @@ StateData::StateData() StateData::~StateData() { - /* - std::ostringstream os; - os << "removing " << renderObjects.size() << " render Objects"; - MessageBox(0,os.str().c_str(),"",MB_OK); - */ + for (int i = 0; i < renderObjects.size(); i++) { removeRenderObject (renderObjects[i]); @@ -114,7 +110,7 @@ void StateData::removeRenderObjectFromList(RenderObject *renderObject) } // assume this only happens on render state end -void StateData::eraseRenderObjects() +void StateData::eraseRenderObjects() { // why clear garbage here? //core->clearGarbage(); @@ -219,7 +215,7 @@ void StateManager::pushState(const std::string &s) s->stateObject = stateObjects[state]; stateObjects[state]->applyState(); } - + stateChangeFlag = true; } } @@ -252,31 +248,18 @@ void StateManager::popState() std::string StateManager::getNameFromDerivedClassTypeName(const std::string &typeidName) { -/* - int loc = typeidName.find_last_of("class "); - if (loc != std::string::npos) - { - std::string tmp = typeidName.substr(6, typeidName.length()); - int loc2 = tmp.find_last_of("::"); - if (loc2 != std::string::npos) - return tmp.substr(loc2+1, tmp.size()); - else - return tmp; - } - else - return typeidName; - */ + return ""; } void StateManager::registerStateObject(StateObject *stateObject, const std::string &name) { - //const char *c = typeid(*stateObject).name(); + stateObject->name = name; stringToLower(stateObject->name); - //getNameFromDerivedClassTypeName(c); + if (stateObject->name.empty()) { exit_error("StateManager::registerStateObject - Empty name."); @@ -284,10 +267,7 @@ void StateManager::registerStateObject(StateObject *stateObject, const std::stri if (!stateObjects[stateObject->name]) stateObjects[stateObject->name] = stateObject; - /* - if (c) - free((void*)c); - */ + } StateObject *StateManager::addStateInstance(StateObject *s) diff --git a/BBGE/StateManager.h b/BBGE/StateManager.h index faadbfc..d92df2e 100644 --- a/BBGE/StateManager.h +++ b/BBGE/StateManager.h @@ -55,7 +55,7 @@ public: StateObject(); virtual ~StateObject(); void action(int id, int state); - + virtual void applyState(){} virtual void removeState(); virtual void update(float dt); @@ -75,19 +75,19 @@ public: StateManager(); ~StateManager(); - + void clearStateObjects(); virtual void applyState (const std::string &state) {} virtual void removeState (std::string state); - + void enqueueJumpState (const std::string &state, bool force = false, bool staged = false); bool isStateJumpPending(); void pushState(const std::string &state); void popState(); void popAllStates(); - + StateData *getState(const std::string &state); StateData *getTopStateData(); @@ -120,7 +120,7 @@ protected: typedef std::map StateObjectMap; StateObjectMap stateObjects; - + private: void jumpState (const std::string &state); // call enqueueJumpState }; diff --git a/BBGE/Strings.cpp b/BBGE/Strings.cpp index 6b1a398..5bbeb26 100644 --- a/BBGE/Strings.cpp +++ b/BBGE/Strings.cpp @@ -159,9 +159,9 @@ std::string getInputCodeToUserString(int key) use = "Right Mouse Button"; if (use == "MOUSE_BUTTON_MIDDLE") use = "Middle Mouse Button"; - + return use; - //return (*i).first; + } } return ""; diff --git a/BBGE/TTFFont.cpp b/BBGE/TTFFont.cpp index dd0d7d3..00e1376 100644 --- a/BBGE/TTFFont.cpp +++ b/BBGE/TTFFont.cpp @@ -233,15 +233,7 @@ int TTFText::findLine(const std::string &label) void TTFText::onRender() { - /* - glColor4f(0,0,0,0.5); - glBegin(GL_QUADS); - glVertex2f(-hw, h/2); - glVertex2f(hw, h/2); - glVertex2f(hw, -h/2); - glVertex2f(-hw, -h/2); - glEnd(); - */ + for (int i = 0; i < text.size(); i++) { @@ -268,12 +260,5 @@ void TTFText::onRender() RenderObject::lastTextureApplied = 0; - /* - glBindTexture(GL_TEXTURE_2D, 0); - glLineWidth(2); - glBegin(GL_LINES); - glVertex2f(-hw, 5); - glVertex2f(hw, 5); - glEnd(); - */ + } diff --git a/BBGE/Texture.cpp b/BBGE/Texture.cpp index ba68b80..8597fdb 100644 --- a/BBGE/Texture.cpp +++ b/BBGE/Texture.cpp @@ -29,40 +29,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif -//#include "pngLoad.h" -//#include "jpeg/jpeglib.h" -/* -#include -#include -#include -*/ -#ifdef Z2D_J2K -//..\j2k-codec\j2k-codec.lib - #include "..\j2k-codec\j2k-codec.h" -#endif -#ifdef BBGE_BUILD_OPENGL + + GLint Texture::filter = GL_LINEAR; GLint Texture::format = 0; -#endif bool Texture::useMipMaps = true; -/* -#ifdef BBGE_BUILD_OPENGL -#include "glext/glext.h" -#endif -*/ Texture::Texture() { -#ifdef BBGE_BUILD_OPENGL textures[0] = 0; -#endif -#ifdef BBGE_BUILD_DIRECTX - d3dTexture = 0; -#endif width = height = 0; repeat = false; @@ -79,7 +58,6 @@ Texture::~Texture() void Texture::read(int tx, int ty, int w, int h, unsigned char *pixels) { -#ifdef BBGE_BUILD_OPENGL if (tx == 0 && ty == 0 && w == this->width && h == this->height) { glBindTexture(GL_TEXTURE_2D, textures[0]); @@ -94,12 +72,10 @@ void Texture::read(int tx, int ty, int w, int h, unsigned char *pixels) << tx << "," << ty << "+" << w << "x" << h << ")"; debugLog(os.str()); } -#endif } void Texture::write(int tx, int ty, int w, int h, const unsigned char *pixels) { -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, textures[0]); glTexSubImage2D(GL_TEXTURE_2D, 0, @@ -145,12 +121,10 @@ void Texture::write(int tx, int ty, int w, int h, const unsigned char *pixels) pixels Specifies a pointer to the image data in memory. */ -#endif } void Texture::unload() { -#ifdef BBGE_BUILD_OPENGL if (textures[0]) { ow = width; @@ -165,28 +139,17 @@ void Texture::unload() glDeleteTextures(1, &textures[0]); textures[0] = 0; } -#endif } void Texture::destroy() { -#ifdef BBGE_BUILD_OPENGL unload(); -#endif -#ifdef BBGE_BUILD_DIRECTX - if (d3dTexture) - { - d3dTexture->Release(); - d3dTexture = 0; - } -#endif core->removeTexture(this); } int Texture::getPixelWidth() { -#ifdef BBGE_BUILD_OPENGL int w = 0, h = 0; unsigned int size = 0; unsigned char *data = getBufferAndSize(&w, &h, &size); @@ -210,14 +173,10 @@ int Texture::getPixelWidth() } free(data); return largestx - smallestx; -#elif defined(BBGE_BUILD_DIRECTX) - return 0; -#endif } int Texture::getPixelHeight() { -#ifdef BBGE_BUILD_OPENGL int w = 0, h = 0; unsigned int size = 0; unsigned char *data = getBufferAndSize(&w, &h, &size); @@ -241,9 +200,6 @@ int Texture::getPixelHeight() } free(data); return largesty - smallesty; -#elif defined(BBGE_BUILD_DIRECTX) - return 0; -#endif } void Texture::reload() @@ -253,11 +209,7 @@ void Texture::reload() unload(); load(loadName); - /*if (ow != -1 && oh != -1) - { - width = ow; - height = oh; - }*/ + debugLog("DONE"); } @@ -287,12 +239,7 @@ bool Texture::load(std::string file) pos = std::string::npos; } - /*if (core->debugLogTextures) - { - std::ostringstream os; - os << "pos [" << pos << "], file :" << file; - debugLog(os.str()); - }*/ + bool found = exists(file); @@ -310,35 +257,14 @@ bool Texture::load(std::string file) file = localisePathInternalModpath(file); file = core->adjustFilenameCase(file); - /* - std::ostringstream os; - os << "Loading texture [" << file << "]"; - debugLog(os.str()); - */ + std::string post = file.substr(file.size()-3, 3); stringToLower(post); if (post == "png") { -#ifdef BBGE_BUILD_OPENGL return loadPNG(file); -#endif -#ifdef BBGE_BUILD_DIRECTX - D3DXCreateTextureFromFile(core->getD3DDevice(), file.c_str(), &this->d3dTexture); - if (!d3dTexture) - { - errorLog ("failed to load texture"); - } - else - { - D3DSURFACE_DESC desc; - this->d3dTexture->GetLevelDesc(0,&desc); - - width = desc.Width; - height = desc.Height; - } -#endif } else if (post == "zga") { @@ -364,7 +290,6 @@ bool Texture::load(std::string file) void Texture::apply(bool repeatOverride) { -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, textures[0]); if (repeat || repeatOverride) { @@ -384,11 +309,6 @@ void Texture::apply(bool repeatOverride) repeating = false; } } -#endif -#ifdef BBGE_BUILD_DIRECTX - core->getD3DDevice()->SetTexture(0, d3dTexture); - -#endif } void Texture::unbind() @@ -400,13 +320,12 @@ bool Texture::loadPNG(const std::string &file) if (file.empty()) return false; bool good = false; -#ifdef BBGE_BUILD_OPENGL pngInfo info; int pngType = PNG_ALPHA; - + if (format != 0) { if (format == GL_LUMINANCE_ALPHA) @@ -444,7 +363,6 @@ bool Texture::loadPNG(const std::string &file) if(memptr) delete [] memptr; -#endif return good; } diff --git a/BBGE/Texture.h b/BBGE/Texture.h index 643a54a..c2933fc 100644 --- a/BBGE/Texture.h +++ b/BBGE/Texture.h @@ -51,26 +51,21 @@ public: int getPixelWidth(); int getPixelHeight(); - + void destroy(); - + int width, height; static ImageTGA *TGAload(const char* filename); static ImageTGA *TGAloadMem(void *mem, int size); - + static bool useMipMaps; bool repeat, repeating; -#ifdef BBGE_BUILD_OPENGL static GLint filter; static GLint format; GLuint textures[1]; -#endif -#ifdef BBGE_BUILD_DIRECTX - LPDIRECT3DTEXTURE9 d3dTexture; -#endif void reload(); @@ -94,7 +89,7 @@ protected: int ow, oh; TextureLoadResult loadResult; - + }; #define UNREFTEX(x) if (x) {x = NULL;} diff --git a/BBGE/Vector.cpp b/BBGE/Vector.cpp index 6dfc060..0b7a328 100644 --- a/BBGE/Vector.cpp +++ b/BBGE/Vector.cpp @@ -39,7 +39,6 @@ void Vector::rotate2DRad(float rad) Vector getRotatedVector(const Vector &vec, float rot) { -#ifdef BBGE_BUILD_OPENGL glPushMatrix(); glLoadIdentity(); @@ -59,9 +58,6 @@ Vector getRotatedVector(const Vector &vec, float rot) glPopMatrix(); return Vector(x,y,z); -#elif defined(BBGE_BUILD_DIRECTX) - return vec; -#endif } // note update this from float lerp @@ -97,7 +93,7 @@ float Bias( float x, float biasAmt ) static float lastExponent = 0; if( lastAmt != biasAmt ) { - lastExponent = logf( biasAmt ) * -1.4427f; // (-1.4427 = 1 / log(0.5)) + lastExponent = logf( biasAmt ) * -1.4427f; } return powf( x, lastExponent ); } @@ -304,7 +300,6 @@ Vector VectorPath::getValue(float usePercent) else if (from && !target) { // Should only happen at end -// msg ("returning just a value"); return from->value; } else if (from && target && from==target) @@ -313,83 +308,22 @@ Vector VectorPath::getValue(float usePercent) } else if (from && target) { - //bool smoothing = false; + Vector v; float perc=0; perc = ((usePercent - from->percent)/(target->percent-from->percent)); - //perc = Gain(perc, 0.8); + Vector targetValue = target->value; Vector fromValue = from->value; - - /* - int nexti = i + 1; - int previ = i - 1; - if (perc > 0.5f && nexti < pathNodes.size()) - { - float scale = ((perc-0.5f)/0.5f) * 0.1f; - targetValue = targetValue * (1.0f-scale) + pathNodes[nexti].value * scale; - } - else if (perc < 0.5f && previ > 0) - { - float scale = (1.0f-(perc/0.5f)) * 0.1f; - targetValue = targetValue * (1.0f-scale) + pathNodes[previ].value * scale; - } - */ - + + + v = (targetValue - fromValue) * (perc); v += fromValue; return v; - /* - int nexti = i + 1; - int previ = i - 1; - if (smoothing && perc >= 0.5f && nexti < pathNodes.size() && nexti >= 0) - { - VectorPathNode *next = &pathNodes[nexti]; - float nextPerc = perc - 0.5f; - v = (target->value - from->value) * (perc-nextPerc); - Vector v2 = (next->value - from->value) * nextPerc; - v = v+v2; - v += from->value; - } - else if (smoothing && perc <= 0.5f && previ < pathNodes.size() && previ >= 0) - { - VectorPathNode *prev = &pathNodes[previ]; - float prevPerc = perc + 0.5f; - v = (target->value - from->value) * (perc-prevPerc); - Vector v2 = (from->value - prev->value) * prevPerc; - //v = (v + v2)/2.0f; - v = v+v2; - v += from->value; - } - else - { - v = (target->value - from->value) * (perc); - v += from->value; - } - */ - /* - int nexti = i + 1; - Vector perp; - if (smoothing && nexti < pathNodes.size() && nexti >= 0) - { - VectorPathNode *next = &pathNodes[nexti]; - Vector perp = (next->value - from->value); - perp = perp.getPerpendicularLeft(); - Vector p = getNearestPointOnLine(from->value, next->value, target->value); - float dist = (target->value - p).getLength2D(); - if (dist > 0) - { - float bulge = sinf(perc * PI); - perp |= dist; - perp *= bulge; - } - } - */ - - - + } return Vector(0,0,0); } @@ -410,21 +344,17 @@ float InterpolatedVector::interpolateTo(Vector vec, float timePeriod, int loopTy data->ease = ease; data->timePassed = 0; - //data->fakeTimePassed = 0; + if (timePeriod < 0) { timePeriod = -timePeriod; timePeriod = (vec-Vector(x,y,z)).getLength3D() / timePeriod; - /* - std::ostringstream os; - os << "calced: " << timePeriod; - debugLog(os.str()); - */ + } data->timePeriod = timePeriod; data->from = Vector (this->x, this->y, this->z); data->target = vec; - + data->loopType = loopType; data->pingPong = pingPong; @@ -521,20 +451,8 @@ void InterpolatedVector::doInterpolate(float dt) { InterpolatedVectorData *data = ensureData(); - //errorLog ("gothere"); - /* - // old method - if (data->ease) - { - float diff = data->timePassed / data->timePeriod; - if (diff > 0.5f) - diff = 1.0f - diff; - diff /= 0.5f; - diff *= 2; - //diff += 0.5f; - data->fakeTimePassed += dt*diff; - } - */ + + data->timePassed += dt; if (data->timePassed >= data->timePeriod) { @@ -566,28 +484,13 @@ void InterpolatedVector::doInterpolate(float dt) { Vector v; - /* - // old method - if (data->ease) - { - v = lerp(data->from, data->target, (data->timePassed / data->timePeriod), data->ease); - //v = (data->target - data->from) * - //v = (data->target - data->from) * (data->fakeTimePassed / data->timePeriod); - } - else - { - float perc = data->timePassed / data->timePeriod; - v = (data->target - data->from) * perc; - } - v += data->from; - */ v = lerp(data->from, data->target, (data->timePassed / data->timePeriod), data->ease ? LERP_EASE : LERP_LINEAR); this->x = v.x; this->y = v.y; this->z = v.z; - //*updatee += data->from; + } } diff --git a/BBGE/Vector.h b/BBGE/Vector.h index cb87cff..6d3ceb4 100644 --- a/BBGE/Vector.h +++ b/BBGE/Vector.h @@ -23,12 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include +#include #include "Event.h" -#ifdef BBGE_BUILD_DIRECTX - #include -#endif typedef float scalar_t; class Vector @@ -53,7 +50,7 @@ public: v[0] = x; v[1] = y; v[2] = z; v[3] = param; return v; } - + // vector assignment const Vector &operator=(const Vector &vec) { @@ -84,7 +81,7 @@ public: // vector add (opposite of negation) const Vector operator+() const - { + { return Vector(*this); } @@ -98,13 +95,13 @@ public: // vector subtraction const Vector operator-(const Vector& vec) const - { + { return Vector(x - vec.x, y - vec.y, z - vec.z); } - + // vector negation const Vector operator-() const - { + { return Vector(-x, -y, -z); } @@ -124,7 +121,7 @@ public: x *= s; y *= s; z *= s; - + return *this; } @@ -178,11 +175,6 @@ public: return vec*s; } -/* friend inline const Vector operator*(const Vector &vec, const scalar_t &s) - { - return Vector(vec.x*s, vec.y*s, vec.z*s); - } -*/ // divecide by scalar const Vector operator/(scalar_t s) const { @@ -253,7 +245,7 @@ public: { if (x == 0 && y == 0 && z == 0) { - //debugLog("Normalizing 0 vector"); + x = y = z = 0; } else @@ -265,7 +257,7 @@ public: { if (x == 0 && y == 0) { - //debugLog("Normalizing 0 vector"); + x = y = z= 0; } else @@ -279,27 +271,14 @@ public: return sqrtf(x*x + y*y + z*z); } - /* - // return vector with specified length - const Vector operator | (const scalar_t length) const - { - return *this * (length / !(*this)); - } - // set length of vector equal to length - const Vector& operator |= (const float length) - { - (*this).setLength2D(length); - return *this; - } - */ inline void setLength3D(const float l) { // IGNORE !! if (l == 0) { - //debugLog("setLength3D divide by 0"); + } else { @@ -314,14 +293,14 @@ public: float len = getLength2D(); if (len == 0) { - //debugLog("divide by zero!"); + } else { this->x *= (l/len); this->y *= (l/len); } - //this->z = 0; + } // return angle between two vectors @@ -330,31 +309,14 @@ public: return acosf(*this % normal); } - /* - inline scalar_t cheatLen() const - { - return (x*x + y*y + z*z); - } - inline scalar_t cheatLen2D() const - { - return (x*x + y*y); - } - inline scalar_t getCheatLength3D() const; - */ + inline bool isLength2DIn(float radius) const { return (x*x + y*y) <= (radius*radius); } - // reflect this vector off surface with normal vector - /* - const Vector inline Reflection(const Vector& normal) const - { - const Vector vec(*this | 1); // normalize this vector - return (vec - normal * 2.0f * (vec % normal)) * !*this; - } - */ + inline void setZero() { @@ -392,12 +354,6 @@ public: z += 360; } -#ifdef BBGE_BUILD_DIRECTX - const D3DCOLOR getD3DColor(float alpha) - { - return D3DCOLOR_RGBA(int(x*255), int(y*255), int(z*255), int(alpha*255)); - } -#endif void rotate2DRad(float rad); void rotate2D360(float angle); }; @@ -451,7 +407,7 @@ struct InterpolatedVectorData pathTimeMultiplier = 1; timePassed = 0; timePeriod = 0; - //fakeTimePassed = 0; + ease = false; followingPath = false; } diff --git a/BBGE/bithacks.h b/BBGE/bithacks.h index db9db48..779a083 100644 --- a/BBGE/bithacks.h +++ b/BBGE/bithacks.h @@ -76,9 +76,6 @@ inline unsigned int clz(uint32 x) - - - }; // end namespace bithacks #endif diff --git a/BBGE/glext/glext.h b/BBGE/glext/glext.h index ce0dd28..5fe54e6 100644 --- a/BBGE/glext/glext.h +++ b/BBGE/glext/glext.h @@ -13,21 +13,21 @@ extern "C" { ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** +** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: This software was created using the ** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has ** not been independently verified as being compliant with the OpenGL(R) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b0f227..4fb278f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,14 +298,9 @@ endif(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) # Aquaria/BBGE specific defines... -ADD_DEFINITIONS(-DGL_GLEXT_LEGACY=1) -ADD_DEFINITIONS(-DHAVE_PUTENV=1) -ADD_DEFINITIONS(-DTIXML_USE_STL=1) ADD_DEFINITIONS(-DBBGE_SKIP_CONFIG_HEADERS=1) # if this is not defined, it will use .h files to set the necessary defines -ADD_DEFINITIONS(-DBBGE_BUILD_SDL=1) ADD_DEFINITIONS(-DBBGE_BUILD_FRAMEBUFFER=1) ADD_DEFINITIONS(-DBBGE_BUILD_SHADERS=1) -ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL=1) ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL_DYNAMIC=1) ADD_DEFINITIONS(-DBBGE_BUILD_FMOD_OPENAL_BRIDGE=1) IF(AQUARIA_USE_VFS) diff --git a/win/vc90/Aquaria.vcproj b/win/vc90/Aquaria.vcproj index 3a99342..906b22c 100644 --- a/win/vc90/Aquaria.vcproj +++ b/win/vc90/Aquaria.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\lua-5.1.4\src";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -124,7 +124,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\lua-5.1.4\src";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;NDEBUG;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;NDEBUG;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" diff --git a/win/vc90/BBGE.vcproj b/win/vc90/BBGE.vcproj index 83b0478..f1cb420 100644 --- a/win/vc90/BBGE.vcproj +++ b/win/vc90/BBGE.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -116,7 +116,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" diff --git a/win/vc90/external.vcproj b/win/vc90/external.vcproj index ccc3664..e46154b 100644 --- a/win/vc90/external.vcproj +++ b/win/vc90/external.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_FCNTL_H;FT_CONFIG_OPTION_SYSTEM_ZLIB;FTGL_LIBRARY_STATIC;FT2_BUILD_LIBRARY;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;VFS_ENABLE_C_API=1" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_FCNTL_H;FT_CONFIG_OPTION_SYSTEM_ZLIB;FTGL_LIBRARY_STATIC;FT2_BUILD_LIBRARY;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;VFS_ENABLE_C_API=1" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="3"