Skip to content

Commit

Permalink
Great update
Browse files Browse the repository at this point in the history
- Updated Lunaris
- Now it won't keep running in the background (sometimes) (sorry about that)
- Added resource into it + icon
  • Loading branch information
Lohkdesgds committed Nov 11, 2021
1 parent 1ffdde8 commit 5990d55
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 23 deletions.
79 changes: 79 additions & 0 deletions FlappyBlock/FlappyBlock.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Portuguese (Brazil) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PTB)
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN
#pragma code_page(1252)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "..\\Resource\\icon_src.ico"


/////////////////////////////////////////////////////////////////////////////
//
// PNG
//

IDB_PNG1 PNG "..\\Resource\\resource.png"

#endif // Portuguese (Brazil) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

17 changes: 15 additions & 2 deletions FlappyBlock/FlappyBlock.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)Lunaris\libs\Lunaris\x86</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -168,6 +169,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)Lunaris\libs\Lunaris\x86</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -185,7 +187,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)Lunaris\libs\x64;</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)Lunaris\libs\Lunaris\x64</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -207,7 +209,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)Lunaris\libs\x64;</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)Lunaris\libs\Lunaris\x64</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand All @@ -216,6 +218,17 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="FlappyBlock.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="..\Resource\icon_src.ico" />
<Image Include="..\Resource\resource.png" />
<Image Include="png1.png" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\AllegroDeps.1.12.0\build\native\AllegroDeps.targets" Condition="Exists('..\packages\AllegroDeps.1.12.0\build\native\AllegroDeps.targets')" />
Expand Down
33 changes: 31 additions & 2 deletions FlappyBlock/FlappyBlock.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="main.cpp" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Filter Include="CODE">
<UniqueIdentifier>{71613b71-d61b-406b-b17e-f1fd84895c2a}</UniqueIdentifier>
</Filter>
<Filter Include="RESOURCES">
<UniqueIdentifier>{0c65a4ed-de07-45dd-954e-0a3fc12f1dad}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>CODE</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>RESOURCES</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\Resource\resource.png">
<Filter>RESOURCES</Filter>
</Image>
<Image Include="png1.png" />
<Image Include="..\Resource\icon_src.ico">
<Filter>RESOURCES</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="FlappyBlock.rc">
<Filter>RESOURCES</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
51 changes: 33 additions & 18 deletions FlappyBlock/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <Lunaris/graphics.h>
#include <Lunaris/events.h>
#include <Lunaris/audio.h>
#include "resource.h"
#include <allegro5/allegro_native_dialog.h>

using namespace Lunaris;

Expand All @@ -14,18 +16,18 @@ constexpr float dist_shadow = 0.01f;
const color around_color = color(0,0,0);
const color bg_color = color(0.0f,0.0f,0.0f,0.6f);

#define myassert(X, ERRMSG) if (!X) { cout << console::color::RED << ERRMSG; lock_console(); }
#define myassert(X, ERRMSG) if (!X) { cout << console::color::RED << ERRMSG; lock_console(ERRMSG); }
#define logging(A, B) { cout << console::color::BLUE << "[" << A << "] " << B;}

void lock_console();
void lock_console(const std::string&);

int main()
{
logging("MAIN", "Starting...");

file fp;

auto main_texture = make_hybrid<texture>();
bool just_die = false;

hybrid_memory<texture> bird_textures[3] = { make_hybrid<texture>(),make_hybrid<texture>(),make_hybrid<texture>() };
hybrid_memory<texture> pipe_up_texture = make_hybrid<texture>();
Expand Down Expand Up @@ -69,31 +71,36 @@ int main()
.set_display_mode(display_options().set_width(576).set_height(1024))
), "Failed to create display!");

disp.set_icon_from_icon_resource(IDI_ICON1);


const auto speed_on_time_f = [&] {
return speed_accel_screen + static_cast<float>(cos(al_get_time())) * 0.001f;
};

myassert(fp.open_temp("flappy_block_XXXX.png", "wb+"), "Could not create temporary file!");
//myassert(fp.open("flappy_block_XXXX.png"), "Could not create temporary file!");
//
//logging("MAIN", "Downloading resources...");
//{
// downloader down;
// myassert(down.get_store(texture_url, [&](const char* buf, const size_t len) { fp.write(buf, len); }), "Could not download texture file!");
// myassert(fp.flush(), "Could not flush temporary file");
//}

logging("MAIN", "Downloading resources...");
{
downloader down;
myassert(down.get_store(texture_url, [&](const char* buf, const size_t len) { fp.write(buf, len); }), "Could not download texture file!");
myassert(fp.flush(), "Could not flush temporary file");
}
auto fp = make_hybrid_derived<file, memfile>(get_executable_resource_as_memfile(IDB_PNG1, (WinString)L"PNG"));
fp->flush();

logging("MAIN", "Loading texture...");
myassert(main_texture->load(fp.get_current_path()), "Failed to load texture");
myassert(main_texture->load(fp), "Failed to load texture");

*background_texture = main_texture->create_sub(0, 0, 144, 256);
*background_texture2 = main_texture->create_sub(146, 0, 144, 256);
*foreground_texture = main_texture->create_sub(292, 0, 168, 56);
*bird_textures[0] = main_texture->create_sub(3, 489, 17, 17);
*bird_textures[1] = main_texture->create_sub(31, 489, 17, 17);
*bird_textures[2] = main_texture->create_sub(59, 489, 17, 17);
*pipe_up_texture = main_texture->create_sub(56, 323, 26, 160); // up to down
*pipe_dw_texture = main_texture->create_sub(84, 323, 26, 160); // down to up
*pipe_up_texture = main_texture->create_sub(56, 323, 26, 160); // up to down
*pipe_dw_texture = main_texture->create_sub(84, 323, 26, 160); // down to up

myassert(main_font->create_builtin_font(), "Could not create font!");

Expand Down Expand Up @@ -123,7 +130,7 @@ int main()
camera.apply();
break;
case ALLEGRO_EVENT_DISPLAY_CLOSE:
disp.destroy();
just_die = true;
break;
default:
cout << console::color::AQUA << "EV: " << ev.type;
Expand Down Expand Up @@ -278,7 +285,7 @@ int main()
{
disp.toggle_flag(ALLEGRO_FULLSCREEN_WINDOW);
reapply_prop = true;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
break;
}
Expand Down Expand Up @@ -330,8 +337,10 @@ int main()
fps_counter.set<float>(enum_sprite_float_e::POS_X, -0.989f);
fps_counter.set<float>(enum_sprite_float_e::POS_Y, -0.989f);
fps_counter.set<float>(enum_sprite_float_e::SCALE_G, 0.06f);
fps_counter.set<float>(enum_sprite_float_e::SCALE_Y, 0.7f);
fps_counter.set<float>(enum_sprite_float_e::SCALE_Y, 1.2f);
fps_counter.set<float>(enum_sprite_float_e::THINK_ELASTIC_SPEED_PROP, 0.0f);
fps_counter.set<bool>(enum_sprite_boolean_e::DRAW_TRANSFORM_COORDS_KEEP_SCALE, true);
fps_counter.set<bool>(enum_sprite_boolean_e::DRAW_TRANSFORM_NO_EFFECT_ON_SCALE, true);
fps_counter.font_set(main_font);
for (auto& i : fourcorners) fps_counter.shadow_insert(i);

Expand Down Expand Up @@ -396,7 +405,7 @@ int main()
auto nowww = std::chrono::system_clock::now() + std::chrono::milliseconds(333);
size_t fps_var = 0;

while (!disp.empty())
while (!just_die)
{
if (reapply_prop) {
reapply_prop = false;
Expand Down Expand Up @@ -432,16 +441,22 @@ int main()
}
else ++fps_var;
}
disp.destroy();

logging("MAIN", "Closed the app.");
return 0;
}


void lock_console()
void lock_console(const std::string& err)
{
#ifdef _DEBUG
while (1) {
std::string str;
std::getline(std::cin, str);
}
#else
al_show_native_message_box(nullptr, "ERROR!", "There was an error!", err.c_str(), nullptr, ALLEGRO_MESSAGEBOX_ERROR);
std::terminate();
#endif
}
17 changes: 17 additions & 0 deletions FlappyBlock/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FlappyBlock.rc
//
#define IDI_ICON1 101
#define IDB_PNG1 102

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
2 changes: 1 addition & 1 deletion Lunaris
Binary file added Resource/icon_src.ico
Binary file not shown.
Binary file added Resource/icon_src.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resource/icon_src.psd
Binary file not shown.
Binary file added Resource/resource.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5990d55

Please sign in to comment.