Mandelbrot explorer
This commit is contained in:
4
C++/Pixel-Engine/Rays/.gitignore
vendored
Normal file
4
C++/Pixel-Engine/Rays/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
CMakeFiles/
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
Makefile
|
||||
48
C++/Pixel-Engine/Rays/.vscode/settings.json
vendored
Normal file
48
C++/Pixel-Engine/Rays/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"chrono": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"fstream": "cpp",
|
||||
"functional": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"memory": "cpp",
|
||||
"new": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ratio": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -4,39 +4,32 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
Rect rect;
|
||||
bool isHoverd = false;
|
||||
|
||||
class RaysApp : public olc::PixelGameEngine {
|
||||
public:
|
||||
RaysApp() {
|
||||
RaysApp()
|
||||
: rect() {
|
||||
sAppName = "Rays";
|
||||
}
|
||||
|
||||
bool OnUserCreate() override {
|
||||
rect.SetRect(100, 100, 200, 100);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnUserUpdate(float fElapsedTime) override {
|
||||
Clear(olc::BLACK);
|
||||
if (!isHoverd) {
|
||||
DrawRect(rect.x, rect.y, rect.w, rect.h, olc::RED);
|
||||
} else {
|
||||
if (rect.Contains(new Vec2<int>(GetMouseX(), GetMouseY()))) {
|
||||
FillRect(rect.x, rect.y, rect.w, rect.h, olc::RED);
|
||||
} else {
|
||||
DrawRect(rect.x, rect.y, rect.w, rect.h, olc::RED);
|
||||
}
|
||||
|
||||
std::cout << "MouseX: " << GetMouseX() << " MouseY: " << GetMouseY() << std::endl;
|
||||
|
||||
if (rect.Contains(new Vec2<int>(GetMouseX(), GetMouseY()))) {
|
||||
isHoverd = true;
|
||||
} else {
|
||||
isHoverd = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Rect rect;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
@@ -569,24 +569,24 @@ namespace olc
|
||||
|
||||
//==========================================================
|
||||
|
||||
// std::wstring ConvertS2W(std::string s)
|
||||
// {
|
||||
// #ifdef _WIN32
|
||||
// int count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, NULL, 0);
|
||||
// wchar_t* buffer = new wchar_t[count];
|
||||
// MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, buffer, count);
|
||||
// std::wstring w(buffer);
|
||||
// delete[] buffer;
|
||||
// return w;
|
||||
// #endif
|
||||
// //#ifdef __MINGW32__
|
||||
// // wchar_t *buffer = new wchar_t[sImageFile.length() + 1];
|
||||
// // mbstowcs(buffer, sImageFile.c_str(), sImageFile.length());
|
||||
// // buffer[sImageFile.length()] = L'\0';
|
||||
// // wsImageFile = buffer;
|
||||
// // delete[] buffer;
|
||||
// //#else
|
||||
// }
|
||||
std::wstring ConvertS2W(std::string s)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, NULL, 0);
|
||||
wchar_t* buffer = new wchar_t[count];
|
||||
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, buffer, count);
|
||||
std::wstring w(buffer);
|
||||
delete[] buffer;
|
||||
return w;
|
||||
#endif
|
||||
//#ifdef __MINGW32__
|
||||
// wchar_t *buffer = new wchar_t[sImageFile.length() + 1];
|
||||
// mbstowcs(buffer, sImageFile.c_str(), sImageFile.length());
|
||||
// buffer[sImageFile.length()] = L'\0';
|
||||
// wsImageFile = buffer;
|
||||
// delete[] buffer;
|
||||
//#else
|
||||
}
|
||||
|
||||
Sprite::Sprite()
|
||||
{
|
||||
@@ -1273,6 +1273,7 @@ namespace olc
|
||||
|
||||
void PixelGameEngine::DrawRect(int32_t x, int32_t y, int32_t w, int32_t h, Pixel p)
|
||||
{
|
||||
w--; h--;
|
||||
DrawLine(x, y, x+w, y, p);
|
||||
DrawLine(x+w, y, x+w, y+h, p);
|
||||
DrawLine(x+w, y+h, x, y+h, p);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user