Stringc Stringc::get_word(int iword) { int i = 0; int iw = 0; int istart = 0; int iend = 0; // Find the start and end location of the desired iword'th word. while ( i < num_chars && iw <= iword) { // Step through spaces while ( i< num_chars && (char_array[i] == ' ' || char_array[i] == '\t')) i++; // Step through a word and save its start and end location if it // is the desired iword. if ( i < num_chars ) { if ( iw == iword) istart = i; while ( i < num_chars && char_array[i] != ' ' && char_array[i] != '\t') { if ( iw == iword) iend = i; i++; } iw++; } } // Extract the word string from the character array if iword exists. if ( iword < iw && iword >= 0) { int word_size = iend-istart+1; Stringc sword(word_size); for ( i=0; i<word_size; i++) { sword[i] = char_array[istart+i]; } sword[word_size] = '\0'; return sword; } else { cout << "\nError in Stringc::get_word routine.\n"; if ( iword < 0 ) cout << " Negative word index does not make sense.\n"; else cout << " Word index is greater than the number of words.\n"; cout << " Returning an empty string as word\n"; Stringc sword(1); sword[0] = '\0'; return sword; } }
inline void op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec>& X) { arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const sword id = (X.aux_uword_b > 0) ? -sword(X.aux_uword_a) : sword(X.aux_uword_a); const unwrap_check<T1> tmp(X.m, out); const Mat<eT>& A = tmp.M; out = A.diag(id); }
bool TestCharacter::testEquipped() { Handle<Character> testChar(new Character()); testChar->setName("TestChar"); Stats *stats = testChar->getStats(); stats->setBaseStat(Stat::STRENGTH, 10.0f); am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f); BodyPart *part = new BodyPart("arm", BodyPartType::ARM); assert(testChar->addBodyPart(part)); Handle<Item> sword(new Item()); sword->getStatModifiers().addStatModifier(Stat::STRENGTH, StatModifier(5.0f, MOD_ADD)); assert(testChar->equipItem(sword, "arm")); am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(15.0f, stats->getStat(Stat::STRENGTH), 0.0001f); assert(testChar->unequipItem("arm")); am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f); return true; }
bool TestCharacter::testSimple() { Handle<Character> testChar(new Character()); testChar->setName("TestChar"); am_equals("TestChar", testChar->getName().c_str()); assert(testChar->getInventory()); Stats *stats = testChar->getStats(); stats->setBaseStat(Stat::STRENGTH, 10.0f); am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f); Handle<Item> sword(new Item()); StatModifiers &modifiers = sword->getStatModifiers(); modifiers.addStatModifier(Stat::STRENGTH, StatModifier(5, MOD_ADD)); stats->addModifiers(modifiers); am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(15.0f, stats->getStat(Stat::STRENGTH), 0.0001f); stats->removeModifiers(modifiers); modifiers.addStatModifier(Stat::STRENGTH, StatModifier(2.0f, MOD_MULTIPLY)); stats->addModifiers(modifiers); am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(25.0f, stats->getStat(Stat::STRENGTH), 0.0001f); return true; }
arma_warn_unused inline sword randi() { return sword( arma_rng::randi<sword>() ); }
bool TestCharacter::testCopy() { Engine *prevEngine = Engine::getEngine(); Engine *eng = new Engine(); eng->addRace(new Race("human")); Engine::setEngine(eng); Handle<Game> game = new Game(); Handle<Character> testChar(new Character()); testChar->setAge(24); testChar->setName("Melli"); testChar->setCameraOffset(0.8f, 0.4f); DialogueComponent *comp = new DialogueComponent(testChar); comp->setDialogueAvailable("testSub1"); comp->setDialogueAvailable("testSub2"); comp->setSubjectLock("testSub1"); testChar->setDialogueComp(comp); testChar->setFixedToGrid(true); testChar->setGender(Gender::FEMALE); testChar->setGraphic(new Sprite("characters/mainChar/front"), false); testChar->setGridLocation(5, 4); testChar->setLevel(2); testChar->setMaxLevel(10); testChar->setPickupReach(1.4f); testChar->setRace(Engine::getEngine()->getRace("human")); Handle<Inventory> inv(testChar->getInventory()); Handle<Item> sword(new Item()); sword->setGraphic(new Sprite("items/sword")); sword->setGroundGraphic(new Sprite("items/swordGround")); sword->getStatModifiers().addStatModifier(Stat::MAX_DAMAGE, StatModifier(5.0f, MOD_ADD)); sword->getStatModifiers().addStatModifier(Stat::MIN_DAMAGE, StatModifier(3.0f, MOD_ADD)); sword->setItemFullname("Sword", "Wooden", "of Death"); sword->setItemType(ItemCommon::SWORD); sword->setInventorySize(2, 3); inv->addItem(sword, 0, 0); Handle<Item> shield(new Item()); shield->getStatModifiers().addStatModifier(Stat::ARMOUR, StatModifier(4.0f, MOD_MULTIPLY)); shield->getStatModifiers().addStatModifier(Stat::ARMOUR, StatModifier(2.0f, MOD_ADD)); shield->setItemFullname("Shield", "Padded", "of ASD"); shield->setItemType(ItemCommon::SHIELD); shield->setInventorySize(2, 2); inv->addItem(shield, 4, 2); testChar->getStats()->setBaseStat(Stat::HEALTH, 10.0f); testChar->getStats()->setBaseStat(Stat::STRENGTH, 5.5f); testChar->getStats()->setBaseStat(Stat::MAX_DAMAGE, 4.0f); testChar->getStats()->setBaseStat(Stat::MIN_DAMAGE, 4.0f); testChar->getStats()->setBaseStat(Stat::ARMOUR, 7.0f); Handle<Item> swordEquip(new Item(*sword)); swordEquip->setItemFullname("Sword", "Wooden", "of Hit"); testChar->addBodyPart(new BodyPart("arm", BodyPartType::ARM, swordEquip)); testChar->addBodyPart(new BodyPart("torso", BodyPartType::TORSO)); testChar->addBodyPart(new BodyPart("legs", BodyPartType::LEGS)); am_equalsDelta(10.0f, testChar->getStats()->getStat(Stat::HEALTH), 0.0001f); am_equalsDelta(5.5f, testChar->getStats()->getStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(9.0f, testChar->getStats()->getStat(Stat::MAX_DAMAGE), 0.0001f); am_equalsDelta(7.0f, testChar->getStats()->getStat(Stat::MIN_DAMAGE), 0.0001f); am_equalsDelta(7.0f, testChar->getStats()->getStat(Stat::ARMOUR), 0.0001f); Handle<Character> copyChar(new Character(*testChar)); am_equalsDelta(24.0f, copyChar->getAge(), 0.0001f); am_equalsStr("Melli", copyChar->getName()); am_equalsDelta(0.8f, copyChar->getCameraOffsetX(), 0.0001f); am_equalsDelta(0.4f, copyChar->getCameraOffsetY(), 0.0001f); DialogueComponent *copyComp = copyChar->getDialogueComp(); assert(copyComp != comp); assert(copyComp->getAttachedTo() == copyChar); assert(copyComp->isDialogueAvailable("testSub1")); assert(copyComp->isDialogueAvailable("testSub2")); assert(!copyComp->isSubjectLocked("testSub1")); assert(copyComp->isSubjectLocked("testSub2")); assert(copyChar->isFixedToGrid()); assert(copyChar->getGender() == Gender::FEMALE); assert(copyChar->getGraphic() != testChar->getGraphic()); assert(copyChar->getGraphic()->getAsset() == testChar->getGraphic()->getAsset()); am_equals(5, copyChar->getGridLocationX()); am_equals(4, copyChar->getGridLocationY()); am_equals(2, copyChar->getLevel()); am_equals(10, copyChar->getMaxLevel()); am_equalsDelta(1.4f, copyChar->getPickupReach(), 0.0001f); assert(copyChar->getRace() == Engine::getEngine()->getRace("human")); Handle<Inventory> copyInv(copyChar->getInventory()); assert(copyInv.get() && copyInv != inv); Handle<Item> copySword(copyInv->getItemAt(0, 0)); assert(copySword.get() && copySword != sword); am_equals(1u, copySword->getStatModifiers().getModifiers()[Stat::MAX_DAMAGE].size()); am_equalsDelta(5.0f, copySword->getStatModifiers().getModifiers()[Stat::MAX_DAMAGE][0].getValue(), 0.0001f); assert(MOD_ADD == copySword->getStatModifiers().getModifiers()[Stat::MAX_DAMAGE][0].getType()); am_equals(1u, copySword->getStatModifiers().getModifiers()[Stat::MIN_DAMAGE].size()); assert(MOD_ADD == copySword->getStatModifiers().getModifiers()[Stat::MIN_DAMAGE][0].getType()); am_equalsDelta(3.0f, copySword->getStatModifiers().getModifiers()[Stat::MIN_DAMAGE][0].getValue(), 0.0001f); am_equalsStr("Sword", copySword->getItemName()); am_equalsStr("Wooden", copySword->getPrefix()); am_equalsStr("of Death", copySword->getPostfix()); am_equalsStr("Wooden Sword of Death", copySword->getFullItemName()); assert(ItemCommon::SWORD == copySword->getItemType()); am_equals(2, copySword->getInventorySizeX()); am_equals(3, copySword->getInventorySizeY()); assert(copySword->getGraphic() != sword->getGraphic()); assert(copySword->getGraphic()->getAsset() == sword->getGraphic()->getAsset()); assert(copySword->getGroundGraphic() != sword->getGroundGraphic()); assert(copySword->getGroundGraphic()->getAsset() == sword->getGroundGraphic()->getAsset()); Handle<Item> copyShield(copyInv->getItemAt(4, 2)); assert(copyShield.get() && copyShield != shield); am_equals(2u, copyShield->getStatModifiers().getModifiers()[Stat::ARMOUR].size()); am_equalsDelta(4.0f, copyShield->getStatModifiers().getModifiers()[Stat::ARMOUR][0].getValue(), 0.0001f); assert(MOD_MULTIPLY == copyShield->getStatModifiers().getModifiers()[Stat::ARMOUR][0].getType()); am_equalsDelta(2.0f, copyShield->getStatModifiers().getModifiers()[Stat::ARMOUR][1].getValue(), 0.0001f); assert(MOD_ADD == copyShield->getStatModifiers().getModifiers()[Stat::ARMOUR][1].getType()); am_equalsStr("Shield", copyShield->getItemName()); am_equalsStr("Padded", copyShield->getPrefix()); am_equalsStr("of ASD", copyShield->getPostfix()); am_equalsStr("Padded Shield of ASD", copyShield->getFullItemName()); assert(ItemCommon::SHIELD == copyShield->getItemType()); am_equals(2, copyShield->getInventorySizeX()); am_equals(2, copyShield->getInventorySizeY()); am_equalsDelta(10.0f, testChar->getStats()->getBaseStat(Stat::HEALTH), 0.0001f); am_equalsDelta(5.5f, testChar->getStats()->getBaseStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(4.0f, testChar->getStats()->getBaseStat(Stat::MAX_DAMAGE), 0.0001f); am_equalsDelta(4.0f, testChar->getStats()->getBaseStat(Stat::MIN_DAMAGE), 0.0001f); am_equalsDelta(7.0f, testChar->getStats()->getBaseStat(Stat::ARMOUR), 0.0001f); const BodyParts &parts = copyChar->getBodyParts(); assert(parts.hasBodyPart("arm")); assert(parts.hasBodyPart("torso")); assert(parts.hasBodyPart("legs")); Handle<Item> swordEquipCopy(parts.getBodyPart("arm")->getEquippedItem()); assert(swordEquipCopy.get() && swordEquipCopy != swordEquip); am_equalsStr("Wooden Sword of Hit", swordEquipCopy->getFullItemName()); am_equalsDelta(10.0f, copyChar->getStats()->getStat(Stat::HEALTH), 0.0001f); am_equalsDelta(5.5f, copyChar->getStats()->getStat(Stat::STRENGTH), 0.0001f); am_equalsDelta(9.0f, copyChar->getStats()->getStat(Stat::MAX_DAMAGE), 0.0001f); am_equalsDelta(7.0f, copyChar->getStats()->getStat(Stat::MIN_DAMAGE), 0.0001f); am_equalsDelta(7.0f, copyChar->getStats()->getStat(Stat::ARMOUR), 0.0001f); Engine::setEngine(prevEngine); delete eng; return true; }
main() { int x, y, loop = 1, fact = 0; char instring[200], outstring[200], sub[200], vrb[200], rst[200], qwd[200]; char osub[200], ovrb[200], orst[200]; fam = 0; printf("Hello there. My name is Eliza and I was written by Mohan Embar.\n"); printf("Please type \"END\" to end this session.\n"); printf("I'm here to help you if I can. What seems to be the trouble?\n"); while (loop) { printf("\n"); gets(instring); printf("\n"); parse(instring); if (numwords == 0) { switch (x = randnum(2)) { case 1 : printf("Don't you have anything to say?\n"); break; case 2 : printf("Cat got your tongue?\n"); break; } continue; } if (!strcmp(s[1],"END")) { printf("Goodbye. Please come again.\n"); break; } agree(); if (bad_word()) printf(b_word_resp()); else if (naughty_word()) printf(n_word_resp()); else if (x = family()) { fam = x; printf(fam_resp()); strcpy(fam_member,s[fam]); } else if (sword("ALIKE",1)) printf(alike_resp()); else if (sword("ALWAYS",1)) printf(always_resp()); else if (sword("BECAUSE",1)) printf(because_resp()); else if (sword("YES",1)) printf(yes_resp()); else if (sword("NO",1) || sword("NOT",1)) printf(neg_resp()); else if (x = i_am()) { /* If occurrence of I AM x.. */ get_til_stop(x,outstring); /* Get I AM x .. into outstring */ printf(i_am_resp(),outstring); /* Print reponse for this */ } else if (real_quest() || (is_helper(s[1]) && is_sub_pronoun(s[2])) || sub_and_helper()) { if (real_quest()) { strcpy(qwd,s[1]); strcpy(vrb,s[2]); strcpy(sub,s[3]); get_til_stop(4,rst); } else if (is_helper(s[1]) && is_sub_pronoun(s[2])) { strcpy(vrb,s[1]); strcpy(sub,s[2]); get_til_stop(3,rst); strcpy(qwd,"YES"); } else if (sub_and_helper()) { x = find_helper(); y = search_back_sub(x); strcpy(vrb,s[x]); get_til_stop(x+1,rst); getrange(y,x-1,sub); strcpy(qwd,"NO"); } make_lower(qwd); if (strcmp(sub,"I")) make_lower(sub); make_lower(vrb); make_lower(rst); /* First do x verb y responses */ /* printf("\n*** %s\n",sub); */ if (!strcmp(sub," I") || !strcmp(sub,"I")) { printf(you_resp()); } else if (!strcmp(qwd,"no")) { /* Record this statement for later use. */ fact = 1; strcpy(osub,sub); strcpy(ovrb,vrb); strcpy(orst,rst); if (is_be(vrb) && !strcmp(sub," you") && (y = sad_word())) { getrange(y,y,outstring); x = randnum(5)+6; } else if (is_be(vrb) && (y = sad_word())) { getrange(y,y,outstring); x = randnum(2)+11; } else if (is_be(vrb)) x = randnum(6); else x = randnum(4); switch (x) { case 1 : printf("How do you feel about%s?\n",cnnv(sub)); break; case 2 : printf("Why %s%s%s?\n",vrb,sub,rst); break; case 3 : for (y=1;sub[y]=sub[y--];y=y+2); sub[0] = toupper(sub[0]); printf("%s %s%s?\n",sub,vrb,rst); break; case 4 : printf("Could you describe%s for me?\n",cnnv(sub)); break; case 5 : printf("What if%s were not%s?\n",sub,rst); break; case 6 : printf("Would you be happy if%s were not%s?\n",sub, rst); break; case 7 : printf("I'm sorry to hear that you are%s.\n",outstring); break; case 8 : printf("Do you think that coming here will help you not to be%s?\n",outstring); break; case 9 : printf("Let's talk about why you feel%s.\n",outstring); break; case 10 : printf("What happened that made you feel%s?\n",outstring); break; case 11 : printf("What could be the reason for your feeling%s?\n",outstring); break; case 12 : printf("What could cause%s to be%s?\n",cnnv(sub),outstring); break; case 13 : printf("If%s came here, would it help%s not to be%s?\n",sub,cnnv(sub),outstring); break; } } else if (!strcmp(sub,"you")) printf(you_know()); else if (!strcmp(qwd,"yes")) { x = randnum(8); switch (x) { case 1 : printf("You want to know if %s %s%s.\n",sub,vrb,rst); break; case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst); break; case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst); break; case 4 : printf("Why does %s concern you?\n",sub); break; case 5 : printf("Why are you thinking of %s?\n",cnnv(sub)); break; case 6 : printf("Tell me more about %s.\n",cnnv(sub)); break; case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub)); break; case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub)); break; case 9 : printf("Why don't you ask %s?\n",cnnv(sub)); break; } } else { x = randnum(8); switch (x) { case 1 : printf("You want to know %s %s %s%s.\n",qwd,sub,vrb,rst); break; case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst); break; case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst); break; case 4 : printf("Why does %s concern you?\n",sub); break; case 5 : printf("Why are you thinking of %s?\n",cnnv(sub)); break; case 6 : printf("Tell me more about %s.\n",cnnv(sub)); break; case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub)); break; case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub)); break; case 9 : printf("Why don't you ask %s?\n",cnnv(sub)); break; } } } else if (is_command()) printf(command_resp()); else if (vague_quest()) printf(question()); else if ((s[numwords][0] == '?') && !real_quest()) printf(question()); else if (x = sad_word()) { getrange(x,x,outstring); for (y=1;outstring[y]=outstring[y--];y=y+2); outstring[0] = toupper(outstring[0]); printf("%s?\n",outstring); } else if (x = can_spit_out()) { if (x<=(numwords-2) && is_sub_pronoun(s[x]) && (matches("NEED",s[x+1]) || matches("WANT",s[x+1]))) { get_til_stop(x+2,outstring); strcpy(sub,s[x]); if (strcmp(sub,"I")) make_lower(sub); if (strcmp(s[x],"I")) make_lower(s[x]); x = randnum(6); switch (x) { case 1 : printf("What would it mean to %s if %s got%s?\n",cnnv2(s[x]),sub,outstring); break; case 2 : printf("Would %s really be happy if %s got%s?\n",sub,sub,outstring); break; case 3 : printf("Why is getting%s so desirable?\n",outstring); break; case 4 : printf("Okay. Suppose %s got%s. Then what?\n",sub,outstring); break; case 5 : printf("Why is this important to %s?\n",cnnv2(sub)); break; case 6 : printf("What price would %s pay to achieve this?\n",sub); break; } } else { get_til_stop(x,outstring); outstring[1]=toupper(outstring[1]); printf("%s.\n",outstring+1); } } else if (fam) { make_lower(fam_member); printf(family_resp(),fam_member); fam = 0; } else if (fact && (randnum(5)==3)) { printf(old_fact(),osub,ovrb,orst); fact = 0; } else { printf(go_on()); } } }
void Read_Blif_N_Pl(ifstream &bliff, ifstream &plf) { /* First section of this file read blif file and store the information to gate_vec0 and gate_map0 */ string line; int FLAG = 0; // use this indicator to deal with multiple lines of input (later output maybe) while (getline(bliff,line)) { if (line.length()<=1) continue; if (line[0]=='#') continue; // cout<<line<<endl; istringstream sword(line); string temp; while (sword>>temp) { if (temp==".model") break; else if ( (temp==".inputs")||(FLAG==1) ) { // cout<<WordCount(line)<<endl; if (FLAG != 1) { for (int i=0; i<WordCount(line)-1; i++) { sword>>temp; if (temp != "\\") { // cout<<temp<<endl; gate *temp_gate_ptr = new gate; temp_gate_ptr->setGateInfo(temp,"PRI_INPUT",60,100); gate_vec0.push_back(temp_gate_ptr); gate_map0[temp] = temp_gate_ptr; FLAG = 0; } else if (temp == "\\") { FLAG = 1; } } } else if (FLAG == 1) { do{ if (temp !="\\") { gate *temp_gate_ptr = new gate; temp_gate_ptr->setGateInfo(temp,"PRI_INPUT",60,100); gate_vec0.push_back(temp_gate_ptr); gate_map0[temp] = temp_gate_ptr; FLAG = 0; } else if (temp == "\\") { FLAG = 1; } } while (sword>>temp); } } else if (temp==".outputs") break; else if (temp==".end") break; else if (temp==".gate") { gate *temp_gate_ptr = new gate; sword>>temp; string temptype=temp; // cout<<temptype<<" "<<WordCount(line)<<endl; for(int i=0; i<WordCount(line)-3; i++) { sword>>temp; temp_gate_ptr->ipt_nodes.push_back(temp.substr(temp.find_first_of("=")+1)); // cout<<temp<<" "; } sword>>temp; // cout<<temp<<endl; temp_gate_ptr->setGateInfo(temp.substr(temp.find_first_of("=")+1), temptype, 60, 100); gate_vec0.push_back(temp_gate_ptr); gate_map0[temp.substr(temp.find_first_of("=")+1)] = temp_gate_ptr; }
int main( int argc, char *argv[] ) { Ogre::Root* root; Ogre::RenderWindow* window; root = new Ogre::Root( "", "" ); #ifndef _DEBUG root->loadPlugin( "RenderSystem_GL.dll" ); #else root->loadPlugin( "RenderSystem_GL_d.dll" ); #endif root->setRenderSystem( root->getAvailableRenderers()[ 0 ] ); root->initialise( false ); Ogre::NameValuePairList misc; misc[ "title" ] = "FFVII Exporter"; window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc ); FILESYSTEM = new FileSystem(); LOGGER = new Logger( "game.log" ); state = GAME; { BinGZipFile* file = new BinGZipFile( "data/en/WINDOW.BIN" ); File* font_graf = file->ExtractGZip( 1 ); File* font_padding = file->ExtractGZip( 2 ); FontFile font( font_padding ); font.Export( "export_en/ui/fonts/ffvii_en.xml", true ); //font_graf->WriteFile( "font.tim" ); Vram* vram = new Vram(); LoadTimFileToVram( font_graf, 0, vram ); //vram->Save( "text" ); Ogre::TexturePtr ptex; Ogre::HardwarePixelBufferSharedPtr buffer; ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC ); buffer = ptex->getBuffer( 0, 0 ); buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD ); const Ogre::PixelBox& pb = buffer->getCurrentLock(); CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false ); Ogre::Image image; image.loadDynamicImage( ( Ogre::uchar* )pb.data, 256, 256, Ogre::PF_R8G8B8A8 ); image.save( "export_en/ui/fonts/ffvii_en.png" ); buffer->unlock(); delete vram; delete file; } { BinGZipFile* file = new BinGZipFile( "data/jp/WINDOW.BIN" ); File* font_graf = file->ExtractGZip( 1 ); File* font_graf2 = file->ExtractGZip( 2 ); File* font_padding = file->ExtractGZip( 3 ); font_padding->WriteFile( "font_padding.dat" ); FontFile font( font_padding ); font.Export( "export_jp/ui/fonts/ffvii_jp.xml", false ); font_graf->WriteFile( "font.tim" ); font_graf2->WriteFile( "font2.tim" ); Vram* vram = new Vram(); LoadTimFileToVram( font_graf, 0, vram ); LoadTimFileToVram( font_graf2, 0, vram ); //vram->Save( "text" ); Ogre::TexturePtr ptex; Ogre::HardwarePixelBufferSharedPtr buffer; ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 512, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC ); buffer = ptex->getBuffer( 0, 0 ); buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD ); const Ogre::PixelBox& pb = buffer->getCurrentLock(); CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false ); CreateTextureFromVram( pb, vram, 256, 0, 0x90, 0x1f7, 0x380, 0x100, BPP_4 , false ); Ogre::Image image; image.loadDynamicImage( ( Ogre::uchar* )pb.data, 512, 256, Ogre::PF_R8G8B8A8 ); image.save( "export_jp/ui/fonts/ffvii_jp.png" ); buffer->unlock(); delete vram; delete file; } { File sword( "sword.tim" ); Vram* vram = new Vram(); LoadTimFileToVram( &sword, 0, vram ); //vram->Save( "sword" ); Ogre::TexturePtr ptex; Ogre::HardwarePixelBufferSharedPtr buffer; ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC ); buffer = ptex->getBuffer( 0, 0 ); buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD ); const Ogre::PixelBox& pb = buffer->getCurrentLock(); CreateTextureFromVram( pb, vram, 0, 0, 0x0, 0x1e0, 0x0, 0x0, BPP_8 , false ); Ogre::Image image; image.loadDynamicImage( ( Ogre::uchar* )pb.data, 256, 256, Ogre::PF_R8G8B8A8 ); image.save( "sword.png" ); buffer->unlock(); delete vram; } LOGGER->Log("===================== Stop the game!!!"); delete FILESYSTEM; delete LOGGER; delete root; return 0; }
void PlayGame(sf::RenderWindow& window) { sf::View view; sf::Image layout; sf::Music theme; theme.openFromFile("resources/audio/Child of Light - Boss Battle Theme.wav"); theme.play(); int mapNum = rand() % 4 + 1; string mapString("resources/environment/map." + std::to_string(mapNum) + ".png"); //string mapString("resources/environment/map." + std::to_string(mapNum) + ".png"); string outputMapString("Loaded Map " + std::to_string(mapNum) + "."); cout << outputMapString << endl; layout.loadFromFile(mapString); sf::Texture red; sf::Texture green; sf::Texture blue; sf::Texture black; sf::Texture blank; red.loadFromFile("resources/environment/darkgrassyrock.jpg"); green.loadFromFile("resources/environment/playerSpawn.jpg"); blue.loadFromFile("resources/environment/purplecliffrock.jpg"); black.loadFromFile("resources/environment/darkgrassyrock.jpg"); blank.loadFromFile("resources/environment/darkestrock.jpg"); Map currentMap(window, 150, red, green, blue, black, blank, layout); sf::Clock deltaTimeClock; float DeltaTime = 0; // load some resources like textures which will be used for the duration of the game sf::Texture petRockTex; petRockTex.loadFromFile("resources/character/petRock.png"); sf::Clock spawnTime; bool pause = false; sf::Texture reaperBossIdleTex; reaperBossIdleTex.loadFromFile("resources/character/Reaper Boss-Idle.png"); //window.setFramerateLimit(60); //std::vector<Character*> petRockList; std::vector<std::unique_ptr<Character>> petRockList; MeleeWeapon sword("axe", "gold", 5, 9, 10, "Golden-BattleAxe.png"); Player player(100, 10, 10, 10, 10, 10, 10, 10, 10, window, petRockList, DeltaTime, currentMap); //ReaperBoss reaperBoss(500, window, player); player.equipMelee(sword); sf::Font asmanFont; sf::Text pauseText; asmanFont.loadFromFile("resources/font/ASMAN.ttf"); pauseText.setFont(asmanFont); pauseText.setString("Paused"); pauseText.setCharacterSize(200); pauseText.setColor(sf::Color::Red); pauseText.setPosition(player.position.x - 350, player.position.y - 20); for (int i = 0; i < 10; i++) { // make 10 enemies std::unique_ptr<Character> newPetRock(new PetRock(1, window, petRockTex, player, DeltaTime, currentMap)); petRockList.push_back(std::move(newPetRock)); } //ReaperBoss reaperBoss(500, window, player); std::unique_ptr<Character> reaperBoss(new ReaperBoss(750, window, player, DeltaTime, currentMap)); petRockList.push_back(std::move(reaperBoss)); //sf::Sprite backGround; //sf::Texture backGroundTex; //backGroundTex.loadFromFile("resources/environment/floorBackground.jpg"); //backGround.setTexture(backGroundTex); //backGround.setScale(5, 5); view.setCenter(sf::Vector2f(player.sprite.getPosition().x, player.sprite.getPosition().y)); view.setSize(1780, 980); while (window.isOpen()) { sf::Time timeFromClock = deltaTimeClock.restart(); DeltaTime = timeFromClock.asSeconds(); if (spawnTime.getElapsedTime().asSeconds() > 10 && petRockList.size() < 10) { for (int i = 0; i < 10; i++) { // make 10 enemies std::unique_ptr<Character> newPetRock(new PetRock(1, window, petRockTex, player, DeltaTime, currentMap)); petRockList.push_back(std::move(newPetRock)); } spawnTime.restart(); } if (!pause && sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) { pause = true; } if (pause && sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) { pause = false; } // get all the input first every frame sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) { window.close(); } } // input loop ended window.setView(view); view.setCenter(sf::Vector2f(player.sprite.getPosition().x, player.sprite.getPosition().y)); window.clear(); if (!pause) { //This is the pause function //window.draw(backGround); currentMap.Update(); player.Update(); for (int i = 0; i < petRockList.size(); i++) { petRockList.at(i)->Update(); } window.draw(player.scoreText); } else { window.draw(pauseText); } window.display(); if (!player.alive) { return; } } }