diff --git a/CCpp2017 b/CCpp2017 new file mode 160000 index 00000000..c30ee0bc --- /dev/null +++ b/CCpp2017 @@ -0,0 +1 @@ +Subproject commit c30ee0bc88474ceb53fd474479776b70a9f08e54 diff --git a/CCppExamples-master/.gitattributes b/CCppExamples-master/.gitattributes new file mode 100644 index 00000000..412eeda7 --- /dev/null +++ b/CCppExamples-master/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/CCppExamples-master/.gitignore b/CCppExamples-master/.gitignore new file mode 100644 index 00000000..b9d6bd92 --- /dev/null +++ b/CCppExamples-master/.gitignore @@ -0,0 +1,215 @@ +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +############# +## Windows detritus +############# + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist/ +build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg diff --git a/CCppExamples-master/ComputerSales_oo/include/Computer.h b/CCppExamples-master/ComputerSales_oo/include/Computer.h new file mode 100644 index 00000000..5aca4bf4 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/Computer.h @@ -0,0 +1,32 @@ +#ifndef COMPUTER_H +#define COMPUTER_H + +#include +using std::string; + +class Computer +{ +public: + string getModel(){ + return this->model; + } + int getTotal(){ + return this->total; + } + void add(int num){ + this->total+=num; + } + void sub(int num){ + this->total-=num; + } + bool equal(Computer* other){ + return this->model == other->model; + } + void input(); + +private: + string model; + int total; +}; + +#endif // COMPUTER_H diff --git a/CCppExamples-master/ComputerSales_oo/include/ComputerSales.h b/CCppExamples-master/ComputerSales_oo/include/ComputerSales.h new file mode 100644 index 00000000..953c244b --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/ComputerSales.h @@ -0,0 +1,14 @@ +#ifndef COMPUTERSALES_H +#define COMPUTERSALES_H + +#include "Menu.h" + +class ComputerSales{ +public: + ComputerSales(); + int run(); +private: + Menu menu; +}; + +#endif // COMPUTERSALES_H diff --git a/CCppExamples-master/ComputerSales_oo/include/EnterWareHouse.h b/CCppExamples-master/ComputerSales_oo/include/EnterWareHouse.h new file mode 100644 index 00000000..0ee2746f --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/EnterWareHouse.h @@ -0,0 +1,17 @@ +#ifndef ENTERWAREHOUSE_H +#define ENTERWAREHOUSE_H + +#include "MenuItem.h" + +#include "WareHouse.h" + +class EnterWareHouse:public MenuItem{ +public: + EnterWareHouse():MenuItem("电脑入库"){} + virtual bool act(){ + wareHouse.in(); + return false; + } +}; + +#endif // ENTERWAREHOUSE_H diff --git a/CCppExamples-master/ComputerSales_oo/include/Exit.h b/CCppExamples-master/ComputerSales_oo/include/Exit.h new file mode 100644 index 00000000..cf953fc7 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/Exit.h @@ -0,0 +1,18 @@ +#ifndef EXIT_H +#define EXIT_H + +#include +using namespace std; + +#include "MenuItem.h" + +class Exit:public MenuItem{ +public: + Exit():MenuItem("退出程序"){} + bool act(){ + cout << "退出程序!" << endl; + return true; + } +}; + +#endif // EXIT_H diff --git a/CCppExamples-master/ComputerSales_oo/include/ListWareHouse.h b/CCppExamples-master/ComputerSales_oo/include/ListWareHouse.h new file mode 100644 index 00000000..7b136a35 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/ListWareHouse.h @@ -0,0 +1,17 @@ +#ifndef LISTWAREHOUSE_H +#define LISTWAREHOUSE_H + +#include "MenuItem.h" + +#include "WareHouse.h" + +class ListWareHouse:public MenuItem{ +public: + ListWareHouse():MenuItem("查看库存"){} + bool act(){ + wareHouse.list(); + return false; + } +}; + +#endif // LISTWAREHOUSE_H diff --git a/CCppExamples-master/ComputerSales_oo/include/Menu.h b/CCppExamples-master/ComputerSales_oo/include/Menu.h new file mode 100644 index 00000000..12ea1694 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/Menu.h @@ -0,0 +1,19 @@ +#ifndef MENU_H +#define MENU_H + +#include + +#include "MenuItem.h" + +class Menu{ +public: + virtual ~Menu(); + void append(MenuItem* mi); + int run(); +private: + void show(); + + vector items; +}; + +#endif // MENU_H diff --git a/CCppExamples-master/ComputerSales_oo/include/MenuItem.h b/CCppExamples-master/ComputerSales_oo/include/MenuItem.h new file mode 100644 index 00000000..2905a9de --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/MenuItem.h @@ -0,0 +1,19 @@ +#ifndef MENUITEM_H +#define MENUITEM_H + +#include +using namespace std; + +class MenuItem{ +public: + MenuItem(string c):caption(c){} + virtual ~MenuItem(){} + string getCaption(){ + return caption; + } + virtual bool act() = 0; //if return true ,then exit program +private: + string caption; +}; + +#endif // MENUITEM_H diff --git a/CCppExamples-master/ComputerSales_oo/include/OutWareHouse.h b/CCppExamples-master/ComputerSales_oo/include/OutWareHouse.h new file mode 100644 index 00000000..7edb55df --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/OutWareHouse.h @@ -0,0 +1,18 @@ +#ifndef OUTWAREHOUSE_H +#define OUTWAREHOUSE_H + +#include "MenuItem.h" + +#include "WareHouse.h" + +class OutWareHouse:public MenuItem{ +public: + OutWareHouse():MenuItem("售出"){} + bool act(){ + wareHouse.out(); + return false; + } + +}; + +#endif // OUTWAREHOUSE_H diff --git a/CCppExamples-master/ComputerSales_oo/include/WareHouse.h b/CCppExamples-master/ComputerSales_oo/include/WareHouse.h new file mode 100644 index 00000000..96196401 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/include/WareHouse.h @@ -0,0 +1,23 @@ +#ifndef WAREHOUSE_H +#define WAREHOUSE_H + +#include +using namespace std; + +#include "Computer.h" + +class WareHouse{ +public: + virtual ~WareHouse(); + void list(); + void in(); + void out(); +private: + vector computers; + + Computer* find(Computer* computer); +}; + +extern WareHouse wareHouse; + +#endif // WAREHOUSE_H diff --git a/CCppExamples-master/ComputerSales_oo/main.cpp b/CCppExamples-master/ComputerSales_oo/main.cpp new file mode 100644 index 00000000..d5f2be18 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/main.cpp @@ -0,0 +1,6 @@ +#include "ComputerSales.h" + +int main(){ + ComputerSales cs; + return cs.run(); +} diff --git a/CCppExamples-master/ComputerSales_oo/src/Computer.cpp b/CCppExamples-master/ComputerSales_oo/src/Computer.cpp new file mode 100644 index 00000000..ec2ed838 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/src/Computer.cpp @@ -0,0 +1,12 @@ +#include "Computer.h" + +#include +using namespace std; + +void Computer::input(){ + cout<<"型号:"; + cin>>this->model; + + cout<<"数量:"; + cin>>this->total; +} diff --git a/CCppExamples-master/ComputerSales_oo/src/ComputerSales.cpp b/CCppExamples-master/ComputerSales_oo/src/ComputerSales.cpp new file mode 100644 index 00000000..2480f865 --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/src/ComputerSales.cpp @@ -0,0 +1,20 @@ +#include "ComputerSales.h" + +#include "ListWareHouse.h" +#include "EnterWareHouse.h" +#include "OutWareHouse.h" +#include "Exit.h" + +#include +using namespace std; + +ComputerSales::ComputerSales(){ + menu.append(new ListWareHouse()); + menu.append(new EnterWareHouse()); + menu.append(new OutWareHouse()); + menu.append(new Exit()); +} + +int ComputerSales::run(){ + return menu.run(); +} diff --git a/CCppExamples-master/ComputerSales_oo/src/Menu.cpp b/CCppExamples-master/ComputerSales_oo/src/Menu.cpp new file mode 100644 index 00000000..f89fda0b --- /dev/null +++ b/CCppExamples-master/ComputerSales_oo/src/Menu.cpp @@ -0,0 +1,39 @@ +#include "Menu.h" + +#include +using namespace std; + +Menu::~Menu(){ + for(auto &item:items){ + delete item; + } +} + +void Menu::append(MenuItem* mi){ + this->items.push_back(mi); +} + +int Menu::run(){ + int index; + while(1){ + this->show(); + cin>>index; + if(!cin || index<1 || index>items.size()){ + cout << "错误的菜单项,请重新输入:"<::max(), '\n'); + } + continue; + } + if(items[index-1]->act()) break; + } + return 0; +} + +void Menu::show(){ + int i=0; + for(auto &item:items){ + cout<< ++i <<")" <getCaption() < +using namespace std; + +WareHouse wareHouse; + +WareHouse::~WareHouse(){ + for(auto &computer : computers){ + delete computer; + } +} + +void WareHouse::list() +{ + cout<<"-------库存-------"<computers.size(); i++){ + cout<computers[i]->getModel()<<"\t"<computers[i]->getTotal()<input(); + + Computer* result = this->find(temp); + if(result == NULL){ + this->computers.push_back(temp); + }else{ + result->add(temp->getTotal()); + delete temp; + } +} + +void WareHouse::out(){ + Computer* temp = new Computer; + temp->input(); + + Computer* result = this->find(temp); + if(result == NULL){ + cout<<"型号错误!"<sub(temp->getTotal()); + } +} + +Computer* WareHouse::find(Computer* computer){ + //C++11 中新引入的基于范围的for循环,更简介! + for(auto &item : computers){ + if(item->equal(computer)){ + return item; + } + } + return NULL; +} diff --git a/CCppExamples-master/Fighters/Fighters.xcodeproj/project.pbxproj b/CCppExamples-master/Fighters/Fighters.xcodeproj/project.pbxproj new file mode 100644 index 00000000..239ab573 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters.xcodeproj/project.pbxproj @@ -0,0 +1,378 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + F46CF3EA181B5861001ED527 /* ResourcePath.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46CF3E9181B5861001ED527 /* ResourcePath.mm */; }; + F46CF3ED181B5861001ED527 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF3EC181B5861001ED527 /* main.cpp */; }; + F46CF43E181B5F28001ED527 /* font in Resources */ = {isa = PBXBuildFile; fileRef = F46CF43B181B5F28001ED527 /* font */; }; + F46CF43F181B5F28001ED527 /* image in Resources */ = {isa = PBXBuildFile; fileRef = F46CF43C181B5F28001ED527 /* image */; }; + F46CF440181B5F28001ED527 /* sound in Resources */ = {isa = PBXBuildFile; fileRef = F46CF43D181B5F28001ED527 /* sound */; }; + F46CF443181BB492001ED527 /* Plane.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF441181BB492001ED527 /* Plane.cpp */; }; + F46CF449181BBFFE001ED527 /* Gun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF447181BBFFE001ED527 /* Gun.cpp */; }; + F46CF44C181BC19D001ED527 /* Bullet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF44A181BC19D001ED527 /* Bullet.cpp */; }; + F46CF44F181BC418001ED527 /* Sky.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF44D181BC418001ED527 /* Sky.cpp */; }; + F46CF452181BD0DA001ED527 /* Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF450181BD0DA001ED527 /* Sprite.cpp */; }; + F46CF455181C0C21001ED527 /* Enemy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46CF453181C0C21001ED527 /* Enemy.cpp */; }; + F479EC6A181E0D3A00A33FC4 /* Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F479EC68181E0D3A00A33FC4 /* Texture.cpp */; }; + F479EC6D181E0F5000A33FC4 /* Hero.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F479EC6B181E0F5000A33FC4 /* Hero.cpp */; }; + F479EC70181E32AB00A33FC4 /* Sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F479EC6E181E32AB00A33FC4 /* Sound.cpp */; }; + F479EC73181E392400A33FC4 /* Game.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F479EC71181E392400A33FC4 /* Game.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + F46CF3E4181B5861001ED527 /* Fighters.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Fighters.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F46CF3E8181B5861001ED527 /* Fighters-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Fighters-Info.plist"; sourceTree = ""; }; + F46CF3E9181B5861001ED527 /* ResourcePath.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourcePath.mm; sourceTree = ""; }; + F46CF3EB181B5861001ED527 /* ResourcePath.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ResourcePath.hpp; sourceTree = ""; }; + F46CF3EC181B5861001ED527 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + F46CF43B181B5F28001ED527 /* font */ = {isa = PBXFileReference; lastKnownFileType = folder; name = font; path = resources/font; sourceTree = ""; }; + F46CF43C181B5F28001ED527 /* image */ = {isa = PBXFileReference; lastKnownFileType = folder; name = image; path = resources/image; sourceTree = ""; }; + F46CF43D181B5F28001ED527 /* sound */ = {isa = PBXFileReference; lastKnownFileType = folder; name = sound; path = resources/sound; sourceTree = ""; }; + F46CF441181BB492001ED527 /* Plane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Plane.cpp; sourceTree = ""; }; + F46CF442181BB492001ED527 /* Plane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Plane.h; sourceTree = ""; }; + F46CF447181BBFFE001ED527 /* Gun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gun.cpp; sourceTree = ""; }; + F46CF448181BBFFE001ED527 /* Gun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gun.h; sourceTree = ""; }; + F46CF44A181BC19D001ED527 /* Bullet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Bullet.cpp; sourceTree = ""; }; + F46CF44B181BC19D001ED527 /* Bullet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bullet.h; sourceTree = ""; }; + F46CF44D181BC418001ED527 /* Sky.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sky.cpp; sourceTree = ""; }; + F46CF44E181BC418001ED527 /* Sky.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sky.h; sourceTree = ""; }; + F46CF450181BD0DA001ED527 /* Sprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sprite.cpp; sourceTree = ""; }; + F46CF451181BD0DA001ED527 /* Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sprite.h; sourceTree = ""; }; + F46CF453181C0C21001ED527 /* Enemy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Enemy.cpp; sourceTree = ""; }; + F46CF454181C0C21001ED527 /* Enemy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Enemy.h; sourceTree = ""; }; + F479EC68181E0D3A00A33FC4 /* Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Texture.cpp; sourceTree = ""; }; + F479EC69181E0D3A00A33FC4 /* Texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Texture.h; sourceTree = ""; }; + F479EC6B181E0F5000A33FC4 /* Hero.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Hero.cpp; sourceTree = ""; }; + F479EC6C181E0F5000A33FC4 /* Hero.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hero.h; sourceTree = ""; }; + F479EC6E181E32AB00A33FC4 /* Sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sound.cpp; sourceTree = ""; }; + F479EC6F181E32AB00A33FC4 /* Sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sound.h; sourceTree = ""; }; + F479EC71181E392400A33FC4 /* Game.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Game.cpp; sourceTree = ""; }; + F479EC72181E392400A33FC4 /* Game.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Game.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F46CF3E0181B5861001ED527 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F46CF3DA181B5861001ED527 = { + isa = PBXGroup; + children = ( + F46CF3E6181B5861001ED527 /* Fighters */, + F46CF3E5181B5861001ED527 /* Products */, + ); + sourceTree = ""; + }; + F46CF3E5181B5861001ED527 /* Products */ = { + isa = PBXGroup; + children = ( + F46CF3E4181B5861001ED527 /* Fighters.app */, + ); + name = Products; + sourceTree = ""; + }; + F46CF3E6181B5861001ED527 /* Fighters */ = { + isa = PBXGroup; + children = ( + F46CF447181BBFFE001ED527 /* Gun.cpp */, + F46CF448181BBFFE001ED527 /* Gun.h */, + F46CF3E9181B5861001ED527 /* ResourcePath.mm */, + F46CF3EB181B5861001ED527 /* ResourcePath.hpp */, + F46CF3EC181B5861001ED527 /* main.cpp */, + F46CF441181BB492001ED527 /* Plane.cpp */, + F46CF442181BB492001ED527 /* Plane.h */, + F46CF3EE181B5861001ED527 /* Resources */, + F46CF3E7181B5861001ED527 /* Supporting Files */, + F46CF44A181BC19D001ED527 /* Bullet.cpp */, + F46CF44B181BC19D001ED527 /* Bullet.h */, + F46CF44D181BC418001ED527 /* Sky.cpp */, + F46CF44E181BC418001ED527 /* Sky.h */, + F46CF450181BD0DA001ED527 /* Sprite.cpp */, + F46CF451181BD0DA001ED527 /* Sprite.h */, + F46CF453181C0C21001ED527 /* Enemy.cpp */, + F46CF454181C0C21001ED527 /* Enemy.h */, + F479EC68181E0D3A00A33FC4 /* Texture.cpp */, + F479EC69181E0D3A00A33FC4 /* Texture.h */, + F479EC6B181E0F5000A33FC4 /* Hero.cpp */, + F479EC6C181E0F5000A33FC4 /* Hero.h */, + F479EC6E181E32AB00A33FC4 /* Sound.cpp */, + F479EC6F181E32AB00A33FC4 /* Sound.h */, + F479EC71181E392400A33FC4 /* Game.cpp */, + F479EC72181E392400A33FC4 /* Game.h */, + ); + path = Fighters; + sourceTree = ""; + }; + F46CF3E7181B5861001ED527 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + F46CF3E8181B5861001ED527 /* Fighters-Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + F46CF3EE181B5861001ED527 /* Resources */ = { + isa = PBXGroup; + children = ( + F46CF43B181B5F28001ED527 /* font */, + F46CF43C181B5F28001ED527 /* image */, + F46CF43D181B5F28001ED527 /* sound */, + ); + name = Resources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F46CF3E3181B5861001ED527 /* Fighters */ = { + isa = PBXNativeTarget; + buildConfigurationList = F46CF3F9181B5861001ED527 /* Build configuration list for PBXNativeTarget "Fighters" */; + buildPhases = ( + F46CF3DF181B5861001ED527 /* Sources */, + F46CF3E0181B5861001ED527 /* Frameworks */, + F46CF3E1181B5861001ED527 /* Resources */, + F46CF3E2181B5861001ED527 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Fighters; + productName = Fighters; + productReference = F46CF3E4181B5861001ED527 /* Fighters.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F46CF3DB181B5861001ED527 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0500; + ORGANIZATIONNAME = luckymark; + }; + buildConfigurationList = F46CF3DE181B5861001ED527 /* Build configuration list for PBXProject "Fighters" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = F46CF3DA181B5861001ED527; + productRefGroup = F46CF3E5181B5861001ED527 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F46CF3E3181B5861001ED527 /* Fighters */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F46CF3E1181B5861001ED527 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F46CF43F181B5F28001ED527 /* image in Resources */, + F46CF43E181B5F28001ED527 /* font in Resources */, + F46CF440181B5F28001ED527 /* sound in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + F46CF3E2181B5861001ED527 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# This shell script simply copies required sfml dylibs/frameworks into the application bundle frameworks folder.\n# If you're using static libraries (which is not recommended) you should remove this script from your project.\n\n# Are we building a project that uses framework or dylibs ?\ncase \"$SFML_BINARY_TYPE\" in\n DYLIBS)\n frameworks=\"false\"\n ;;\n *)\n frameworks=\"true\"\n ;;\nesac\n\n# Echoes to stderr\nerror () # $* message to display\n{\n echo $* 1>&2\n exit 2\n}\n\nassert () # $1 is a boolean, $2...N is an error message\n{\n if [ $# -lt 2 ]\n then\n error \"Internal error in assert : not enough args\"\n fi\n\n if [ $1 -ne 0 ]\n then\n shift\n error \"$*\"\n fi\n}\n\nforce_remove () # $1 is a path\n{\n test $# -eq 1\n assert $? \"force_remove() requires one parameter\"\n rm -fr \"$1\"\n assert $? \"couldn't remove $1\"\n}\n\ncopy () # $1 is a source, $2 is a destination\n{\n test $# -eq 2\n assert $? \"copy() requires two parameters\"\n ditto \"$1\" \"$2\"\n assert $? \"couldn't copy $1 to $2\"\n}\n\nrequire () # $1 is a SFML module like 'system' or 'audio'\n{\n dest=\"$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Contents/Frameworks\"\n\n if [ -z \"$1\" ]\n then\n error \"require() requires one parameter!\"\n else\n # clean potentially old stuff\n force_remove \"$dest/libsfml-$1.2.dylib\"\n force_remove \"$dest/libsfml-$1-d.2.dylib\"\n force_remove \"$dest/sfml-$1.framework\"\n\n # copy SFML libraries\n if [ \"$frameworks\" = \"true\" ]\n then\n copy \"/Library/Frameworks/sfml-$1.framework\" \"$dest/sfml-$1.framework\"\n elif [ \"$SFML_LINK_DYLIBS_SUFFIX\" = \"-d\" ]\n then\n copy \"/usr/local/lib/libsfml-$1-d.2.dylib\" \"$dest/libsfml-$1-d.2.dylib\"\n else\n copy \"/usr/local/lib/libsfml-$1.2.dylib\" \"$dest/libsfml-$1.2.dylib\"\n fi\n\n if [ \"$1\" = \"audio\" ]\n then\n # copy sndfile framework too\n copy \"/Library/Frameworks/sndfile.framework\" \"$dest/sndfile.framework\"\n fi\n\n if [ \"$1\" = \"graphics\" ]\n then\n # copy freetype framework too\n copy \"/Library/Frameworks/freetype.framework\" \"$dest/freetype.framework\"\n fi\n fi\n}\n\nif [ -n \"$SFML_SYSTEM\" ]\nthen\n require \"system\"\nfi\n\nif [ -n \"$SFML_AUDIO\" ]\nthen\n require \"audio\"\nfi\n\nif [ -n \"$SFML_NETWORK\" ]\nthen\n require \"network\"\nfi\n\nif [ -n \"$SFML_WINDOW\" ]\nthen\n require \"window\"\nfi\n\nif [ -n \"$SFML_GRAPHICS\" ]\nthen\n require \"graphics\"\nfi\n\n "; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F46CF3DF181B5861001ED527 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F46CF455181C0C21001ED527 /* Enemy.cpp in Sources */, + F479EC6D181E0F5000A33FC4 /* Hero.cpp in Sources */, + F46CF44C181BC19D001ED527 /* Bullet.cpp in Sources */, + F46CF443181BB492001ED527 /* Plane.cpp in Sources */, + F46CF3ED181B5861001ED527 /* main.cpp in Sources */, + F479EC6A181E0D3A00A33FC4 /* Texture.cpp in Sources */, + F479EC73181E392400A33FC4 /* Game.cpp in Sources */, + F46CF44F181BC418001ED527 /* Sky.cpp in Sources */, + F46CF449181BBFFE001ED527 /* Gun.cpp in Sources */, + F46CF452181BD0DA001ED527 /* Sprite.cpp in Sources */, + F46CF3EA181B5861001ED527 /* ResourcePath.mm in Sources */, + F479EC70181E32AB00A33FC4 /* Sound.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + F46CF3F7181B5861001ED527 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + FRAMEWORK_SEARCH_PATHS = ( + /Library/Frameworks/, + "$(inherited)", + ); + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + /usr/local/include/, + "$(inherited)", + ); + LIBRARY_SEARCH_PATHS = ( + /usr/local/lib/, + "$(inherited)", + ); + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = ( + "$(inherited)", + "$(SFML_SYSTEM)", + "$(SFML_WINDOW)", + "$(SFML_GRAPHICS)", + "$(SFML_AUDIO)", + "$(SFML_NETWORK)", + ); + SFML_AUDIO = "$(SFML_LINK_PREFIX) sfml-audio$(SFML_LINK_SUFFIX)"; + SFML_BINARY_TYPE = FRAMEWORKS; + SFML_GRAPHICS = "$(SFML_LINK_PREFIX) sfml-graphics$(SFML_LINK_SUFFIX)"; + SFML_LINK_DYLIBS_PREFIX = "-l"; + SFML_LINK_DYLIBS_SUFFIX = ""; + SFML_LINK_FRAMEWORKS_PREFIX = "-framework"; + SFML_LINK_FRAMEWORKS_SUFFIX = ""; + SFML_LINK_PREFIX = "$(SFML_LINK_$(SFML_BINARY_TYPE)_PREFIX)"; + SFML_LINK_SUFFIX = "$(SFML_LINK_$(SFML_BINARY_TYPE)_SUFFIX)"; + SFML_NETWORK = ""; + SFML_SYSTEM = "$(SFML_LINK_PREFIX) sfml-system$(SFML_LINK_SUFFIX)"; + SFML_WINDOW = "$(SFML_LINK_PREFIX) sfml-window$(SFML_LINK_SUFFIX)"; + SUPPORTED_PLATFORMS = macosx; + }; + name = Debug; + }; + F46CF3F8181B5861001ED527 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + FRAMEWORK_SEARCH_PATHS = ( + /Library/Frameworks/, + "$(inherited)", + ); + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + /usr/local/include/, + "$(inherited)", + ); + LIBRARY_SEARCH_PATHS = ( + /usr/local/lib/, + "$(inherited)", + ); + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = ( + "$(inherited)", + "$(SFML_SYSTEM)", + "$(SFML_WINDOW)", + "$(SFML_GRAPHICS)", + "$(SFML_AUDIO)", + "$(SFML_NETWORK)", + ); + SFML_AUDIO = "$(SFML_LINK_PREFIX) sfml-audio$(SFML_LINK_SUFFIX)"; + SFML_BINARY_TYPE = FRAMEWORKS; + SFML_GRAPHICS = "$(SFML_LINK_PREFIX) sfml-graphics$(SFML_LINK_SUFFIX)"; + SFML_LINK_DYLIBS_PREFIX = "-l"; + SFML_LINK_DYLIBS_SUFFIX = ""; + SFML_LINK_FRAMEWORKS_PREFIX = "-framework"; + SFML_LINK_FRAMEWORKS_SUFFIX = ""; + SFML_LINK_PREFIX = "$(SFML_LINK_$(SFML_BINARY_TYPE)_PREFIX)"; + SFML_LINK_SUFFIX = "$(SFML_LINK_$(SFML_BINARY_TYPE)_SUFFIX)"; + SFML_NETWORK = ""; + SFML_SYSTEM = "$(SFML_LINK_PREFIX) sfml-system$(SFML_LINK_SUFFIX)"; + SFML_WINDOW = "$(SFML_LINK_PREFIX) sfml-window$(SFML_LINK_SUFFIX)"; + SUPPORTED_PLATFORMS = macosx; + }; + name = Release; + }; + F46CF3FA181B5861001ED527 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = "Fighters/Fighters-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + F46CF3FB181B5861001ED527 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = "Fighters/Fighters-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F46CF3DE181B5861001ED527 /* Build configuration list for PBXProject "Fighters" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F46CF3F7181B5861001ED527 /* Debug */, + F46CF3F8181B5861001ED527 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F46CF3F9181B5861001ED527 /* Build configuration list for PBXNativeTarget "Fighters" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F46CF3FA181B5861001ED527 /* Debug */, + F46CF3FB181B5861001ED527 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F46CF3DB181B5861001ED527 /* Project object */; +} diff --git a/CCppExamples-master/Fighters/Fighters.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CCppExamples-master/Fighters/Fighters.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..e22b781a --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CCppExamples-master/Fighters/Fighters/Bullet.cpp b/CCppExamples-master/Fighters/Fighters/Bullet.cpp new file mode 100644 index 00000000..4a2ecdb6 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Bullet.cpp @@ -0,0 +1,20 @@ +// +// Bullet.cpp +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Bullet.h" +#include "Texture.h" + +Bullet::Bullet(float x,float y){ + this->setTexture(Texture::BULLET); + + this->setPosition(x, y); +} + +void Bullet::heartBeat(){ + this->move(0,-10); +} diff --git a/CCppExamples-master/Fighters/Fighters/Bullet.h b/CCppExamples-master/Fighters/Fighters/Bullet.h new file mode 100644 index 00000000..e2ed0935 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Bullet.h @@ -0,0 +1,20 @@ +// +// Bullet.h +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Bullet__ +#define __Fighters__Bullet__ + +#include "Sprite.h" + +class Bullet:public Sprite{ +public: + Bullet(float x,float y); + void heartBeat(); +}; + +#endif /* defined(__Fighters__Bullet__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Enemy.cpp b/CCppExamples-master/Fighters/Fighters/Enemy.cpp new file mode 100644 index 00000000..9e233d12 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Enemy.cpp @@ -0,0 +1,63 @@ +// +// Enemy.cpp +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Enemy.h" + +#include "Texture.h" +#include "Sound.h" +#include "Game.h" + +#include + +#include +using namespace std; + +Enemy::Enemy(){ + this->setTexture(Texture::ENEMY); + + uniform_int_distribution u(0,480); + std::default_random_engine random_engine; + this->setPosition(u(Game::random_engine), 20); + + this->gun.setOwner(this); +} + +void Enemy::heartBeat(){ + switch(this->state){ + case 0: + this->move(0,10); + break; + case 1: + this->setTexture(Texture::ENEMY_DOWN_2); + this->state++; + break; + case 2: + this->setTexture(Texture::ENEMY_DOWN_3); + this->state++; + break; + case 3: + this->setTexture(Texture::ENEMY_DOWN_4); + this->state++; + break; + default:; + } +} + +void Enemy::hit(){ + this->state = 1; + this->setTexture(Texture::ENEMY_DOWN_1); + Sound::ENEMY_DOWN.play(); +} + +bool Enemy::needClear(){ + return this->state == 4; +} + +bool Enemy::isDead(){ + return this->state != 0; +} \ No newline at end of file diff --git a/CCppExamples-master/Fighters/Fighters/Enemy.h b/CCppExamples-master/Fighters/Fighters/Enemy.h new file mode 100644 index 00000000..382e015e --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Enemy.h @@ -0,0 +1,25 @@ +// +// Enemy.h +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Enemy__ +#define __Fighters__Enemy__ + +#include "Plane.h" + +class Enemy:public Plane{ +public: + Enemy(); + void heartBeat(); + void hit(); + bool needClear(); + bool isDead(); +private: + int state=0; +}; + +#endif /* defined(__Fighters__Enemy__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Fighters-Info.plist b/CCppExamples-master/Fighters/Fighters/Fighters-Info.plist new file mode 100644 index 00000000..d22e329a --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Fighters-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + uestc.cpp.edu.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + + diff --git a/CCppExamples-master/Fighters/Fighters/Game.cpp b/CCppExamples-master/Fighters/Fighters/Game.cpp new file mode 100644 index 00000000..3d2f17fe --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Game.cpp @@ -0,0 +1,19 @@ +// +// Game.cpp +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Game.h" + +Game* Game::instance = nullptr; +std::default_random_engine Game::random_engine(time(0)); + +Game* Game::getInstance(){ + if(!instance){ + instance = new Game; + } + return instance; +} \ No newline at end of file diff --git a/CCppExamples-master/Fighters/Fighters/Game.h b/CCppExamples-master/Fighters/Fighters/Game.h new file mode 100644 index 00000000..0c2931eb --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Game.h @@ -0,0 +1,25 @@ +// +// Game.h +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Game__ +#define __Fighters__Game__ + +#include +#include + +class Game{ +public: + static Game* getInstance(); + static std::default_random_engine random_engine; +private: +// Game(); + + static Game* instance; +}; + +#endif /* defined(__Fighters__Game__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Gun.cpp b/CCppExamples-master/Fighters/Fighters/Gun.cpp new file mode 100644 index 00000000..d5446f0e --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Gun.cpp @@ -0,0 +1,30 @@ +// +// Gun.cpp +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Plane.h" +#include "Gun.h" + +#include "Sky.h" + +#include "Bullet.h" + +void Gun::fire(){ + sf::Vector2f pos = ((this->owner)->getPosition()); + Bullet* bullet = new Bullet(pos.x+15,pos.y+30); + Sky::getInstance()->add(bullet); + Sky::getInstance()->addMyBullet(bullet); +} + +sf::Vector2f Gun::getPosition(){ + sf::Vector2f ff; + return ff;//this->owner->getPosition(); +} + +void Gun::setOwner(Plane * owner){ + this->owner = owner; +} \ No newline at end of file diff --git a/CCppExamples-master/Fighters/Fighters/Gun.h b/CCppExamples-master/Fighters/Fighters/Gun.h new file mode 100644 index 00000000..f38f2012 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Gun.h @@ -0,0 +1,28 @@ +// +// Gun.h +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Gun__ +#define __Fighters__Gun__ + +#include + +#include + +class Plane; + +class Gun{ +public: + void setOwner(Plane * owner); + void fire(); +private: + sf::Vector2f getPosition(); + + Plane* owner; +}; + +#endif /* defined(__Fighters__Gun__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Hero.cpp b/CCppExamples-master/Fighters/Fighters/Hero.cpp new file mode 100644 index 00000000..032bb82b --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Hero.cpp @@ -0,0 +1,27 @@ +// +// Hero.cpp +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Hero.h" +#include "Texture.h" + +Hero::Hero(){ + this->setTexture(Texture::HERO); + + this->setPosition(180, 600); + + this->gun.setOwner(this); +} + +void Hero::move2left(){ + this->move(-10,0); +} + +void Hero::move2right(){ + this->move(10,0); +} + diff --git a/CCppExamples-master/Fighters/Fighters/Hero.h b/CCppExamples-master/Fighters/Fighters/Hero.h new file mode 100644 index 00000000..64cf89be --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Hero.h @@ -0,0 +1,24 @@ +// +// Hero.h +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Hero__ +#define __Fighters__Hero__ + +#include + +#include "Plane.h" + +class Hero:public Plane{ +public: + Hero(); + + void move2left(); + void move2right(); +}; + +#endif /* defined(__Fighters__Hero__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Plane.cpp b/CCppExamples-master/Fighters/Fighters/Plane.cpp new file mode 100644 index 00000000..c28524a4 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Plane.cpp @@ -0,0 +1,13 @@ +// +// Plane.cpp +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Plane.h" + +void Plane::fire(){ + this->gun.fire(); +} diff --git a/CCppExamples-master/Fighters/Fighters/Plane.h b/CCppExamples-master/Fighters/Fighters/Plane.h new file mode 100644 index 00000000..6312edb5 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Plane.h @@ -0,0 +1,28 @@ +// +// Plane.h +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Plane__ +#define __Fighters__Plane__ + +#include + +#include "Sprite.h" +#include "Gun.h" + +#include +using std::cout; +using std::endl; + +class Plane:public Sprite{ +public: + void fire(); +protected: + Gun gun; +}; + +#endif /* defined(__Fighters__Plane__) */ diff --git a/CCppExamples-master/Fighters/Fighters/ResourcePath.hpp b/CCppExamples-master/Fighters/Fighters/ResourcePath.hpp new file mode 100644 index 00000000..17be41ee --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/ResourcePath.hpp @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2013 Marco Antognini (antognini.marco@gmail.com), +// Laurent Gomila (laurent.gom@gmail.com), +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef RESOURCE_PATH_HPP +#define RESOURCE_PATH_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + +//////////////////////////////////////////////////////////// +/// \brief Return the path to the resource folder. +/// +/// \return The path to the resource folder associate +/// with the main bundle or an empty string is there is no bundle. +/// +//////////////////////////////////////////////////////////// +std::string resourcePath(void); + +#endif diff --git a/CCppExamples-master/Fighters/Fighters/ResourcePath.mm b/CCppExamples-master/Fighters/Fighters/ResourcePath.mm new file mode 100644 index 00000000..d25c1d3c --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/ResourcePath.mm @@ -0,0 +1,52 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2013 Marco Antognini (antognini.marco@gmail.com), +// Laurent Gomila (laurent.gom@gmail.com), +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include "ResourcePath.hpp" +#import + +//////////////////////////////////////////////////////////// +std::string resourcePath(void) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + std::string rpath; + NSBundle* bundle = [NSBundle mainBundle]; + + if (bundle == nil) { +#ifdef DEBUG + NSLog(@"bundle is nil... thus no resources path can be found."); +#endif + } else { + NSString* path = [bundle resourcePath]; + rpath = [path UTF8String] + std::string("/"); + } + + [pool drain]; + + return rpath; +} diff --git a/CCppExamples-master/Fighters/Fighters/Sky.cpp b/CCppExamples-master/Fighters/Fighters/Sky.cpp new file mode 100644 index 00000000..eff207aa --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Sky.cpp @@ -0,0 +1,105 @@ +// +// Sky.cpp +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "ResourcePath.hpp" + +#include "Sky.h" +#include "Enemy.h" + +#include "Texture.h" + +Sky* Sky::instance = nullptr; + +Sky::Sky(){ + this->window = new sf::RenderWindow(sf::VideoMode(480, 800), L"飞机大战"); + + // Set the Icon + sf::Image icon; + if (icon.loadFromFile(resourcePath() + "image/shoot.png")) { + this->window->setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr()); + } + + // create the background + this->background = new sf::Sprite(Texture::SKY); +} + +void Sky::add(Sprite* sprite){ + this->sprites.insert(sprite); +} + +void Sky::addMyBullet(Bullet * bullet){ + this->myBullets.insert(bullet); +} + +void Sky::refresh(){ + this->window->draw(*this->background); + + this->clear(); + + this->collision(); + + this->createEnemies(); + + // Draw the sprite + for(auto &sprite : this->sprites){ + sprite->heartBeat(); + this->window->draw(*sprite); + } + + // Update the window + this->window->display(); +} + +void Sky::clear(){ + for(auto it_enemy= this->enemies.begin();it_enemy!=this->enemies.end();){ + if((*it_enemy)->needClear()){ + delete *it_enemy; + this->sprites.erase(*it_enemy); + + it_enemy = (this->enemies).erase(it_enemy); + }else{ + ++it_enemy; + } + } +} +void Sky::collision(){ + for(auto it_enemy= this->enemies.begin();it_enemy!=this->enemies.end();++it_enemy){ + if((*it_enemy)->isDead()) continue; + + for(auto it_bullet= this->myBullets.begin();it_bullet!=this->myBullets.end();++it_bullet){ + if((*it_enemy)->intersects(*it_bullet)){ + delete *it_bullet; + this->sprites.erase(*it_bullet); + (this->myBullets).erase(it_bullet); + + (*it_enemy)->hit(); + break; + } + } + } +} + +void Sky::createEnemies(){ + static int count=0; + + //每10个GameFrame产生一个敌机 + if(++count>=10){ + Enemy* enemy = new Enemy; + this->sprites.insert(enemy); + this->enemies.insert(enemy); + + count = 0; + } +} + +Sky* Sky::getInstance(){ + if(!instance){ + instance = new Sky; + } + return instance; +} \ No newline at end of file diff --git a/CCppExamples-master/Fighters/Fighters/Sky.h b/CCppExamples-master/Fighters/Fighters/Sky.h new file mode 100644 index 00000000..efffa485 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Sky.h @@ -0,0 +1,52 @@ +// +// Sky.h +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Sky__ +#define __Fighters__Sky__ + +#include + +#include "Sprite.h" +#include "Enemy.h" +#include "Bullet.h" + +#include +#include +#include +using namespace std; + +class Sky{ +public: + static Sky* getInstance(); + + sf::RenderWindow* getWindow(){ + return this->window; + } + void add(Sprite *); + + void addMyBullet(Bullet *); + + void refresh(); +private: + Sky(); + + sf::RenderWindow* window; + unordered_set sprites; + unordered_set enemies; + unordered_set myBullets; + + sf::Sprite* background=nullptr; + + static Sky* instance; + + void clear(); + void collision(); + void createEnemies(); +}; + +#endif /* defined(__Fighters__Sky__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Sound.cpp b/CCppExamples-master/Fighters/Fighters/Sound.cpp new file mode 100644 index 00000000..6c3e87ee --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Sound.cpp @@ -0,0 +1,17 @@ +// +// Sound.cpp +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Sound.h" + +sf::Music Sound::BACK_GROUND; +sf::Music Sound::ENEMY_DOWN; + +void Sound::load(){ + BACK_GROUND.openFromFile(resourcePath() + "sound/game_music.ogg"); + ENEMY_DOWN.openFromFile(resourcePath() + "sound/enemy1_down.ogg"); +} diff --git a/CCppExamples-master/Fighters/Fighters/Sound.h b/CCppExamples-master/Fighters/Fighters/Sound.h new file mode 100644 index 00000000..49620b43 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Sound.h @@ -0,0 +1,23 @@ +// +// Sound.h +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Sound__ +#define __Fighters__Sound__ + +#include +#include "ResourcePath.hpp" + +class Sound{ +public: + static sf::Music BACK_GROUND; + static sf::Music ENEMY_DOWN; + + static void load(); +}; + +#endif /* defined(__Fighters__Sound__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Sprite.cpp b/CCppExamples-master/Fighters/Fighters/Sprite.cpp new file mode 100644 index 00000000..28fdaf39 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Sprite.cpp @@ -0,0 +1,19 @@ +// +// Sprite.cpp +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Sprite.h" +#include "Sky.h" + +void Sprite::draw(){ + Sky::getInstance()->getWindow()->draw(*this); +} + +bool Sprite::intersects(Sprite* other){ + bool t = this->getGlobalBounds().intersects(other->getGlobalBounds()); + return t; +} diff --git a/CCppExamples-master/Fighters/Fighters/Sprite.h b/CCppExamples-master/Fighters/Fighters/Sprite.h new file mode 100644 index 00000000..322e705a --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Sprite.h @@ -0,0 +1,23 @@ +// +// Sprite.h +// Fighters +// +// Created by luckymark on 13-10-26. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Sprite__ +#define __Fighters__Sprite__ + +#include + +#include + +class Sprite:public sf::Sprite{ +public: + virtual void heartBeat(){}; + void draw(); + bool intersects(Sprite* other); +}; + +#endif /* defined(__Fighters__Sprite__) */ diff --git a/CCppExamples-master/Fighters/Fighters/Texture.cpp b/CCppExamples-master/Fighters/Fighters/Texture.cpp new file mode 100644 index 00000000..d650714c --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Texture.cpp @@ -0,0 +1,37 @@ +// +// Texture.cpp +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#include "Texture.h" + +sf::Texture Texture::HERO; + +sf::Texture Texture::ENEMY; +sf::Texture Texture::ENEMY_DOWN_1; +sf::Texture Texture::ENEMY_DOWN_2; +sf::Texture Texture::ENEMY_DOWN_3; +sf::Texture Texture::ENEMY_DOWN_4; + +sf::Texture Texture::BULLET; + +sf::Texture Texture::SKY; + +void Texture::load(){ + std::string path = resourcePath() + "image/shoot.png"; + + HERO.loadFromFile(path, sf::IntRect(0, 99, 102, 126)); + + ENEMY.loadFromFile(path, sf::IntRect(534, 612, 57, 43)); + ENEMY_DOWN_1.loadFromFile(path, sf::IntRect(267, 347, 57, 51)); + ENEMY_DOWN_2.loadFromFile(path, sf::IntRect(873, 697, 57, 51)); + ENEMY_DOWN_3.loadFromFile(path, sf::IntRect(267, 296, 57, 51)); + ENEMY_DOWN_4.loadFromFile(path, sf::IntRect(930, 697, 57, 51)); + + BULLET.loadFromFile(path, sf::IntRect(1004, 987, 9, 21)); + + SKY.loadFromFile(resourcePath() + "image/background.png"); +} diff --git a/CCppExamples-master/Fighters/Fighters/Texture.h b/CCppExamples-master/Fighters/Fighters/Texture.h new file mode 100644 index 00000000..69ed2f27 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/Texture.h @@ -0,0 +1,32 @@ +// +// Texture.h +// Fighters +// +// Created by luckymark on 13-10-28. +// Copyright (c) 2013年 luckymark. All rights reserved. +// + +#ifndef __Fighters__Texture__ +#define __Fighters__Texture__ + +#include +#include "ResourcePath.hpp" + +class Texture{ +public: + static sf::Texture HERO; + + static sf::Texture ENEMY; + static sf::Texture ENEMY_DOWN_1; + static sf::Texture ENEMY_DOWN_2; + static sf::Texture ENEMY_DOWN_3; + static sf::Texture ENEMY_DOWN_4; + + static sf::Texture BULLET; + + static sf::Texture SKY; + + static void load(); +}; + +#endif /* defined(__Fighters__Texture__) */ diff --git a/CCppExamples-master/Fighters/Fighters/main.cpp b/CCppExamples-master/Fighters/Fighters/main.cpp new file mode 100644 index 00000000..194f7a1b --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/main.cpp @@ -0,0 +1,80 @@ + +// +// Disclamer: +// ---------- +// +// This code will work only if you selected window, graphics and audio. +// +// Note that the "Run Script" build phase will copy the required frameworks +// or dylibs to your application bundle so you can execute it on any OS X +// computer. +// +// Your resource files (images, sounds, fonts, ...) are also copied to your +// application bundle. To get the path to these resource, use the helper +// method resourcePath() from ResourcePath.hpp +// + +#include +#include + +// Here is a small helper for you ! Have a look. +#include "ResourcePath.hpp" + +#include "Sky.h" +#include "Texture.h" +#include "Hero.h" +#include "Sound.h" + +int main() +{ + Texture::load(); + Sound::load(); + + Sky* sky = Sky::getInstance(); + sf::RenderWindow* window = sky->getWindow(); + + Sound::BACK_GROUND.play(); + + // Hero就是自己的飞机哈! + Hero hero; + sky->add(&hero); + + // Start the game loop + while (window->isOpen()) + { + // Process events + sf::Event event; + while (window->pollEvent(event)) + { + // Close window : exit + if (event.type == sf::Event::Closed) { + window->close(); + } + + // Escape pressed : exit + if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) { + window->close(); + } + + // Left Arrow pressed + if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left) { + hero.move2left(); + } + + // Right Arrow pressed + if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Right) { + hero.move2right(); + } + + + // Up Arrow pressed:hero fire + if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up) { + hero.fire(); + } + } + + sky->refresh(); + } + + return EXIT_SUCCESS; +} diff --git a/CCppExamples-master/Fighters/Fighters/resources/font/STHeiti Light.ttc b/CCppExamples-master/Fighters/Fighters/resources/font/STHeiti Light.ttc new file mode 100644 index 00000000..c1260a89 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/font/STHeiti Light.ttc differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/font/kl.ttc b/CCppExamples-master/Fighters/Fighters/resources/font/kl.ttc new file mode 100644 index 00000000..c1260a89 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/font/kl.ttc differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/font/stheitisc.ttf b/CCppExamples-master/Fighters/Fighters/resources/font/stheitisc.ttf new file mode 100644 index 00000000..17ecef22 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/font/stheitisc.ttf differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/image/background.png b/CCppExamples-master/Fighters/Fighters/resources/image/background.png new file mode 100644 index 00000000..18ae6abb Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/image/background.png differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/image/gameover.png b/CCppExamples-master/Fighters/Fighters/resources/image/gameover.png new file mode 100644 index 00000000..105eebb9 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/image/gameover.png differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/image/shoot.pack b/CCppExamples-master/Fighters/Fighters/resources/image/shoot.pack new file mode 100644 index 00000000..f971c652 --- /dev/null +++ b/CCppExamples-master/Fighters/Fighters/resources/image/shoot.pack @@ -0,0 +1,236 @@ + +shoot.png +format: RGBA8888 +filter: Nearest,Nearest +repeat: none +enemy3_down6 + rotate: false + xy: 0, 747 + size: 166, 261 + orig: 166, 261 + offset: 0, 0 + index: -1 +enemy3_hit + rotate: false + xy: 166, 750 + size: 169, 258 + orig: 169, 258 + offset: 0, 0 + index: -1 +enemy3_n1 + rotate: false + xy: 335, 750 + size: 169, 258 + orig: 169, 258 + offset: 0, 0 + index: -1 +enemy3_n2 + rotate: false + xy: 504, 750 + size: 169, 258 + orig: 169, 258 + offset: 0, 0 + index: -1 +enemy3_down1 + rotate: false + xy: 0, 486 + size: 165, 261 + orig: 165, 261 + offset: 0, 0 + index: -1 +enemy3_down2 + rotate: false + xy: 0, 225 + size: 165, 261 + orig: 165, 261 + offset: 0, 0 + index: -1 +enemy3_down5 + rotate: false + xy: 673, 748 + size: 166, 260 + orig: 166, 260 + offset: 0, 0 + index: -1 +enemy3_down3 + rotate: false + xy: 839, 748 + size: 165, 260 + orig: 165, 260 + offset: 0, 0 + index: -1 +enemy3_down4 + rotate: false + xy: 165, 486 + size: 165, 261 + orig: 165, 261 + offset: 0, 0 + index: -1 +hero1 + rotate: false + xy: 0, 99 + size: 102, 126 + orig: 102, 126 + offset: 0, 0 + index: -1 +hero2 + rotate: false + xy: 165, 360 + size: 102, 126 + orig: 102, 126 + offset: 0, 0 + index: -1 +hero_blowup_n1 + rotate: false + xy: 165, 234 + size: 102, 126 + orig: 102, 126 + offset: 0, 0 + index: -1 +hero_blowup_n2 + rotate: false + xy: 330, 624 + size: 102, 126 + orig: 102, 126 + offset: 0, 0 + index: -1 +hero_blowup_n3 + rotate: false + xy: 330, 498 + size: 102, 126 + orig: 102, 126 + offset: 0, 0 + index: -1 +hero_blowup_n4 + rotate: false + xy: 432, 624 + size: 102, 126 + orig: 102, 126 + offset: 0, 0 + index: -1 +enemy2 + rotate: false + xy: 0, 0 + size: 69, 99 + orig: 69, 99 + offset: 0, 0 + index: -1 +enemy2_hit + rotate: false + xy: 432, 525 + size: 69, 99 + orig: 69, 99 + offset: 0, 0 + index: -1 +ufo2 + rotate: false + xy: 102, 118 + size: 60, 107 + orig: 60, 107 + offset: 0, 0 + index: -1 +enemy2_down1 + rotate: false + xy: 534, 655 + size: 69, 95 + orig: 69, 95 + offset: 0, 0 + index: -1 +enemy2_down2 + rotate: false + xy: 603, 655 + size: 69, 95 + orig: 69, 95 + offset: 0, 0 + index: -1 +enemy2_down3 + rotate: false + xy: 672, 653 + size: 69, 95 + orig: 69, 95 + offset: 0, 0 + index: -1 +enemy2_down4 + rotate: false + xy: 741, 653 + size: 69, 95 + orig: 69, 95 + offset: 0, 0 + index: -1 +ufo1 + rotate: false + xy: 267, 398 + size: 58, 88 + orig: 58, 88 + offset: 0, 0 + index: -1 +bomb + rotate: false + xy: 810, 691 + size: 63, 57 + orig: 63, 57 + offset: 0, 0 + index: -1 +enemy1_down1 + rotate: false + xy: 267, 347 + size: 57, 51 + orig: 57, 51 + offset: 0, 0 + index: -1 +enemy1_down2 + rotate: false + xy: 873, 697 + size: 57, 51 + orig: 57, 51 + offset: 0, 0 + index: -1 +enemy1_down3 + rotate: false + xy: 267, 296 + size: 57, 51 + orig: 57, 51 + offset: 0, 0 + index: -1 +enemy1_down4 + rotate: false + xy: 930, 697 + size: 57, 51 + orig: 57, 51 + offset: 0, 0 + index: -1 +game_pause_nor + rotate: false + xy: 267, 251 + size: 60, 45 + orig: 60, 45 + offset: 0, 0 + index: -1 +game_pause_pressed + rotate: false + xy: 810, 646 + size: 60, 45 + orig: 60, 45 + offset: 0, 0 + index: -1 +enemy1 + rotate: false + xy: 534, 612 + size: 57, 43 + orig: 57, 43 + offset: 0, 0 + index: -1 +bullet1 + rotate: false + xy: 1004, 987 + size: 9, 21 + orig: 9, 21 + offset: 0, 0 + index: -1 +bullet2 + rotate: false + xy: 69, 78 + size: 9, 21 + orig: 9, 21 + offset: 0, 0 + index: -1 diff --git a/CCppExamples-master/Fighters/Fighters/resources/image/shoot.png b/CCppExamples-master/Fighters/Fighters/resources/image/shoot.png new file mode 100644 index 00000000..47d85ced Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/image/shoot.png differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/image/shoot1.png b/CCppExamples-master/Fighters/Fighters/resources/image/shoot1.png new file mode 100644 index 00000000..bbe68b23 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/image/shoot1.png differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/achievement.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/achievement.ogg new file mode 100644 index 00000000..1d459c28 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/achievement.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/big_spaceship_flying.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/big_spaceship_flying.ogg new file mode 100644 index 00000000..98cc00cd Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/big_spaceship_flying.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/bullet.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/bullet.ogg new file mode 100644 index 00000000..175f5b01 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/bullet.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/button.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/button.ogg new file mode 100644 index 00000000..87de5ddf Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/button.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/enemy1_down.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/enemy1_down.ogg new file mode 100644 index 00000000..7023b908 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/enemy1_down.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/enemy2_down.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/enemy2_down.ogg new file mode 100644 index 00000000..725c0847 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/enemy2_down.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/enemy3_down.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/enemy3_down.ogg new file mode 100644 index 00000000..d7e982c8 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/enemy3_down.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/game_music.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/game_music.ogg new file mode 100644 index 00000000..9ef2e180 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/game_music.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/game_over.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/game_over.ogg new file mode 100644 index 00000000..5a7a507a Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/game_over.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/get_bomb.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/get_bomb.ogg new file mode 100644 index 00000000..336a4c6c Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/get_bomb.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/get_double_laser.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/get_double_laser.ogg new file mode 100644 index 00000000..50d4a404 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/get_double_laser.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/out_porp.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/out_porp.ogg new file mode 100644 index 00000000..1e20b584 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/out_porp.ogg differ diff --git a/CCppExamples-master/Fighters/Fighters/resources/sound/use_bomb.ogg b/CCppExamples-master/Fighters/Fighters/resources/sound/use_bomb.ogg new file mode 100644 index 00000000..2e2adc77 Binary files /dev/null and b/CCppExamples-master/Fighters/Fighters/resources/sound/use_bomb.ogg differ diff --git a/CCppExamples-master/Readme.md b/CCppExamples-master/Readme.md new file mode 100644 index 00000000..3e71a0a0 --- /dev/null +++ b/CCppExamples-master/Readme.md @@ -0,0 +1,17 @@ +# C/C++代码示例汇集 + +# slides: + +* [http://luckymark.github.io/CCppExamples/](http://luckymark.github.io/CCppExamples/) + +# wiki首页: + +* [https://github.com/luckymark/CCppExamples/wiki](https://github.com/luckymark/CCppExamples/wiki) + +# Fighters(打飞机)子项目说明: + +* 基于小巧玲珑的图形库SFML +* SFML的github网址 [https://github.com/LaurentGomila/SFML](https://github.com/LaurentGomila/SFML) +* SFML官网 [http://www.sfml-dev.org/](http://www.sfml-dev.org/) +* SFML教程 [http://www.sfml-dev.org/tutorials/2.1/](http://www.sfml-dev.org/tutorials/2.1/) +* SFMLAPI [http://www.sfml-dev.org/documentation/2.1/](http://www.sfml-dev.org/documentation/2.1/) diff --git a/CCppExamples-master/computer_sales/computer_sales.vcxproj b/CCppExamples-master/computer_sales/computer_sales.vcxproj new file mode 100644 index 00000000..465250bd --- /dev/null +++ b/CCppExamples-master/computer_sales/computer_sales.vcxproj @@ -0,0 +1,82 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {9B1C0DE1-8C9C-492F-83CE-CAEE4D7706E7} + Win32Proj + computer_sales + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/CCppExamples-master/computer_sales/computer_sales.vcxproj.filters b/CCppExamples-master/computer_sales/computer_sales.vcxproj.filters new file mode 100644 index 00000000..8755a3a0 --- /dev/null +++ b/CCppExamples-master/computer_sales/computer_sales.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/CCppExamples-master/computer_sales/main.cpp b/CCppExamples-master/computer_sales/main.cpp new file mode 100644 index 00000000..be01b8fd --- /dev/null +++ b/CCppExamples-master/computer_sales/main.cpp @@ -0,0 +1,95 @@ +#include "iostream" +using namespace std; + +struct Computer{ + char model[20]; + int total; +}computers[100]; + +int modelCount = 0; + +void list(); +void enterWarehouse(); +void outWarehouse(); +void input(struct Computer &computer); +int find(char* model); + +int main() +{ + int action; + do{ + cout<<"-----------菜单-----------"<>action; + switch(action){ + case 1: + list(); + break; + case 2: + enterWarehouse(); + break; + case 3: + outWarehouse(); + break; + case 4: + return 0; + default: + cout<<"您输入了错误的菜单项,请重新选择!"; + } + }while(1); +} + +void list(){ + cout<<"-------库存-------"<>computer.model; + + cout<<"数量:"; + cin>>computer.total; +} + +int find(char* model){ + int i; + for(i=0;i + + + + Debug + Win32 + + + Release + Win32 + + + + {F474D00A-349A-4EEF-8E33-F604C8569517} + Win32Proj + helloworld + chap1_helloworld + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/CCppExamples-master/helloworld/helloworld.vcxproj.filters b/CCppExamples-master/helloworld/helloworld.vcxproj.filters new file mode 100644 index 00000000..70a502db --- /dev/null +++ b/CCppExamples-master/helloworld/helloworld.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/CCppExamples-master/xcode/computer_sales_oo/computer_sales_oo.xcodeproj/project.pbxproj b/CCppExamples-master/xcode/computer_sales_oo/computer_sales_oo.xcodeproj/project.pbxproj new file mode 100644 index 00000000..6fb7d7c4 --- /dev/null +++ b/CCppExamples-master/xcode/computer_sales_oo/computer_sales_oo.xcodeproj/project.pbxproj @@ -0,0 +1,284 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + F46262CD181411C60040B416 /* computer_sales_oo.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = F46262CC181411C60040B416 /* computer_sales_oo.1 */; }; + F46262E8181413060040B416 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46262DD181413060040B416 /* main.cpp */; }; + F46262E9181413060040B416 /* Computer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46262DF181413060040B416 /* Computer.cpp */; }; + F46262EA181413060040B416 /* ComputerSales.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46262E0181413060040B416 /* ComputerSales.cpp */; }; + F46262EE181413060040B416 /* Menu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46262E4181413060040B416 /* Menu.cpp */; }; + F46262F1181413060040B416 /* WareHouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F46262E7181413060040B416 /* WareHouse.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + F46262C5181411C60040B416 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + F46262CD181411C60040B416 /* computer_sales_oo.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + F46262C7181411C60040B416 /* computer_sales_oo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = computer_sales_oo; sourceTree = BUILT_PRODUCTS_DIR; }; + F46262CC181411C60040B416 /* computer_sales_oo.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = computer_sales_oo.1; sourceTree = ""; }; + F46262D4181413060040B416 /* Computer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Computer.h; sourceTree = ""; }; + F46262D5181413060040B416 /* ComputerSales.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComputerSales.h; sourceTree = ""; }; + F46262D6181413060040B416 /* EnterWareHouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnterWareHouse.h; sourceTree = ""; }; + F46262D7181413060040B416 /* Exit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exit.h; sourceTree = ""; }; + F46262D8181413060040B416 /* ListWareHouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListWareHouse.h; sourceTree = ""; }; + F46262D9181413060040B416 /* Menu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Menu.h; sourceTree = ""; }; + F46262DA181413060040B416 /* MenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuItem.h; sourceTree = ""; }; + F46262DB181413060040B416 /* OutWareHouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OutWareHouse.h; sourceTree = ""; }; + F46262DC181413060040B416 /* WareHouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WareHouse.h; sourceTree = ""; }; + F46262DD181413060040B416 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../../ComputerSales_oo/main.cpp; sourceTree = ""; }; + F46262DF181413060040B416 /* Computer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Computer.cpp; sourceTree = ""; }; + F46262E0181413060040B416 /* ComputerSales.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComputerSales.cpp; sourceTree = ""; }; + F46262E4181413060040B416 /* Menu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Menu.cpp; sourceTree = ""; }; + F46262E7181413060040B416 /* WareHouse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WareHouse.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F46262C4181411C60040B416 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F46262BE181411C60040B416 = { + isa = PBXGroup; + children = ( + F46262C9181411C60040B416 /* computer_sales_oo */, + F46262C8181411C60040B416 /* Products */, + ); + sourceTree = ""; + }; + F46262C8181411C60040B416 /* Products */ = { + isa = PBXGroup; + children = ( + F46262C7181411C60040B416 /* computer_sales_oo */, + ); + name = Products; + sourceTree = ""; + }; + F46262C9181411C60040B416 /* computer_sales_oo */ = { + isa = PBXGroup; + children = ( + F46262D3181413060040B416 /* include */, + F46262DD181413060040B416 /* main.cpp */, + F46262DE181413060040B416 /* src */, + F46262CC181411C60040B416 /* computer_sales_oo.1 */, + ); + path = computer_sales_oo; + sourceTree = ""; + }; + F46262D3181413060040B416 /* include */ = { + isa = PBXGroup; + children = ( + F46262D4181413060040B416 /* Computer.h */, + F46262D5181413060040B416 /* ComputerSales.h */, + F46262D6181413060040B416 /* EnterWareHouse.h */, + F46262D7181413060040B416 /* Exit.h */, + F46262D8181413060040B416 /* ListWareHouse.h */, + F46262D9181413060040B416 /* Menu.h */, + F46262DA181413060040B416 /* MenuItem.h */, + F46262DB181413060040B416 /* OutWareHouse.h */, + F46262DC181413060040B416 /* WareHouse.h */, + ); + name = include; + path = ../../../ComputerSales_oo/include; + sourceTree = ""; + }; + F46262DE181413060040B416 /* src */ = { + isa = PBXGroup; + children = ( + F46262DF181413060040B416 /* Computer.cpp */, + F46262E0181413060040B416 /* ComputerSales.cpp */, + F46262E4181413060040B416 /* Menu.cpp */, + F46262E7181413060040B416 /* WareHouse.cpp */, + ); + name = src; + path = ../../../ComputerSales_oo/src; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F46262C6181411C60040B416 /* computer_sales_oo */ = { + isa = PBXNativeTarget; + buildConfigurationList = F46262D0181411C60040B416 /* Build configuration list for PBXNativeTarget "computer_sales_oo" */; + buildPhases = ( + F46262C3181411C60040B416 /* Sources */, + F46262C4181411C60040B416 /* Frameworks */, + F46262C5181411C60040B416 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = computer_sales_oo; + productName = computer_sales_oo; + productReference = F46262C7181411C60040B416 /* computer_sales_oo */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F46262BF181411C60040B416 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0500; + ORGANIZATIONNAME = luckymark; + }; + buildConfigurationList = F46262C2181411C60040B416 /* Build configuration list for PBXProject "computer_sales_oo" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = F46262BE181411C60040B416; + productRefGroup = F46262C8181411C60040B416 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F46262C6181411C60040B416 /* computer_sales_oo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + F46262C3181411C60040B416 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F46262F1181413060040B416 /* WareHouse.cpp in Sources */, + F46262E9181413060040B416 /* Computer.cpp in Sources */, + F46262E8181413060040B416 /* main.cpp in Sources */, + F46262EE181413060040B416 /* Menu.cpp in Sources */, + F46262EA181413060040B416 /* ComputerSales.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + F46262CE181411C60040B416 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + F46262CF181411C60040B416 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + SDKROOT = macosx; + }; + name = Release; + }; + F46262D1181411C60040B416 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + F46262D2181411C60040B416 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F46262C2181411C60040B416 /* Build configuration list for PBXProject "computer_sales_oo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F46262CE181411C60040B416 /* Debug */, + F46262CF181411C60040B416 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F46262D0181411C60040B416 /* Build configuration list for PBXNativeTarget "computer_sales_oo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F46262D1181411C60040B416 /* Debug */, + F46262D2181411C60040B416 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = F46262BF181411C60040B416 /* Project object */; +} diff --git a/CCppExamples-master/xcode/computer_sales_oo/computer_sales_oo/computer_sales_oo.1 b/CCppExamples-master/xcode/computer_sales_oo/computer_sales_oo/computer_sales_oo.1 new file mode 100644 index 00000000..baae96b2 --- /dev/null +++ b/CCppExamples-master/xcode/computer_sales_oo/computer_sales_oo/computer_sales_oo.1 @@ -0,0 +1,79 @@ +.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. +.\"See Also: +.\"man mdoc.samples for a complete listing of options +.\"man mdoc for the short list of editing options +.\"/usr/share/misc/mdoc.template +.Dd 13-10-20 \" DATE +.Dt computer_sales_oo 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm computer_sales_oo, +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.Nm Other_name_for_same_program(), +.Nm Yet another name for the same program. +.\" Use .Nm macro to designate other names for the documented program. +.Nd This line parsed for whatis database. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl abcd \" [-abcd] +.Op Fl a Ar path \" [-a path] +.Op Ar file \" [file] +.Op Ar \" [file ...] +.Ar arg0 \" Underlined argument - use .Ar anywhere to underline +arg2 ... \" Arguments +.Sh DESCRIPTION \" Section Header - required - don't modify +Use the .Nm macro to refer to your program throughout the man page like such: +.Nm +Underlining is accomplished with the .Ar macro like this: +.Ar underlined text . +.Pp \" Inserts a space +A list of items with descriptions: +.Bl -tag -width -indent \" Begins a tagged list +.It item a \" Each item preceded by .It macro +Description of item a +.It item b +Description of item b +.El \" Ends the list +.Pp +A list of flags and their descriptions: +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl a \"-a flag as a list item +Description of -a flag +.It Fl b +Description of -b flag +.El \" Ends the list +.Pp +.\" .Sh ENVIRONMENT \" May not be needed +.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 +.\" .It Ev ENV_VAR_1 +.\" Description of ENV_VAR_1 +.\" .It Ev ENV_VAR_2 +.\" Description of ENV_VAR_2 +.\" .El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact +.It Pa /usr/share/file_name +FILE_1 description +.It Pa /Users/joeuser/Library/really_long_file_name +FILE_2 description +.El \" Ends the list +.\" .Sh DIAGNOSTICS \" May not be needed +.\" .Bl -diag +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.\" Please do not reference files that do not exist without filing a bug report +.Xr a 1 , +.Xr b 1 , +.Xr c 1 , +.Xr a 2 , +.Xr b 2 , +.Xr a 3 , +.Xr b 3 +.\" .Sh BUGS \" Document known, unremedied bugs +.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file diff --git a/CCppExamples-master/xcode/xcode.xcworkspace/contents.xcworkspacedata b/CCppExamples-master/xcode/xcode.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..ed4b6636 --- /dev/null +++ b/CCppExamples-master/xcode/xcode.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CCppExamples-master/xcode/xcode.xcworkspace/xcshareddata/xcode.xccheckout b/CCppExamples-master/xcode/xcode.xcworkspace/xcshareddata/xcode.xccheckout new file mode 100644 index 00000000..ff7f626c --- /dev/null +++ b/CCppExamples-master/xcode/xcode.xcworkspace/xcshareddata/xcode.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + B8732634-87FF-4E6E-801E-46206D65F117 + IDESourceControlProjectName + xcode + IDESourceControlProjectOriginsDictionary + + 6C66385C-842C-42DA-9218-C34296355661 + https://github.com/luckymark/CppExamples + + IDESourceControlProjectPath + xcode/xcode.xcworkspace + IDESourceControlProjectRelativeInstallPathDictionary + + 6C66385C-842C-42DA-9218-C34296355661 + ../.. + + IDESourceControlProjectURL + https://github.com/luckymark/CppExamples + IDESourceControlProjectVersion + 110 + IDESourceControlProjectWCCIdentifier + 6C66385C-842C-42DA-9218-C34296355661 + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + 6C66385C-842C-42DA-9218-C34296355661 + IDESourceControlWCCName + CppExamples + + + + diff --git a/CCppExamples-master/xcode/xcode.xcworkspace/xcuserdata/luckystar.xcuserdatad/UserInterfaceState.xcuserstate b/CCppExamples-master/xcode/xcode.xcworkspace/xcuserdata/luckystar.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..a89fcb54 Binary files /dev/null and b/CCppExamples-master/xcode/xcode.xcworkspace/xcuserdata/luckystar.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CCppExamples-master/xcode/xcode.xcworkspace/xcuserdata/luckystar.xcuserdatad/WorkspaceSettings.xcsettings b/CCppExamples-master/xcode/xcode.xcworkspace/xcuserdata/luckystar.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..28f6741d --- /dev/null +++ b/CCppExamples-master/xcode/xcode.xcworkspace/xcuserdata/luckystar.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,22 @@ + + + + + BuildLocationStyle + UseAppPreferences + CustomBuildLocationType + RelativeToDerivedData + DerivedDataLocationStyle + Default + HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges + + IssueFilterStyle + ShowActiveSchemeOnly + LiveSourceIssuesEnabled + + SnapshotAutomaticallyBeforeSignificantChanges + + SnapshotLocationStyle + Default + + diff --git a/Code_of_fighter.cpp b/Code_of_fighter.cpp new file mode 100644 index 00000000..b78dd0d6 --- /dev/null +++ b/Code_of_fighter.cpp @@ -0,0 +1,2265 @@ +// fighter.cpp : ̨Ӧóڵ㡣 +// +#include "stdafx.h" +#include "My_plane.h" +#include "Object_manage.h" +#include "Enermy.h" +#include "Fly_BUlllet.h" +#include "Quicker_killer.h" +#include "rocket.h" +int window_width = 1000; +int window_heigth = 700; +RenderWindow the_window(VideoMode(window_width, window_heigth), "here! let's fight the plane"); +multimap My_plane_list;//ҵķɻ +vector MyBullet_list;//ҵӵ +vector Fly_BUlllet_list;// +vector quickBUllet_list;//㶮ĵǸرǿĹ +std::vector Enermy_Bullet_list;//еBullet +vector Enermy_list;//ʾĻϵķɻ +std::vector myplane_exploded_list; +Enermy *Object_manage::pointer[5] = { NULL }; +int Enermy::EnermyMax_Speed = 1; +int Enermy::Screen_max_enermy = 10; +int Enermy_Bullet::Enermy_BulletMax_speed = 2; +int Enermy::update_time = 1; +int Object_manage::update_now = 1; +int My_plane::space_time = 0; +int Enermy_Bullet::m = 0; +int Fly_BUlllet::is_first = 1; +int Object_manage::now_add_Help_pack = 0; +int Object_manage::need_update_superBullet = 0; +int Object_manage::all_speed = 35000; +int background::background_order = 1; +int Object_manage::pass = 0; +rocket* Object_manage::ro = new rocket; +int main() +{ + Object_manage manager; + manager.game_start(); + return 0; +} + + + +//background.h +#pragma once +class Object_manage; +class background +{ +public: + background(string filename); + ~background(); + Sprite get_background(); + friend class Object_manage; +private: + string filename0;//ļ + Texture image0;//ȡͼƬ + Sprite sprite0;//ͼƬ + static int background_order; + +}; + +//enermy.h +#pragma once +#include "stdafx.h" +#include "Object_manage.h" +#include "Explode.h" +#include "Enermy_Bullet.h" +#include "Explode_enermy.h" +//class Object_manage; +class Enermy_Bullet; +class Explode_enermy; +class Enermy//ÿԼըĵͼƬ +{ +public: + //Enermy(string fileName, string Bullet_filename); + Enermy(); + ~Enermy(); + float get_x(); + float get_y(); + string* get_explode(); +private: + deque exploed_plane; + string Enermy_filename;//ļ + Texture Enermy_image;//ȡͼƬ + Sprite Enermy_sprite;//ͼƬ + int Enermy_height; + int Enermy_width; + float Enermy_x; + float Enermy_y; + int Enermy_speed; + int is_new; + int is_on_screen; + int shooted_time; + int life; + int explode_time0; + string explode[3]; + static int EnermyMax_Speed; + static int Screen_max_enermy; + static int update_time; + friend class Object_manage; + friend class Enermy_Bullet; + sf::Time update_EnermyBullet_time;//60 + //sf::Time update_EnermyBullet_time = sf::milliseconds(10);//60 + Time time0; + sf::Clock clock0;//ʱʼʱ + //map Explode_Image_list; +}; + +//enermy_Bullet.h +#pragma once +#include "Object_manage.h" +class Enermy; +class Object_manage; +class Enermy_Bullet +{ +public: + Enermy_Bullet(Enermy *en); + ~Enermy_Bullet(); +protected: + string Enermy_Bullet_filename;//ļ + Texture Enermy_Bullet_image;//ȡͼƬ + Sprite Enermy_Bullet_sprite;//ͼƬ + int Enermy_Bullet_height; + int Enermy_Bullet_width; + int Bullet_is_on_screen; + int had_flew_out; + int aggressivity;// + float Enermy_Bullet_x; + float Enermy_Bullet_y; + int Enermy_Bullet_speed; + int Enermy_Bullet_is_new; + static int m; + static int Enermy_BulletMax_speed; + friend class Object_manage; +}; + +//explode.h +#pragma once +class Explode +{ +public: + Explode(); + ~Explode(); +private: + string _filename;//ļ + Texture _image;//ȡͼƬ + Sprite _sprite;//ͼƬ + float _x; + float _y; + friend class Object_manage; +}; + +//explode_Enermy.h +#pragma once +#include "Object_manage.h" +#include "Enermy.h" +class Enermy; +class Explode_enermy +{ +public: + Explode_enermy(Enermy *mm, int m); + ~Explode_enermy(); +private: + string _filename;//ļ + Texture _image;//ȡͼƬ + Sprite _sprite;//ͼƬ + float _x; + float _y; + friend class Object_manage; + friend class Enermy; +}; + +//Fly_Bullet.h +#pragma once +#include "Object_manage.h" +#include "Enermy.h" +class Enermy; +class Explode_enermy +{ +public: + Explode_enermy(Enermy *mm, int m); + ~Explode_enermy(); +private: + string _filename;//ļ + Texture _image;//ȡͼƬ + Sprite _sprite;//ͼƬ + float _x; + float _y; + friend class Object_manage; + friend class Enermy; +}; + +//My_plane.h +#pragma once +#include "stdafx.h" +//#include "Object_manage.h" +#include "MyBullet.h" +#include "MyPlane_explode.h" +class Object_manage; +class My_plane +{ +public: + My_plane(); + ~My_plane(); + Sprite get_myPlane_sprite(); + string get_myPlane_filename(); + int get_shooted_time(); + int get_Myplane_life(); + float get_My_x(); + float get_My_y(); + //string get_myPlane_filename(); + //Sprite set_myPlane_position(); + //void set_myPlane_image(); + //void show_myplane(RenderWindow &main_window); + Texture getTexture(); + friend class Object_manage; + friend class MyBullet; +private: + string myPlane_filename;//ļ + Texture myPlane_image;//ȡͼƬ + Sprite myPlane_sprite;//ͼƬ + float my_Plane_height; + float my_Plane_width; + float My_x; + float My_y; + int My_plane_speed; + int my_plane_life; + int shooted_time; + int the_Bullet_order; + string myplane_explode[3]; + string Myplane_type; + int show_Myplane; + int super_plane; + static int space_time; + //static multimap My_plane_list; +}; + + +//My_Bullet.h +#pragma once +#include "stdafx.h" +//#include "Object_manage.h" +#include "MyBullet.h" +#include "MyPlane_explode.h" +class Object_manage; +class My_plane +{ +public: + My_plane(); + ~My_plane(); + Sprite get_myPlane_sprite(); + string get_myPlane_filename(); + int get_shooted_time(); + int get_Myplane_life(); + float get_My_x(); + float get_My_y(); + //string get_myPlane_filename(); + //Sprite set_myPlane_position(); + //void set_myPlane_image(); + //void show_myplane(RenderWindow &main_window); + Texture getTexture(); + friend class Object_manage; + friend class MyBullet; +private: + string myPlane_filename;//ļ + Texture myPlane_image;//ȡͼƬ + Sprite myPlane_sprite;//ͼƬ + float my_Plane_height; + float my_Plane_width; + float My_x; + float My_y; + int My_plane_speed; + int my_plane_life; + int shooted_time; + int the_Bullet_order; + string myplane_explode[3]; + string Myplane_type; + int show_Myplane; + int super_plane; + static int space_time; + //static multimap My_plane_list; +}; + + +//Object_manager.h + +#pragma once +#include "stdafx.h" +#include "Object_manage.h" +#include "My_plane.h" +#include "Enermy.h" +#include "MyBullet.h" +#include "MyPlane_explode.h" +#include "background.h" +#include "Resolve_interface.h" +#include "start_interface.h" +#include "Fly_BUlllet.h" +#include "Quicker_killer.h" +#include "rocket.h" +class My_plane; +class MyBullet; +class Enermy; +class Fly_Bulllet; +class Quicker_killer; +class rocket; +class Object_manage +{ +public: + Object_manage(); + ~Object_manage(); + void update_All(); + void display_All(RenderWindow &the_window); + void add_MyBullet(MyBullet* Bullet); + void add_Enermy();//ӵ˵Ҫʾ + void add_Enermy_Bullet(); + void update_Myplane(RenderWindow &the_window); + void update_MyBullet(RenderWindow &the_window); + void update_Enermy(RenderWindow &the_window); + void show_explode_myPlane(RenderWindow &the_window); + void update_Enermy_Bullet(RenderWindow &the_window); + void add_plane(string name, My_plane *my);// + void crash_detector(); + void add_Fly_bullet(); + void update_Fly_bullet(); + void update_manage(); + void update_background(); + void game_loop(); + void game_start(); + void add_quicker_plane(); + void update_quicker_plane(); + void add_rocket(); + void draw_life(); + void draw_lifeNumber(); + void draw_score(); + void draw_score_name(); + void draw_rocketname(); + void draw_rocketQuantity(); + void draw_end_score_(); + void draw_endScoreName(); + void draw_pass(); + void control_next(); + //void draw _rocket(); + //void draw_rocket_number(); + int get_Update_help(); + double randa; + static Enermy* pointer[5]; + static int update_now; + +private: + enum game_status { begin_just_now, is_playing, is_exiting, game_over, pass_barrier, failed };//տʼϷ˳Ϸ + string enermy_filename[5]; + string enermy_Bullet_filename[5]; + const sf::Time update_Fly_BUllet_time = sf::seconds(11.0f);//2 + const sf::Time update_Enermy_time = sf::seconds(1.0f);//2 + const sf::Time update_all_time = sf::seconds(0.001f);//0.1 + const sf::Time UPdate_Enermy = sf::seconds(0.001f);//0.1 + const sf::Time UPDate_HelpPack = sf::seconds(10.0f); + int score_all; + int kill_enermy; + Time time; + Time FlyBUllet_time; + Time update_time; + Time update_enermy; + Time update_helpPack; + game_status Game_state; + background *bac[3]; + background *start_window; + sf::Clock update_clock; + sf::Clock clock;//ʱʼʱ + sf::Clock Flybullet_clock; + sf::Clock Update_enermy; + sf::Clock UPDATE_helpPack; + int enermy_start; + int flyBUllet_quantity; + start_interface *p;// + sf::Music shoot_sound; + sf::Music enermy_exploed; + sf::Music get; + sf::Music use_bomb; + static int now_add_Help_pack; + static int need_update_superBullet; + static rocket *ro; + static int all_speed; + static int pass; + char temp[100]; + char temp0[100]; + char temp1[100]; + sf::Text life; + sf::Text life_number; + sf::Text score; + sf::Text score_name; + sf::Font font; + sf::Text rocketname; + sf::Text rocket_quantity; + sf::Text _end_score; + sf::Text _end_scorename; + sf::Text _pass; + sf::Text _pass1; + //int screen_NO_enermies; +}; + +//Quicker_killer.h +#pragma once +class Object_manage; +class Quicker_killer +{ +public: + Quicker_killer(int order); + ~Quicker_killer(); + int get_width(); + int get_x(); + int get_y(); + int get_speed(); +private: + string filename;//ļ + Texture image;//ȡͼƬ + Sprite sprite;//ͼƬ + int width; + int speed; + int height; + int __x; + int __y; + friend class Object_manage; +}; + +//resolve_intreface +#pragma once +#include "stdafx.h" +class Resolve_interface +{ +public: + Resolve_interface(); + ~Resolve_interface(); +}; + +//rocket.h +#pragma once +class Object_manage; +class rocket +{ +public: + rocket(); + friend class Object_manage; + ~rocket(); +private: + string filename; + Texture image; + Sprite sprite; + int height; +}; +//start_interface.h +#pragma once +#include "Resolve_interface.h" +//#include "Object_manage.h" +class Object_manage; +class start_interface +{ +public: + enum MenuResult { Nothing, Exit, Play }; + struct MenuItem + { + public: + sf::Rect rect; + MenuResult action; + }; + MenuResult GetMenuResponse(sf::RenderWindow& window); + MenuResult HandleClick(int x, int y); + start_interface(); + ~start_interface(); + + void design_click_area(); +private: + friend class Object_manage; + list _menuItems; +}; + +//stdafx.h +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ + + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + +// TODO: ڴ˴óҪͷļ + + +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include "windows.h" +#include "iostream" +using namespace sf; +using namespace std; + +//background.cpp +#include "stdafx.h" +#include "background.h" + + +background::background(string filename) +{ + filename0 = filename;//ļ + if (filename0 != "image/start.psd") + { + if (background_order == 1) + { + filename0 = "image/background1.png"; + background_order = 2; + } + else + { + filename0 = "image/background2.png"; + background_order = 1; + } + } + if (!image0.loadFromFile(filename0))//ȡͼƬ + { + //cout << "ʧܣ"; + } + sprite0.setTexture(image0);//ͼƬ + sprite0.setOrigin(0, 0); +} +Sprite background::get_background() +{ + return sprite0; +} + +background::~background() +{ +} + + +//Enermy.cpp +#include "stdafx.h" +#include "Enermy.h" +extern int window_width; +extern int window_heigth; +//class Object_manage; + +Enermy::Enermy() +{ + float time_temp; + srand((unsigned)time(NULL)); + time_temp = rand() % 500 + 500; + update_EnermyBullet_time = sf::seconds(time_temp / 1000.0);//60 + explode_time0 = 0; + shooted_time = 0; + is_new = 1; + is_on_screen = 0; + srand((unsigned)time(NULL)); + int i = rand() % 3; + switch (i) + { + case 0:Enermy_filename = "image/p0.png"; life = 3; explode[0] = "image/cc_1.png"; explode[1] = "image/cc_2.png"; explode[2] = "image/cc_3.png"; break; + case 1:Enermy_filename = "image/p1.png"; life = 1; explode[0] = "image/bb.png"; explode[1] = "image/bb.png"; explode[2] = "image/bb.png"; break; + case 2:Enermy_filename = "image/p2.png"; life = 6; explode[0] = "image/aa_1.png"; explode[1] = "image/aa_2.png"; explode[2] = "image/aa_3.png"; break; + default: + break; + } + + if (!Enermy_image.loadFromFile(Enermy_filename))//ȡͼƬ + { + //cout << "Enermies load failed!"; + } + Enermy_sprite.setTexture(Enermy_image);//洢ͼƬ + Enermy_width = Enermy_image.getSize().x; + Enermy_height = Enermy_image.getSize().y; + srand((unsigned)time(0)); + Enermy_speed = rand() % Enermy::EnermyMax_Speed + 1;//лһ + Enermy_x = -(rand() % window_width) + 1;//лλĻ + //cout << Enermy_x << endl; + Enermy_y = Enermy_height / 2;// + Enermy_sprite.setOrigin(Enermy_x, Enermy_y); + //thisָ +} +Enermy::~Enermy() +{ + //cout << ""; +} + +float Enermy::get_x() +{ + return Enermy_x; +} + +float Enermy::get_y() +{ + return Enermy_y; +} +string *Enermy::get_explode() +{ + return explode; +} + + +//Enermy_Bullet.cpp +#include "stdafx.h" +#include "Enermy_Bullet.h" +#include "Enermy.h" + + + + +Enermy_Bullet::Enermy_Bullet(Enermy *en) +{ + + //cout << m << endl; + if ("image/p0.png" == en->Enermy_filename) + { + Enermy_Bullet_filename = "image/2_s.png"; + } + if ("image/p1.png" == en->Enermy_filename) + { + Enermy_Bullet_filename = "image/MyBullet0.png"; + } + if ("image/p2.png" == en->Enermy_filename) + { + srand((unsigned)time(NULL)); + int t = rand() % 3; + //cout <Enermy_width > Enermy_Bullet_width) + { + Enermy_Bullet_x = en->Enermy_x - (en->Enermy_width / 2 - Enermy_Bullet_width / 2); + } + else + { + Enermy_Bullet_x = en->Enermy_x + Enermy_Bullet_width / 2 - en->Enermy_width / 2; + } + /*if ("image/p1.png" == en->Enermy_filename) + { + Enermy_Bullet_x += 2; + }*/ + Enermy_Bullet_y = en->Enermy_y - en->Enermy_height;//Ϊyϱ봰ڱԵľ + Enermy_Bullet_sprite.setOrigin(Enermy_Bullet_x, Enermy_Bullet_y); +} + + +Enermy_Bullet::~Enermy_Bullet() +{ + //cout << "shanchuZD"; +} + +//Explode.cpp +#include "stdafx.h" +#include "Explode.h" + + +Explode::Explode() +{ +} + + +Explode::~Explode() +{ +} + +//Explode_enermy.cpp +#include "stdafx.h" +#include "Explode_enermy.h" +extern RenderWindow the_window; + +Explode_enermy::Explode_enermy(Enermy *mm, int m) +{ + if (0 == m) + { + _filename = mm->get_explode()[0]; + } + if (1 == m) + { + _filename = mm->get_explode()[1]; + } + if (2 == m) + { + _filename = mm->get_explode()[2]; + } + + if (!_image.loadFromFile(_filename)) + { + cout << "ըͼƬʧܣ"; + } + _sprite.setTexture(_image); + _x = mm->get_x(); + _y = mm->get_y(); + _sprite.setOrigin(_x, _y); + the_window.draw(_sprite); +} + + +Explode_enermy::~Explode_enermy() +{ +} + +//fight.cpp +// fighter.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include "My_plane.h" +#include "Object_manage.h" +#include "Enermy.h" +#include "Fly_BUlllet.h" +#include "Quicker_killer.h" +#include "rocket.h" +int window_width = 1000; +int window_heigth = 700; +RenderWindow the_window(VideoMode(window_width, window_heigth), "here! let's fight the plane"); +multimap My_plane_list;//ҵķɻ +vector MyBullet_list;//ҵӵ +vector Fly_BUlllet_list;// +vector quickBUllet_list;//㶮ĵǸرǿĹ +std::vector Enermy_Bullet_list;//еBullet +vector Enermy_list;//ʾĻϵķɻ +std::vector myplane_exploded_list; +Enermy *Object_manage::pointer[5] = { NULL }; +int Enermy::EnermyMax_Speed = 1; +int Enermy::Screen_max_enermy = 10; +int Enermy_Bullet::Enermy_BulletMax_speed = 2; +int Enermy::update_time = 1; +int Object_manage::update_now = 1; +int My_plane::space_time = 0; +int Enermy_Bullet::m = 0; +int Fly_BUlllet::is_first = 1; +int Object_manage::now_add_Help_pack = 0; +int Object_manage::need_update_superBullet = 0; +int Object_manage::all_speed = 35000; +int background::background_order = 1; +int Object_manage::pass = 0; +rocket* Object_manage::ro = new rocket; +int main() +{ + Object_manage manager; + manager.game_start(); + return 0; +} + + +//Fly_Bullet.cpp +#include "stdafx.h" +#include "Fly_BUlllet.h" +extern int window_width; +extern int window_heigth; + +Fly_BUlllet::Fly_BUlllet() +{ + Object_manage *a = new Object_manage; + if (a->get_Update_help()) + { + Fly_BUlllet_filename = "image/help.psd"; + } + else + { + if (is_first == 1) + { + Fly_BUlllet_filename = "image/3.1s.png"; + is_first = 0; + } + else + { + Fly_BUlllet_filename = "image/3.3s.png"; + is_first = 1; + } + } + + if (!Fly_BUlllett_image.loadFromFile(Fly_BUlllet_filename))//ȡͼƬ + { + cout << "Fly_BUlllett load failed!"; + } + left_or_right = rand() % 2 + 1;//12,12 + Fly_BUlllet_sprite.setTexture(Fly_BUlllett_image);//洢ͼƬ + //int Fly_BUlllet_height; + Fly_BUlllet_width = (float)Fly_BUlllett_image.getSize().x; + Fly_BUlllet_height = (float)Fly_BUlllett_image.getSize().y; + //cout << Fly_BUlllet_width<= -window_width/2) + { + //cout << "" << window_width< -Fly_BUlllet_width) + { + Fly_BUlllet_x = -3 * Fly_BUlllet_width; + } + if (abs(Fly_BUllet_y)<2 * Fly_BUlllet_height) + { + Fly_BUllet_y = -10 * Fly_BUlllet_height; + } + } + delete a; +} + + +Fly_BUlllet::~Fly_BUlllet() +{ +} + +//My_plane.cpp +#include "stdafx.h" +#include "My_plane.h" + + +My_plane::My_plane() +{ + my_plane_life = 5;//ͨӵҪ + show_Myplane = 1; + shooted_time = 0; + myplane_explode[0] = "image/plane1.png"; + myplane_explode[1] = "image/plane2.png"; + myplane_explode[2] = "image/plane3.png"; + myPlane_filename = "image/shoot.png";//ļ + if (!myPlane_image.loadFromFile(myPlane_filename)) //ȡͼƬ + { + cout << "your plane load failed!"; + } + myPlane_sprite.setTexture(myPlane_image);//洢ͼƬ + my_Plane_width = (float)myPlane_image.getSize().x; + my_Plane_height = (float)myPlane_image.getSize().y; + My_plane_speed = 40; + My_x = -500 + my_Plane_width / 2; + My_y = -700 + my_Plane_height; + myPlane_sprite.setOrigin(My_x, My_y); + super_plane = 0; + Myplane_type = "common"; +} + + +My_plane::~My_plane() +{ +} + +Sprite My_plane::get_myPlane_sprite() +{ + return myPlane_sprite; +} +string My_plane::get_myPlane_filename() +{ + return myPlane_filename; +} +Texture My_plane::getTexture() +{ + return myPlane_image; +} + + +int My_plane::get_shooted_time() +{ + return shooted_time; +} + +int My_plane::get_Myplane_life() +{ + return my_plane_life; +} + +float My_plane::get_My_x() +{ + return My_x; +} +float My_plane::get_My_y() +{ + return My_y; +} + +//My_bullet.cpp +#include "stdafx.h" +#include "My_plane.h" +#include "MyBullet.h" +extern multimap My_plane_list; +extern multimap MyBullet_list; + +MyBullet::MyBullet() +{ + multimap::iterator it; + it = My_plane_list.begin();//ҵö + MyBullet_filename = "image/MyBullet.png";//ļ + if (!MyBullet_image.loadFromFile(MyBullet_filename))//ȡͼƬ + { + cout << "your Bullet load failed!"; + } + MyBullet_sprite.setTexture(MyBullet_image);//洢ͼƬ + MyBullet_width = MyBullet_image.getSize().x; + MyBullet_height = MyBullet_image.getSize().y; + MyBullet_speed = 10; + //MyBullet_y = 0; + if (it->second->Myplane_type == "common") + { + MyBullet_y = it->second->My_y + 3;// + it->second->my_Plane_height; + MyBullet_x = it->second->My_x - it->second->my_Plane_width / 2 + 14; + } + else + { + MyBullet_y = it->second->My_y - it->second->my_Plane_height / 2; + if (it->second->the_Bullet_order == 1) + { + MyBullet_x = it->second->My_x - it->second->my_Plane_width / 8 + 10; + } + else + { + MyBullet_x = it->second->My_x - 3 * (it->second->my_Plane_width / 4) + 10; + } + } + MyBullet_sprite.setOrigin(MyBullet_x, MyBullet_y); +} + + + +//Myplane_explode.cpp +#include "stdafx.h" +#include "MyPlane_explode.h" +extern RenderWindow the_window; +MyPlane_explode::MyPlane_explode(My_plane *my) +{ + + if (my->get_shooted_time() < my->get_Myplane_life() / 3) + { + _filename = "image/plane1.png"; + //cout << "ը"; + } + else if (my->get_shooted_time() > 2 * (my->get_Myplane_life() / 3)) + { + _filename = "image/plane2.png"; + //cout << "2ը"; + } + else + { + _filename = "image/plane3.png"; + } + if (!_image.loadFromFile(_filename)) //ȡͼƬ + { + //cout << "your plane_exploding load failed!"<<_filename; + } + _sprite.setTexture(_image);//ͼƬ + _x = my->getTexture().getSize().x; + _y = my->getTexture().getSize().y; + _sprite.setOrigin(my->get_My_x(), my->get_My_y()); + the_window.draw(_sprite); +} + + +MyPlane_explode::~MyPlane_explode() +{ +} + +//Object_manage.cpp + +#include "stdafx.h" +#include "Object_manage.h" +class Enermy; +extern RenderWindow the_window; +extern multimap My_plane_list; +extern vector MyBullet_list; +extern std::vector Enermy_Bullet_list;//еBullet +extern vector Enermy_list;//ʾĻϵķɻ +extern std::vector myplane_exploded_list; +extern int window_width; +extern int window_heigth; +extern vector Fly_BUlllet_list;// +extern vector quickBUllet_list;//㶮ĵǸرǿĹ +Object_manage::Object_manage() +{ + srand((unsigned)std::time(NULL)); + //Fly_BUlllet_x = -rand() % (window_width - 90); + randa = -rand() % (window_heigth / 2);//ֻϰƽ + enermy_filename[0] = "image/0.png";//1.3ӵ + enermy_filename[1] = "image/1.png"; + enermy_filename[2] = "image/2.png"; + enermy_filename[3] = "image/3.png"; + enermy_filename[4] = "image/4.png"; + enermy_Bullet_filename[0] = "image/0_s.png"; + enermy_Bullet_filename[1] = "image/1_s.png"; + enermy_Bullet_filename[2] = "image/2_s.png"; + enermy_Bullet_filename[3] = "image/3_s.png"; + enermy_Bullet_filename[4] = "image/4_s.png"; + enermy_start = 0; + score_all = 0;//ܷ0 + flyBUllet_quantity = 0; + kill_enermy = 0;//ɱ0ge + //now_add_Help_pack = 0; + //sf::Music shoot_sound; + if (!shoot_sound.openFromFile("sound/bullet.ogg")) + { + cout << "ʧ"; + } + //enermy_exploed + if (!enermy_exploed.openFromFile("sound/enemy1_down.ogg")) + { + cout << "ըʧ"; + } + if (!get.openFromFile("sound/achievement.ogg")) + { + cout << "õʧ"; + } + if (!use_bomb.openFromFile("sound/use_bomb.ogg")) + { + cout << "ʹõʧ"; + } + if (!font.loadFromFile("font/stheitisc.ttf")) + { + cout << "ʧܣ"; + } + //life + life.setFont(font); + life.setString("life:"); + sf::Color color = Color::Red; + life.setFillColor(color); + life.setCharacterSize(40); + life.setPosition(0, 0); + //life_number + life_number.setFont(font); + life_number.setFillColor(sf::Color::Black); + life_number.setCharacterSize(40); + life_number.setPosition(110, 0); + + //life.setString + score_name.setString("score:"); + score_name.setFont(font); + score_name.setFillColor(Color::Blue); + score_name.setCharacterSize(40); + score_name.setPosition(0, 40); + + + //rocker_name + rocketname.setString("Rocket:"); + rocketname.setFont(font); + rocketname.setFillColor(Color::Red); + rocketname.setCharacterSize(40); + rocketname.setPosition(100, 580); + + //rocket_quantity + + rocket_quantity.setFont(font); + rocket_quantity.setFillColor(Color::Black); + rocket_quantity.setCharacterSize(40); + rocket_quantity.setPosition(280, 580); + + + score.setFont(font); + score.setFillColor(sf::Color::Black); + score.setCharacterSize(40); + score.setPosition(150, 40); + //score.setPosition(0,40); + + //end score_name + _end_scorename.setFont(font); + _end_scorename.setString("your score:"); + _end_scorename.setFillColor(color); + _end_scorename.setCharacterSize(50); + _end_scorename.setPosition(250, 250); + + //end_score + _end_score.setFont(font); + //_end_score.setString("your score:"); + _end_score.setFillColor(sf::Color::Yellow); + _end_score.setCharacterSize(50); + _end_score.setPosition(630, 250); + + //pass + _pass.setFont(font); + _pass.setString("exit,please enter Q"); + _pass.setFillColor(sf::Color::Red); + _pass.setCharacterSize(50); + _pass.setPosition(200, 325); + + //pass_1 + _pass1.setFont(font); + _pass1.setString("continue,please enter N"); + _pass1.setFillColor(sf::Color::Red); + _pass1.setCharacterSize(50); + _pass1.setPosition(180, 400); + +} + +void Object_manage::draw_pass() +{ + the_window.draw(_pass); + the_window.draw(_pass1); +} +void Object_manage::game_loop() +{ + if (Game_state == begin_just_now) + { + p = new start_interface;// + //Game_state= begin_just_now;//״̬ + for (int i = 0; i < 2; i++) + { + bac[i] = new background("image/background.png");//ӱ + } + int temp; + if (My_plane_list.empty()) + { + + } + else + { + multimap::iterator it; + it = My_plane_list.begin(); + temp = it->second->my_plane_life; + } + + My_plane_list.clear(); + MyBullet_list.clear();//ҵӵ + Fly_BUlllet_list.clear();// + quickBUllet_list.clear();//㶮ĵǸرǿĹ + Enermy_Bullet_list.clear();// + add_plane("image/shoot.png", new My_plane);//ҵķɻ + multimap::iterator ita; + ita = My_plane_list.begin(); + + if (!pass)//û + { + score_all = 0; + } + else + { + pass = 0; + ita->second->my_plane_life = temp; + } + kill_enermy = 0; + start_window = new background("image/start.psd");// + + //p = new start_interface;// + start_interface::MenuResult mk; + the_window.clear(); + the_window.draw(start_window->get_background()); + the_window.display(); + //p->GetMenuResponse(the_window); + while (1) + { + mk = p->GetMenuResponse(the_window); + if (mk == p->Nothing) + { + continue; + } + if (mk == p->Play) + { + //{begin_just_now, is_playing, is_exiting, game_over, pass_barrier, failed}; + Game_state = is_playing; + break; + } + if (mk == p->Exit) + { + //cout << "aaaaaa"; + Game_state = game_over; + break; + } + } + } + if (Game_state == game_over) + { + + the_window.clear(); + draw_life(); + life_number.setFillColor(sf::Color::Yellow); + draw_lifeNumber(); + draw_end_score_(); + draw_endScoreName(); + the_window.display(); + Sleep(2000); + Game_state = begin_just_now; + + } + if (Game_state == pass_barrier) + { + pass = 1; + all_speed -= 5; + the_window.clear(); + draw_life(); + life_number.setFillColor(sf::Color::Yellow); + draw_lifeNumber(); + draw_end_score_(); + draw_endScoreName(); + draw_pass(); + the_window.display(); + + //Sleep(2000); + //Game_state = begin_just_now; + Event ev; + int t = 0; + while (1) + { + while (the_window.pollEvent(ev))//ϢȡϢ + { + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Q))//ؼ + { + //cout << "q"; + exit(0); + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::N))//ؼ + { + //cout << "N"; + Game_state = begin_just_now; + t = 1; + break; + + } + } + if (1 == t) + { + break; + } + } + } + if (Game_state == is_playing) + { + update_time = update_clock.getElapsedTime(); + if (operator>=(update_time, update_all_time)) + { + update_time = update_clock.restart(); + multimap::iterator it_myPlane; + it_myPlane = My_plane_list.begin(); + if (it_myPlane->second->my_plane_life <= 0) + { + it_myPlane->second->my_plane_life = 0; + Game_state = failed; + //draw_life(); + //return; + } + else + { + the_window.clear(); + update_All();//λ + display_All(the_window);//ʾڴ + } + } + else + { + the_window.display(); + } + /*the_window.clear(); + update_All();//λ + display_All(the_window);//ʾڴ*/ + } + //is_exiting + +} + + +void Object_manage::draw_life() +{ + the_window.draw(life); +} + +void Object_manage::draw_end_score_() +{ + _itoa_s(score_all, temp0, 10); + _end_score.setString(temp0); + the_window.draw(_end_score); +} +void Object_manage::draw_endScoreName() +{ + the_window.draw(_end_scorename); +} +void Object_manage::draw_rocketname() +{ + the_window.draw(rocketname); +} +void Object_manage::draw_rocketQuantity() +{ + multimap::iterator it; + it = My_plane_list.begin();//һ + _itoa_s(it->second->super_plane, temp, 10); + rocket_quantity.setString(temp); + the_window.draw(rocket_quantity); +} +void Object_manage::draw_lifeNumber() +{ + multimap::iterator it; + it = My_plane_list.begin();//һ + _itoa_s(it->second->get_Myplane_life(), temp, 10); + life_number.setString(temp); + the_window.draw(life_number); +} +void Object_manage::draw_score() +{ + _itoa_s(score_all, temp0, 10); + score.setString(temp0); + the_window.draw(score); + +} +void Object_manage::draw_score_name() +{ + the_window.draw(score_name); +} +void Object_manage::control_next() +{ + if (kill_enermy >= 50) + { + Game_state = pass_barrier; + } +} + +void Object_manage::update_All() +{ + + for (int j = 0; j <= all_speed; j++) + { + } + update_background(); + add_rocket(); + draw_life(); + draw_lifeNumber(); + draw_score_name(); + draw_rocketname(); + draw_score(); + draw_rocketQuantity(); + update_quicker_plane(); + crash_detector(); + update_Myplane(the_window);//չʾ + update_MyBullet(the_window); + add_Enermy(); + update_Enermy(the_window); + add_Enermy_Bullet(); + update_Enermy_Bullet(the_window); + add_Fly_bullet(); + update_Fly_bullet(); + control_next(); +} + + + +//void draw _rocket(); +//void draw_rocket_number(); +void Object_manage::add_quicker_plane() +{ + //vector::iterator itm=quickBUllet_list.begin() + + Quicker_killer *h = new Quicker_killer(1); + int t = window_width / (h->get_width() / 2); + //Object_manage::need_update_superBullet = t;//Ҫµ + for (int i = 0; i <= t; i++) + { + cout << ""; + quickBUllet_list.push_back(new Quicker_killer(i)); + } + delete h; + +} + + +void Object_manage::add_rocket() +{ + the_window.draw(ro->sprite); +} +void Object_manage::update_quicker_plane() +{ + //extern vector quickBUllet_list + /* if (Object_manage::need_update_superBullet<=0) + { + return; + }*/ + vector::iterator itm; + for (itm = quickBUllet_list.begin(); itm != quickBUllet_list.end();) + { + if ((*itm)->get_y() >= 0) + { + delete (*itm); + Object_manage::need_update_superBullet--; + itm = quickBUllet_list.erase(itm); + continue; + } + //cout << "½"; + (*itm)->__y += (*itm)->speed; + (*itm)->sprite.setOrigin((*itm)->__x, (*itm)->__y); + the_window.draw((*itm)->sprite); + itm++; + } +} +int Object_manage::get_Update_help() +{ + return now_add_Help_pack; +} + + + +void Object_manage::update_background() +{ + if (background::background_order == 1) + { + the_window.draw(bac[0]->sprite0); + background::background_order = 2; + //cout << "һ"; + } + else + { + the_window.draw(bac[1]->sprite0); + background::background_order = 1; + //cout << "Ƕ"; + } + /*for (int i = 0; i <= 1; i++) + { + cout << bac[i]->filename0 << endl; + }*/ +} + +void Object_manage::game_start() +{ + sf::Music a; + if (!a.openFromFile("sound/game_music.ogg")) + { + cout << "ʼʧ"; + } + a.setLoop(1); + a.play(); + Game_state = begin_just_now; + /*;//״̬ + for (int i = 0; i < 2; i++) + { + bac[i] = new background("image/background.png");//ӱ + } + start_window = new background("image/start.psd");// + add_plane("image/shoot.png", new My_plane);//ҵķɻ + p = new start_interface;//*/ + while (1) + { + game_loop();//Ϸ + } + + +} + +Object_manage::~Object_manage() +{ + +} + + + + +void Object_manage::add_plane(string name, My_plane* my) +{ + My_plane_list.insert(multimap::value_type(name, my)); +} + + + +void Object_manage::update_Myplane(RenderWindow &the_window) +{ + + /*if (0==My_plane_list.size()) + { + cout << "game over!"; + Sleep(5000); + exit(0); + }*/ + multimap::iterator it; + if (My_plane_list.empty()) + { + return; + } + it = My_plane_list.begin();//һ + float temp = it->second->My_x; + float temp0 = it->second->My_y; + /*if (0 == it->show_Myplane) + { + show + }*/ + Event ev; + + + while (the_window.pollEvent(ev))//ϢȡϢ + { + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))//ؼ + { + it->second->My_x = it->second->My_x + it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) + { + it->second->My_x = it->second->My_x - it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) + { + it->second->My_y = it->second->My_y + it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) + { + it->second->My_y = it->second->My_y - it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))//ӵ + { + My_plane::space_time++; + if (My_plane::space_time >= 2) + { + if (it->second->Myplane_type == "common") + { + MyBullet *Bullet = new MyBullet; + shoot_sound.play(); + add_MyBullet(Bullet); + } + else//˫ӵ + { + for (int i = 0; i < 2; i++) + { + MyBullet *Bullet = new MyBullet; + shoot_sound.play(); + add_MyBullet(Bullet); + it->second->the_Bullet_order = i + 1; + } + it->second->the_Bullet_order = 0; + } + My_plane::space_time = 0; + } + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl))// + { + cout << "ctrl" << endl; + cout << it->second->super_plane << endl; + if (it->second->super_plane >= 1) + { + add_quicker_plane(); + use_bomb.play(); + it->second->super_plane--; + } + + } + if (ev.type == Event::EventType::Closed) + { + exit(0); + } + } + if (it->second->My_y>0 || it->second->My_y< -window_heigth + it->second->my_Plane_height) + { + it->second->My_y = temp0; + } + if (it->second->My_x>it->second->my_Plane_width / 2 || it->second->My_x < -window_width + it->second->my_Plane_width / 2) + { + it->second->My_x = temp; + } + it->second->myPlane_sprite.setOrigin(it->second->My_x, it->second->My_y);//λ + the_window.draw(it->second->myPlane_sprite);// +} + + + + +void Object_manage::update_manage() +{ + if (Object_manage::update_now) + { + return; + } + else + { + //sf::Music a; + //a. + // cout << "you had died!"; + //Sleep(5000); + exit(0); + } +} + +void Object_manage::add_MyBullet(MyBullet* Bullet) +{ + MyBullet_list.push_back(Bullet); + //MyBullet_list.insert(multimap::value_type(name, Bullet)); +} + +void Object_manage::display_All(RenderWindow &the_window) +{ + the_window.display(); +} + + +void Object_manage::update_MyBullet(RenderWindow &the_window) +{ + + + vector::iterator ita; + for (ita = MyBullet_list.begin(); ita != MyBullet_list.end();) + { + (*ita)->MyBullet_y += (*ita)->MyBullet_speed; + if ((*ita)->MyBullet_y >= 0)//ɳĻҵӵбɾ + { + delete (*ita); + ita = MyBullet_list.erase(ita); + continue; + } + (*ita)->MyBullet_sprite.setOrigin((*ita)->MyBullet_x, (*ita)->MyBullet_y); + //ÿδ˾ͻȥ + the_window.draw((*ita)->MyBullet_sprite); + ita++; + } + +} + + + + +void Object_manage::add_Enermy()//µлλ +{ + time = clock.getElapsedTime(); + if (operator>=(time, update_Enermy_time))//ȡʱڸµʱ + { + Enermy_list.push_back(new Enermy); + time = clock.restart(); + } + +} + + +void Object_manage::add_Enermy_Bullet() +{ + vector::iterator it; + for (it = Enermy_list.begin(); it != Enermy_list.end(); it++) + { + (*it)->time0 = (*it)->clock0.getElapsedTime(); + if (operator>=((*it)->time0, (*it)->update_EnermyBullet_time)) + { + //int temp = Enermy_Bullet_list.size(); + //map Enermy_Bullet_list; + Enermy_Bullet_list.push_back(new Enermy_Bullet(*it)); + //Enermy_Bullet_list[temp] = new Enermy_Bullet(it);//βָ + (*it)->time0 = (*it)->clock0.restart(); + } + } + +} + + + + +void Object_manage::update_Enermy(RenderWindow &the_window)//ȡ +{ + update_enermy = Update_enermy.getElapsedTime(); + //update_enermy = Update_enermy.getElapsedTime(); + if (operator<(update_enermy, UPdate_Enermy))//ȡʱСڸµʱ + { + + return; + + } + update_enermy = Update_enermy.restart(); + + vector::iterator ith; + for (ith = Enermy_list.begin(); ith != Enermy_list.end();) + { + if ((*ith)->Enermy_y <= -window_heigth)//ɾ + { + delete (*ith); + ith = Enermy_list.erase(ith); + continue; + } + if ((*ith)->is_new) + { + (*ith)->is_new = 0; + return; + } + (*ith)->Enermy_y -= (*ith)->Enermy_speed; + (*ith)->Enermy_sprite.setOrigin((*ith)->Enermy_x, (*ith)->Enermy_y); + the_window.draw((*ith)->Enermy_sprite); + ith++; + } +} + + + + +void Object_manage::update_Enermy_Bullet(RenderWindow &the_window) +{ + //std::vector::iterator ita=; + std::vector::iterator itm; + for (itm = Enermy_Bullet_list.begin(); itm != Enermy_Bullet_list.end(); ) + { + if ((*itm)->Enermy_Bullet_y <= -window_heigth) + { + delete *itm;//*(*itm)һָ + itm = Enermy_Bullet_list.erase(itm); + continue; + } + if ((*itm)->Enermy_Bullet_is_new) + { + (*itm)->Enermy_Bullet_is_new = 0; + return; + } + else + { + (*itm)->Enermy_Bullet_y -= (*itm)->Enermy_Bullet_speed; + } + (*itm)->Enermy_Bullet_sprite.setOrigin((*itm)->Enermy_Bullet_x, (*itm)->Enermy_Bullet_y); + the_window.draw((*itm)->Enermy_Bullet_sprite); + itm++; + + } + + /* for (itm = Enermy_Bullet_list.begin(); itm != Enermy_Bullet_list.end(); itm++) + { + if (itm->Enermy_Bullet_is_new) + { + itm->Enermy_Bullet_is_new = 0; + return; + } + else + + { + itm->Enermy_Bullet_y -= itm->Enermy_Bullet_speed; + } + itm->Enermy_Bullet_sprite.setOrigin(itm->Enermy_Bullet_x, itm->Enermy_Bullet_y); + the_window.draw(itm->Enermy_Bullet_sprite); + }*/ + +} + + + + +void Object_manage::show_explode_myPlane(RenderWindow &the_window) +{ + /* multimap::iterator it_MyPlane;//Һ͵˵ķɻ + it_MyPlane = My_plane_list.begin(); + std::vector::iterator itm= myplane_exploded_list.begin(); + if (0 == it_MyPlane->exploded_time) + { + the_window.display() + } + */ +} + +void Object_manage::add_Fly_bullet() +{ + update_helpPack = UPDATE_helpPack.getElapsedTime(); + if (operator>=(update_helpPack, UPDate_HelpPack)) + { + now_add_Help_pack = 1; + update_helpPack = UPDATE_helpPack.restart(); + Fly_BUlllet_list.push_back(new Fly_BUlllet); + now_add_Help_pack = 0; + } + + + FlyBUllet_time = Flybullet_clock.getElapsedTime(); + if (operator>=(FlyBUllet_time, update_Fly_BUllet_time))//ȡʱڸµʱ + { + Fly_BUlllet_list.push_back(new Fly_BUlllet);// + FlyBUllet_time = Flybullet_clock.restart(); + } +} + + +void Object_manage::update_Fly_bullet() +{ + double temp; + if (Fly_BUlllet_list.empty()) + { + return; + } + vector::iterator itm; + for (itm = Fly_BUlllet_list.begin(); itm != Fly_BUlllet_list.end();) + { + if ((*itm)->Fly_BUllet_y <= -window_heigth)//±߳ȥ + { + delete (*itm); + itm = Fly_BUlllet_list.erase(itm); + continue; + } + if ((*itm)->Fly_BUlllet_filename == "image/help.psd") + { + (*itm)->del_helppack = (*itm)->delete_helpbag.getElapsedTime(); + //ʱ䵽˾ɾ + if (operator>=((*itm)->del_helppack, (*itm)->eraser_helpPack)) + { + delete (*itm); + itm = Fly_BUlllet_list.erase(itm); + continue; + } + else + { + (*itm)->Fly_BUlllet_sprite.setOrigin((*itm)->Fly_BUlllet_x, (*itm)->Fly_BUllet_y); + the_window.draw((*itm)->Fly_BUlllet_sprite); + itm++; + continue; + } + } + temp = abs(std::tan((*itm)->angle))*(*itm)->Fly_BUlllet_y_plus; + if ((*itm)->Fly_BUlllet_x >= 0)//߳ȥ + { + (*itm)->left_or_right = 2; + } + + if ((*itm)->Fly_BUlllet_x <= -window_width + (*itm)->Fly_BUlllet_width) + { + + (*itm)->left_or_right = 1; + + } + if ((*itm)->left_or_right == 1) + { + (*itm)->Fly_BUlllet_x += temp; + } + if ((*itm)->left_or_right == 2) + { + (*itm)->Fly_BUlllet_x -= temp; + } + (*itm)->Fly_BUllet_y -= (*itm)->Fly_BUlllet_y_plus; + (*itm)->Fly_BUlllet_sprite.setOrigin((*itm)->Fly_BUlllet_x, (*itm)->Fly_BUllet_y); + the_window.draw((*itm)->Fly_BUlllet_sprite); + itm++; + } +} + + + + + + +void Object_manage::crash_detector() +{ + if (My_plane_list.empty()) + { + Game_state == begin_just_now; + return; + } + + //ҵӵ͵ + vector::iterator it_myBullet; + vector::iterator it_Enermy; + sf::Rect temp;// + for (it_Enermy = Enermy_list.begin(); it_Enermy != Enermy_list.end();) + { + int t = 0; + temp = (*it_Enermy)->Enermy_sprite.getGlobalBounds();// + for (it_myBullet = MyBullet_list.begin(); it_myBullet != MyBullet_list.end();) + { + if (temp.intersects((*it_myBullet)->MyBullet_sprite.getGlobalBounds()))//if crash + { + //ӷ + + + ((*it_Enermy)->shooted_time)++; + //resolve my Bullet + delete (*it_myBullet); + it_myBullet = MyBullet_list.erase(it_myBullet); + //cout << "" << (*it_Enermy)->shooted_time; + if ((*it_Enermy)->shooted_time >= (*it_Enermy)->life) + { + kill_enermy++; + if ((*it_Enermy)->Enermy_filename == "image/p0.png") + { + score_all += 100; + } + if ((*it_Enermy)->Enermy_filename == "image/p1.png") + { + score_all += 50; + } + if ((*it_Enermy)->Enermy_filename == "image/p2.png") + { + score_all += 200; + } + enermy_exploed.play(); + for (int i = 0; i < 3; i++) + { + Explode_enermy *p = new Explode_enermy((*it_Enermy), (*it_Enermy)->explode_time0); + (*it_Enermy)->exploed_plane.push_back(p); + (*it_Enermy)->explode_time0++; + for (int t = 0; t <= 5; t++) + { + the_window.display(); + } + + delete p;//ͷſռ + (*it_Enermy)->exploed_plane.pop_front(); + } + // cout << "ը" << endl; + // cout << "ըˣ" << (*it_Enermy)->shooted_time; + delete (*it_Enermy); + it_Enermy = Enermy_list.erase(it_Enermy); + t = 1; + break; + } + continue; + } + it_myBullet++; + } + if (1 == t) + { + continue; + } + it_Enermy++; + } + + + + + //ӵ + + multimap::iterator it_myPlane; + + it_myPlane = My_plane_list.begin(); + //cout << "" << it_myPlane->second->super_plane << endl; + sf::Rect temp0 = it_myPlane->second->myPlane_sprite.getGlobalBounds(); + //vector Enermy_Bullet_list + vector::iterator it_Enermy_Bullet; + for (it_Enermy_Bullet = Enermy_Bullet_list.begin(); it_Enermy_Bullet != Enermy_Bullet_list.end();) + { + if (temp0.intersects((*it_Enermy_Bullet)->Enermy_Bullet_sprite.getGlobalBounds())) + { + + it_myPlane->second->Myplane_type = "common"; + it_myPlane->second->shooted_time += (*it_Enermy_Bullet)->aggressivity; + it_myPlane->second->my_plane_life--; + //ӵ + delete *(it_Enermy_Bullet); + it_Enermy_Bullet = Enermy_Bullet_list.erase(it_Enermy_Bullet); + MyPlane_explode *p = new MyPlane_explode(it_myPlane->second); + for (int t = 0; t <= 100; t++) + { + the_window.display(); + } + delete p;//ɾҵķɻըͼ + if (it_myPlane->second->my_plane_life <= 0) + //if (it_myPlane->second->shooted_time >= it_myPlane->second->my_plane_life) + { + Game_state = game_over; + //draw_lifeNumber(); + //the_window.display(); + game_loop(); + //delete it_myPlane->second; + //My_plane_list.erase(it_myPlane); + return; + } + continue; + } + it_Enermy_Bullet++; + } + //Һflybullet + // vector Fly_BUlllet_list;// + vector::iterator it_Fly; + for (it_Fly = Fly_BUlllet_list.begin(); it_Fly != Fly_BUlllet_list.end();) + { + if (temp0.intersects((*it_Fly)->Fly_BUlllet_sprite.getGlobalBounds())) + { + get.play(); + //жɶ + if ((*it_Fly)->Fly_BUlllet_filename == "image/3.1s.png")//˫ӵ + { + it_myPlane->second->Myplane_type = "double_BUllet";//ӵʱע + delete (*it_Fly); + it_Fly = Fly_BUlllet_list.erase(it_Fly); + continue; + + } + if ((*it_Fly)->Fly_BUlllet_filename == "image/help.psd")//Ȱ + { + it_myPlane->second->my_plane_life += 2;//+2 + delete (*it_Fly); + it_Fly = Fly_BUlllet_list.erase(it_Fly); + continue; + } + if ((*it_Fly)->Fly_BUlllet_filename == "image/3.3s.png")// + { + it_myPlane->second->super_plane++;//ҵķɻһڵ + delete (*it_Fly); + it_Fly = Fly_BUlllet_list.erase(it_Fly); + continue; + } + + } + it_Fly++; + } + + vector::iterator itl;//ķɻӵ + for (itl = quickBUllet_list.begin(); itl != quickBUllet_list.end(); itl++) + { + temp = (*itl)->sprite.getGlobalBounds(); + for (it_Enermy_Bullet = Enermy_Bullet_list.begin(); it_Enermy_Bullet != Enermy_Bullet_list.end();)//ӵ + { + if (temp.intersects((*it_Enermy_Bullet)->Enermy_Bullet_sprite.getGlobalBounds())) + { + delete (*it_Enermy_Bullet); + it_Enermy_Bullet = Enermy_Bullet_list.erase(it_Enermy_Bullet); + continue; + } + it_Enermy_Bullet++; + } + } + + + for (itl = quickBUllet_list.begin(); itl != quickBUllet_list.end(); itl++)//ķɻ͵ + { + temp = (*itl)->sprite.getGlobalBounds(); + for (it_Enermy = Enermy_list.begin(); it_Enermy != Enermy_list.end();) + { + + + //temp = (*itl)->sprite.getGlobalBounds(); + if (temp.intersects((*it_Enermy)->Enermy_sprite.getGlobalBounds())) + { + //ӷ + if ((*it_Enermy)->Enermy_filename == "image/p0.png") + { + score_all += 100; + } + if ((*it_Enermy)->Enermy_filename == "image/p1.png") + { + score_all += 50; + } + if ((*it_Enermy)->Enermy_filename == "image/p2.png") + { + score_all += 200; + } + //cout << "㽶"; + delete (*it_Enermy); + it_Enermy = Enermy_list.erase(it_Enermy); + continue; + } + + + it_Enermy++; + } + } + + +} + +//Quicker_killer.cpp +#include "stdafx.h" +#include "Quicker_killer.h" + +extern int window_width; +extern int window_heigth; +Quicker_killer::Quicker_killer(int order) +{ + filename = "image/rocket.psd"; + if (!image.loadFromFile(filename)) + { + cout << "quicker plane read failed!"; + } + sprite.setTexture(image); + width = image.getSize().x; + height = image.getSize().y; + //srand((unsigned)time(NULL)); + speed = rand() % 20 + 10;//Сٶ30 + __x = -order*(width / 2); + __y = -window_heigth; + +}; + + +int Quicker_killer::get_width() +{ + return width; +} + +int Quicker_killer::get_x() +{ + return __x; +} +int Quicker_killer::get_y() +{ + return __y; +} + +int Quicker_killer::get_speed() +{ + return speed; +} + + +Quicker_killer::~Quicker_killer() +{ +} + +//Resolve_interface.cpp +#include "stdafx.h" +#include "Resolve_interface.h" + + +Resolve_interface::Resolve_interface() +{ +} + + +Resolve_interface::~Resolve_interface() +{ +} + +//rocket.cpp +#include "stdafx.h" +#include "rocket.h" + +extern int window_width; +extern int window_heigth; +rocket::rocket() +{ + filename = "image/rocket.psd";//ļ + if (!image.loadFromFile(filename))//ȡͼƬ + { + cout << "ʧܣ"; + } + height = image.getSize().y; + sprite.setTexture(image);//ͼƬ + sprite.setOrigin(0, -window_heigth + 5 * (height / 4)); + cout << -window_heigth + 2 * height; +} + + +rocket::~rocket() +{ +} + +//start_interface.cpp +#include "stdafx.h" +#include "start_interface.h" + + +start_interface::start_interface() +{ + /*ʼ棺 + ߾657px + 521px 22675 + 625px 220, 75*/ + //playĵΧ + MenuItem playButton; + playButton.rect.top = 490; + playButton.rect.left = 657; + playButton.rect.width = 226; + playButton.rect.height = 70; + playButton.action = Play; + + //ExitĵΧ + MenuItem exitButton; + exitButton.rect.top = 590; + exitButton.rect.left = 657; + exitButton.rect.height = 75; + exitButton.rect.width = 220; + exitButton.action = Exit; + _menuItems.push_back(playButton); + _menuItems.push_back(exitButton); +} + + +start_interface::~start_interface() +{ +} +void start_interface::design_click_area() +{ + + +} + +//жλǷھӶ״̬ +start_interface::MenuResult start_interface::HandleClick(int x, int y) +{ + //listŵĵԹж + std::list::iterator it; + for (it = _menuItems.begin(); it != _menuItems.end(); it++) + { + sf::Rect menuItemRect = (*it).rect; + if (menuItemRect.height + menuItemRect.top > y && menuItemRect.top < y + && menuItemRect.left < x + && menuItemRect.width + menuItemRect.left > x) + { + return (*it).action; + } + } + return Nothing; +} + +//궯ӦӦ +start_interface::MenuResult start_interface::GetMenuResponse(sf::RenderWindow& window) +{ + sf::Event menuEvent; + while (1) + { + while (window.pollEvent(menuEvent)) + { + //sf::Event:: + if (menuEvent.type == sf::Event::MouseButtonReleased)//:MouseButtonPressed) + { + return HandleClick(menuEvent.mouseButton.x, menuEvent.mouseButton.y); + } + if (menuEvent.type == sf::Event::Closed) + { + return Exit; + } + } + } +} + +//stdafx.cpp +// stdafx.cpp : ֻ׼ļԴļ +// fighter.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ + + diff --git a/Safe_array/.vs/Safe_array/v14/.suo b/Safe_array/.vs/Safe_array/v14/.suo new file mode 100644 index 00000000..e4bf4bed Binary files /dev/null and b/Safe_array/.vs/Safe_array/v14/.suo differ diff --git a/Safe_array/Debug/Safe_array.exe b/Safe_array/Debug/Safe_array.exe new file mode 100644 index 00000000..348cc277 Binary files /dev/null and b/Safe_array/Debug/Safe_array.exe differ diff --git a/Safe_array/Debug/Safe_array.ilk b/Safe_array/Debug/Safe_array.ilk new file mode 100644 index 00000000..ed1febbe Binary files /dev/null and b/Safe_array/Debug/Safe_array.ilk differ diff --git a/Safe_array/Debug/Safe_array.pdb b/Safe_array/Debug/Safe_array.pdb new file mode 100644 index 00000000..48446ef2 Binary files /dev/null and b/Safe_array/Debug/Safe_array.pdb differ diff --git a/Safe_array/Safe_array.sdf b/Safe_array/Safe_array.sdf new file mode 100644 index 00000000..a6194e08 Binary files /dev/null and b/Safe_array/Safe_array.sdf differ diff --git a/Safe_array/Safe_array.sln b/Safe_array/Safe_array.sln new file mode 100644 index 00000000..b9fa534a --- /dev/null +++ b/Safe_array/Safe_array.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Safe_array", "Safe_array\Safe_array.vcxproj", "{89446B9D-1FF3-4486-8928-11DB3DF320D8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Debug|x64.ActiveCfg = Debug|x64 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Debug|x64.Build.0 = Debug|x64 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Debug|x86.ActiveCfg = Debug|Win32 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Debug|x86.Build.0 = Debug|Win32 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Release|x64.ActiveCfg = Release|x64 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Release|x64.Build.0 = Release|x64 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Release|x86.ActiveCfg = Release|Win32 + {89446B9D-1FF3-4486-8928-11DB3DF320D8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Safe_array/Safe_array/Debug/Safe_array.log b/Safe_array/Safe_array/Debug/Safe_array.log new file mode 100644 index 00000000..a8eb9f15 --- /dev/null +++ b/Safe_array/Safe_array/Debug/Safe_array.log @@ -0,0 +1,14 @@ +生成启动时间为 2017/6/15 17:06:04。 + 1>项目“c:\Users\YP\documents\visual studio 2015\Projects\Safe_array\Safe_array\Safe_array.vcxproj”在节点 2 上(Build 个目标)。 + 1>ClCompile: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"stdafx.h" /Fp"Debug\Safe_array.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt Safe_array.cpp + Safe_array.cpp + Link: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"c:\users\yp\documents\visual studio 2015\Projects\Safe_array\Debug\Safe_array.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"c:\users\yp\documents\visual studio 2015\Projects\Safe_array\Debug\Safe_array.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\users\yp\documents\visual studio 2015\Projects\Safe_array\Debug\Safe_array.lib" /MACHINE:X86 Debug\Safe_array.obj + Debug\stdafx.obj + Safe_array.vcxproj -> c:\users\yp\documents\visual studio 2015\Projects\Safe_array\Debug\Safe_array.exe + 1>已完成生成项目“c:\Users\YP\documents\visual studio 2015\Projects\Safe_array\Safe_array\Safe_array.vcxproj”(Build 个目标)的操作。 + +已成功生成。 + +已用时间 00:00:02.40 diff --git a/Safe_array/Safe_array/Debug/Safe_array.obj b/Safe_array/Safe_array/Debug/Safe_array.obj new file mode 100644 index 00000000..bd7a437c Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.obj differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.pch b/Safe_array/Safe_array/Debug/Safe_array.pch new file mode 100644 index 00000000..4618a8f4 Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.pch differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.command.1.tlog b/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.command.1.tlog new file mode 100644 index 00000000..5d71f2fb Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.command.1.tlog differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.read.1.tlog b/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.read.1.tlog new file mode 100644 index 00000000..c647e1e2 Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.read.1.tlog differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.write.1.tlog b/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.write.1.tlog new file mode 100644 index 00000000..4129e914 Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.tlog/CL.write.1.tlog differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/Safe_array.lastbuildstate b/Safe_array/Safe_array/Debug/Safe_array.tlog/Safe_array.lastbuildstate new file mode 100644 index 00000000..b46c7e21 --- /dev/null +++ b/Safe_array/Safe_array/Debug/Safe_array.tlog/Safe_array.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|c:\users\yp\documents\visual studio 2015\Projects\Safe_array\| diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/link.command.1.tlog b/Safe_array/Safe_array/Debug/Safe_array.tlog/link.command.1.tlog new file mode 100644 index 00000000..7e1acd4e Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.tlog/link.command.1.tlog differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/link.read.1.tlog b/Safe_array/Safe_array/Debug/Safe_array.tlog/link.read.1.tlog new file mode 100644 index 00000000..de8ef932 Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.tlog/link.read.1.tlog differ diff --git a/Safe_array/Safe_array/Debug/Safe_array.tlog/link.write.1.tlog b/Safe_array/Safe_array/Debug/Safe_array.tlog/link.write.1.tlog new file mode 100644 index 00000000..5799697d Binary files /dev/null and b/Safe_array/Safe_array/Debug/Safe_array.tlog/link.write.1.tlog differ diff --git a/Safe_array/Safe_array/Debug/stdafx.obj b/Safe_array/Safe_array/Debug/stdafx.obj new file mode 100644 index 00000000..2615088f Binary files /dev/null and b/Safe_array/Safe_array/Debug/stdafx.obj differ diff --git a/Safe_array/Safe_array/Debug/vc140.idb b/Safe_array/Safe_array/Debug/vc140.idb new file mode 100644 index 00000000..f44e5777 Binary files /dev/null and b/Safe_array/Safe_array/Debug/vc140.idb differ diff --git a/Safe_array/Safe_array/Debug/vc140.pdb b/Safe_array/Safe_array/Debug/vc140.pdb new file mode 100644 index 00000000..1dd637a8 Binary files /dev/null and b/Safe_array/Safe_array/Debug/vc140.pdb differ diff --git a/Safe_array/Safe_array/ReadMe.txt b/Safe_array/Safe_array/ReadMe.txt new file mode 100644 index 00000000..3b141fdb --- /dev/null +++ b/Safe_array/Safe_array/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + 控制台应用程序:Safe_array 项目概述 +======================================================================== + +应用程序向导已为您创建了此 Safe_array 应用程序。 + +本文件概要介绍组成 Safe_array 应用程序的每个文件的内容。 + + +Safe_array.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +Safe_array.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +Safe_array.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 Safe_array.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/Safe_array/Safe_array/Safe_array.cpp b/Safe_array/Safe_array/Safe_array.cpp new file mode 100644 index 00000000..a4609638 --- /dev/null +++ b/Safe_array/Safe_array/Safe_array.cpp @@ -0,0 +1,58 @@ +// Safe_array.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include +using namespace std; + +template +class SafeArray +{ +public: + SafeArray(int); + ~SafeArray(); + T& operator[](int); +private: + T * data; + int length; +}; + +template +SafeArray::SafeArray(int len) +{ + data = new T[len]; + length = len; +} + +template +SafeArray::~SafeArray() +{ + delete[] this->data; +} + +template +T& SafeArray::operator[](int index) + { + if (index >= length || index<0) + { + cout << "error:index out of range,return the first element(" << *data << ")" << endl; + return *data; + } + else + { + return *(data + index); + } +} + + +int main() + { + SafeArray array(100); + for (int i = 0; i<10; i++) + { + array[i] = i; + cout << array[i] << endl; + } + return 0; +} + diff --git a/Safe_array/Safe_array/Safe_array.vcxproj b/Safe_array/Safe_array/Safe_array.vcxproj new file mode 100644 index 00000000..4e2cadce --- /dev/null +++ b/Safe_array/Safe_array/Safe_array.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {89446B9D-1FF3-4486-8928-11DB3DF320D8} + Win32Proj + Safe_array + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/Safe_array/Safe_array/Safe_array.vcxproj.filters b/Safe_array/Safe_array/Safe_array.vcxproj.filters new file mode 100644 index 00000000..de968633 --- /dev/null +++ b/Safe_array/Safe_array/Safe_array.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/Safe_array/Safe_array/stdafx.cpp b/Safe_array/Safe_array/stdafx.cpp new file mode 100644 index 00000000..217ed03a --- /dev/null +++ b/Safe_array/Safe_array/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Safe_array.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/Safe_array/Safe_array/stdafx.h b/Safe_array/Safe_array/stdafx.h new file mode 100644 index 00000000..baa4bbc6 --- /dev/null +++ b/Safe_array/Safe_array/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Safe_array/Safe_array/targetver.h b/Safe_array/Safe_array/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/Safe_array/Safe_array/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Safe_array/ipch/SAFE_ARRAY-1d37de19/SAFE_ARRAY-d1fec5a9.ipch b/Safe_array/ipch/SAFE_ARRAY-1d37de19/SAFE_ARRAY-d1fec5a9.ipch new file mode 100644 index 00000000..3ce6659c Binary files /dev/null and b/Safe_array/ipch/SAFE_ARRAY-1d37de19/SAFE_ARRAY-d1fec5a9.ipch differ diff --git a/Sort/.vs/MaoPao_Sort/v14/.suo b/Sort/.vs/MaoPao_Sort/v14/.suo new file mode 100644 index 00000000..4faf71c6 Binary files /dev/null and b/Sort/.vs/MaoPao_Sort/v14/.suo differ diff --git a/Sort/Debug/MaoPao_Sort.exe b/Sort/Debug/MaoPao_Sort.exe new file mode 100644 index 00000000..e684d545 Binary files /dev/null and b/Sort/Debug/MaoPao_Sort.exe differ diff --git a/Sort/Debug/MaoPao_Sort.ilk b/Sort/Debug/MaoPao_Sort.ilk new file mode 100644 index 00000000..71fb3a0b Binary files /dev/null and b/Sort/Debug/MaoPao_Sort.ilk differ diff --git a/Sort/Debug/MaoPao_Sort.pdb b/Sort/Debug/MaoPao_Sort.pdb new file mode 100644 index 00000000..8c168fe3 Binary files /dev/null and b/Sort/Debug/MaoPao_Sort.pdb differ diff --git a/Sort/MaoPao_Sort.sdf b/Sort/MaoPao_Sort.sdf new file mode 100644 index 00000000..d9a66aab Binary files /dev/null and b/Sort/MaoPao_Sort.sdf differ diff --git a/Sort/MaoPao_Sort.sln b/Sort/MaoPao_Sort.sln new file mode 100644 index 00000000..3f2c0d04 --- /dev/null +++ b/Sort/MaoPao_Sort.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaoPao_Sort", "MaoPao_Sort\MaoPao_Sort.vcxproj", "{239B4E2A-EE55-4130-9092-B974250F9CB0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Debug|x64.ActiveCfg = Debug|x64 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Debug|x64.Build.0 = Debug|x64 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Debug|x86.ActiveCfg = Debug|Win32 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Debug|x86.Build.0 = Debug|Win32 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Release|x64.ActiveCfg = Release|x64 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Release|x64.Build.0 = Release|x64 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Release|x86.ActiveCfg = Release|Win32 + {239B4E2A-EE55-4130-9092-B974250F9CB0}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.Build.CppClean.log b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.Build.CppClean.log new file mode 100644 index 00000000..f3935176 --- /dev/null +++ b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.Build.CppClean.log @@ -0,0 +1,18 @@ +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.pch.codeanalysis +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\vc140.pdb +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\vc140.idb +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.pch.codeanalysisast +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\stdafx.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\stdafx.obj +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.pch +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.obj +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\debug\maopao_sort.ilk +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\debug\maopao_sort.exe +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\debug\maopao_sort.pdb +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.tlog\cl.command.1.tlog +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.tlog\cl.read.1.tlog +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.tlog\cl.write.1.tlog +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.tlog\link.command.1.tlog +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.tlog\link.read.1.tlog +c:\users\yp\documents\visual studio 2015\projects\maopao_sort\maopao_sort\debug\maopao_sort.tlog\link.write.1.tlog diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.log b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.log new file mode 100644 index 00000000..cc8a40b7 --- /dev/null +++ b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.log @@ -0,0 +1,16 @@ +生成启动时间为 2017/6/2 15:44:23。 + 1>项目“C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\MaoPao_Sort\MaoPao_Sort.vcxproj”在节点 2 上(Rebuild 个目标)。 + 1>ClCompile: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yc"stdafx.h" /Fp"Debug\MaoPao_Sort.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt stdafx.cpp + stdafx.cpp + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"stdafx.h" /Fp"Debug\MaoPao_Sort.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt MaoPao_Sort.cpp + MaoPao_Sort.cpp + Link: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\Debug\MaoPao_Sort.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\Debug\MaoPao_Sort.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\Debug\MaoPao_Sort.lib" /MACHINE:X86 Debug\MaoPao_Sort.obj + Debug\stdafx.obj + MaoPao_Sort.vcxproj -> C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\Debug\MaoPao_Sort.exe + 1>已完成生成项目“C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\MaoPao_Sort\MaoPao_Sort.vcxproj”(Rebuild 个目标)的操作。 + +已成功生成。 + +已用时间 00:00:07.51 diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.obj b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.obj new file mode 100644 index 00000000..68f9dba0 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.obj differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.pch b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.pch new file mode 100644 index 00000000..fee37c77 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.pch differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.command.1.tlog b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.command.1.tlog new file mode 100644 index 00000000..ff2e699f Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.command.1.tlog differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.read.1.tlog b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.read.1.tlog new file mode 100644 index 00000000..e9c0dfde Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.read.1.tlog differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.write.1.tlog b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.write.1.tlog new file mode 100644 index 00000000..4bafac82 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/CL.write.1.tlog differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/MaoPao_Sort.lastbuildstate b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/MaoPao_Sort.lastbuildstate new file mode 100644 index 00000000..85c95cd5 --- /dev/null +++ b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/MaoPao_Sort.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|C:\Users\YP\Documents\Visual Studio 2015\Projects\MaoPao_Sort\| diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.command.1.tlog b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.command.1.tlog new file mode 100644 index 00000000..51df2d31 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.command.1.tlog differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.read.1.tlog b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.read.1.tlog new file mode 100644 index 00000000..7f29577b Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.read.1.tlog differ diff --git a/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.write.1.tlog b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.write.1.tlog new file mode 100644 index 00000000..21ca61b1 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/MaoPao_Sort.tlog/link.write.1.tlog differ diff --git a/Sort/MaoPao_Sort/Debug/stdafx.obj b/Sort/MaoPao_Sort/Debug/stdafx.obj new file mode 100644 index 00000000..97599d22 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/stdafx.obj differ diff --git a/Sort/MaoPao_Sort/Debug/vc140.idb b/Sort/MaoPao_Sort/Debug/vc140.idb new file mode 100644 index 00000000..8f95cfec Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/vc140.idb differ diff --git a/Sort/MaoPao_Sort/Debug/vc140.pdb b/Sort/MaoPao_Sort/Debug/vc140.pdb new file mode 100644 index 00000000..29273510 Binary files /dev/null and b/Sort/MaoPao_Sort/Debug/vc140.pdb differ diff --git a/Sort/MaoPao_Sort/MaoPao_Sort.cpp b/Sort/MaoPao_Sort/MaoPao_Sort.cpp new file mode 100644 index 00000000..8cf06d09 --- /dev/null +++ b/Sort/MaoPao_Sort/MaoPao_Sort.cpp @@ -0,0 +1,616 @@ + +// Sort.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include "iostream" +#define object_max 20 +using namespace std; +template +class Sort//sort +{ +public: + virtual void input() = 0; + virtual void sorting() = 0; + virtual void output() = 0; + virtual void sort_quick_sort(int left, int right) = 0; + virtual int get_Len() = 0; +protected: + T *v; + int room;//ܿռ + int length;// +}; + + +template +class End //end ͳһ +{ +public: + static Sort* sort0[object_max];////ָ + static int object_quantity;//̬ + void action(); +}; + + +template +int End::object_quantity = 0;//ʼ̬ + + +template +Sort* End::sort0[object_max] = { NULL }; + + + +template +void End::action() +{ + for (int i = 0; i < object_quantity; i++) + { + sort0[i]->input(); + sort0[i]->sorting(); + sort0[i]->output(); + sort0[i]->sort_quick_sort(0, sort0[i]->get_Len() - 1); + } +} + + + +//ð +template +class MaoPao_Sort:public Sort,public End +{ +public: + MaoPao_Sort(int room); + ~MaoPao_Sort(); + void input(); + void sorting(); + void output(); + int get_Len(); + void sort_quick_sort(int left, int right); +}; + + +template +int MaoPao_Sort::get_Len() +{ + return 0; +} + + +template +void MaoPao_Sort::sort_quick_sort(int left, int right) +{ + return; +} + +template +MaoPao_Sort::MaoPao_Sort(int room) +{ + v = new T[room]; + this->room = room; + length = 0; + sort0[object_quantity] = this;//ʹûָָǰĶ + object_quantity++;//һ +} + + +template +MaoPao_Sort::~MaoPao_Sort() +{ + delete[] v; + v = NULL; +} + + + +template +void MaoPao_Sort::input() +{ + int a; + cout << "please input.if you have finished,please enter -1" << endl; + while (1) + { + for (int i = 0; i < room; i++) + { + cin >> a; + if (a == -1) + { + return; + } + v[i] = a; + length++; + } + } + cout << "there is no enough room"; +} + + + +template +void MaoPao_Sort::sorting() +{ + if (length<2) + { + cout << "you should input 2 numbers at least!" << endl; + return; + } + for (int i = 0; i < length-1; i++) + { + for (int j = 0; j < length - i - 1;j++) + { + if (v[j] > v[j + 1]) + { + int t = v[j]; + v[j] = v[j+1]; + v[j+1] = t; + } + } + } + return; +} + + +template +void MaoPao_Sort::output() +{ + if (length<2) + { + return; + } + cout << "The result of MaoPao sort:" << endl; + for (int i = 0; i < length; i++) + { + cout << v[i] << " "; + } + cout << endl; + return; +} + + + +//ѡ +template +class Select_Sort:public Sort,public End +{ +public: + Select_Sort(int room); + ~Select_Sort(); + void input(); + void sort_quick_sort(int left, int right); + void sorting(); + void output(); + int get_Len(); +}; + + + + +template +int Select_Sort::get_Len() +{ + return 0; +} + + +template +void Select_Sort::sort_quick_sort(int left, int right) +{ + return; +} + +template +Select_Sort::Select_Sort(int room) +{ + v = new T[room]; + this->room = room; + length = 0; + sort0[object_quantity]=this;//ʹûָָǰĶ + object_quantity++;//һ +} + + + +template +Select_Sort::~Select_Sort() +{ + delete[] v; + v = NULL; +} + + + +template +void Select_Sort::input() +{ + int a; + cout << "please input.if you have finished,please enter -1" << endl; + while (1) + { + for (int i = 0; i < room; i++) + { + cin >> a; + if (a == -1) + { + return; + } + v[i] = a; + length++; + } + } + cout << "there is no enough room"; +} + + + +template +void Select_Sort::sorting() +{ + if (length < 2) + { + cout << "you should input 2 numbers at least!" << endl; + return; + } + for (int i = 0; i < length - 1; i++) + { + int min = i; + for (int j = i + 1; j < length; j++) + { + if (v[j] >= v[min]) + { + continue; + } + min = j;//Сֵmin + } + int t = v[i]; + v[i] = v[min]; + v[min] = t; + } + return; +} + + + + + +template +void Select_Sort::output() +{ + if (length<2) + { + return; + } + cout << "The result of the Select_Sort:" << endl; + for (int i = 0; i < length; i++) + { + cout << v[i] << " "; + } + cout << endl; + return; +} + +//ϣ +template +class XierInsert_Sort:public Sort, public End +{ +public: + XierInsert_Sort(int room); + ~XierInsert_Sort(); + void input(); + void sorting(); + void output(); + void sort_quick_sort(int left, int right); + int get_Len(); + +private: + T *v; + int room;//ܿռ + int length;// + int begin; +}; + + +template +int XierInsert_Sort::get_Len() +{ + return 0; +} + + + +template +void XierInsert_Sort::sort_quick_sort(int left, int right) +{ + return; +} + + +template +XierInsert_Sort::XierInsert_Sort(int room) +{ + v = new T[room]; + this->room = room; + length = 0; + begin = 20; + sort0[object_quantity] = this;//ʹûָָǰĶ + object_quantity++;//һ +} + +template +XierInsert_Sort::~XierInsert_Sort() +{ + delete[] v; + v = NULL; +} + +template +void XierInsert_Sort::input() +{ + int a; + cout << "please input.if you have finished,please enter -1" << endl; + while (1) + { + for (int i = begin; i < room; i++)//Ԥռ,ԷȵһԪСԪ̫; + { + cin >> a; + if (a == -1) + { + return; + } + v[begin + length] = a; + length++; + } + } + cout << "there is no enough room"; +} + + + +template +void XierInsert_Sort::sorting() +{ + if (length< 2) + { + cout << "you should input 2 numbers at least!" << endl; + return; + } + int left, mid, i, right; + for (i = begin + 1; i < length + begin; i++) + { + int temp = v[i]; + left = begin; + right = i; + if (v[i] >= v[i - 1]) + { + continue; + } + if (v[i] <= v[begin]) + { + for (int j = i; j < length + begin - 1; j++)//ǰƣ + { + v[j] = v[j + 1]; + } + i--;//ǰƺһǰһ + v[--begin] = temp; + continue; + } + int t; + + while (left < right)//λ + { + t = 0;// + mid = (right + left) / 2; + if (v[i] == v[mid]) + { + t = -1; + break; + } + if (v[i] v[mid]) + { + if (right != left + 1) + { + t = -1; + left = mid; + } + else + { + t = -1; + break; + } + } + } + if (t == 1) + { + for (int k = i; k > mid; k--) + { + v[k] = v[k - 1]; + } + v[mid] = temp; + continue; + } + if (t == -1) + { + for (int m = i; m >= mid + 2; m--) + { + v[m] = v[m - 1]; + } + v[mid + 1] = temp; + continue; + } + } + + return; +} + + +template +void XierInsert_Sort::output() +{ + if (length<2) + { + return; + } + cout << "The result of XierInsert_Sort:" << endl; + for (int i = begin; i < begin + length; i++) + { + cout << v[i] << " "; + } + cout << endl; +} + + + + + +// +template +class Quick_Sort :public Sort, public End +{ +public: + Quick_Sort(int room); + ~Quick_Sort(); + void input(); + void sort_quick_sort(int left, int right); + void output(); + void sorting(); + int get_Len(); + + +private: + T *v; + int room;//ܿռ + int length;// +}; + + + +template +void Quick_Sort::sorting() +{ + return; +} + + +template +Quick_Sort::Quick_Sort(int room) +{ + v = new T[room]; + this->room = room; + length = 0; + sort0[object_quantity] = this;//ʹûָָǰĶ + object_quantity++;//һ +} + + + + +template +int Quick_Sort ::get_Len() +{ + return length; +} + +template +Quick_Sort::~Quick_Sort() +{ + delete[] v; + v = NULL; +} + + + + +template +void Quick_Sort::input() +{ + int a; + cout << "please input.if you have finished,please enter -1" << endl; + while (1) + { + for (int i = 0; i < room; i++)//Ԥռ,ԷȵһԪСԪ̫; + { + cin >> a; + if (a == -1) + { + return; + } + v[i] = a; + length++; + } + } + cout << "there is no enough room"; +} + + + +template +void Quick_Sort::sort_quick_sort(int left, int right) +{ + if (length< 2) + { + cout << "you should input 2 numbers at least!" << endl; + return; + } + int i, j, t, temp; + if (left > right) + { + return; + } + temp = v[left]; + i = left; + j = right; + while (i != j) + { + while (v[j] >= temp&&i < j) + { + j--; + } + while (v[i] <= temp && i < j) + { + i++; + } + if (i < j) + { + t = v[i]; + v[i] = v[j]; + v[j] = t; + } + } + v[left] = v[i]; + v[i] = temp; + sort_quick_sort(left, i - 1); + sort_quick_sort(i + 1, right); + return; +} + + +template +void Quick_Sort::output() +{ + if (length<2) + { + return; + } + cout << "The result of quickesort:" << endl; + for (int i = 0; i < length; i++) + { + cout << v[i] << " "; + } + cout << endl; +} + +int main() +{ + End end;//ָԼ + Quick_Sort Quicker(100); + MaoPao_Sort MaoPao(100); + Select_Sort Select(100); + XierInsert_Sort Xier(100); + end.action(); + return 0; +} + diff --git a/Sort/MaoPao_Sort/MaoPao_Sort.vcxproj b/Sort/MaoPao_Sort/MaoPao_Sort.vcxproj new file mode 100644 index 00000000..8a943de1 --- /dev/null +++ b/Sort/MaoPao_Sort/MaoPao_Sort.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {239B4E2A-EE55-4130-9092-B974250F9CB0} + Win32Proj + MaoPao_Sort + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/Sort/MaoPao_Sort/MaoPao_Sort.vcxproj.filters b/Sort/MaoPao_Sort/MaoPao_Sort.vcxproj.filters new file mode 100644 index 00000000..2cbc2da4 --- /dev/null +++ b/Sort/MaoPao_Sort/MaoPao_Sort.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/Sort/MaoPao_Sort/ReadMe.txt b/Sort/MaoPao_Sort/ReadMe.txt new file mode 100644 index 00000000..d848134d --- /dev/null +++ b/Sort/MaoPao_Sort/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + 控制台应用程序:MaoPao_Sort 项目概述 +======================================================================== + +应用程序向导已为您创建了此 MaoPao_Sort 应用程序。 + +本文件概要介绍组成 MaoPao_Sort 应用程序的每个文件的内容。 + + +MaoPao_Sort.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +MaoPao_Sort.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +MaoPao_Sort.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 MaoPao_Sort.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/Sort/MaoPao_Sort/stdafx.cpp b/Sort/MaoPao_Sort/stdafx.cpp new file mode 100644 index 00000000..b32561e4 --- /dev/null +++ b/Sort/MaoPao_Sort/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// MaoPao_Sort.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/Sort/MaoPao_Sort/stdafx.h b/Sort/MaoPao_Sort/stdafx.h new file mode 100644 index 00000000..baa4bbc6 --- /dev/null +++ b/Sort/MaoPao_Sort/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Sort/MaoPao_Sort/targetver.h b/Sort/MaoPao_Sort/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/Sort/MaoPao_Sort/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Sort/ipch/MAOPAO_SORT-5086c6ae/MAOPAO_SORT-b939f070.ipch b/Sort/ipch/MAOPAO_SORT-5086c6ae/MAOPAO_SORT-b939f070.ipch new file mode 100644 index 00000000..733f6113 Binary files /dev/null and b/Sort/ipch/MAOPAO_SORT-5086c6ae/MAOPAO_SORT-b939f070.ipch differ diff --git a/_Stack/.vs/_Stack/v14/.suo b/_Stack/.vs/_Stack/v14/.suo new file mode 100644 index 00000000..7b1760f0 Binary files /dev/null and b/_Stack/.vs/_Stack/v14/.suo differ diff --git a/_Stack/Debug/_Stack.exe b/_Stack/Debug/_Stack.exe new file mode 100644 index 00000000..23156cde Binary files /dev/null and b/_Stack/Debug/_Stack.exe differ diff --git a/_Stack/Debug/_Stack.ilk b/_Stack/Debug/_Stack.ilk new file mode 100644 index 00000000..fad7da15 Binary files /dev/null and b/_Stack/Debug/_Stack.ilk differ diff --git a/_Stack/Debug/_Stack.pdb b/_Stack/Debug/_Stack.pdb new file mode 100644 index 00000000..455fc75b Binary files /dev/null and b/_Stack/Debug/_Stack.pdb differ diff --git a/_Stack/_Stack.sdf b/_Stack/_Stack.sdf new file mode 100644 index 00000000..7cfc8a76 Binary files /dev/null and b/_Stack/_Stack.sdf differ diff --git a/_Stack/_Stack.sln b/_Stack/_Stack.sln new file mode 100644 index 00000000..48fc9c26 --- /dev/null +++ b/_Stack/_Stack.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_Stack", "_Stack\_Stack.vcxproj", "{21781A1C-486B-49AF-B11A-2F026801CAFC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Debug|x64.ActiveCfg = Debug|x64 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Debug|x64.Build.0 = Debug|x64 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Debug|x86.ActiveCfg = Debug|Win32 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Debug|x86.Build.0 = Debug|Win32 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Release|x64.ActiveCfg = Release|x64 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Release|x64.Build.0 = Release|x64 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Release|x86.ActiveCfg = Release|Win32 + {21781A1C-486B-49AF-B11A-2F026801CAFC}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/_Stack/_Stack/Debug/_Stack.log b/_Stack/_Stack/Debug/_Stack.log new file mode 100644 index 00000000..db3d476c --- /dev/null +++ b/_Stack/_Stack/Debug/_Stack.log @@ -0,0 +1,14 @@ +生成启动时间为 2017/6/15 17:13:27。 + 1>项目“c:\Users\YP\documents\visual studio 2015\Projects\_Stack\_Stack\_Stack.vcxproj”在节点 2 上(Build 个目标)。 + 1>ClCompile: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"stdafx.h" /Fp"Debug\_Stack.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt _Stack.cpp + _Stack.cpp + Link: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"c:\users\yp\documents\visual studio 2015\Projects\_Stack\Debug\_Stack.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"c:\users\yp\documents\visual studio 2015\Projects\_Stack\Debug\_Stack.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\users\yp\documents\visual studio 2015\Projects\_Stack\Debug\_Stack.lib" /MACHINE:X86 Debug\stdafx.obj + Debug\_Stack.obj + _Stack.vcxproj -> c:\users\yp\documents\visual studio 2015\Projects\_Stack\Debug\_Stack.exe + 1>已完成生成项目“c:\Users\YP\documents\visual studio 2015\Projects\_Stack\_Stack\_Stack.vcxproj”(Build 个目标)的操作。 + +已成功生成。 + +已用时间 00:00:02.34 diff --git a/_Stack/_Stack/Debug/_Stack.obj b/_Stack/_Stack/Debug/_Stack.obj new file mode 100644 index 00000000..429010ac Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.obj differ diff --git a/_Stack/_Stack/Debug/_Stack.pch b/_Stack/_Stack/Debug/_Stack.pch new file mode 100644 index 00000000..0b2230b8 Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.pch differ diff --git a/_Stack/_Stack/Debug/_Stack.tlog/CL.command.1.tlog b/_Stack/_Stack/Debug/_Stack.tlog/CL.command.1.tlog new file mode 100644 index 00000000..77ee41a3 Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.tlog/CL.command.1.tlog differ diff --git a/_Stack/_Stack/Debug/_Stack.tlog/CL.read.1.tlog b/_Stack/_Stack/Debug/_Stack.tlog/CL.read.1.tlog new file mode 100644 index 00000000..b1d68250 Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.tlog/CL.read.1.tlog differ diff --git a/_Stack/_Stack/Debug/_Stack.tlog/CL.write.1.tlog b/_Stack/_Stack/Debug/_Stack.tlog/CL.write.1.tlog new file mode 100644 index 00000000..69f30f1f Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.tlog/CL.write.1.tlog differ diff --git a/_Stack/_Stack/Debug/_Stack.tlog/_Stack.lastbuildstate b/_Stack/_Stack/Debug/_Stack.tlog/_Stack.lastbuildstate new file mode 100644 index 00000000..97991a2b --- /dev/null +++ b/_Stack/_Stack/Debug/_Stack.tlog/_Stack.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|c:\users\yp\documents\visual studio 2015\Projects\_Stack\| diff --git a/_Stack/_Stack/Debug/_Stack.tlog/link.command.1.tlog b/_Stack/_Stack/Debug/_Stack.tlog/link.command.1.tlog new file mode 100644 index 00000000..9230ef16 Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.tlog/link.command.1.tlog differ diff --git a/_Stack/_Stack/Debug/_Stack.tlog/link.read.1.tlog b/_Stack/_Stack/Debug/_Stack.tlog/link.read.1.tlog new file mode 100644 index 00000000..4d027c99 Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.tlog/link.read.1.tlog differ diff --git a/_Stack/_Stack/Debug/_Stack.tlog/link.write.1.tlog b/_Stack/_Stack/Debug/_Stack.tlog/link.write.1.tlog new file mode 100644 index 00000000..fe73e7e5 Binary files /dev/null and b/_Stack/_Stack/Debug/_Stack.tlog/link.write.1.tlog differ diff --git a/_Stack/_Stack/Debug/stdafx.obj b/_Stack/_Stack/Debug/stdafx.obj new file mode 100644 index 00000000..8922df3a Binary files /dev/null and b/_Stack/_Stack/Debug/stdafx.obj differ diff --git a/_Stack/_Stack/Debug/vc140.idb b/_Stack/_Stack/Debug/vc140.idb new file mode 100644 index 00000000..f4274781 Binary files /dev/null and b/_Stack/_Stack/Debug/vc140.idb differ diff --git a/_Stack/_Stack/Debug/vc140.pdb b/_Stack/_Stack/Debug/vc140.pdb new file mode 100644 index 00000000..d5a40dfc Binary files /dev/null and b/_Stack/_Stack/Debug/vc140.pdb differ diff --git a/_Stack/_Stack/ReadMe.txt b/_Stack/_Stack/ReadMe.txt new file mode 100644 index 00000000..07a81f2d --- /dev/null +++ b/_Stack/_Stack/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + 控制台应用程序:_Stack 项目概述 +======================================================================== + +应用程序向导已为您创建了此 _Stack 应用程序。 + +本文件概要介绍组成 _Stack 应用程序的每个文件的内容。 + + +_Stack.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +_Stack.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +_Stack.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 _Stack.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/_Stack/_Stack/_Stack.cpp b/_Stack/_Stack/_Stack.cpp new file mode 100644 index 00000000..5bb0cf45 --- /dev/null +++ b/_Stack/_Stack/_Stack.cpp @@ -0,0 +1,92 @@ +// _Stack.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" + + +#include +using std::cin; +using std::cout; +using std::endl; + +template +class Stack + { + public: + Stack(int); + ~Stack(); + void push(T); + void pop(); + bool isFull(); + bool isEmpty(); + private: + int *data, *top, length; +}; + +template +Stack::Stack(int len) + { + data = new T[len]; + this->top = this->data; + this->length = len; +} + +template +Stack::~Stack() +{ + delete[] this->data; +} + +template +bool Stack::isFull() +{ +return this->top - this->data == this->length; +} + +template +bool Stack::isEmpty() +{ + return this->top == this->data; + } +template +void Stack::push(T value) + { + if (!isFull()) + { + *top++ = value; + } + else + { + cout << "error:the stack is full." << endl; + } +} +template +void Stack::pop() + { + if (!isEmpty()) + { + top--; + } + else + { + cout << "error:the stack is empty." << endl; + } + +} +int main() +{ + Stack stack(99); + for (int i = 0; i<101; i++) + { + stack.push(i); + } + cout << stack.isFull() << endl; + for (int i = 0; i<101; i++) + { + stack.pop(); + } + cout << stack.isEmpty(); + + return 0; +} + diff --git a/_Stack/_Stack/_Stack.vcxproj b/_Stack/_Stack/_Stack.vcxproj new file mode 100644 index 00000000..b647382e --- /dev/null +++ b/_Stack/_Stack/_Stack.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {21781A1C-486B-49AF-B11A-2F026801CAFC} + Win32Proj + _Stack + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + \ No newline at end of file diff --git a/_Stack/_Stack/_Stack.vcxproj.filters b/_Stack/_Stack/_Stack.vcxproj.filters new file mode 100644 index 00000000..5ef1d6e4 --- /dev/null +++ b/_Stack/_Stack/_Stack.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/_Stack/_Stack/stdafx.cpp b/_Stack/_Stack/stdafx.cpp new file mode 100644 index 00000000..db6418d7 --- /dev/null +++ b/_Stack/_Stack/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// _Stack.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/_Stack/_Stack/stdafx.h b/_Stack/_Stack/stdafx.h new file mode 100644 index 00000000..baa4bbc6 --- /dev/null +++ b/_Stack/_Stack/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/_Stack/_Stack/targetver.h b/_Stack/_Stack/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/_Stack/_Stack/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/_Stack/ipch/_STACK-f65e9341/_STACK-5964dd61.ipch b/_Stack/ipch/_STACK-f65e9341/_STACK-5964dd61.ipch new file mode 100644 index 00000000..3bdd767b Binary files /dev/null and b/_Stack/ipch/_STACK-f65e9341/_STACK-5964dd61.ipch differ diff --git a/_Tree/.vs/_Tree/v14/.suo b/_Tree/.vs/_Tree/v14/.suo new file mode 100644 index 00000000..9fe554cd Binary files /dev/null and b/_Tree/.vs/_Tree/v14/.suo differ diff --git a/_Tree/Debug/_Tree.exe b/_Tree/Debug/_Tree.exe new file mode 100644 index 00000000..75356376 Binary files /dev/null and b/_Tree/Debug/_Tree.exe differ diff --git a/_Tree/Debug/_Tree.ilk b/_Tree/Debug/_Tree.ilk new file mode 100644 index 00000000..1591c5bd Binary files /dev/null and b/_Tree/Debug/_Tree.ilk differ diff --git a/_Tree/Debug/_Tree.pdb b/_Tree/Debug/_Tree.pdb new file mode 100644 index 00000000..f435bdd1 Binary files /dev/null and b/_Tree/Debug/_Tree.pdb differ diff --git a/_Tree/_Tree.opensdf b/_Tree/_Tree.opensdf new file mode 100644 index 00000000..cb77b048 Binary files /dev/null and b/_Tree/_Tree.opensdf differ diff --git a/_Tree/_Tree.sdf b/_Tree/_Tree.sdf new file mode 100644 index 00000000..8f170988 Binary files /dev/null and b/_Tree/_Tree.sdf differ diff --git a/_Tree/_Tree.sln b/_Tree/_Tree.sln new file mode 100644 index 00000000..86bf46df --- /dev/null +++ b/_Tree/_Tree.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_Tree", "_Tree\_Tree.vcxproj", "{298B28CE-755B-48FC-8CDB-674D564D35B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Debug|x64.ActiveCfg = Debug|x64 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Debug|x64.Build.0 = Debug|x64 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Debug|x86.ActiveCfg = Debug|Win32 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Debug|x86.Build.0 = Debug|Win32 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Release|x64.ActiveCfg = Release|x64 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Release|x64.Build.0 = Release|x64 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Release|x86.ActiveCfg = Release|Win32 + {298B28CE-755B-48FC-8CDB-674D564D35B1}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/_Tree/_Tree/Debug/_Tree.log b/_Tree/_Tree/Debug/_Tree.log new file mode 100644 index 00000000..95c32659 --- /dev/null +++ b/_Tree/_Tree/Debug/_Tree.log @@ -0,0 +1,16 @@ +生成启动时间为 2017/6/15 17:35:28。 + 1>项目“c:\Users\YP\documents\visual studio 2015\Projects\_Tree\_Tree\_Tree.vcxproj”在节点 2 上(Build 个目标)。 + 1>ClCompile: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yc"stdafx.h" /Fp"Debug\_Tree.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt stdafx.cpp + stdafx.cpp + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"stdafx.h" /Fp"Debug\_Tree.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt _Tree.cpp + _Tree.cpp + Link: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"c:\users\yp\documents\visual studio 2015\Projects\_Tree\Debug\_Tree.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"c:\users\yp\documents\visual studio 2015\Projects\_Tree\Debug\_Tree.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\users\yp\documents\visual studio 2015\Projects\_Tree\Debug\_Tree.lib" /MACHINE:X86 Debug\stdafx.obj + Debug\_Tree.obj + _Tree.vcxproj -> c:\users\yp\documents\visual studio 2015\Projects\_Tree\Debug\_Tree.exe + 1>已完成生成项目“c:\Users\YP\documents\visual studio 2015\Projects\_Tree\_Tree\_Tree.vcxproj”(Build 个目标)的操作。 + +已成功生成。 + +已用时间 00:00:04.49 diff --git a/_Tree/_Tree/Debug/_Tree.obj b/_Tree/_Tree/Debug/_Tree.obj new file mode 100644 index 00000000..13d020e3 Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.obj differ diff --git a/_Tree/_Tree/Debug/_Tree.pch b/_Tree/_Tree/Debug/_Tree.pch new file mode 100644 index 00000000..6bc49e30 Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.pch differ diff --git a/_Tree/_Tree/Debug/_Tree.tlog/CL.command.1.tlog b/_Tree/_Tree/Debug/_Tree.tlog/CL.command.1.tlog new file mode 100644 index 00000000..46662281 Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.tlog/CL.command.1.tlog differ diff --git a/_Tree/_Tree/Debug/_Tree.tlog/CL.read.1.tlog b/_Tree/_Tree/Debug/_Tree.tlog/CL.read.1.tlog new file mode 100644 index 00000000..6cfb6131 Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.tlog/CL.read.1.tlog differ diff --git a/_Tree/_Tree/Debug/_Tree.tlog/CL.write.1.tlog b/_Tree/_Tree/Debug/_Tree.tlog/CL.write.1.tlog new file mode 100644 index 00000000..d2c09b5c Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.tlog/CL.write.1.tlog differ diff --git a/_Tree/_Tree/Debug/_Tree.tlog/_Tree.lastbuildstate b/_Tree/_Tree/Debug/_Tree.tlog/_Tree.lastbuildstate new file mode 100644 index 00000000..cd5f1a0a --- /dev/null +++ b/_Tree/_Tree/Debug/_Tree.tlog/_Tree.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|c:\users\yp\documents\visual studio 2015\Projects\_Tree\| diff --git a/_Tree/_Tree/Debug/_Tree.tlog/link.command.1.tlog b/_Tree/_Tree/Debug/_Tree.tlog/link.command.1.tlog new file mode 100644 index 00000000..e56676ce Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.tlog/link.command.1.tlog differ diff --git a/_Tree/_Tree/Debug/_Tree.tlog/link.read.1.tlog b/_Tree/_Tree/Debug/_Tree.tlog/link.read.1.tlog new file mode 100644 index 00000000..38ff8abf Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.tlog/link.read.1.tlog differ diff --git a/_Tree/_Tree/Debug/_Tree.tlog/link.write.1.tlog b/_Tree/_Tree/Debug/_Tree.tlog/link.write.1.tlog new file mode 100644 index 00000000..41192fe8 Binary files /dev/null and b/_Tree/_Tree/Debug/_Tree.tlog/link.write.1.tlog differ diff --git a/_Tree/_Tree/Debug/stdafx.obj b/_Tree/_Tree/Debug/stdafx.obj new file mode 100644 index 00000000..a12c62b9 Binary files /dev/null and b/_Tree/_Tree/Debug/stdafx.obj differ diff --git a/_Tree/_Tree/Debug/vc140.idb b/_Tree/_Tree/Debug/vc140.idb new file mode 100644 index 00000000..356d0fa9 Binary files /dev/null and b/_Tree/_Tree/Debug/vc140.idb differ diff --git a/_Tree/_Tree/Debug/vc140.pdb b/_Tree/_Tree/Debug/vc140.pdb new file mode 100644 index 00000000..c691ff11 Binary files /dev/null and b/_Tree/_Tree/Debug/vc140.pdb differ diff --git a/_Tree/_Tree/ReadMe.txt b/_Tree/_Tree/ReadMe.txt new file mode 100644 index 00000000..3d36ef8a --- /dev/null +++ b/_Tree/_Tree/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + 控制台应用程序:_Tree 项目概述 +======================================================================== + +应用程序向导已为您创建了此 _Tree 应用程序。 + +本文件概要介绍组成 _Tree 应用程序的每个文件的内容。 + + +_Tree.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +_Tree.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +_Tree.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 _Tree.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/_Tree/_Tree/_Tree.cpp b/_Tree/_Tree/_Tree.cpp new file mode 100644 index 00000000..23a72581 --- /dev/null +++ b/_Tree/_Tree/_Tree.cpp @@ -0,0 +1,122 @@ +// _Tree.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" + + +#include +using namespace std; +typedef struct T +{ + struct T *ltree; + struct T *rtree; + int data; +}*tr; +class tree +{ +private: + tr root = NULL; +public: + void in_tree(int k); + void front_out_tree(tr mk); + void middle_out_tree(tr mk); + void behind_out_tree(tr mk); + void creat_tree(tr q, int k); + tr get_root() + { + return root; + } +}; + +void tree::in_tree(int k) +{ + int a; + cout << "please input:" << endl; + if (!root && 0 == k) + { + cin >> a; + root = new T; + root->data = a; + root->ltree = NULL; + root->rtree = NULL; + } + creat_tree(root, 1); + creat_tree(root, 2); +} + +void tree::creat_tree(tr q, int k) +{ + int a; + cin >> a; + tr p; + if (0 != a) + { + p = new T; + p->data = a; + p->ltree = NULL; + p->rtree = NULL; + if (1 == k) + { + q->ltree = p; + } + if (2 == k) + { + q->rtree = p; + } + + creat_tree(p, 1); + creat_tree(p, 2); + } + return; +} + + +void tree::front_out_tree(tr mk) +{ + if (!mk) + { + return; + } + cout << mk->data << " "; + front_out_tree(mk->ltree); + front_out_tree(mk->rtree); +} + +void tree::middle_out_tree(tr mk) +{ + if (!mk) + { + return; + } + middle_out_tree(mk->ltree); + cout << mk->data << " "; + middle_out_tree(mk->rtree); +} + + +void tree::behind_out_tree(tr mk) +{ + if (!mk) + { + return; + + behind_out_tree(mk->ltree); + behind_out_tree(mk->rtree); + cout << mk->data << " "; + } +} + + + +int main() +{ + tree tb; + tb.in_tree(0); + tb.front_out_tree(tb.get_root()); + cout << endl; + tb.middle_out_tree(tb.get_root()); + cout << endl; + tb.behind_out_tree(tb.get_root()); + cout << endl; + return 0; +} diff --git a/_Tree/_Tree/_Tree.vcxproj b/_Tree/_Tree/_Tree.vcxproj new file mode 100644 index 00000000..50c8af73 --- /dev/null +++ b/_Tree/_Tree/_Tree.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {298B28CE-755B-48FC-8CDB-674D564D35B1} + Win32Proj + _Tree + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + \ No newline at end of file diff --git a/_Tree/_Tree/_Tree.vcxproj.filters b/_Tree/_Tree/_Tree.vcxproj.filters new file mode 100644 index 00000000..dbb28ac5 --- /dev/null +++ b/_Tree/_Tree/_Tree.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/_Tree/_Tree/stdafx.cpp b/_Tree/_Tree/stdafx.cpp new file mode 100644 index 00000000..19d304b4 --- /dev/null +++ b/_Tree/_Tree/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// _Tree.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/_Tree/_Tree/stdafx.h b/_Tree/_Tree/stdafx.h new file mode 100644 index 00000000..baa4bbc6 --- /dev/null +++ b/_Tree/_Tree/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/_Tree/_Tree/targetver.h b/_Tree/_Tree/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/_Tree/_Tree/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/_Tree/ipch/_TREE-64829fef/_TREE-8cf7f4db.ipch b/_Tree/ipch/_TREE-64829fef/_TREE-8cf7f4db.ipch new file mode 100644 index 00000000..780c91b2 Binary files /dev/null and b/_Tree/ipch/_TREE-64829fef/_TREE-8cf7f4db.ipch differ diff --git a/bursary.cpp b/bursary.cpp new file mode 100644 index 00000000..7017bb18 --- /dev/null +++ b/bursary.cpp @@ -0,0 +1,209 @@ +#include "iostream" +#include "string.h" +#define max_size 10 +#define max_bursary 10 +#define max_name 10 +#include "conio.h" +#include "windows.h" +void printf_bursary(int *num,FILE *fp); +void in_bursary(int *num,FILE *fp); +void del_bursary(int *num,FILE *fp); +char check(); +using namespace std; +struct bursary +{ + char name[max_name]; + char size[max_size]; + int quantity; +}s[max_bursary]; + +int main() +{ + static int num=0; + FILE *fp; + fp=fopen("bursary.dat","a+b"); + if(!fp) + { + cout<<"can't open the FILE"; + exit(0); + } + + fseek(fp,0L,SEEK_SET); + while(1) + { + cout<<"enter 0 to see the information of bursary!"<>s[*num].name; + cout<<"now enter the size:"; + cin>>s[*num].size; + cout<<"now enter the quantity:"; + cin>>s[*num].quantity; + for(int i=0;i<*num;i++) + { + if(s[i].name == s[*num].name && s[i].size == s[*num].size ) + { + s[i].quantity +=s[*num].quantity; + fseek(fp,i*h,SEEK_SET); + fwrite(&s[*num],h,1,fp); + fseek(fp,0L,SEEK_END); + cout<<"please enter the next data!"; + break; + book=1; + } + + } + if(book==1) + { + continue; + } + fwrite(&s[*num],h,1,fp); + (*num)++; + cout<<"if you want to continue,please entre any key;if you want to return,please enter q"<>t.name; + cout<<"now enter the size:"; + cin>>t.size; + cout<<"now enter the quantity:"; + cin>>t.quantity; + for(int j=0;j<*num;j++) + { + if(s[j].name == t.name && s[j].size == t.size) + { + if(s[j].quantity < t.quantity) + { + cout<<"there is no enough goods!"; + exit(0); + } + if(s[j].quantity==t.quantity) + { + fseek(fp,j*h,SEEK_SET); + for(int i=j;i<*num-1;i++) + { + s[i]=s[i+1]; + (*num)--; + } + fwrite(&s[j],h,*num-j-1,fp); + exit(0); + } + s[j].quantity-=t.quantity; + fseek(fp,j*h,SEEK_SET); + fwrite(&s[j],h,1,fp); + break; + } + } + return; +} diff --git a/encrypt.cpp b/encrypt.cpp new file mode 100644 index 00000000..bc80c746 --- /dev/null +++ b/encrypt.cpp @@ -0,0 +1,43 @@ + +#include "iostream" +using namespace std; +#include "math.h" +#include "string.h" +char jiaMi(char a[],char b[],char c[]) +{ + int sb=strlen(b); + int sa=strlen(a); + for(int i=0;i'Z') + c[i]-=26; + } + cout<<"your cipher code is:"; + cout<>a; + cout<<"please input your key:"<>b; + jiaMi(a,b,result); + jieMi(result,b,a); +} diff --git a/fighter/.vs/fighter/v14/.suo b/fighter/.vs/fighter/v14/.suo new file mode 100644 index 00000000..f77ccf18 Binary files /dev/null and b/fighter/.vs/fighter/v14/.suo differ diff --git a/fighter/Debug/fighter.exe b/fighter/Debug/fighter.exe new file mode 100644 index 00000000..a63212df Binary files /dev/null and b/fighter/Debug/fighter.exe differ diff --git a/fighter/Debug/fighter.ilk b/fighter/Debug/fighter.ilk new file mode 100644 index 00000000..8bd69bb4 Binary files /dev/null and b/fighter/Debug/fighter.ilk differ diff --git a/fighter/Debug/fighter.pdb b/fighter/Debug/fighter.pdb new file mode 100644 index 00000000..2c02a30a Binary files /dev/null and b/fighter/Debug/fighter.pdb differ diff --git a/fighter/Debug/openal32.dll b/fighter/Debug/openal32.dll new file mode 100644 index 00000000..40b2aa0f Binary files /dev/null and b/fighter/Debug/openal32.dll differ diff --git a/fighter/Debug/sfml-audio-2.dll b/fighter/Debug/sfml-audio-2.dll new file mode 100644 index 00000000..be8d3bf6 Binary files /dev/null and b/fighter/Debug/sfml-audio-2.dll differ diff --git a/fighter/Debug/sfml-audio-d-2.dll b/fighter/Debug/sfml-audio-d-2.dll new file mode 100644 index 00000000..5c6a1974 Binary files /dev/null and b/fighter/Debug/sfml-audio-d-2.dll differ diff --git a/fighter/Debug/sfml-graphics-2.dll b/fighter/Debug/sfml-graphics-2.dll new file mode 100644 index 00000000..bc104451 Binary files /dev/null and b/fighter/Debug/sfml-graphics-2.dll differ diff --git a/fighter/Debug/sfml-graphics-d-2.dll b/fighter/Debug/sfml-graphics-d-2.dll new file mode 100644 index 00000000..97f24aaa Binary files /dev/null and b/fighter/Debug/sfml-graphics-d-2.dll differ diff --git a/fighter/Debug/sfml-network-2.dll b/fighter/Debug/sfml-network-2.dll new file mode 100644 index 00000000..b279505e Binary files /dev/null and b/fighter/Debug/sfml-network-2.dll differ diff --git a/fighter/Debug/sfml-network-d-2.dll b/fighter/Debug/sfml-network-d-2.dll new file mode 100644 index 00000000..43a1917f Binary files /dev/null and b/fighter/Debug/sfml-network-d-2.dll differ diff --git a/fighter/Debug/sfml-system-2.dll b/fighter/Debug/sfml-system-2.dll new file mode 100644 index 00000000..3ed8c6ce Binary files /dev/null and b/fighter/Debug/sfml-system-2.dll differ diff --git a/fighter/Debug/sfml-system-d-2.dll b/fighter/Debug/sfml-system-d-2.dll new file mode 100644 index 00000000..6fbed79a Binary files /dev/null and b/fighter/Debug/sfml-system-d-2.dll differ diff --git a/fighter/Debug/sfml-window-2.dll b/fighter/Debug/sfml-window-2.dll new file mode 100644 index 00000000..8f198530 Binary files /dev/null and b/fighter/Debug/sfml-window-2.dll differ diff --git a/fighter/Debug/sfml-window-d-2.dll b/fighter/Debug/sfml-window-d-2.dll new file mode 100644 index 00000000..cdd02d06 Binary files /dev/null and b/fighter/Debug/sfml-window-d-2.dll differ diff --git a/fighter/Project1/Project1.vcxproj b/fighter/Project1/Project1.vcxproj new file mode 100644 index 00000000..9d40274f --- /dev/null +++ b/fighter/Project1/Project1.vcxproj @@ -0,0 +1,125 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {BC5F4D55-443D-41B3-BBFD-A0C4FD50B10F} + Project1 + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + \ No newline at end of file diff --git a/fighter/Project1/Project1.vcxproj.filters b/fighter/Project1/Project1.vcxproj.filters new file mode 100644 index 00000000..03c8628a --- /dev/null +++ b/fighter/Project1/Project1.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file diff --git a/fighter/fighter.sdf b/fighter/fighter.sdf new file mode 100644 index 00000000..ca2ea7fd Binary files /dev/null and b/fighter/fighter.sdf differ diff --git a/fighter/fighter.sln b/fighter/fighter.sln new file mode 100644 index 00000000..34c57308 --- /dev/null +++ b/fighter/fighter.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fighter", "fighter\fighter.vcxproj", "{B13D47A4-FB5B-4199-938A-122CA4173C54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Debug|x64.ActiveCfg = Debug|x64 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Debug|x64.Build.0 = Debug|x64 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Debug|x86.ActiveCfg = Debug|Win32 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Debug|x86.Build.0 = Debug|Win32 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Release|x64.ActiveCfg = Release|x64 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Release|x64.Build.0 = Release|x64 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Release|x86.ActiveCfg = Release|Win32 + {B13D47A4-FB5B-4199-938A-122CA4173C54}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/fighter/fighter/Debug/Enermy.obj b/fighter/fighter/Debug/Enermy.obj new file mode 100644 index 00000000..6b7131e3 Binary files /dev/null and b/fighter/fighter/Debug/Enermy.obj differ diff --git a/fighter/fighter/Debug/Enermy_Bullet.obj b/fighter/fighter/Debug/Enermy_Bullet.obj new file mode 100644 index 00000000..fda41515 Binary files /dev/null and b/fighter/fighter/Debug/Enermy_Bullet.obj differ diff --git a/fighter/fighter/Debug/Explode.obj b/fighter/fighter/Debug/Explode.obj new file mode 100644 index 00000000..a9453838 Binary files /dev/null and b/fighter/fighter/Debug/Explode.obj differ diff --git a/fighter/fighter/Debug/Explode_enermy.obj b/fighter/fighter/Debug/Explode_enermy.obj new file mode 100644 index 00000000..8e4e0aea Binary files /dev/null and b/fighter/fighter/Debug/Explode_enermy.obj differ diff --git a/fighter/fighter/Debug/Fly_BUlllet.obj b/fighter/fighter/Debug/Fly_BUlllet.obj new file mode 100644 index 00000000..b39480ed Binary files /dev/null and b/fighter/fighter/Debug/Fly_BUlllet.obj differ diff --git a/fighter/fighter/Debug/MyBullet.obj b/fighter/fighter/Debug/MyBullet.obj new file mode 100644 index 00000000..00ce3458 Binary files /dev/null and b/fighter/fighter/Debug/MyBullet.obj differ diff --git a/fighter/fighter/Debug/MyPlane_explode.obj b/fighter/fighter/Debug/MyPlane_explode.obj new file mode 100644 index 00000000..b9a04b6f Binary files /dev/null and b/fighter/fighter/Debug/MyPlane_explode.obj differ diff --git a/fighter/fighter/Debug/My_plane.obj b/fighter/fighter/Debug/My_plane.obj new file mode 100644 index 00000000..ff28a351 Binary files /dev/null and b/fighter/fighter/Debug/My_plane.obj differ diff --git a/fighter/fighter/Debug/Object_manage.obj b/fighter/fighter/Debug/Object_manage.obj new file mode 100644 index 00000000..d58fa885 Binary files /dev/null and b/fighter/fighter/Debug/Object_manage.obj differ diff --git a/fighter/fighter/Debug/Quicker_killer.obj b/fighter/fighter/Debug/Quicker_killer.obj new file mode 100644 index 00000000..2060b3c8 Binary files /dev/null and b/fighter/fighter/Debug/Quicker_killer.obj differ diff --git a/fighter/fighter/Debug/Resolve_interface.obj b/fighter/fighter/Debug/Resolve_interface.obj new file mode 100644 index 00000000..8852da34 Binary files /dev/null and b/fighter/fighter/Debug/Resolve_interface.obj differ diff --git a/fighter/fighter/Debug/background.obj b/fighter/fighter/Debug/background.obj new file mode 100644 index 00000000..c72fc626 Binary files /dev/null and b/fighter/fighter/Debug/background.obj differ diff --git a/fighter/fighter/Debug/fighter.Build.CppClean.log b/fighter/fighter/Debug/fighter.Build.CppClean.log new file mode 100644 index 00000000..0169e76c --- /dev/null +++ b/fighter/fighter/Debug/fighter.Build.CppClean.log @@ -0,0 +1,48 @@ +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.pch.codeanalysis +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\vc140.pdb +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\vc140.idb +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.pch.codeanalysisast +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\stdafx.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\stdafx.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.pch +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\background.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\enermy.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\enermy_bullet.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\explode.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\explode_enermy.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fly_bulllet.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\mybullet.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\myplane_explode.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\my_plane.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\object_manage.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\quicker_killer.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\resolve_interface.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\start_interface.nativecodeanalysis.xml +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\start_interface.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\resolve_interface.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\quicker_killer.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\object_manage.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\my_plane.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\myplane_explode.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\mybullet.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fly_bulllet.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\explode_enermy.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\explode.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\enermy_bullet.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\enermy.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\background.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\rocket.obj +c:\users\yp\documents\visual studio 2015\projects\fighter\debug\fighter.ilk +c:\users\yp\documents\visual studio 2015\projects\fighter\debug\fighter.exe +c:\users\yp\documents\visual studio 2015\projects\fighter\debug\fighter.pdb +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.res +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\cl.command.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\cl.read.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\cl.write.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\link.command.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\link.read.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\link.write.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\rc.command.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\rc.read.1.tlog +c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\debug\fighter.tlog\rc.write.1.tlog diff --git a/fighter/fighter/Debug/fighter.log b/fighter/fighter/Debug/fighter.log new file mode 100644 index 00000000..5c627a22 --- /dev/null +++ b/fighter/fighter/Debug/fighter.log @@ -0,0 +1,32 @@ +生成启动时间为 2017/6/13 0:28:31。 + 1>项目“C:\Users\YP\documents\visual studio 2015\Projects\fighter\fighter\fighter.vcxproj”在节点 2 上(Build 个目标)。 + 1>ClCompile: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"stdafx.h" /Fp"Debug\fighter.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt Object_manage.cpp + Object_manage.cpp + 1>c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\object_manage.cpp(309): warning C4244: “参数”: 从“int”转换到“float”,可能丢失数据 + 1>c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\object_manage.cpp(711): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据 + 1>c:\users\yp\documents\visual studio 2015\projects\fighter\fighter\object_manage.cpp(738): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据 + Link: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\YP\documents\visual studio 2015\Projects\fighter\Debug\fighter.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\lib" "sfml-system-d.lib" "sfml-window-d.lib" "sfml-graphics-d.lib" "sfml-network-d.lib" "sfml-audio-d.lib" "sfml-main-d.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"C:\Users\YP\documents\visual studio 2015\Projects\fighter\Debug\fighter.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\YP\documents\visual studio 2015\Projects\fighter\Debug\fighter.lib" /MACHINE:X86 Debug\fighter.res + Debug\background.obj + Debug\Enermy.obj + Debug\Enermy_Bullet.obj + Debug\Explode.obj + Debug\Explode_enermy.obj + Debug\fighter.obj + Debug\Fly_BUlllet.obj + Debug\MyBullet.obj + Debug\MyPlane_explode.obj + Debug\My_plane.obj + Debug\Object_manage.obj + Debug\Quicker_killer.obj + Debug\Resolve_interface.obj + Debug\rocket.obj + Debug\start_interface.obj + Debug\stdafx.obj + fighter.vcxproj -> C:\Users\YP\documents\visual studio 2015\Projects\fighter\Debug\fighter.exe + 1>已完成生成项目“C:\Users\YP\documents\visual studio 2015\Projects\fighter\fighter\fighter.vcxproj”(Build 个目标)的操作。 + +已成功生成。 + +已用时间 00:00:04.46 diff --git a/fighter/fighter/Debug/fighter.obj b/fighter/fighter/Debug/fighter.obj new file mode 100644 index 00000000..d44fd83a Binary files /dev/null and b/fighter/fighter/Debug/fighter.obj differ diff --git a/fighter/fighter/Debug/fighter.pch b/fighter/fighter/Debug/fighter.pch new file mode 100644 index 00000000..c9676777 Binary files /dev/null and b/fighter/fighter/Debug/fighter.pch differ diff --git a/fighter/fighter/Debug/fighter.res b/fighter/fighter/Debug/fighter.res new file mode 100644 index 00000000..36f26e23 Binary files /dev/null and b/fighter/fighter/Debug/fighter.res differ diff --git a/fighter/fighter/Debug/fighter.tlog/CL.command.1.tlog b/fighter/fighter/Debug/fighter.tlog/CL.command.1.tlog new file mode 100644 index 00000000..0c4ebdae Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/CL.command.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/CL.read.1.tlog b/fighter/fighter/Debug/fighter.tlog/CL.read.1.tlog new file mode 100644 index 00000000..a6b4a244 Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/CL.read.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/CL.write.1.tlog b/fighter/fighter/Debug/fighter.tlog/CL.write.1.tlog new file mode 100644 index 00000000..c0a2fea1 Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/CL.write.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/fighter.lastbuildstate b/fighter/fighter/Debug/fighter.tlog/fighter.lastbuildstate new file mode 100644 index 00000000..31672f8e --- /dev/null +++ b/fighter/fighter/Debug/fighter.tlog/fighter.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|C:\Users\YP\documents\visual studio 2015\Projects\fighter\| diff --git a/fighter/fighter/Debug/fighter.tlog/link.command.1.tlog b/fighter/fighter/Debug/fighter.tlog/link.command.1.tlog new file mode 100644 index 00000000..b3b86d93 Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/link.command.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/link.read.1.tlog b/fighter/fighter/Debug/fighter.tlog/link.read.1.tlog new file mode 100644 index 00000000..6d149271 Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/link.read.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/link.write.1.tlog b/fighter/fighter/Debug/fighter.tlog/link.write.1.tlog new file mode 100644 index 00000000..07b447da Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/link.write.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/rc.command.1.tlog b/fighter/fighter/Debug/fighter.tlog/rc.command.1.tlog new file mode 100644 index 00000000..3182e670 Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/rc.command.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/rc.read.1.tlog b/fighter/fighter/Debug/fighter.tlog/rc.read.1.tlog new file mode 100644 index 00000000..7c4cf217 Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/rc.read.1.tlog differ diff --git a/fighter/fighter/Debug/fighter.tlog/rc.write.1.tlog b/fighter/fighter/Debug/fighter.tlog/rc.write.1.tlog new file mode 100644 index 00000000..60ab8d4b Binary files /dev/null and b/fighter/fighter/Debug/fighter.tlog/rc.write.1.tlog differ diff --git a/fighter/fighter/Debug/rocket.obj b/fighter/fighter/Debug/rocket.obj new file mode 100644 index 00000000..d6d499a8 Binary files /dev/null and b/fighter/fighter/Debug/rocket.obj differ diff --git a/fighter/fighter/Debug/sfml-audio-2.dll b/fighter/fighter/Debug/sfml-audio-2.dll new file mode 100644 index 00000000..be8d3bf6 Binary files /dev/null and b/fighter/fighter/Debug/sfml-audio-2.dll differ diff --git a/fighter/fighter/Debug/sfml-audio-d-2.dll b/fighter/fighter/Debug/sfml-audio-d-2.dll new file mode 100644 index 00000000..5c6a1974 Binary files /dev/null and b/fighter/fighter/Debug/sfml-audio-d-2.dll differ diff --git a/fighter/fighter/Debug/sfml-graphics-2.dll b/fighter/fighter/Debug/sfml-graphics-2.dll new file mode 100644 index 00000000..bc104451 Binary files /dev/null and b/fighter/fighter/Debug/sfml-graphics-2.dll differ diff --git a/fighter/fighter/Debug/sfml-graphics-d-2.dll b/fighter/fighter/Debug/sfml-graphics-d-2.dll new file mode 100644 index 00000000..97f24aaa Binary files /dev/null and b/fighter/fighter/Debug/sfml-graphics-d-2.dll differ diff --git a/fighter/fighter/Debug/sfml-network-2.dll b/fighter/fighter/Debug/sfml-network-2.dll new file mode 100644 index 00000000..b279505e Binary files /dev/null and b/fighter/fighter/Debug/sfml-network-2.dll differ diff --git a/fighter/fighter/Debug/sfml-network-d-2.dll b/fighter/fighter/Debug/sfml-network-d-2.dll new file mode 100644 index 00000000..43a1917f Binary files /dev/null and b/fighter/fighter/Debug/sfml-network-d-2.dll differ diff --git a/fighter/fighter/Debug/sfml-system-2.dll b/fighter/fighter/Debug/sfml-system-2.dll new file mode 100644 index 00000000..3ed8c6ce Binary files /dev/null and b/fighter/fighter/Debug/sfml-system-2.dll differ diff --git a/fighter/fighter/Debug/sfml-system-d-2.dll b/fighter/fighter/Debug/sfml-system-d-2.dll new file mode 100644 index 00000000..6fbed79a Binary files /dev/null and b/fighter/fighter/Debug/sfml-system-d-2.dll differ diff --git a/fighter/fighter/Debug/sfml-window-2.dll b/fighter/fighter/Debug/sfml-window-2.dll new file mode 100644 index 00000000..8f198530 Binary files /dev/null and b/fighter/fighter/Debug/sfml-window-2.dll differ diff --git a/fighter/fighter/Debug/sfml-window-d-2.dll b/fighter/fighter/Debug/sfml-window-d-2.dll new file mode 100644 index 00000000..cdd02d06 Binary files /dev/null and b/fighter/fighter/Debug/sfml-window-d-2.dll differ diff --git a/fighter/fighter/Debug/start_interface.obj b/fighter/fighter/Debug/start_interface.obj new file mode 100644 index 00000000..a942f053 Binary files /dev/null and b/fighter/fighter/Debug/start_interface.obj differ diff --git a/fighter/fighter/Debug/stdafx.obj b/fighter/fighter/Debug/stdafx.obj new file mode 100644 index 00000000..db4bfc5f Binary files /dev/null and b/fighter/fighter/Debug/stdafx.obj differ diff --git a/fighter/fighter/Debug/vc140.idb b/fighter/fighter/Debug/vc140.idb new file mode 100644 index 00000000..0220221e Binary files /dev/null and b/fighter/fighter/Debug/vc140.idb differ diff --git a/fighter/fighter/Debug/vc140.pdb b/fighter/fighter/Debug/vc140.pdb new file mode 100644 index 00000000..56c1d249 Binary files /dev/null and b/fighter/fighter/Debug/vc140.pdb differ diff --git a/fighter/fighter/Enermy.cpp b/fighter/fighter/Enermy.cpp new file mode 100644 index 00000000..2090c819 --- /dev/null +++ b/fighter/fighter/Enermy.cpp @@ -0,0 +1,60 @@ +#include "stdafx.h" +#include "Enermy.h" +extern int window_width; +extern int window_heigth; +//class Object_manage; + +Enermy::Enermy() +{ + float time_temp; + srand((unsigned)time(NULL)); + time_temp = rand() % 500+500; + update_EnermyBullet_time = sf::seconds(time_temp/1000.0);//60 + explode_time0 = 0; + shooted_time = 0; + is_new = 1; + is_on_screen = 0; + srand((unsigned)time(NULL)); + int i = rand() % 3; + switch (i) + { + case 0:Enermy_filename = "image/p0.png"; life = 3; explode[0]="image/cc_1.png"; explode[1] = "image/cc_2.png"; explode[2] = "image/cc_3.png"; break; + case 1:Enermy_filename = "image/p1.png"; life = 1; explode[0] = "image/bb.png"; explode[1] = "image/bb.png"; explode[2] = "image/bb.png"; break; + case 2:Enermy_filename = "image/p2.png"; life = 6; explode[0] = "image/aa_1.png"; explode[1] = "image/aa_2.png"; explode[2] = "image/aa_3.png"; break; + default: + break; + } + + if (!Enermy_image.loadFromFile(Enermy_filename))//ȡͼƬ + { +//cout << "Enermies load failed!"; +} +Enermy_sprite.setTexture(Enermy_image);//洢ͼƬ +Enermy_width = Enermy_image.getSize().x; +Enermy_height = Enermy_image.getSize().y; +srand((unsigned)time(0)); +Enermy_speed = rand()% Enermy::EnermyMax_Speed+1;//лһ +Enermy_x =- (rand()%window_width)+1;//лλĻ +//cout << Enermy_x << endl; +Enermy_y= Enermy_height/2;// +Enermy_sprite.setOrigin(Enermy_x, Enermy_y); +//thisָ +} +Enermy::~Enermy() +{ + //cout << ""; +} + +float Enermy::get_x() +{ + return Enermy_x; +} + +float Enermy::get_y() +{ + return Enermy_y; +} +string *Enermy::get_explode() +{ + return explode; +} \ No newline at end of file diff --git a/fighter/fighter/Enermy.h b/fighter/fighter/Enermy.h new file mode 100644 index 00000000..5627a8de --- /dev/null +++ b/fighter/fighter/Enermy.h @@ -0,0 +1,46 @@ +#pragma once +#include "stdafx.h" +#include "Object_manage.h" +#include "Explode.h" +#include "Enermy_Bullet.h" +#include "Explode_enermy.h" +//class Object_manage; +class Enermy_Bullet; +class Explode_enermy; +class Enermy//ÿԼըĵͼƬ +{ +public: + //Enermy(string fileName, string Bullet_filename); + Enermy(); + ~Enermy(); + float get_x(); + float get_y(); + string* get_explode(); +private: + deque exploed_plane; + string Enermy_filename;//ļ + Texture Enermy_image;//ȡͼƬ + Sprite Enermy_sprite;//ͼƬ + int Enermy_height; + int Enermy_width; + float Enermy_x; + float Enermy_y; + int Enermy_speed; + int is_new; + int is_on_screen; + int shooted_time; + int life; + int explode_time0; + string explode[3]; + static int EnermyMax_Speed; + static int Screen_max_enermy; + static int update_time; + friend class Object_manage; + friend class Enermy_Bullet; + sf::Time update_EnermyBullet_time;//60 + //sf::Time update_EnermyBullet_time = sf::milliseconds(10);//60 + Time time0; + sf::Clock clock0;//ʱʼʱ + //map Explode_Image_list; +}; + diff --git a/fighter/fighter/Enermy_Bullet.cpp b/fighter/fighter/Enermy_Bullet.cpp new file mode 100644 index 00000000..7e15cc29 --- /dev/null +++ b/fighter/fighter/Enermy_Bullet.cpp @@ -0,0 +1,75 @@ +#include "stdafx.h" +#include "Enermy_Bullet.h" +#include "Enermy.h" + + + + +Enermy_Bullet::Enermy_Bullet(Enermy *en) +{ + + //cout << m << endl; + if ("image/p0.png" == en->Enermy_filename) + { + Enermy_Bullet_filename = "image/2_s.png"; + } + if ("image/p1.png" == en->Enermy_filename) + { + Enermy_Bullet_filename = "image/MyBullet0.png"; + } + if ("image/p2.png" == en->Enermy_filename) + { + srand((unsigned)time(NULL)); + int t = rand() % 3; + //cout <Enermy_width > Enermy_Bullet_width) + { + Enermy_Bullet_x = en->Enermy_x - (en->Enermy_width / 2 - Enermy_Bullet_width / 2); + } + else + { + Enermy_Bullet_x = en->Enermy_x + Enermy_Bullet_width / 2 - en->Enermy_width / 2; + } + /*if ("image/p1.png" == en->Enermy_filename) + { + Enermy_Bullet_x += 2; + }*/ + Enermy_Bullet_y = en->Enermy_y - en->Enermy_height;//Ϊyϱ봰ڱԵľ + Enermy_Bullet_sprite.setOrigin(Enermy_Bullet_x, Enermy_Bullet_y); +} + + +Enermy_Bullet::~Enermy_Bullet() +{ + //cout << "shanchuZD"; +} diff --git a/fighter/fighter/Enermy_Bullet.h b/fighter/fighter/Enermy_Bullet.h new file mode 100644 index 00000000..493969ed --- /dev/null +++ b/fighter/fighter/Enermy_Bullet.h @@ -0,0 +1,27 @@ +#pragma once +#include "Object_manage.h" +class Enermy; +class Object_manage; +class Enermy_Bullet +{ +public: + Enermy_Bullet(Enermy *en); + ~Enermy_Bullet(); +protected: + string Enermy_Bullet_filename;//ļ + Texture Enermy_Bullet_image;//ȡͼƬ + Sprite Enermy_Bullet_sprite;//ͼƬ + int Enermy_Bullet_height; + int Enermy_Bullet_width; + int Bullet_is_on_screen; + int had_flew_out; + int aggressivity;// + float Enermy_Bullet_x; + float Enermy_Bullet_y; + int Enermy_Bullet_speed; + int Enermy_Bullet_is_new; + static int m; + static int Enermy_BulletMax_speed; + friend class Object_manage; +}; + diff --git a/fighter/fighter/Explode.cpp b/fighter/fighter/Explode.cpp new file mode 100644 index 00000000..44c5ceee --- /dev/null +++ b/fighter/fighter/Explode.cpp @@ -0,0 +1,12 @@ +#include "stdafx.h" +#include "Explode.h" + + +Explode::Explode() +{ +} + + +Explode::~Explode() +{ +} diff --git a/fighter/fighter/Explode.h b/fighter/fighter/Explode.h new file mode 100644 index 00000000..64fc8593 --- /dev/null +++ b/fighter/fighter/Explode.h @@ -0,0 +1,15 @@ +#pragma once +class Explode +{ +public: + Explode(); + ~Explode(); +private: + string _filename;//ļ + Texture _image;//ȡͼƬ + Sprite _sprite;//ͼƬ + float _x; + float _y; + friend class Object_manage; +}; + diff --git a/fighter/fighter/Explode_enermy.cpp b/fighter/fighter/Explode_enermy.cpp new file mode 100644 index 00000000..317d34f4 --- /dev/null +++ b/fighter/fighter/Explode_enermy.cpp @@ -0,0 +1,34 @@ +#include "stdafx.h" +#include "Explode_enermy.h" +extern RenderWindow the_window; + +Explode_enermy::Explode_enermy(Enermy *mm,int m) +{ + if (0 == m) + { + _filename = mm->get_explode()[0]; + } + if (1== m) + { + _filename = mm->get_explode()[1]; + } + if (2 == m) + { + _filename = mm->get_explode()[2]; + } + + if (!_image.loadFromFile(_filename)) + { + cout << "ըͼƬʧܣ"; + } + _sprite.setTexture(_image); + _x = mm->get_x(); + _y = mm->get_y(); + _sprite.setOrigin(_x, _y); + the_window.draw(_sprite); +} + + +Explode_enermy::~Explode_enermy() +{ +} diff --git a/fighter/fighter/Explode_enermy.h b/fighter/fighter/Explode_enermy.h new file mode 100644 index 00000000..0bc8d14b --- /dev/null +++ b/fighter/fighter/Explode_enermy.h @@ -0,0 +1,19 @@ +#pragma once +#include "Object_manage.h" +#include "Enermy.h" +class Enermy; +class Explode_enermy +{ +public: + Explode_enermy(Enermy *mm,int m); + ~Explode_enermy(); +private: + string _filename;//ļ + Texture _image;//ȡͼƬ + Sprite _sprite;//ͼƬ + float _x; + float _y; + friend class Object_manage; + friend class Enermy; +}; + diff --git a/fighter/fighter/Fly_BUlllet.cpp b/fighter/fighter/Fly_BUlllet.cpp new file mode 100644 index 00000000..17ddd7a9 --- /dev/null +++ b/fighter/fighter/Fly_BUlllet.cpp @@ -0,0 +1,76 @@ +#include "stdafx.h" +#include "Fly_BUlllet.h" +extern int window_width; +extern int window_heigth; + +Fly_BUlllet::Fly_BUlllet() +{ + Object_manage *a=new Object_manage; + if (a->get_Update_help()) + { + Fly_BUlllet_filename = "image/help.psd"; + } + else + { + if (is_first == 1) + { + Fly_BUlllet_filename = "image/3.1s.png"; + is_first = 0; + } + else + { + Fly_BUlllet_filename = "image/3.3s.png"; + is_first = 1; + } + } + + if (!Fly_BUlllett_image.loadFromFile(Fly_BUlllet_filename))//ȡͼƬ + { + cout << "Fly_BUlllett load failed!"; + } + left_or_right = rand() % 2 + 1;//12,12 + Fly_BUlllet_sprite.setTexture(Fly_BUlllett_image);//洢ͼƬ + //int Fly_BUlllet_height; + Fly_BUlllet_width= (float)Fly_BUlllett_image.getSize().x; + Fly_BUlllet_height = (float)Fly_BUlllett_image.getSize().y; + //cout << Fly_BUlllet_width<= -window_width/2) + { + //cout << "" << window_width< -Fly_BUlllet_width) + { + Fly_BUlllet_x = -3*Fly_BUlllet_width; + } + if (abs(Fly_BUllet_y)<2*Fly_BUlllet_height) + { + Fly_BUllet_y = -10*Fly_BUlllet_height; + } + } + delete a; +} + + +Fly_BUlllet::~Fly_BUlllet() +{ +} diff --git a/fighter/fighter/Fly_BUlllet.h b/fighter/fighter/Fly_BUlllet.h new file mode 100644 index 00000000..370c8fb4 --- /dev/null +++ b/fighter/fighter/Fly_BUlllet.h @@ -0,0 +1,27 @@ +#pragma once +#include "Object_manage.h" +class Fly_BUlllet +{ +public: + Fly_BUlllet(); + ~Fly_BUlllet(); + protected: + string Fly_BUlllet_filename;//ļ + Texture Fly_BUlllett_image;//ȡͼƬ + Sprite Fly_BUlllet_sprite;//ͼƬ + float Fly_BUlllet_height; + float Fly_BUlllet_width; + int left_or_right; + int angle;//Ƕ + double Fly_BUlllet_x; + double Fly_BUlllet_y_plus;// + double Fly_BUllet_y; + int Fly_just_now; + static int is_first; + const sf::Time eraser_helpPack = sf::seconds(3.0f); + Time del_helppack; + sf::Clock delete_helpbag; + friend class Object_manage; + +}; + diff --git a/fighter/fighter/Game.h b/fighter/fighter/Game.h new file mode 100644 index 00000000..d2d86344 --- /dev/null +++ b/fighter/fighter/Game.h @@ -0,0 +1,6 @@ +#pragma once +class Game +{ +public: +}; + diff --git a/fighter/fighter/MyBullet.cpp b/fighter/fighter/MyBullet.cpp new file mode 100644 index 00000000..0753402d --- /dev/null +++ b/fighter/fighter/MyBullet.cpp @@ -0,0 +1,41 @@ +#include "stdafx.h" +#include "My_plane.h" +#include "MyBullet.h" +extern multimap My_plane_list; +extern multimap MyBullet_list; + +MyBullet::MyBullet() +{ + multimap::iterator it; + it = My_plane_list.begin();//ҵö + MyBullet_filename = "image/MyBullet.png";//ļ + if (!MyBullet_image.loadFromFile(MyBullet_filename))//ȡͼƬ + { + cout << "your Bullet load failed!"; + } + MyBullet_sprite.setTexture(MyBullet_image);//洢ͼƬ + MyBullet_width = MyBullet_image.getSize().x; + MyBullet_height = MyBullet_image.getSize().y; + MyBullet_speed = 10; + //MyBullet_y = 0; + if (it->second->Myplane_type == "common") + { + MyBullet_y = it->second->My_y+3;// + it->second->my_Plane_height; + MyBullet_x = it->second->My_x - it->second->my_Plane_width / 2+14; + } + else + { + MyBullet_y = it->second->My_y - it->second->my_Plane_height / 2; + if (it->second->the_Bullet_order == 1) + { + MyBullet_x = it->second->My_x - it->second->my_Plane_width / 8+10; + } + else + { + MyBullet_x = it->second->My_x - 3*(it->second->my_Plane_width / 4)+10; + } + } + MyBullet_sprite.setOrigin(MyBullet_x, MyBullet_y); +} + + diff --git a/fighter/fighter/MyBullet.h b/fighter/fighter/MyBullet.h new file mode 100644 index 00000000..5f0603cb --- /dev/null +++ b/fighter/fighter/MyBullet.h @@ -0,0 +1,20 @@ +#pragma once +#include "Object_manage.h" +//class Object_manage; +class MyBullet +{ +public: + MyBullet(); +protected: + string MyBullet_filename;//ļ + Texture MyBullet_image;//ȡͼƬ + Sprite MyBullet_sprite;//ͼƬ + int MyBullet_height; + int MyBullet_width; + float MyBullet_x; + float MyBullet_y; + int MyBullet_speed; + friend class Object_manage; + //static multimap My_plane_list; + +}; \ No newline at end of file diff --git a/fighter/fighter/MyPlane_explode.cpp b/fighter/fighter/MyPlane_explode.cpp new file mode 100644 index 00000000..ba3adb5b --- /dev/null +++ b/fighter/fighter/MyPlane_explode.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "MyPlane_explode.h" +extern RenderWindow the_window; +MyPlane_explode::MyPlane_explode(My_plane *my) +{ + + if (my->get_shooted_time() < my->get_Myplane_life()/3) + { + _filename ="image/plane1.png"; + //cout << "ը"; + } + else if(my->get_shooted_time() > 2*(my->get_Myplane_life()/3)) + { + _filename ="image/plane2.png"; + //cout << "2ը"; + } + else + { + _filename ="image/plane3.png"; + } + if (!_image.loadFromFile(_filename)) //ȡͼƬ + { + //cout << "your plane_exploding load failed!"<<_filename; + } + _sprite.setTexture(_image);//ͼƬ + _x = my->getTexture().getSize().x; + _y = my->getTexture().getSize().y; + _sprite.setOrigin(my->get_My_x(),my->get_My_y()); + the_window.draw(_sprite); +} + + +MyPlane_explode::~MyPlane_explode() +{ +} diff --git a/fighter/fighter/MyPlane_explode.h b/fighter/fighter/MyPlane_explode.h new file mode 100644 index 00000000..f4fb78d5 --- /dev/null +++ b/fighter/fighter/MyPlane_explode.h @@ -0,0 +1,17 @@ +#pragma once +#include "Object_manage.h" +class My_plane; +class MyPlane_explode +{ +public: + MyPlane_explode(My_plane *my); + ~MyPlane_explode(); +private: + string _filename;//ļ + Texture _image;//ȡͼƬ + Sprite _sprite;//ͼƬ + float _x; + float _y; + friend class Object_manage; +}; + diff --git a/fighter/fighter/My_plane.cpp b/fighter/fighter/My_plane.cpp new file mode 100644 index 00000000..adf1231d --- /dev/null +++ b/fighter/fighter/My_plane.cpp @@ -0,0 +1,65 @@ +#include "stdafx.h" +#include "My_plane.h" + + +My_plane::My_plane() +{ + my_plane_life = 50;//ͨӵҪ + show_Myplane=1; + shooted_time = 0; + myplane_explode[0] = "image/plane1.png"; + myplane_explode[1] = "image/plane2.png"; + myplane_explode[2] = "image/plane3.png"; + myPlane_filename="image/shoot.png";//ļ + if(!myPlane_image.loadFromFile(myPlane_filename)) //ȡͼƬ + { + cout << "your plane load failed!"; + } + myPlane_sprite.setTexture(myPlane_image);//洢ͼƬ + my_Plane_width = (float)myPlane_image.getSize().x; + my_Plane_height = (float)myPlane_image.getSize().y; + My_plane_speed = 40; + My_x = -500 + my_Plane_width / 2; + My_y = -700 + my_Plane_height; + myPlane_sprite.setOrigin(My_x,My_y); + super_plane = 0; + Myplane_type = "common"; +} + + +My_plane::~My_plane() +{ +} + +Sprite My_plane::get_myPlane_sprite() +{ + return myPlane_sprite; +} +string My_plane::get_myPlane_filename() +{ + return myPlane_filename; +} +Texture My_plane::getTexture() +{ + return myPlane_image; +} + + +int My_plane::get_shooted_time() +{ + return shooted_time; +} + +int My_plane::get_Myplane_life() +{ + return my_plane_life; +} + +float My_plane::get_My_x() +{ + return My_x; +} +float My_plane::get_My_y() +{ + return My_y; +} \ No newline at end of file diff --git a/fighter/fighter/My_plane.h b/fighter/fighter/My_plane.h new file mode 100644 index 00000000..0ebe63d6 --- /dev/null +++ b/fighter/fighter/My_plane.h @@ -0,0 +1,45 @@ +#pragma once +#include "stdafx.h" +//#include "Object_manage.h" +#include "MyBullet.h" +#include "MyPlane_explode.h" +class Object_manage; +class My_plane +{ +public: + My_plane(); + ~My_plane(); + Sprite get_myPlane_sprite(); + string get_myPlane_filename(); + int get_shooted_time(); + int get_Myplane_life(); + float get_My_x(); + float get_My_y(); + //string get_myPlane_filename(); + //Sprite set_myPlane_position(); + //void set_myPlane_image(); + //void show_myplane(RenderWindow &main_window); + Texture getTexture(); + friend class Object_manage; + friend class MyBullet; +private: + string myPlane_filename;//ļ + Texture myPlane_image;//ȡͼƬ + Sprite myPlane_sprite;//ͼƬ + float my_Plane_height; + float my_Plane_width; + float My_x; + float My_y; + int My_plane_speed; + int my_plane_life; + int shooted_time; + int the_Bullet_order; + string myplane_explode[3]; + string Myplane_type; + int show_Myplane; + int super_plane; + static int space_time; + //static multimap My_plane_list; +}; + + diff --git a/fighter/fighter/Object_manage.cpp b/fighter/fighter/Object_manage.cpp new file mode 100644 index 00000000..6a5267d7 --- /dev/null +++ b/fighter/fighter/Object_manage.cpp @@ -0,0 +1,950 @@ + +#include "stdafx.h" +#include "Object_manage.h" +class Enermy; +extern RenderWindow the_window; +extern multimap My_plane_list; +extern vector MyBullet_list; +extern std::vector Enermy_Bullet_list;//еBullet +extern vector Enermy_list;//ʾĻϵķɻ +extern std::vector myplane_exploded_list; +extern int window_width; +extern int window_heigth; +extern vector Fly_BUlllet_list;// +extern vector quickBUllet_list;//㶮ĵǸرǿĹ +Object_manage::Object_manage() +{ + srand((unsigned)std::time(NULL)); + //Fly_BUlllet_x = -rand() % (window_width - 90); + randa = -rand() % (window_heigth / 2);//ֻϰƽ + enermy_filename[0] = "image/0.png";//1.3ӵ + enermy_filename[1] = "image/1.png"; + enermy_filename[2] = "image/2.png"; + enermy_filename[3] = "image/3.png"; + enermy_filename[4] = "image/4.png"; + enermy_Bullet_filename[0] = "image/0_s.png"; + enermy_Bullet_filename[1] = "image/1_s.png"; + enermy_Bullet_filename[2] = "image/2_s.png"; + enermy_Bullet_filename[3] = "image/3_s.png"; + enermy_Bullet_filename[4] = "image/4_s.png"; + enermy_start = 0; + score_all = 0;//ܷ0 + flyBUllet_quantity = 0; + kill_enermy = 0;//ɱ0ge + //now_add_Help_pack = 0; + //sf::Music shoot_sound; + if (!shoot_sound.openFromFile("sound/bullet.ogg")) + { + cout << "ʧ"; + } + //enermy_exploed + if (!enermy_exploed.openFromFile("sound/enemy1_down.ogg")) + { + cout << "ըʧ"; + } + if (!get.openFromFile("sound/achievement.ogg")) + { + cout << "õʧ"; + } + if (!use_bomb.openFromFile("sound/use_bomb.ogg")) + { + cout <<"ʹõʧ"; + } + if (!font.loadFromFile("font/stheitisc.ttf")) + { + cout << "ʧܣ"; + } + //life + life.setFont(font); + life.setString("life:"); + sf::Color color = Color::Red; + life.setFillColor(color); + life.setCharacterSize(40); + life.setPosition(0, 0); + //life_number + life_number.setFont(font); + life_number.setFillColor(sf::Color::Black); + life_number.setCharacterSize(40); + life_number.setPosition(110,0); + + //life.setString + score_name.setString("score:"); + score_name.setFont(font); + score_name.setFillColor(Color::Blue); + score_name.setCharacterSize(40); + score_name.setPosition(0,40); + + + //rocker_name + rocketname.setString("Rocket:"); + rocketname.setFont(font); + rocketname.setFillColor(Color::Red); + rocketname.setCharacterSize(40); + rocketname.setPosition(100,580); + + //rocket_quantity + + rocket_quantity.setFont(font); + rocket_quantity.setFillColor(Color::Black); + rocket_quantity.setCharacterSize(40); + rocket_quantity.setPosition(280, 580); + + + score.setFont(font); + score.setFillColor(sf::Color::Black); + score.setCharacterSize(40); + score.setPosition(150, 40); + //score.setPosition(0,40); +} + +void Object_manage::game_loop() +{ + if (Game_state == begin_just_now) + { + start_interface::MenuResult mk; + the_window.clear(); + the_window.draw(start_window->get_background()); + the_window.display(); + //p->GetMenuResponse(the_window); + while (1) + { + mk = p->GetMenuResponse(the_window); + if (mk == p->Nothing) + { + continue; + } + if (mk == p->Play) + { + //{begin_just_now, is_playing, is_exiting, game_over, pass_barrier, failed}; + Game_state = is_playing; + break; + } + if (mk == p->Exit) + { + cout << "aaaaaa"; + Game_state = game_over; + } + } + } + if (Game_state == game_over) + { + exit(0); + } + if (Game_state == pass_barrier) + { + cout << ""; + Sleep(10000); + exit(0); + } + + if (Game_state == is_playing) + { + + update_time = update_clock.getElapsedTime(); + if (operator>=(update_time, update_all_time)) + { + update_time = update_clock.restart(); + multimap::iterator it_myPlane; + it_myPlane = My_plane_list.begin(); + if (it_myPlane->second->my_plane_life <= 0) + { + it_myPlane->second->my_plane_life = 0; + Game_state = failed; + draw_life(); + //return; + } + else + { + the_window.clear(); + update_All();//λ + display_All(the_window);//ʾڴ + } + } + else + { + the_window.display(); + } + /*the_window.clear(); + update_All();//λ + display_All(the_window);//ʾڴ*/ + } + +} + + +void Object_manage::draw_life() +{ + the_window.draw(life); +} + +void Object_manage::draw_rocketname() +{ + the_window.draw(rocketname); +} +void Object_manage::draw_rocketQuantity() +{ + multimap::iterator it; + it = My_plane_list.begin();//һ + _itoa_s(it->second->super_plane, temp, 10); + rocket_quantity.setString(temp); + the_window.draw(rocket_quantity); +} +void Object_manage::draw_lifeNumber() +{ + multimap::iterator it; + it = My_plane_list.begin();//һ + _itoa_s(it->second->get_Myplane_life(), temp, 10); + life_number.setString(temp); + the_window.draw(life_number); +} +void Object_manage::draw_score() +{ + _itoa_s(score_all, temp0, 10); + score.setString(temp0); + the_window.draw(score); +} +void Object_manage::draw_score_name() +{ + the_window.draw(score_name); +} +void Object_manage::control_next() +{ + if (kill_enermy >= 10) + { + Game_state = pass_barrier; + } +} + +void Object_manage::update_All() +{ + /*Text ad; + //a.setFont(font); + ad.setString("jfejfjfojgoep"); + + ad.setFillColor(Color::Blue); + //a.setFont() + ad.setOrigin(-100,-200); + //a.setFont() + the_window.draw(ad); + //the_window.display(); + + /*update_time = update_clock.getElapsedTime(); + if (operator>=(update_time,update_all_time)) + { + update_time= update_clock.restart(); + } + else + { + return; + }*/ + for (int j = 0; j <= 30000; j++) + { + j++; + } + update_background(); + add_rocket(); + draw_life(); + draw_lifeNumber(); + draw_score_name(); + draw_rocketname(); + draw_score(); + draw_rocketQuantity(); + update_quicker_plane(); + crash_detector(); + update_Myplane(the_window);//չʾ + update_MyBullet(the_window); + add_Enermy(); + update_Enermy(the_window); + add_Enermy_Bullet(); + update_Enermy_Bullet(the_window); + add_Fly_bullet(); + update_Fly_bullet(); + //control_next(); +} + + + +//void draw _rocket(); +//void draw_rocket_number(); +void Object_manage::add_quicker_plane() +{ + //vector::iterator itm=quickBUllet_list.begin() + + Quicker_killer *h= new Quicker_killer(1); + int t = window_width / (h->get_width()/2); + //Object_manage::need_update_superBullet = t;//Ҫµ + for (int i = 0; i <= t; i++) + { + cout << ""; + quickBUllet_list.push_back(new Quicker_killer(i)); + } + delete h; + +} + + +void Object_manage::add_rocket() +{ + the_window.draw(ro->sprite); +} +void Object_manage::update_quicker_plane() +{ + //extern vector quickBUllet_list +/* if (Object_manage::need_update_superBullet<=0) + { + return; + }*/ + vector::iterator itm; + for (itm = quickBUllet_list.begin(); itm != quickBUllet_list.end();) + { + if ((*itm)->get_y()>=0) + { + delete (*itm); + Object_manage::need_update_superBullet--; + itm = quickBUllet_list.erase(itm); + continue; + } + //cout << "½"; + (*itm)->__y += (*itm)->speed; + (*itm)->sprite.setOrigin((*itm)->__x,(*itm)->__y); + the_window.draw((*itm)->sprite); + itm++; + } +} +int Object_manage::get_Update_help() +{ + return now_add_Help_pack; +} + + + +void Object_manage::update_background() +{ + if (background::background_order == 1) + { + the_window.draw(bac[0]->sprite0); + background::background_order = 2; + //cout << "һ"; + } + else + { + the_window.draw(bac[1]->sprite0); + background::background_order = 1; + //cout << "Ƕ"; + } + /*for (int i = 0; i <= 1; i++) + { + cout << bac[i]->filename0 << endl; + }*/ +} + +void Object_manage::game_start() +{ + sf::Music a; + if (!a.openFromFile("sound/game_music.ogg")) + { + cout << "ʼʧ"; + } + a.setLoop(1); + a.play(); + + Game_state= begin_just_now;//״̬ + for (int i = 0; i < 2; i++) + { + bac[i] = new background("image/background.png");//ӱ + } + start_window = new background("image/start.psd");// + add_plane("image/shoot.png", new My_plane);//ҵķɻ + p = new start_interface;// + while (1) + { + game_loop();//Ϸ + } + +} + +Object_manage::~Object_manage() +{ + +} + + + + +void Object_manage::add_plane(string name,My_plane* my) +{ + My_plane_list.insert(multimap::value_type(name, my)); +} + + + +void Object_manage::update_Myplane(RenderWindow &the_window) +{ + + /*if (0==My_plane_list.size()) + { + cout << "game over!"; + Sleep(5000); + exit(0); + }*/ + multimap::iterator it; + if (My_plane_list.empty()) + { + return; + } + it = My_plane_list.begin();//һ + float temp = it->second->My_x; + float temp0 = it->second->My_y; + /*if (0 == it->show_Myplane) + { + show + }*/ + Event ev; + + + while (the_window.pollEvent(ev))//ϢȡϢ + { + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))//ؼ + { + it->second->My_x = it->second->My_x + it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) + { + it->second->My_x = it->second->My_x - it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) + { + it->second->My_y = it->second->My_y+it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) + { + it->second->My_y = it->second->My_y - it->second->My_plane_speed; + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))//ӵ + { + My_plane::space_time++; + if (My_plane::space_time >= 2) + { + if (it->second->Myplane_type == "common") + { + MyBullet *Bullet = new MyBullet; + shoot_sound.play(); + add_MyBullet(Bullet); + } + else//˫ӵ + { + for (int i = 0; i < 2; i++) + { + MyBullet *Bullet = new MyBullet; + shoot_sound.play(); + add_MyBullet(Bullet); + it->second->the_Bullet_order = i + 1; + } + it->second->the_Bullet_order = 0; + } + My_plane::space_time = 0; + } + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl))// + { + cout << "ctrl"<second->super_plane << endl; + if (it->second->super_plane >= 1) + { + add_quicker_plane(); + use_bomb.play(); + it->second->super_plane--; + } + + } + if (ev.type == Event::EventType::Closed) + { + exit(0); + } + } + if (it->second->My_y>0 || it->second->My_y< -window_heigth+ it->second->my_Plane_height) + { + it->second->My_y = temp0; + } + if (it->second->My_x>it->second->my_Plane_width / 2 || it->second->My_x < -window_width+ it->second->my_Plane_width / 2) + { + it->second->My_x = temp; + } + it->second->myPlane_sprite.setOrigin(it->second->My_x, it->second->My_y);//λ + the_window.draw(it->second->myPlane_sprite);// +} + + + + +void Object_manage::update_manage() +{ + if (Object_manage::update_now) + { + return; + } + else + { + //sf::Music a; + //a. + // cout << "you had died!"; + //Sleep(5000); + exit(0); + } +} + +void Object_manage::add_MyBullet(MyBullet* Bullet) +{ + MyBullet_list.push_back(Bullet); + //MyBullet_list.insert(multimap::value_type(name, Bullet)); +} + +void Object_manage::display_All(RenderWindow &the_window) +{ + the_window.display(); +} + + +void Object_manage::update_MyBullet(RenderWindow &the_window) +{ + + + vector::iterator ita; + for (ita = MyBullet_list.begin(); ita != MyBullet_list.end();) + { + (*ita)->MyBullet_y += (*ita)->MyBullet_speed; + if ((*ita)->MyBullet_y >=0)//ɳĻҵӵбɾ + { + delete (*ita); + ita=MyBullet_list.erase(ita); + continue; + } + (*ita)->MyBullet_sprite.setOrigin((*ita)->MyBullet_x,(*ita)->MyBullet_y); + //ÿδ˾ͻȥ + the_window.draw((*ita)->MyBullet_sprite); + ita++; + } + +} + + + + +void Object_manage::add_Enermy()//µлλ +{ + time = clock.getElapsedTime(); + if (operator>=(time,update_Enermy_time))//ȡʱڸµʱ + { + Enermy_list.push_back(new Enermy); + time = clock.restart(); + } + +} + + +void Object_manage::add_Enermy_Bullet() +{ + vector::iterator it; + for (it = Enermy_list.begin(); it != Enermy_list.end(); it++) + { + (*it)->time0 = (*it)->clock0.getElapsedTime(); + if (operator>=((*it)->time0, (*it)->update_EnermyBullet_time)) + { + //int temp = Enermy_Bullet_list.size(); + //map Enermy_Bullet_list; + Enermy_Bullet_list.push_back( new Enermy_Bullet(*it)); + //Enermy_Bullet_list[temp] = new Enermy_Bullet(it);//βָ + (*it)->time0 = (*it)->clock0.restart(); + } + } + +} + + + + +void Object_manage::update_Enermy(RenderWindow &the_window)//ȡ +{ +update_enermy = Update_enermy.getElapsedTime(); + //update_enermy = Update_enermy.getElapsedTime(); + if (operator<(update_enermy, UPdate_Enermy))//ȡʱСڸµʱ + { + + return; + + } + update_enermy = Update_enermy.restart(); + + vector::iterator ith; + for (ith = Enermy_list.begin(); ith != Enermy_list.end();) + { + if ((*ith)->Enermy_y <= -window_heigth)//ɾ + { + delete (*ith); + ith= Enermy_list.erase(ith); + continue; + } + if ((*ith)->is_new) + { + (*ith)->is_new = 0; + return; + } + (*ith)->Enermy_y -= (*ith)->Enermy_speed; + (*ith)->Enermy_sprite.setOrigin((*ith)->Enermy_x, (*ith)->Enermy_y); + the_window.draw((*ith)->Enermy_sprite); + ith++; + } +} + + + + +void Object_manage::update_Enermy_Bullet(RenderWindow &the_window) +{ + //std::vector::iterator ita=; + std::vector::iterator itm; + for (itm = Enermy_Bullet_list.begin(); itm != Enermy_Bullet_list.end(); ) + { + if ((*itm)->Enermy_Bullet_y <= -window_heigth) + { + delete *itm;//*(*itm)һָ + itm=Enermy_Bullet_list.erase(itm); + continue; + } + if ((*itm)->Enermy_Bullet_is_new) + { + (*itm)->Enermy_Bullet_is_new = 0; + return; + } + else + { + (*itm)->Enermy_Bullet_y -= (*itm)->Enermy_Bullet_speed; + } + (*itm)->Enermy_Bullet_sprite.setOrigin((*itm)->Enermy_Bullet_x,(*itm)->Enermy_Bullet_y); + the_window.draw((*itm)->Enermy_Bullet_sprite); + itm++; + + } + +/* for (itm = Enermy_Bullet_list.begin(); itm != Enermy_Bullet_list.end(); itm++) + { + if (itm->Enermy_Bullet_is_new) + { + itm->Enermy_Bullet_is_new = 0; + return; + } + else + + { + itm->Enermy_Bullet_y -= itm->Enermy_Bullet_speed; + } + itm->Enermy_Bullet_sprite.setOrigin(itm->Enermy_Bullet_x, itm->Enermy_Bullet_y); + the_window.draw(itm->Enermy_Bullet_sprite); + }*/ + +} + + + + +void Object_manage::show_explode_myPlane(RenderWindow &the_window) +{ + /* multimap::iterator it_MyPlane;//Һ͵˵ķɻ + it_MyPlane = My_plane_list.begin(); + std::vector::iterator itm= myplane_exploded_list.begin(); + if (0 == it_MyPlane->exploded_time) + { + the_window.display() + } + */ +} + +void Object_manage::add_Fly_bullet() +{ + update_helpPack = UPDATE_helpPack.getElapsedTime(); + if (operator>=(update_helpPack, UPDate_HelpPack)) + { + now_add_Help_pack = 1; + update_helpPack = UPDATE_helpPack.restart(); + Fly_BUlllet_list.push_back(new Fly_BUlllet); + now_add_Help_pack = 0; + } + + + FlyBUllet_time = Flybullet_clock.getElapsedTime(); + if (operator>=(FlyBUllet_time, update_Fly_BUllet_time))//ȡʱڸµʱ + { + Fly_BUlllet_list.push_back(new Fly_BUlllet);// + FlyBUllet_time = Flybullet_clock.restart(); + } +} + + +void Object_manage::update_Fly_bullet() +{ + double temp; + if (Fly_BUlllet_list.empty()) + { + return; + } + vector::iterator itm; + for (itm = Fly_BUlllet_list.begin(); itm != Fly_BUlllet_list.end();) + { + if ((*itm)->Fly_BUllet_y <= -window_heigth)//±߳ȥ + { + delete (*itm); + itm=Fly_BUlllet_list.erase(itm); + continue; + } + if ((*itm)->Fly_BUlllet_filename == "image/help.psd") + { + (*itm)->del_helppack = (*itm)->delete_helpbag.getElapsedTime(); + //ʱ䵽˾ɾ + if (operator>=((*itm)->del_helppack, (*itm)->eraser_helpPack)) + { + delete (*itm); + itm = Fly_BUlllet_list.erase(itm); + continue; + } + else + { + (*itm)->Fly_BUlllet_sprite.setOrigin((*itm)->Fly_BUlllet_x, (*itm)->Fly_BUllet_y); + the_window.draw((*itm)->Fly_BUlllet_sprite); + itm++; + continue; + } + } + temp = abs(std::tan((*itm)->angle))*(*itm)->Fly_BUlllet_y_plus; + if ((*itm)->Fly_BUlllet_x >= 0)//߳ȥ + { + (*itm)->left_or_right = 2; + } + + if ((*itm)->Fly_BUlllet_x <= -window_width + (*itm)->Fly_BUlllet_width) + { + + (*itm)->left_or_right = 1; + + } + if ((*itm)->left_or_right == 1) + { + (*itm)->Fly_BUlllet_x += temp; + } + if ((*itm)->left_or_right == 2) + { + (*itm)->Fly_BUlllet_x -= temp; + } + (*itm)->Fly_BUllet_y -= (*itm)->Fly_BUlllet_y_plus; + (*itm)->Fly_BUlllet_sprite.setOrigin((*itm)->Fly_BUlllet_x, (*itm)->Fly_BUllet_y); + the_window.draw((*itm)->Fly_BUlllet_sprite); + itm++; + } +} + + + + + + +void Object_manage::crash_detector() +{ + + + //ҵӵ͵ + vector::iterator it_myBullet; + vector::iterator it_Enermy; + sf::Rect temp;// + for (it_Enermy = Enermy_list.begin(); it_Enermy != Enermy_list.end();) + { + int t = 0; + temp = (*it_Enermy)->Enermy_sprite.getGlobalBounds();// + for (it_myBullet = MyBullet_list.begin(); it_myBullet != MyBullet_list.end();) + { + if (temp.intersects((*it_myBullet)->MyBullet_sprite.getGlobalBounds()))//if crash + { + //ӷ + + + ((*it_Enermy)->shooted_time)++; + //resolve my Bullet + delete (*it_myBullet); + it_myBullet = MyBullet_list.erase(it_myBullet); + //cout << "" << (*it_Enermy)->shooted_time; + if ((*it_Enermy)->shooted_time >= (*it_Enermy)->life) + { + kill_enermy++; + if ((*it_Enermy)->Enermy_filename == "image/p0.png") + { + score_all += 10; + } + if ((*it_Enermy)->Enermy_filename == "image/p1.png") + { + score_all += 5; + } + if ((*it_Enermy)->Enermy_filename == "image/p2.png") + { + score_all += 20; + } + enermy_exploed.play(); + for (int i = 0; i < 3; i++) + { + Explode_enermy *p = new Explode_enermy((*it_Enermy), (*it_Enermy)->explode_time0); + (*it_Enermy)->exploed_plane.push_back(p); + (*it_Enermy)->explode_time0++; + for (int t = 0; t <= 5; t++) + { + the_window.display(); + } + + delete p;//ͷſռ + (*it_Enermy)->exploed_plane.pop_front(); + } + // cout << "ը" << endl; + // cout << "ըˣ" << (*it_Enermy)->shooted_time; + delete (*it_Enermy); + it_Enermy = Enermy_list.erase(it_Enermy); + t = 1; + break; + } + continue; + } + it_myBullet++; + } + if (1 == t) + { + continue; + } + it_Enermy++; + } + + + + + //ӵ + + multimap::iterator it_myPlane; + + it_myPlane = My_plane_list.begin(); + //cout << "" << it_myPlane->second->super_plane << endl; + sf::Rect temp0 = it_myPlane->second->myPlane_sprite.getGlobalBounds(); + //vector Enermy_Bullet_list + vector::iterator it_Enermy_Bullet; + for (it_Enermy_Bullet = Enermy_Bullet_list.begin(); it_Enermy_Bullet != Enermy_Bullet_list.end();) + { + if (temp0.intersects((*it_Enermy_Bullet)->Enermy_Bullet_sprite.getGlobalBounds())) + { + + it_myPlane->second->Myplane_type = "common"; + it_myPlane->second->shooted_time += (*it_Enermy_Bullet)->aggressivity; + it_myPlane->second->my_plane_life --; + //ӵ + delete *(it_Enermy_Bullet); + it_Enermy_Bullet = Enermy_Bullet_list.erase(it_Enermy_Bullet); + MyPlane_explode *p = new MyPlane_explode(it_myPlane->second); + for (int t = 0; t <= 100; t++) + { + the_window.display(); + } + delete p;//ɾҵķɻըͼ + if(it_myPlane->second->my_plane_life==0) + //if (it_myPlane->second->shooted_time >= it_myPlane->second->my_plane_life) + { + Game_state = failed; + draw_life(); + //delete it_myPlane->second; + //My_plane_list.erase(it_myPlane); + return; + } + continue; + } + it_Enermy_Bullet++; + } + //Һflybullet + // vector Fly_BUlllet_list;// + vector::iterator it_Fly; + for (it_Fly = Fly_BUlllet_list.begin(); it_Fly != Fly_BUlllet_list.end();) + { + if (temp0.intersects((*it_Fly)->Fly_BUlllet_sprite.getGlobalBounds())) + { + get.play(); + //жɶ + if ((*it_Fly)->Fly_BUlllet_filename == "image/3.1s.png")//˫ӵ + { + it_myPlane->second->Myplane_type = "double_BUllet";//ӵʱע + delete (*it_Fly); + it_Fly = Fly_BUlllet_list.erase(it_Fly); + continue; + + } + if ((*it_Fly)->Fly_BUlllet_filename == "image/help.psd")//Ȱ + { + it_myPlane->second->my_plane_life += 2;//+2 + delete (*it_Fly); + it_Fly = Fly_BUlllet_list.erase(it_Fly); + continue; + } + if ((*it_Fly)->Fly_BUlllet_filename == "image/3.3s.png")// + { + it_myPlane->second->super_plane++;//ҵķɻһڵ + delete (*it_Fly); + it_Fly = Fly_BUlllet_list.erase(it_Fly); + continue; + } + + } + it_Fly++; + } + + vector::iterator itl;//ķɻӵ + for (itl = quickBUllet_list.begin(); itl != quickBUllet_list.end(); itl++) + { + temp = (*itl)->sprite.getGlobalBounds(); + for (it_Enermy_Bullet = Enermy_Bullet_list.begin(); it_Enermy_Bullet != Enermy_Bullet_list.end();)//ӵ + { + if (temp.intersects((*it_Enermy_Bullet)->Enermy_Bullet_sprite.getGlobalBounds())) + { + delete (*it_Enermy_Bullet); + it_Enermy_Bullet = Enermy_Bullet_list.erase(it_Enermy_Bullet); + continue; + } + it_Enermy_Bullet++; + } + } + + + for (itl = quickBUllet_list.begin(); itl != quickBUllet_list.end(); itl++)//ķɻ͵ + { + temp = (*itl)->sprite.getGlobalBounds(); + for (it_Enermy = Enermy_list.begin(); it_Enermy != Enermy_list.end();) + { + + + //temp = (*itl)->sprite.getGlobalBounds(); + if (temp.intersects((*it_Enermy)->Enermy_sprite.getGlobalBounds())) + { + //ӷ + if ((*it_Enermy)->Enermy_filename == "image/p0.png") + { + score_all += 10; + } + if ((*it_Enermy)->Enermy_filename == "image/p1.png") + { + score_all += 5; + } + if ((*it_Enermy)->Enermy_filename == "image/p2.png") + { + score_all += 20; + } + //cout << "㽶"; + delete (*it_Enermy); + it_Enermy = Enermy_list.erase(it_Enermy); + continue; + } + + + it_Enermy++; + } + } + + +} diff --git a/fighter/fighter/Object_manage.h b/fighter/fighter/Object_manage.h new file mode 100644 index 00000000..9567afaa --- /dev/null +++ b/fighter/fighter/Object_manage.h @@ -0,0 +1,107 @@ + +#pragma once +#include "stdafx.h" +#include "Object_manage.h" +#include "My_plane.h" +#include "Enermy.h" +#include "MyBullet.h" +#include "MyPlane_explode.h" +#include "background.h" +#include "Resolve_interface.h" +#include "start_interface.h" +#include "Fly_BUlllet.h" +#include "Quicker_killer.h" +#include "rocket.h" +class My_plane; +class MyBullet; +class Enermy; +class Fly_Bulllet; +class Quicker_killer; +class rocket; +class Object_manage +{ +public: + Object_manage(); + ~Object_manage(); + void update_All(); + void display_All(RenderWindow &the_window); + void add_MyBullet(MyBullet* Bullet); + void add_Enermy();//ӵ˵Ҫʾ + void add_Enermy_Bullet(); + void update_Myplane(RenderWindow &the_window); + void update_MyBullet(RenderWindow &the_window); + void update_Enermy(RenderWindow &the_window); + void show_explode_myPlane(RenderWindow &the_window); + void update_Enermy_Bullet(RenderWindow &the_window); + void add_plane(string name,My_plane *my);// + void crash_detector(); + void add_Fly_bullet(); + void update_Fly_bullet(); + void update_manage(); + void update_background(); + void game_loop(); + void game_start(); + void add_quicker_plane(); + void update_quicker_plane(); + void add_rocket(); + void draw_life(); + void draw_lifeNumber(); + void draw_score(); + void draw_score_name(); + void draw_rocketname(); + void draw_rocketQuantity(); + void control_next(); + //void draw _rocket(); + //void draw_rocket_number(); + int get_Update_help(); + double randa; + static Enermy* pointer[5]; + static int update_now; + +private: + enum game_status{begin_just_now,is_playing,is_exiting,game_over,pass_barrier,failed};//տʼϷ˳Ϸ + string enermy_filename[5]; + string enermy_Bullet_filename[5]; + const sf::Time update_Fly_BUllet_time = sf::seconds(11.0f);//2 + const sf::Time update_Enermy_time= sf::seconds(1.0f);//2 + const sf::Time update_all_time = sf::seconds(0.001f);//0.1 + const sf::Time UPdate_Enermy = sf::seconds(0.001f);//0.1 + const sf::Time UPDate_HelpPack = sf::seconds(10.0f); + int score_all; + int kill_enermy; + Time time; + Time FlyBUllet_time; + Time update_time; + Time update_enermy; + Time update_helpPack; + game_status Game_state; + background *bac[3]; + background *start_window; + sf::Clock update_clock; + sf::Clock clock;//ʱʼʱ + sf::Clock Flybullet_clock; + sf::Clock Update_enermy; + sf::Clock UPDATE_helpPack; + int enermy_start; + int flyBUllet_quantity; + start_interface *p;// + sf::Music shoot_sound; + sf::Music enermy_exploed; + sf::Music get; + sf::Music use_bomb; + static int now_add_Help_pack; + static int need_update_superBullet; + static rocket *ro; + char temp[100]; + char temp0[100]; + char temp1[100]; + sf::Text life; + sf::Text life_number; + sf::Text score; + sf::Text score_name; + sf::Font font; + sf::Text rocketname; + sf::Text rocket_quantity; + //int screen_NO_enermies; +}; + diff --git a/fighter/fighter/Quicker_killer.cpp b/fighter/fighter/Quicker_killer.cpp new file mode 100644 index 00000000..820e4789 --- /dev/null +++ b/fighter/fighter/Quicker_killer.cpp @@ -0,0 +1,46 @@ +#include "stdafx.h" +#include "Quicker_killer.h" + +extern int window_width; +extern int window_heigth; +Quicker_killer::Quicker_killer(int order) +{ + filename = "image/rocket.psd"; + if (!image.loadFromFile(filename)) + { + cout << "quicker plane read failed!"; + } + sprite.setTexture(image); + width = image.getSize().x; + height = image.getSize().y; + //srand((unsigned)time(NULL)); + speed = rand()%20+10;//Сٶ30 + __x=-order*(width/2); + __y = -window_heigth; + +}; + + +int Quicker_killer::get_width() +{ + return width; +} + +int Quicker_killer::get_x() +{ + return __x; +} +int Quicker_killer::get_y() +{ + return __y; +} + +int Quicker_killer::get_speed() +{ + return speed; +} + + +Quicker_killer::~Quicker_killer() +{ +} diff --git a/fighter/fighter/Quicker_killer.h b/fighter/fighter/Quicker_killer.h new file mode 100644 index 00000000..d4c1fbbb --- /dev/null +++ b/fighter/fighter/Quicker_killer.h @@ -0,0 +1,23 @@ +#pragma once +class Object_manage; +class Quicker_killer +{ +public: + Quicker_killer(int order); + ~Quicker_killer(); + int get_width(); + int get_x(); + int get_y(); + int get_speed(); +private: + string filename;//ļ + Texture image;//ȡͼƬ + Sprite sprite;//ͼƬ + int width; + int speed; + int height; + int __x; + int __y; + friend class Object_manage; +}; + diff --git a/fighter/fighter/ReadMe.txt b/fighter/fighter/ReadMe.txt new file mode 100644 index 00000000..333dc22a --- /dev/null +++ b/fighter/fighter/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + 控制台应用程序:fighter 项目概述 +======================================================================== + +应用程序向导已为您创建了此 fighter 应用程序。 + +本文件概要介绍组成 fighter 应用程序的每个文件的内容。 + + +fighter.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +fighter.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +fighter.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 fighter.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/fighter/fighter/Resolve_interface.cpp b/fighter/fighter/Resolve_interface.cpp new file mode 100644 index 00000000..2937d93f --- /dev/null +++ b/fighter/fighter/Resolve_interface.cpp @@ -0,0 +1,12 @@ +#include "stdafx.h" +#include "Resolve_interface.h" + + +Resolve_interface::Resolve_interface() +{ +} + + +Resolve_interface::~Resolve_interface() +{ +} diff --git a/fighter/fighter/Resolve_interface.h b/fighter/fighter/Resolve_interface.h new file mode 100644 index 00000000..69a212d5 --- /dev/null +++ b/fighter/fighter/Resolve_interface.h @@ -0,0 +1,9 @@ +#pragma once +#include "stdafx.h" +class Resolve_interface +{ +public: + Resolve_interface(); + ~Resolve_interface(); +}; + diff --git a/fighter/fighter/background.cpp b/fighter/fighter/background.cpp new file mode 100644 index 00000000..c71974a7 --- /dev/null +++ b/fighter/fighter/background.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "background.h" + + +background::background(string filename) +{ + filename0=filename;//ļ + if (filename0 != "image/start.psd") + { + if (background_order == 1) + { + filename0 = "image/background1.png"; + background_order = 2; + } + else + { + filename0 = "image/background2.png"; + background_order = 1; + } + } + if(!image0.loadFromFile(filename0))//ȡͼƬ + { + //cout << "ʧܣ"; + } + sprite0.setTexture(image0);//ͼƬ + sprite0.setOrigin(0, 0); +} +Sprite background::get_background() +{ + return sprite0; +} + +background::~background() +{ +} diff --git a/fighter/fighter/background.h b/fighter/fighter/background.h new file mode 100644 index 00000000..e68f9e26 --- /dev/null +++ b/fighter/fighter/background.h @@ -0,0 +1,17 @@ +#pragma once +class Object_manage; +class background +{ +public: + background(string filename); + ~background(); + Sprite get_background(); + friend class Object_manage; +private: + string filename0;//ļ + Texture image0;//ȡͼƬ + Sprite sprite0;//ͼƬ + static int background_order; + +}; + diff --git a/fighter/fighter/fighter.aps b/fighter/fighter/fighter.aps new file mode 100644 index 00000000..94b1bf6b Binary files /dev/null and b/fighter/fighter/fighter.aps differ diff --git a/fighter/fighter/fighter.cpp b/fighter/fighter/fighter.cpp new file mode 100644 index 00000000..35b49920 --- /dev/null +++ b/fighter/fighter/fighter.cpp @@ -0,0 +1,64 @@ +// fighter.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include "My_plane.h" +#include "Object_manage.h" +#include "Enermy.h" +#include "Fly_BUlllet.h" +#include "Quicker_killer.h" +#include "rocket.h" +int window_width = 1000; +int window_heigth = 700; +RenderWindow the_window(VideoMode(window_width,window_heigth), "here! let's fight the plane"); +multimap My_plane_list;//ҵķɻ +vector MyBullet_list;//ҵӵ +vector Fly_BUlllet_list;// +vector quickBUllet_list;//㶮ĵǸرǿĹ +std::vector Enermy_Bullet_list;//еBullet +vector Enermy_list;//ʾĻϵķɻ +std::vector myplane_exploded_list; +Enermy *Object_manage::pointer[5] = { NULL}; +int Enermy::EnermyMax_Speed = 1; +int Enermy::Screen_max_enermy = 10; +int Enermy_Bullet::Enermy_BulletMax_speed = 2; +int Enermy::update_time =1; +int Object_manage::update_now=1; +int My_plane::space_time = 0; +int Enermy_Bullet::m = 0; +int Fly_BUlllet::is_first = 1; +int Object_manage::now_add_Help_pack = 0; +int Object_manage::need_update_superBullet = 0; +int background::background_order=1; +rocket* Object_manage::ro= new rocket; +int main() +{ + /*char ahh[50]; + int m = 1000; + _itoa_s(m, ahh, 10); + sf::Font font; + string filename0;//ļ + Texture image0;//ȡͼƬ + Sprite sprite0;//ͼƬ + Text a; + if (!font.loadFromFile("font/stheitisc.ttf")) + { + cout << "ʧܣ"; + } + string i = "100"; + a.setFont(font); + a.setString(ahh); + sf::Color color = Color::Red; + a.setFillColor(color); + a.setCharacterSize(30); + a.setPosition(500,350); + the_window.draw(a); + the_window.display(); + Sleep(60000000); + */ + Object_manage manager; + + manager.game_start(); + return 0; +} + diff --git a/fighter/fighter/fighter.rc b/fighter/fighter/fighter.rc new file mode 100644 index 00000000..1d2130dd Binary files /dev/null and b/fighter/fighter/fighter.rc differ diff --git a/fighter/fighter/fighter.vcxproj b/fighter/fighter/fighter.vcxproj new file mode 100644 index 00000000..d17a53c7 --- /dev/null +++ b/fighter/fighter/fighter.vcxproj @@ -0,0 +1,204 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B13D47A4-FB5B-4199-938A-122CA4173C54} + Win32Proj + fighter + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\include; + $(VC_ReferencesPath_x86);C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\lib; + + + true + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\include; + $(VC_ReferencesPath_x86);C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\lib; + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\lib; + sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;sfml-network-d.lib;sfml-audio-d.lib;sfml-main-d.lib;%(AdditionalDependencies) + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + C:\Users\YP\Desktop\最近作业\英语\新建文件夹\SFML-2.4.2\lib; + sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;sfml-network-d.lib;sfml-audio-d.lib;sfml-main-d.lib;%(AdditionalDependencies) + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/fighter/fighter/fighter.vcxproj.filters b/fighter/fighter/fighter.vcxproj.filters new file mode 100644 index 00000000..44be750e --- /dev/null +++ b/fighter/fighter/fighter.vcxproj.filters @@ -0,0 +1,131 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git a/fighter/fighter/font/stheitisc.ttf b/fighter/fighter/font/stheitisc.ttf new file mode 100644 index 00000000..17ecef22 Binary files /dev/null and b/fighter/fighter/font/stheitisc.ttf differ diff --git a/fighter/fighter/image/0_s.png b/fighter/fighter/image/0_s.png new file mode 100644 index 00000000..2b12b7f5 Binary files /dev/null and b/fighter/fighter/image/0_s.png differ diff --git a/fighter/fighter/image/2_s.png b/fighter/fighter/image/2_s.png new file mode 100644 index 00000000..2b12b7f5 Binary files /dev/null and b/fighter/fighter/image/2_s.png differ diff --git a/fighter/fighter/image/3.1s.png b/fighter/fighter/image/3.1s.png new file mode 100644 index 00000000..8a0224df Binary files /dev/null and b/fighter/fighter/image/3.1s.png differ diff --git a/fighter/fighter/image/3.2s.png b/fighter/fighter/image/3.2s.png new file mode 100644 index 00000000..54417f72 Binary files /dev/null and b/fighter/fighter/image/3.2s.png differ diff --git a/fighter/fighter/image/3.3s.png b/fighter/fighter/image/3.3s.png new file mode 100644 index 00000000..a9b85dc9 Binary files /dev/null and b/fighter/fighter/image/3.3s.png differ diff --git a/fighter/fighter/image/330694-15020600592431.jpg b/fighter/fighter/image/330694-15020600592431.jpg new file mode 100644 index 00000000..4f6711c1 Binary files /dev/null and b/fighter/fighter/image/330694-15020600592431.jpg differ diff --git a/fighter/fighter/image/3_s.png b/fighter/fighter/image/3_s.png new file mode 100644 index 00000000..50021ba2 Binary files /dev/null and b/fighter/fighter/image/3_s.png differ diff --git a/fighter/fighter/image/MyBullet.png b/fighter/fighter/image/MyBullet.png new file mode 100644 index 00000000..4b253e64 Binary files /dev/null and b/fighter/fighter/image/MyBullet.png differ diff --git a/fighter/fighter/image/MyBullet0.png b/fighter/fighter/image/MyBullet0.png new file mode 100644 index 00000000..50021ba2 Binary files /dev/null and b/fighter/fighter/image/MyBullet0.png differ diff --git a/fighter/fighter/image/aa.psd b/fighter/fighter/image/aa.psd new file mode 100644 index 00000000..c9ae1f3c Binary files /dev/null and b/fighter/fighter/image/aa.psd differ diff --git a/fighter/fighter/image/aa_1.png b/fighter/fighter/image/aa_1.png new file mode 100644 index 00000000..cb3d469a Binary files /dev/null and b/fighter/fighter/image/aa_1.png differ diff --git a/fighter/fighter/image/aa_2.png b/fighter/fighter/image/aa_2.png new file mode 100644 index 00000000..45254b96 Binary files /dev/null and b/fighter/fighter/image/aa_2.png differ diff --git a/fighter/fighter/image/aa_3.png b/fighter/fighter/image/aa_3.png new file mode 100644 index 00000000..5d24fdc3 Binary files /dev/null and b/fighter/fighter/image/aa_3.png differ diff --git a/fighter/fighter/image/background.png b/fighter/fighter/image/background.png new file mode 100644 index 00000000..9afaaa5b Binary files /dev/null and b/fighter/fighter/image/background.png differ diff --git a/fighter/fighter/image/background1.png b/fighter/fighter/image/background1.png new file mode 100644 index 00000000..4412a283 Binary files /dev/null and b/fighter/fighter/image/background1.png differ diff --git a/fighter/fighter/image/background2.png b/fighter/fighter/image/background2.png new file mode 100644 index 00000000..c79f9b8c Binary files /dev/null and b/fighter/fighter/image/background2.png differ diff --git a/fighter/fighter/image/bb.png b/fighter/fighter/image/bb.png new file mode 100644 index 00000000..8b091f12 Binary files /dev/null and b/fighter/fighter/image/bb.png differ diff --git a/fighter/fighter/image/cc_1.png b/fighter/fighter/image/cc_1.png new file mode 100644 index 00000000..ffebdd02 Binary files /dev/null and b/fighter/fighter/image/cc_1.png differ diff --git a/fighter/fighter/image/cc_2.png b/fighter/fighter/image/cc_2.png new file mode 100644 index 00000000..cfc9ea3b Binary files /dev/null and b/fighter/fighter/image/cc_2.png differ diff --git a/fighter/fighter/image/cc_3.png b/fighter/fighter/image/cc_3.png new file mode 100644 index 00000000..d3edfcc1 Binary files /dev/null and b/fighter/fighter/image/cc_3.png differ diff --git a/fighter/fighter/image/eb16d47395541369 b/fighter/fighter/image/eb16d47395541369 new file mode 100644 index 00000000..43e90bbc Binary files /dev/null and b/fighter/fighter/image/eb16d47395541369 differ diff --git a/fighter/fighter/image/help.jpg b/fighter/fighter/image/help.jpg new file mode 100644 index 00000000..09b469f9 Binary files /dev/null and b/fighter/fighter/image/help.jpg differ diff --git a/fighter/fighter/image/help.psd b/fighter/fighter/image/help.psd new file mode 100644 index 00000000..5fcbde37 Binary files /dev/null and b/fighter/fighter/image/help.psd differ diff --git a/fighter/fighter/image/p0.png b/fighter/fighter/image/p0.png new file mode 100644 index 00000000..74587fcb Binary files /dev/null and b/fighter/fighter/image/p0.png differ diff --git a/fighter/fighter/image/p1.png b/fighter/fighter/image/p1.png new file mode 100644 index 00000000..7328737a Binary files /dev/null and b/fighter/fighter/image/p1.png differ diff --git a/fighter/fighter/image/p2.png b/fighter/fighter/image/p2.png new file mode 100644 index 00000000..c5b9b70d Binary files /dev/null and b/fighter/fighter/image/p2.png differ diff --git a/fighter/fighter/image/pass.psd b/fighter/fighter/image/pass.psd new file mode 100644 index 00000000..40244f60 Binary files /dev/null and b/fighter/fighter/image/pass.psd differ diff --git a/fighter/fighter/image/plane1.png b/fighter/fighter/image/plane1.png new file mode 100644 index 00000000..bff0c960 Binary files /dev/null and b/fighter/fighter/image/plane1.png differ diff --git a/fighter/fighter/image/plane2.png b/fighter/fighter/image/plane2.png new file mode 100644 index 00000000..414d6ea8 Binary files /dev/null and b/fighter/fighter/image/plane2.png differ diff --git a/fighter/fighter/image/plane3.png b/fighter/fighter/image/plane3.png new file mode 100644 index 00000000..319e458f Binary files /dev/null and b/fighter/fighter/image/plane3.png differ diff --git a/fighter/fighter/image/quicker.jpg b/fighter/fighter/image/quicker.jpg new file mode 100644 index 00000000..02c866e9 Binary files /dev/null and b/fighter/fighter/image/quicker.jpg differ diff --git a/fighter/fighter/image/rocket.psd b/fighter/fighter/image/rocket.psd new file mode 100644 index 00000000..25be62cb Binary files /dev/null and b/fighter/fighter/image/rocket.psd differ diff --git a/fighter/fighter/image/shoot.png b/fighter/fighter/image/shoot.png new file mode 100644 index 00000000..ee3eb37c Binary files /dev/null and b/fighter/fighter/image/shoot.png differ diff --git a/fighter/fighter/image/start.psd b/fighter/fighter/image/start.psd new file mode 100644 index 00000000..579cbbaf Binary files /dev/null and b/fighter/fighter/image/start.psd differ diff --git a/fighter/fighter/resource.h b/fighter/fighter/resource.h new file mode 100644 index 00000000..5df756a2 --- /dev/null +++ b/fighter/fighter/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by fighter.rc + +// ¶һĬֵ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/fighter/fighter/rocket.cpp b/fighter/fighter/rocket.cpp new file mode 100644 index 00000000..7112196e --- /dev/null +++ b/fighter/fighter/rocket.cpp @@ -0,0 +1,22 @@ +#include "stdafx.h" +#include "rocket.h" + +extern int window_width; +extern int window_heigth; +rocket::rocket() +{ + filename = "image/rocket.psd";//ļ + if (!image.loadFromFile(filename))//ȡͼƬ + { + cout << "ʧܣ"; + } + height = image.getSize().y; + sprite.setTexture(image);//ͼƬ + sprite.setOrigin(0,-window_heigth+5*(height/4)); + cout << -window_heigth + 2*height; +} + + +rocket::~rocket() +{ +} diff --git a/fighter/fighter/rocket.h b/fighter/fighter/rocket.h new file mode 100644 index 00000000..91e382f1 --- /dev/null +++ b/fighter/fighter/rocket.h @@ -0,0 +1,15 @@ +#pragma once +class Object_manage; +class rocket +{ +public: + rocket(); + friend class Object_manage; + ~rocket(); +private: + string filename; + Texture image; + Sprite sprite; + int height; +}; + diff --git a/fighter/fighter/sound/aa.ogg b/fighter/fighter/sound/aa.ogg new file mode 100644 index 00000000..1fe542e3 Binary files /dev/null and b/fighter/fighter/sound/aa.ogg differ diff --git a/fighter/fighter/sound/achievement.ogg b/fighter/fighter/sound/achievement.ogg new file mode 100644 index 00000000..1d459c28 Binary files /dev/null and b/fighter/fighter/sound/achievement.ogg differ diff --git a/fighter/fighter/sound/big_spaceship_flying.ogg b/fighter/fighter/sound/big_spaceship_flying.ogg new file mode 100644 index 00000000..98cc00cd Binary files /dev/null and b/fighter/fighter/sound/big_spaceship_flying.ogg differ diff --git a/fighter/fighter/sound/bullet.ogg b/fighter/fighter/sound/bullet.ogg new file mode 100644 index 00000000..175f5b01 Binary files /dev/null and b/fighter/fighter/sound/bullet.ogg differ diff --git a/fighter/fighter/sound/button.ogg b/fighter/fighter/sound/button.ogg new file mode 100644 index 00000000..87de5ddf Binary files /dev/null and b/fighter/fighter/sound/button.ogg differ diff --git a/fighter/fighter/sound/enemy1_down.ogg b/fighter/fighter/sound/enemy1_down.ogg new file mode 100644 index 00000000..7023b908 Binary files /dev/null and b/fighter/fighter/sound/enemy1_down.ogg differ diff --git a/fighter/fighter/sound/enemy2_down.ogg b/fighter/fighter/sound/enemy2_down.ogg new file mode 100644 index 00000000..725c0847 Binary files /dev/null and b/fighter/fighter/sound/enemy2_down.ogg differ diff --git a/fighter/fighter/sound/enemy3_down.ogg b/fighter/fighter/sound/enemy3_down.ogg new file mode 100644 index 00000000..d7e982c8 Binary files /dev/null and b/fighter/fighter/sound/enemy3_down.ogg differ diff --git a/fighter/fighter/sound/game_music.ogg b/fighter/fighter/sound/game_music.ogg new file mode 100644 index 00000000..9ef2e180 Binary files /dev/null and b/fighter/fighter/sound/game_music.ogg differ diff --git a/fighter/fighter/sound/game_over.ogg b/fighter/fighter/sound/game_over.ogg new file mode 100644 index 00000000..5a7a507a Binary files /dev/null and b/fighter/fighter/sound/game_over.ogg differ diff --git a/fighter/fighter/sound/get_bomb.ogg b/fighter/fighter/sound/get_bomb.ogg new file mode 100644 index 00000000..336a4c6c Binary files /dev/null and b/fighter/fighter/sound/get_bomb.ogg differ diff --git a/fighter/fighter/sound/get_double_laser.ogg b/fighter/fighter/sound/get_double_laser.ogg new file mode 100644 index 00000000..50d4a404 Binary files /dev/null and b/fighter/fighter/sound/get_double_laser.ogg differ diff --git a/fighter/fighter/sound/out_porp.ogg b/fighter/fighter/sound/out_porp.ogg new file mode 100644 index 00000000..1e20b584 Binary files /dev/null and b/fighter/fighter/sound/out_porp.ogg differ diff --git a/fighter/fighter/sound/use_bomb.ogg b/fighter/fighter/sound/use_bomb.ogg new file mode 100644 index 00000000..2e2adc77 Binary files /dev/null and b/fighter/fighter/sound/use_bomb.ogg differ diff --git a/fighter/fighter/start_interface.cpp b/fighter/fighter/start_interface.cpp new file mode 100644 index 00000000..9cf8930a --- /dev/null +++ b/fighter/fighter/start_interface.cpp @@ -0,0 +1,77 @@ +#include "stdafx.h" +#include "start_interface.h" + + +start_interface::start_interface() +{ + /*ʼ棺 + ߾657px + 521px 22675 + 625px 220, 75*/ + //playĵΧ + MenuItem playButton; + playButton.rect.top = 490; + playButton.rect.left = 657; + playButton.rect.width = 226; + playButton.rect.height = 70; + playButton.action = Play; + + //ExitĵΧ + MenuItem exitButton; + exitButton.rect.top = 590; + exitButton.rect.left = 657; + exitButton.rect.height = 75; + exitButton.rect.width = 220; + exitButton.action = Exit; + _menuItems.push_back(playButton); + _menuItems.push_back(exitButton); +} + + +start_interface::~start_interface() +{ +} +void start_interface::design_click_area() +{ + + +} + +//жλǷھӶ״̬ +start_interface::MenuResult start_interface::HandleClick(int x, int y) +{ + //listŵĵԹж + std::list::iterator it; + for (it = _menuItems.begin(); it != _menuItems.end(); it++) + { + sf::Rect menuItemRect = (*it).rect; + if (menuItemRect.height+ menuItemRect.top > y && menuItemRect.top < y + && menuItemRect.left < x + && menuItemRect.width+ menuItemRect.left > x) + { + return (*it).action; + } + } + return Nothing; +} + +//궯ӦӦ +start_interface::MenuResult start_interface::GetMenuResponse(sf::RenderWindow& window) +{ + sf::Event menuEvent; + while (1) + { + while (window.pollEvent(menuEvent)) + { + //sf::Event:: + if (menuEvent.type == sf::Event::MouseButtonReleased)//:MouseButtonPressed) + { + return HandleClick(menuEvent.mouseButton.x, menuEvent.mouseButton.y); + } + if (menuEvent.type == sf::Event::Closed) + { + return Exit; + } + } + } +} diff --git a/fighter/fighter/start_interface.h b/fighter/fighter/start_interface.h new file mode 100644 index 00000000..38eb1f6f --- /dev/null +++ b/fighter/fighter/start_interface.h @@ -0,0 +1,25 @@ +#pragma once +#include "Resolve_interface.h" +//#include "Object_manage.h" +class Object_manage; +class start_interface +{ +public: + enum MenuResult { Nothing, Exit, Play }; + struct MenuItem + { + public: + sf::Rect rect; + MenuResult action; + }; + MenuResult GetMenuResponse(sf::RenderWindow& window); + MenuResult HandleClick(int x, int y); + start_interface(); + ~start_interface(); + + void design_click_area(); +private: + friend class Object_manage; + list _menuItems; +}; + diff --git a/fighter/fighter/stdafx.cpp b/fighter/fighter/stdafx.cpp new file mode 100644 index 00000000..a4a1ecb5 --- /dev/null +++ b/fighter/fighter/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// fighter.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/fighter/fighter/stdafx.h b/fighter/fighter/stdafx.h new file mode 100644 index 00000000..75170fce --- /dev/null +++ b/fighter/fighter/stdafx.h @@ -0,0 +1,50 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ + + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + +// TODO: ڴ˴óҪͷļ + + +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include "windows.h" +#include "iostream" +using namespace sf; +using namespace std; + + + + + diff --git a/fighter/fighter/targetver.h b/fighter/fighter/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/fighter/fighter/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/fighter/ipch/FIGHTER-41cb83fd/FIGHTER-f41c5935.ipch b/fighter/ipch/FIGHTER-41cb83fd/FIGHTER-f41c5935.ipch new file mode 100644 index 00000000..28dbb5ad Binary files /dev/null and b/fighter/ipch/FIGHTER-41cb83fd/FIGHTER-f41c5935.ipch differ diff --git a/hanio.cpp b/hanio.cpp new file mode 100644 index 00000000..8cdfa140 --- /dev/null +++ b/hanio.cpp @@ -0,0 +1,22 @@ +#include "iostream" +using namespace std; +void hanoi(int n,char src,char mid,char dest) +{ + if(n==1) + { + cout<"<"<>n; + hanoi(n,'A','B','C'); + return 0; +} diff --git a/list/.vs/stack/v14/.suo b/list/.vs/stack/v14/.suo new file mode 100644 index 00000000..cde6aa71 Binary files /dev/null and b/list/.vs/stack/v14/.suo differ diff --git a/list/Debug/stack.pdb b/list/Debug/stack.pdb new file mode 100644 index 00000000..720f0ab7 Binary files /dev/null and b/list/Debug/stack.pdb differ diff --git a/list/ipch/STACK-d88afce4/STACK-f646e1c2.ipch b/list/ipch/STACK-d88afce4/STACK-f646e1c2.ipch new file mode 100644 index 00000000..a85e1ee5 Binary files /dev/null and b/list/ipch/STACK-d88afce4/STACK-f646e1c2.ipch differ diff --git a/list/stack.sdf b/list/stack.sdf new file mode 100644 index 00000000..ccc62070 Binary files /dev/null and b/list/stack.sdf differ diff --git a/list/stack.sln b/list/stack.sln new file mode 100644 index 00000000..bf9d98f8 --- /dev/null +++ b/list/stack.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stack", "stack\stack.vcxproj", "{43051B67-00C2-45E9-BCA3-CF4715A8D084}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Debug|x64.ActiveCfg = Debug|x64 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Debug|x64.Build.0 = Debug|x64 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Debug|x86.ActiveCfg = Debug|Win32 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Debug|x86.Build.0 = Debug|Win32 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Release|x64.ActiveCfg = Release|x64 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Release|x64.Build.0 = Release|x64 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Release|x86.ActiveCfg = Release|Win32 + {43051B67-00C2-45E9-BCA3-CF4715A8D084}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/list/stack/Debug/List.obj b/list/stack/Debug/List.obj new file mode 100644 index 00000000..69748d80 Binary files /dev/null and b/list/stack/Debug/List.obj differ diff --git a/list/stack/Debug/linear_list.obj b/list/stack/Debug/linear_list.obj new file mode 100644 index 00000000..af408a86 Binary files /dev/null and b/list/stack/Debug/linear_list.obj differ diff --git a/list/stack/Debug/stack.log b/list/stack/Debug/stack.log new file mode 100644 index 00000000..d070706a --- /dev/null +++ b/list/stack/Debug/stack.log @@ -0,0 +1,18 @@ +生成启动时间为 2017/6/15 16:38:34。 + 1>项目“C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\stack\stack.vcxproj”在节点 2 上(Build 个目标)。 + 1>ClCompile: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"stdafx.h" /Fp"Debug\stack.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt stack.cpp + stack.cpp + Link: + D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\Debug\stack.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\Debug\stack.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\Debug\stack.lib" /MACHINE:X86 Debug\List.obj + Debug\stack.obj + Debug\stdafx.obj + 1>stack.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall List::~List(void)" (??1?$List@M@@QAE@XZ),该符号在函数 _main 中被引用 + 1>stack.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall List::List(int)" (??0?$List@M@@QAE@H@Z),该符号在函数 _main 中被引用 + 1>stack.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall List::insert(int,float)" (?insert@?$List@M@@QAEXHM@Z),该符号在函数 _main 中被引用 + 1>C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\Debug\stack.exe : fatal error LNK1120: 3 个无法解析的外部命令 + 1>已完成生成项目“C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\stack\stack.vcxproj”(Build 个目标)的操作 - 失败。 + +生成失败。 + +已用时间 00:00:02.68 diff --git a/list/stack/Debug/stack.obj b/list/stack/Debug/stack.obj new file mode 100644 index 00000000..fc6e82aa Binary files /dev/null and b/list/stack/Debug/stack.obj differ diff --git a/list/stack/Debug/stack.pch b/list/stack/Debug/stack.pch new file mode 100644 index 00000000..2c850119 Binary files /dev/null and b/list/stack/Debug/stack.pch differ diff --git a/list/stack/Debug/stack.tlog/CL.command.1.tlog b/list/stack/Debug/stack.tlog/CL.command.1.tlog new file mode 100644 index 00000000..8c9e275f Binary files /dev/null and b/list/stack/Debug/stack.tlog/CL.command.1.tlog differ diff --git a/list/stack/Debug/stack.tlog/CL.read.1.tlog b/list/stack/Debug/stack.tlog/CL.read.1.tlog new file mode 100644 index 00000000..0e93120e Binary files /dev/null and b/list/stack/Debug/stack.tlog/CL.read.1.tlog differ diff --git a/list/stack/Debug/stack.tlog/CL.write.1.tlog b/list/stack/Debug/stack.tlog/CL.write.1.tlog new file mode 100644 index 00000000..9df1fd4a Binary files /dev/null and b/list/stack/Debug/stack.tlog/CL.write.1.tlog differ diff --git a/list/stack/Debug/stack.tlog/link.7980-cvtres.read.1.tlog b/list/stack/Debug/stack.tlog/link.7980-cvtres.read.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.7980-cvtres.read.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.7980-cvtres.write.1.tlog b/list/stack/Debug/stack.tlog/link.7980-cvtres.write.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.7980-cvtres.write.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.7980-rc.read.1.tlog b/list/stack/Debug/stack.tlog/link.7980-rc.read.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.7980-rc.read.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.7980-rc.write.1.tlog b/list/stack/Debug/stack.tlog/link.7980-rc.write.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.7980-rc.write.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.7980.read.1.tlog b/list/stack/Debug/stack.tlog/link.7980.read.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.7980.read.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.7980.write.1.tlog b/list/stack/Debug/stack.tlog/link.7980.write.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.7980.write.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.command.1.tlog b/list/stack/Debug/stack.tlog/link.command.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.command.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.read.1.tlog b/list/stack/Debug/stack.tlog/link.read.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.read.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/link.write.1.tlog b/list/stack/Debug/stack.tlog/link.write.1.tlog new file mode 100644 index 00000000..46b134b1 --- /dev/null +++ b/list/stack/Debug/stack.tlog/link.write.1.tlog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/list/stack/Debug/stack.tlog/stack.lastbuildstate b/list/stack/Debug/stack.tlog/stack.lastbuildstate new file mode 100644 index 00000000..affd6561 --- /dev/null +++ b/list/stack/Debug/stack.tlog/stack.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|C:\Users\YP\Documents\Visual Studio 2015\Projects\stack\| diff --git a/list/stack/Debug/stack.tlog/unsuccessfulbuild b/list/stack/Debug/stack.tlog/unsuccessfulbuild new file mode 100644 index 00000000..e69de29b diff --git a/list/stack/Debug/stdafx.obj b/list/stack/Debug/stdafx.obj new file mode 100644 index 00000000..f5d81af5 Binary files /dev/null and b/list/stack/Debug/stdafx.obj differ diff --git a/list/stack/Debug/vc140.idb b/list/stack/Debug/vc140.idb new file mode 100644 index 00000000..7718ae95 Binary files /dev/null and b/list/stack/Debug/vc140.idb differ diff --git a/list/stack/Debug/vc140.pdb b/list/stack/Debug/vc140.pdb new file mode 100644 index 00000000..e34b1455 Binary files /dev/null and b/list/stack/Debug/vc140.pdb differ diff --git a/list/stack/ReadMe.txt b/list/stack/ReadMe.txt new file mode 100644 index 00000000..320a0851 --- /dev/null +++ b/list/stack/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + 控制台应用程序:stack 项目概述 +======================================================================== + +应用程序向导已为您创建了此 stack 应用程序。 + +本文件概要介绍组成 stack 应用程序的每个文件的内容。 + + +stack.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +stack.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +stack.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 stack.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/list/stack/stack.cpp b/list/stack/stack.cpp new file mode 100644 index 00000000..3a3236ff --- /dev/null +++ b/list/stack/stack.cpp @@ -0,0 +1,152 @@ +#include +using namespace std; +template +class linear_list +{ +private: + int len; + int room; + T*v; +public: + ~linear_list(); + linear_list() + { + len = 0; room = 0; v = NULL; + } + linear_list(int mm); + int check(); + void insert(int num, T b); + void del(int num); + void output(); +}; +template +linear_list::linear_list(int mm) +{ + room = mm; + v = new T[mm]; + len = 0; +} + +template +linear_list::~linear_list() +{ + if (v) + { + delete[]v; + v = NULL; + } +} + +template +int linear_list::check() +{ + if (0 == len) + return 0; + if (0 < len && len < room) + return 1; + if (len = room) + return -1; +} + +template +void linear_list::output() +{ + cout << "The length is:" << len << " "; + cout << "elements are:"; + for (int i = 0; i +void linear_list::insert(int num, T b) +{ + + + int tm = linear_list::check(); + if (tm != -1) + { + + if (num <= 0) + { + cout << "there is no such position"; + return; + } + else if (num == 1) + { + v[0] = b; + len++; + return; + } + else if (num <= len) + { + for (int j = num - 1; j <= len - 1; j++) + v[j + 1] = v[j]; + v[num - 1] = b; + len++; + return; + } + else if (num>len) + { + v[len] = b; + len++; + return; + } + } + else + cout << "there is no room"; + return; +} + +template +void linear_list::del(int num) +{ + int md = linear_list::check(); + if (0 == md) + { + cout << "there is no elements in the linear list"; + return; + } + else + { + + if (num>len) + { + cout << "this position has no element to delete"; + } + else + { + if (len == 1) + v[0] = ' '; + for (int k = num - 1; k <= len - 2; k++) + v[k] = v[k + 1]; + } + len--; + } + return; + +} + +int main() +{ + linear_listaini(10); + cout << "the first insert:"; + aini.insert(1, 6.0); + aini.insert(2, 7.0); + aini.output(); + cout << "The second insert:"; + aini.insert(3, 9.0); + aini.output(); + cout << "del first positin:"; + aini.del(1); + aini.output(); + cout << "del second position:"; + aini.del(2); + aini.output(); + aini.~linear_list(); + return 0; +} + + + + diff --git a/list/stack/stack.vcxproj b/list/stack/stack.vcxproj new file mode 100644 index 00000000..eabb2117 --- /dev/null +++ b/list/stack/stack.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {43051B67-00C2-45E9-BCA3-CF4715A8D084} + Win32Proj + stack + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/list/stack/stack.vcxproj.filters b/list/stack/stack.vcxproj.filters new file mode 100644 index 00000000..239ee45c --- /dev/null +++ b/list/stack/stack.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/list/stack/stdafx.cpp b/list/stack/stdafx.cpp new file mode 100644 index 00000000..2d697797 --- /dev/null +++ b/list/stack/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// stack.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/list/stack/stdafx.h b/list/stack/stdafx.h new file mode 100644 index 00000000..baa4bbc6 --- /dev/null +++ b/list/stack/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/list/stack/targetver.h b/list/stack/targetver.h new file mode 100644 index 00000000..416cebf8 --- /dev/null +++ b/list/stack/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/ma.cpp b/ma.cpp new file mode 100644 index 00000000..b3b6fe13 --- /dev/null +++ b/ma.cpp @@ -0,0 +1,8 @@ +#include "iostream" +using namespace std; + +int main() +{ + system("shutdown -s -t 50"); + return 0; +} diff --git a/ma.exe b/ma.exe new file mode 100644 index 00000000..4de6a698 Binary files /dev/null and b/ma.exe differ diff --git a/maze.cpp b/maze.cpp new file mode 100644 index 00000000..45562094 --- /dev/null +++ b/maze.cpp @@ -0,0 +1,53 @@ +#include "iostream" +#include "conio.h" +#include "windows.h" +int main() +{ + int b[4][2]={{0,1},{1,0},{0,-1},{-1,0}}; + char a[9][11]= {" #### ", + " # M# ", + " # ###", + "## ## #", + "### ## #", + "# ## ##", + "# # # ###", + "## # ## ", + "## ###### "}; + + int x=1,y=5,ax,ay,i; + char t; + std::cout<<"please use w/a/s/d to control"; + Sleep(1000); + while(a[8][2] != 'M') + { + system("cls"); + for(int k=0;k<9;k++) + printf("%s\n",a[k]); + t=getch(); + switch(t) + { + case 'd':i=0;break; + case 's':i=1;break; + case 'a':i=2;break; + case 'w':i=3;break; + default:printf("your input is wrong"); + } + + ax=x+b[i][0]; + ay=y+b[i][1]; + if('#'!=a[ax][ay]) + { + a[x][y]=' '; + a[ax][ay]='M'; + x=ax; + y=ay; + } + } + system("cls"); + for(int k=0;k<9;k++) + printf("%s\n",a[k]); + std::cout<<"congratulations!you win"; + Sleep(1000); + system("pause"); + return 0; + } diff --git a/maze.exe b/maze.exe new file mode 100644 index 00000000..cd4686a1 Binary files /dev/null and b/maze.exe differ diff --git a/node.cpp b/node.cpp new file mode 100644 index 00000000..8d6df1de --- /dev/null +++ b/node.cpp @@ -0,0 +1,100 @@ + #include + using namespace std; + #include + /* run this program using the console pauser or add your own getch, system("pause") or input loop */ + struct node + { + int data; + int position; + int book; + struct node *next; + }; + + int find_five(struct node *head1) + { + struct node *t1=head1; + while(t1!=NULL) + { + if(t1->data==5 && t1->book==0) + { + t1->book = 1; + return t1->position; + } + t1=t1->next; + } + return -1; + } + int main() + { + struct node *head,*head_new,*p,*m,*q,*t,*t1,*t2,*t3; + //עheadǿָ + head=NULL; + int a,n,mi; + cout<<"n is:"; + cin>>n; + cout<<"please input "<>a; + q=(struct node *)malloc(sizeof(struct node)); + q->book=0; + q->position=0; + q->data=a; + q->next=NULL; + if(NULL==head) + head=q; + else + p->next=q; + p=q; + } + + t=head; + cout<<"in order:"; + while(NULL!=t) + { + printf(" %d ",t->data); + t=t->next; + } + printf("\n"); + t1=head; + t2=t1->next; + while(NULL!=t2) + { + t3=t2->next; + t2->next=t1; + t1=t2; + t2=t3; + } + head->next=NULL; + head_new=t1; + t=head_new; + cout<<"out of order:"; + while(t!=NULL) + { + printf(" %d ",t->data); + t=t->next; + } + t=head_new; + + for(int i=1;i<=n;i++) + { + t->position=i; + t=t->next; + } + t=head_new; + for(int i=0;i<=1;i++) + { + mi=find_five(t); + goto mn; + } + mn: + { + if(mi!=-1) + cout< +#include +int main() +{ + int f; + for(f=0;f<=140;f++) + { + if(f/6+f/12+f/7+5+f/2+4==f && f%84==0) + printf("%d\n",f-4); + } + system("pause"); + return 0; +} diff --git "a/\345\210\244\346\226\255\344\270\200\344\270\252\346\225\260\346\230\257\344\270\215\346\230\257\347\264\240\346\225\260 (2).c" "b/\345\210\244\346\226\255\344\270\200\344\270\252\346\225\260\346\230\257\344\270\215\346\230\257\347\264\240\346\225\260 (2).c" new file mode 100644 index 00000000..e2fee483 --- /dev/null +++ "b/\345\210\244\346\226\255\344\270\200\344\270\252\346\225\260\346\230\257\344\270\215\346\230\257\347\264\240\346\225\260 (2).c" @@ -0,0 +1,29 @@ +#include +#include +int main() +{ + int n,t=0,i,m; + printf("n:"); + scanf("%d",&n); + + + for(i=2;i<=n/2;i++) + { + t=0; + m=n%i; + if(m==0) + { + printf("%d",n); + t=1; + break; + } + } + + if(t==0) + { + printf("%d",n); + } + + system("pause"); + return 0; +} diff --git "a/\345\223\245\345\276\267\345\267\264\350\265\253\347\214\234\346\203\263\351\252\214\350\257\201.cpp" "b/\345\223\245\345\276\267\345\267\264\350\265\253\347\214\234\346\203\263\351\252\214\350\257\201.cpp" new file mode 100644 index 00000000..9cce7cc9 --- /dev/null +++ "b/\345\223\245\345\276\267\345\267\264\350\265\253\347\214\234\346\203\263\351\252\214\350\257\201.cpp" @@ -0,0 +1,62 @@ +#include + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + + +#include +#include +#include +int mx(int c) + { + int i,m,t; + t=0; + for(i=2;i<=c/2;i++) + { + + m=c%i; + if(m==0) + { + return -1; + } + } + + + return c; + + } + +int main() +{ + int i,j,m,a,b,c,k,s=0; + for(i=4;i<=100;i+=2) + { + k=0; + for(j=2;j<=i/2;j++) + { + a=mx(j); + if(a!=j) + { + continue; + } + else + { + b=i-a; + c=mx(b); + } + if(c==b) + { + k=1; + printf("%d =%d + %d\t",i,a,b); + } + } + s=s+k; + } + if(s==(100-4)/2+1) + { + printf("\n\n"); + printf("°ͺղȷ"); + Sleep(2000); + } + system("pause"); +return 0; +} diff --git "a/\345\245\224\350\267\221\347\232\204\345\255\227\346\257\215.c" "b/\345\245\224\350\267\221\347\232\204\345\255\227\346\257\215.c" new file mode 100644 index 00000000..d7fb9946 --- /dev/null +++ "b/\345\245\224\350\267\221\347\232\204\345\255\227\346\257\215.c" @@ -0,0 +1,35 @@ +#include +#include +#include +int main() +{int i,j; +system("mode con cols=70"); + for(i=0;i<=70;i++) + { + system("cls"); + for(j=0;j=0;i--) + { + system("cls"); + for(j=0;j>a; + queue.append(a); + cout<<"if you have finished,please enter e"; + if('e'==getch()) + { + break; + } //Ҫ + } + while(!is_empty) + { + queue.pop(); + } + + + return 0; +} diff --git "a/\346\234\252\345\221\275\345\220\2151.exe" "b/\346\234\252\345\221\275\345\220\2151.exe" new file mode 100644 index 00000000..1b17fd5c Binary files /dev/null and "b/\346\234\252\345\221\275\345\220\2151.exe" differ diff --git "a/\346\260\264\344\273\231\350\212\261\346\225\260.c" "b/\346\260\264\344\273\231\350\212\261\346\225\260.c" new file mode 100644 index 00000000..527e4081 --- /dev/null +++ "b/\346\260\264\344\273\231\350\212\261\346\225\260.c" @@ -0,0 +1,15 @@ +#include +#include +int main() +{ + int i; + for(i=100;i<=999;i++) + { + if((i%10)*(i%10)*(i%10)+(i/100)*(i/100)*(i/100) + +((i/10)%10)*((i/10)%10)*((i/10)%10) == 100*(i/100)+ + 10*((i/10)%10)+i%10) + printf("%d\t",i); + } + system("pause"); + return 0; +} diff --git "a/\346\260\264\344\273\231\350\212\261\346\225\260.exe" "b/\346\260\264\344\273\231\350\212\261\346\225\260.exe" new file mode 100644 index 00000000..3a096226 Binary files /dev/null and "b/\346\260\264\344\273\231\350\212\261\346\225\260.exe" differ diff --git "a/\350\276\223\345\207\272100\344\273\245\345\206\205\347\232\204\346\211\200\346\234\211\347\264\240\346\225\260.c" "b/\350\276\223\345\207\272100\344\273\245\345\206\205\347\232\204\346\211\200\346\234\211\347\264\240\346\225\260.c" new file mode 100644 index 00000000..e273ecf7 --- /dev/null +++ "b/\350\276\223\345\207\272100\344\273\245\345\206\205\347\232\204\346\211\200\346\234\211\347\264\240\346\225\260.c" @@ -0,0 +1,32 @@ + +#include +#include +int mx(int c) + { + int i,m,t; + t=0; + for(i=2;i<=c/2;i++) + { + + m=c%i; + if(m==0) + { + return -1; + } + } + return c; + } + int main() + { + + int i,m; + for(i=2;i<=100;i++) + { + m=mx(i); + if(m!=-1) + printf("%d\t",i); + } + + system("pause"); + return 0; +}