-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from Moros1138/example-dropdown
Example dropdown
- Loading branch information
Showing
26 changed files
with
690 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
cacheDirectory=".phpunit.cache" | ||
backupStaticProperties="false"> | ||
<testsuites> | ||
<testsuite name="Browser Test Suite"> | ||
<directory suffix="Test.php">./tests/Browser</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#define OLC_PGE_APPLICATION | ||
#include "olcPixelGameEngine.h" | ||
|
||
#if defined(__EMSCRIPTEN__) | ||
#include <emscripten.h> | ||
#endif | ||
|
||
// EMSCRIPTEN ONLY! | ||
// | ||
// At runtime, this function attempts to load a file | ||
// from the provided URL, and maps it to emscripten's | ||
// filesystem. You can then use the file in any C/C++ | ||
// filesystem function as if it were on the local disk. | ||
void FILE_RESOLVE(const char* url, const char* file) | ||
{ | ||
#if defined(__EMSCRIPTEN__) | ||
emscripten_wget(url, file); | ||
emscripten_sleep(0); | ||
#endif | ||
} | ||
|
||
// Override base class with your custom functionality | ||
class Example : public olc::PixelGameEngine | ||
{ | ||
public: | ||
Example() | ||
{ | ||
// Name your application | ||
sAppName = "PGEtinker Classic Example"; | ||
} | ||
|
||
public: | ||
|
||
// OnUserCreate is Called once at the start and | ||
// is where you do things like load files and | ||
// initilize variables. | ||
bool OnUserCreate() override | ||
{ | ||
// load "assets/gfx/broken.png" from a URL | ||
FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); | ||
|
||
renImageFromUrl.Load("assets/gfx/broken.png"); | ||
|
||
color = RandomColor(); | ||
return true; | ||
} | ||
|
||
// OnUserUpdate is called once per frame and | ||
// is where you draw things to the screen | ||
bool OnUserUpdate(float fElapsedTime) override | ||
{ | ||
// when you left click the mouse | ||
if(GetMouse(0).bPressed) | ||
{ | ||
// change the color | ||
color = RandomColor(); | ||
|
||
// print out the current mouse position (x, y) | ||
std::cout << GetMousePos() << "\n"; | ||
} | ||
|
||
// clear the screen to the provided color | ||
Clear(color); | ||
|
||
// Draw the yellow outline | ||
DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); | ||
|
||
// draw some test | ||
DrawStringDropShadow(5, 5, "Hello, PGE", olc::WHITE, olc::BLACK); | ||
DrawStringDropShadow(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE, olc::BLACK); | ||
DrawStringDropShadow(5, 220, GetMousePos().str(), olc::WHITE, olc::BLACK); | ||
|
||
// draw the loaded sprite | ||
DrawSprite(5, 100, renImageFromUrl.Sprite()); | ||
|
||
// draw a circle where the mouse is currently located | ||
FillCircle(GetMousePos(), 3, olc::RED); | ||
|
||
// draw a point where the mouse is currently located | ||
Draw(GetMousePos(), olc::WHITE); | ||
|
||
return true; | ||
} | ||
|
||
void DrawStringDropShadow(const int x, const int y, const std::string& text, const olc::Pixel& foregroundColor, const olc::Pixel& backgroundColor) | ||
{ | ||
DrawString(x + 1, y + 1, text, backgroundColor); | ||
DrawString( x, y, text, foregroundColor); | ||
} | ||
|
||
olc::Pixel RandomColor() | ||
{ | ||
// we limit to the darker half of the colors | ||
return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); | ||
} | ||
|
||
public: // class variables | ||
|
||
// this is the color that is changed every mouse click | ||
olc::Pixel color; | ||
|
||
// this is the sprite that is loaded from a URL | ||
olc::Renderable renImageFromUrl; | ||
}; | ||
|
||
int main() | ||
{ | ||
// an instance of the Example, called demo | ||
Example demo; | ||
|
||
// attempt to construct the window/screen 256x240 pixels, | ||
// with pixels that are 2x2. If successful, start | ||
// the demo. | ||
if (demo.Construct(256, 240, 2, 2)) | ||
demo.Start(); | ||
|
||
// this is the end of the program | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#define OLC_PGE_APPLICATION | ||
#include "olcPixelGameEngine.h" | ||
|
||
#if defined(__EMSCRIPTEN__) | ||
#include <emscripten.h> | ||
#endif | ||
|
||
void FILE_RESOLVE(const char* url, const char* file) | ||
{ | ||
#if defined(__EMSCRIPTEN__) | ||
emscripten_wget(url, file); | ||
emscripten_sleep(0); | ||
#endif | ||
} | ||
|
||
// Override base class with your custom functionality | ||
class Example : public olc::PixelGameEngine | ||
{ | ||
public: | ||
Example() | ||
{ | ||
// Name your application | ||
sAppName = "Bare PGE"; | ||
} | ||
|
||
public: | ||
bool OnUserCreate() override | ||
{ | ||
// Called once at the start, so create things here | ||
return true; | ||
} | ||
|
||
bool OnUserUpdate(float fElapsedTime) override | ||
{ | ||
// Called once per frame, draws random coloured pixels | ||
return true; | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
Example demo; | ||
if (demo.Construct(256, 240, 2, 2)) | ||
demo.Start(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#define OLC_PGE_APPLICATION | ||
#include "olcPixelGameEngine.h" | ||
|
||
#if defined(__EMSCRIPTEN__) | ||
#include <emscripten.h> | ||
#endif | ||
|
||
void FILE_RESOLVE(const char* url, const char* file) | ||
{ | ||
#if defined(__EMSCRIPTEN__) | ||
emscripten_wget(url, file); | ||
emscripten_sleep(0); | ||
#endif | ||
} | ||
|
||
// Override base class with your custom functionality | ||
class Example : public olc::PixelGameEngine | ||
{ | ||
public: | ||
Example() | ||
{ | ||
// Name your application | ||
sAppName = "Example 4"; | ||
} | ||
|
||
public: | ||
bool OnUserCreate() override | ||
{ | ||
// Called once at the start, so create things here | ||
|
||
// built with emscripten, maps the url to the virtual filesystem and makes it | ||
// available to the standard C/C++ file i/o functions without change! | ||
// | ||
// built with any other native toolchain, the macro does nothing and all file | ||
// access is done just as it would in any other normal scenario. | ||
FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); | ||
|
||
renBroken.Load("assets/gfx/broken.png"); | ||
|
||
color = RandomColor(); | ||
return true; | ||
} | ||
|
||
bool OnUserUpdate(float fElapsedTime) override | ||
{ | ||
// Called once per frame, draws random coloured pixels | ||
if(GetMouse(0).bPressed) | ||
color = RandomColor(); | ||
|
||
Clear(color); | ||
DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); | ||
DrawString(6, 6, "Hello, PGE", olc::BLACK); | ||
DrawString(5, 5, "Hello, PGE", olc::WHITE); | ||
DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); | ||
DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); | ||
|
||
DrawSprite(5, 100, renBroken.Sprite()); | ||
|
||
DrawString(6, 221, GetMousePos().str(), olc::BLACK); | ||
DrawString(5, 220, GetMousePos().str(), olc::WHITE); | ||
FillCircle(GetMousePos(), 3, olc::RED); | ||
Draw(GetMousePos(), olc::WHITE); | ||
return true; | ||
} | ||
|
||
olc::Pixel RandomColor() | ||
{ | ||
return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); | ||
} | ||
|
||
olc::Pixel color; | ||
olc::Renderable renBroken; | ||
}; | ||
|
||
int main() | ||
{ | ||
Example demo; | ||
if (demo.Construct(256, 240, 2, 2)) | ||
demo.Start(); | ||
return 0; | ||
} |
Oops, something went wrong.