Skip to content

Commit

Permalink
v2.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomango committed Oct 23, 2022
1 parent 7b821d5 commit 59373c5
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 87 deletions.
10 changes: 5 additions & 5 deletions PushBox/Buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static DrawingStyle buttonDisabledStyle = DrawingStyle(Color::LightGray);
MyTextButton::MyTextButton(const String& text, Function<void()> callback)
{
this->setText(text);
this->setFont(Font(L"新宋体", 28, Font::Weight::Bold));
this->setFont(Font("新宋体", 28, Font::Weight::Bold));
this->setDrawingStyle(buttonNormalStyle);

// 添加按钮监听器
Expand Down Expand Up @@ -46,7 +46,7 @@ void MyTextButton::setEnable(bool enable)

SoundButton::SoundButton()
{
static auto sound = L"res/background.wav";
static auto sound = "res/background.wav";

lis = gcnew ToggleButtonListener(g_SoundOpen, [=](ButtonEvent evt, bool state) {
if (evt == ButtonEvent::Clicked) {
Expand All @@ -63,7 +63,7 @@ SoundButton::SoundButton()
g_SoundOpen = state;
this->setState(state);
// 保存信息到文件
Data::saveBool(L"sound", g_SoundOpen);
Data::saveBool("sound", g_SoundOpen);
}
});
this->addListener(lis);
Expand All @@ -78,7 +78,7 @@ void SoundButton::updateStatus()

void SoundButton::setState(bool state)
{
static auto soundon = L"res/soundon.png";
static auto soundoff = L"res/soundoff.png";
static auto soundon = "res/soundon.png";
static auto soundoff = "res/soundoff.png";
this->open(state ? soundon : soundoff);
}
58 changes: 29 additions & 29 deletions PushBox/PlayScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
PlayScene::PlayScene(int level)
{
// 创建字体
auto font = Font(L"新宋体", 28, Font::Weight::Bold);
auto font2 = Font(L"新宋体", 20, Font::Weight::Bold);
auto font = Font("新宋体", 28, Font::Weight::Bold);
auto font2 = Font("新宋体", 20, Font::Weight::Bold);

// 当前关卡文字
levelText = gcnew Text(L"", font);
levelText = gcnew Text("", font);
levelText->setPos(520, 30);
this->addChild(levelText);

// 当前步数文字
stepText = gcnew Text(L"", font2);
stepText = gcnew Text("", font2);
stepText->setPos(520, 100);
this->addChild(stepText);

// 最佳步数文字
bestText = gcnew Text(L"", font2);
bestText = gcnew Text("", font2);
bestText->setPos(520, 140);
this->addChild(bestText);

// 按 ESC 退出提示文字
auto exitText = gcnew Text(L"按ESC返回", font2);
auto exitText = gcnew Text("按ESC返回", font2);
exitText->setPos(520, 250);
this->addChild(exitText);

// 按回车重新开始提示文字
auto restartText = gcnew Text(L"按回车重开", font2);
auto restartText = gcnew Text("按回车重开", font2);
restartText->setPos(520, 290);
this->addChild(restartText);

Expand Down Expand Up @@ -121,27 +121,27 @@ void PlayScene::Flush()
// 1.墙
if (piece.type == TYPE::Wall)
{
sprite->open(L"res/wall.gif");
sprite->open("res/wall.gif");
}
// 2.得分点处的地面
else if (piece.type == TYPE::Ground && piece.isPoint)
{
sprite->open(L"res/point.gif");
sprite->open("res/point.gif");
}
// 3.普通地面
else if (piece.type == TYPE::Ground)
{
sprite->open(L"res/floor.gif");
sprite->open("res/floor.gif");
}
// 4.得分点处的箱子
else if (piece.type == TYPE::Box && piece.isPoint)
{
sprite->open(L"res/boxinpoint.gif");
sprite->open("res/boxinpoint.gif");
}
// 5.普通箱子
else if (piece.type == TYPE::Box)
{
sprite->open(L"res/box.gif");
sprite->open("res/box.gif");
}
// 6.正在推箱子的角色
else if (piece.type == TYPE::Man && g_Pushing)
Expand All @@ -150,16 +150,16 @@ void PlayScene::Flush()
switch (g_Direct)
{
case 1:
sprite->open(L"res/manhandup.gif");
sprite->open("res/manhandup.gif");
break;
case 2:
sprite->open(L"res/manhanddown.gif");
sprite->open("res/manhanddown.gif");
break;
case 3:
sprite->open(L"res/manhandleft.gif");
sprite->open("res/manhandleft.gif");
break;
case 4:
sprite->open(L"res/manhandright.gif");
sprite->open("res/manhandright.gif");
break;
}
}
Expand All @@ -169,16 +169,16 @@ void PlayScene::Flush()
switch (g_Direct)
{
case 1:
sprite->open(L"res/manup.gif");
sprite->open("res/manup.gif");
break;
case 2:
sprite->open(L"res/mandown.gif");
sprite->open("res/mandown.gif");
break;
case 3:
sprite->open(L"res/manleft.gif");
sprite->open("res/manleft.gif");
break;
case 4:
sprite->open(L"res/manright.gif");
sprite->open("res/manright.gif");
break;
}
}
Expand All @@ -200,22 +200,22 @@ void PlayScene::SetLevel(int level)
// 保存关卡等级
::g_CurrentLevel = level;
// 保存关卡信息到文件
Data::saveInt(L"level", ::g_CurrentLevel);
Data::saveInt("level", ::g_CurrentLevel);
// 修改关卡信息文字
levelText->setText(L"" + std::to_wstring(level) + L"");
levelText->setText("" + std::to_string(level) + "");

// 重置步数
SetStep(0);
// 获取最佳步数
String strLevel = L"level" + std::to_wstring(level);
String strLevel = "level" + std::to_string(level);
int bestStep = Data::getInt(strLevel, 0);
if (bestStep != 0)
{
bestText->setText(L"最佳" + std::to_wstring(bestStep) + L"");
bestText->setText("最佳" + std::to_string(bestStep) + "");
}
else
{
bestText->setText(L"");
bestText->setText("");
}

// 获取关卡地图信息
Expand Down Expand Up @@ -251,7 +251,7 @@ void PlayScene::Move(int x, int y, int direct)
map.value[map.roleY][map.roleX].type = TYPE::Ground;
map.value[y][x].type = TYPE::Man;
// 播放音效
if (::g_SoundOpen) MusicPlayer::play(L"res/manmove.wav");
if (::g_SoundOpen) MusicPlayer::play("res/manmove.wav");
}
// 3.前面是箱子
else if (map.value[y][x].type == TYPE::Box)
Expand Down Expand Up @@ -289,7 +289,7 @@ void PlayScene::Move(int x, int y, int direct)
map.value[y][x].type = TYPE::Man;
map.value[map.roleY][map.roleX].type = TYPE::Ground;
// 播放音效
if (::g_SoundOpen) MusicPlayer::play(L"res/boxmove.wav");
if (::g_SoundOpen) MusicPlayer::play("res/boxmove.wav");
}
// 重新保存角色位置
map.roleX = x;
Expand All @@ -303,13 +303,13 @@ void PlayScene::SetStep(int step)
// 保存步数
this->step = step;
// 修改步数文字
stepText->setText(L"当前" + std::to_wstring(step) + L"");
stepText->setText("当前" + std::to_string(step) + "");
}

void PlayScene::GameOver()
{
// 获取最佳步数
String strLevel = L"level" + std::to_wstring(g_CurrentLevel);
String strLevel = "level" + std::to_string(g_CurrentLevel);
int bestStep = Data::getInt(strLevel, 0);
// 重新保存最佳步数
if (bestStep == 0 || step < bestStep)
Expand Down
44 changes: 8 additions & 36 deletions PushBox/PushBox.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,24 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '17.0'">v143</PlatformToolset>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '17.0'">v143</PlatformToolset>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '17.0'">v143</PlatformToolset>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '17.0'">v143</PlatformToolset>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -107,7 +79,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand All @@ -119,7 +91,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand All @@ -133,7 +105,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand All @@ -149,7 +121,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand Down
8 changes: 4 additions & 4 deletions PushBox/StartScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
StartScene::StartScene()
{
// 添加背景图
auto background = gcnew Sprite(L"res/start.jpg");
auto background = gcnew Sprite("res/start.jpg");
this->addChild(background);

// 修改节点默认中心点位置
Node::setDefaultAnchor(0.5, 0.5);

// 创建开始游戏按钮
auto startBtn = gcnew MyTextButton(L"新游戏", [=]() {
auto startBtn = gcnew MyTextButton("新游戏", [=]() {
this->Start();
});
// 设置按钮位置
startBtn->setPos(Window::getWidth() / 2, 260);
this->addChild(startBtn);

// 继续游戏按钮
resumeBtn = gcnew MyTextButton(L"继续关卡", [=]() {
resumeBtn = gcnew MyTextButton("继续关卡", [=]() {
this->Continue();
});
// 设置按钮位置
Expand All @@ -33,7 +33,7 @@ StartScene::StartScene()
this->addChild(resumeBtn);

// 创建退出按钮
auto exitBtn = gcnew MyTextButton(L"退出", [=]() {
auto exitBtn = gcnew MyTextButton("退出", [=]() {
this->Exit();
});
// 设置按钮位置
Expand Down
6 changes: 3 additions & 3 deletions PushBox/SuccessScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
SuccessScene::SuccessScene()
{
// 背景图片
auto background = gcnew Sprite(L"res/success.jpg");
auto background = gcnew Sprite("res/success.jpg");
this->addChild(background);

// 回主菜单按钮
auto backBtn = gcnew Button();
backBtn->setNormal(gcnew Text(L"回主菜单", Font(L"新宋体", 28, Font::Weight::Bold), DrawingStyle(Color::Black)));
backBtn->setMouseOver(gcnew Text(L"回主菜单", Font(L"新宋体", 28, Font::Weight::Bold), DrawingStyle(Color::Blue)));
backBtn->setNormal(gcnew Text("回主菜单", Font("新宋体", 28, Font::Weight::Bold), DrawingStyle(Color::Black)));
backBtn->setMouseOver(gcnew Text("回主菜单", Font("新宋体", 28, Font::Weight::Bold), DrawingStyle(Color::Blue)));
backBtn->setPos(255, 350);
// 设置回调函数
backBtn->setClickFunc([]()
Expand Down
Binary file modified PushBox/logo.ico
Binary file not shown.
Loading

0 comments on commit 59373c5

Please sign in to comment.