Magic_Game/Demo/main.cpp

109 lines
3.1 KiB
C++
Raw Normal View History

2017-10-13 11:42:36 +08:00
#include "..\Easy2D\easy2d.h"
2017-12-11 18:17:24 +08:00
#include <iostream>
2017-10-13 11:42:36 +08:00
2017-10-14 01:07:34 +08:00
int WINAPI WinMain(
2017-12-08 19:50:59 +08:00
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
2017-10-14 01:07:34 +08:00
int nCmdShow
)
2017-10-13 11:42:36 +08:00
{
2017-12-11 18:17:24 +08:00
if (!EApp::init(L"Demo", 250, 150))
2017-12-08 19:50:59 +08:00
return -1;
2017-10-13 11:42:36 +08:00
2017-12-11 18:17:24 +08:00
EString str;
str += L"123";
str += L"4";
UINT h1 = str.hash();
2017-12-11 22:41:53 +08:00
EString string;
string = string + L"Hello" + 2017 + L"!";
string.append(L"Hello").append(2017).append(L"!");
2017-12-11 18:17:24 +08:00
EString str2;
str2 += 1;
str2 += 2L;
str2 += 2.3;
str2 += 4.6f;
UINT h2 = str2.hash();
str2 += std::wstring(L"sdf");
EString str3;
str3 += str2 + str;
UINT h3 = str3.hash();
2017-12-08 19:50:59 +08:00
auto scene = new EScene();
2017-12-11 18:17:24 +08:00
EApp::enterScene(scene);
for (int i = 0; i < 25; i++)
{
auto sprite = new ESprite(L"test.png");
sprite->setScale(0.5f);
sprite->setPos(ERandom::between(0, EApp::getWidth()), ERandom::between(0, EApp::getHeight()));
scene->add(sprite);
}
//auto scene = new EScene();
//scene->retain();
//auto text = new EText(L"<22><><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>", L"<22><><EFBFBD><EFBFBD>");
//text->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
////text->setWordWrapping(true);
////text->setWordWrappingWidth(130);
//text->setRotation(40);
//text->runAction(new EActionLoop(new EActionTwo(new EActionFadeOut(1), new EActionFadeIn(1))));
//scene->add(text);
//auto listener = new EListenerKeyboardPress([=]() {
// if (EKeyboardMsg::getKeyValue() == EKeyboardMsg::KEY::SPACE)
// {
// EApp::backScene(new ETransitionMove(0.5f, ETransitionMove::DOWN));
// }
//});
//listener->bindWith(scene);
//auto scene2 = new EScene();
//auto bird = new ESprite(L"atlas.png", 5, 982, 34, 24);
//auto animation = new EAnimation();
//animation->addFrame(new ESpriteFrame(L"atlas.png", 5, 982, 34, 24));
//animation->addFrame(new ESpriteFrame(L"atlas.png", 61, 982, 34, 24));
//animation->addFrame(new ESpriteFrame(L"atlas.png", 117, 982, 34, 24));
//animation->addFrame(new ESpriteFrame(L"atlas.png", 61, 982, 34, 24));
//bird->runAction(new EActionLoop(animation));
//bird->setPivot(0.5f, 0.5f);
//bird->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
//scene2->add(bird);
//auto btnStart = new ESprite(L"atlas.png", 702, 234, 116, 70);
//auto btnStartSelected = new ESprite(L"atlas.png", 702, 234, 116, 70);
//btnStartSelected->setPosY(5);
//auto button = new EButton(btnStart, btnStartSelected, [=] {
// /*if (EApp::isPaused())
// {
// EApp::resume();
// }
// else
// {
// EApp::pause();
// }*/
// EApp::enterScene(scene, new ETransitionMove(1, ETransitionMove::RIGHT));
//});
//button->setPivot(0.5f, 0.5f);
//button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2 + 100);
//scene2->add(button);
//EMusicUtils::playMusic(L"music.wav", -1);
///*scene2->runAction(new EActionSequence(5,
// new EActionCallback([]() { EMusicUtils::playMusic(L"music.wav", -1); }),
// new EActionDelay(3),
// new EActionCallback([]() { EMusicUtils::pauseMusic(L"music.wav"); }),
// new EActionDelay(10),
// new EActionCallback([]() { EMusicUtils::resumeMusic(L"music.wav"); })));*/
//EApp::enterScene(scene2, new ETransitionMove(1, ETransitionMove::UP));
2017-12-08 19:50:59 +08:00
return EApp::run();
2017-10-13 11:42:36 +08:00
}