Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
6e18d9cfe4 | |||
f9fa215051 |
@ -53,50 +53,50 @@ private:
|
|||||||
if(state&0x2&&!internal_panelState[UP-UP][0].bPressed){
|
if(state&0x2&&!internal_panelState[UP-UP][0].bPressed){
|
||||||
internal_panelState[UP-UP][0]={true,false,true};
|
internal_panelState[UP-UP][0]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x2)&&!internal_panelState[UP-UP][0].bReleased){
|
if(!(state&0x2)&&internal_panelState[UP-UP][0].bHeld){
|
||||||
internal_panelState[UP-UP][0]={false,true,false};
|
internal_panelState[UP-UP][0]={false,true,false};
|
||||||
}
|
}
|
||||||
if(state&0x20&&!internal_panelState[RIGHT-UP][0].bPressed){
|
if(state&0x20&&!internal_panelState[RIGHT-UP][0].bPressed){
|
||||||
internal_panelState[RIGHT-UP][0]={true,false,true};
|
internal_panelState[RIGHT-UP][0]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x20)&&!internal_panelState[RIGHT-UP][0].bReleased){
|
if(!(state&0x20)&&internal_panelState[RIGHT-UP][0].bHeld){
|
||||||
internal_panelState[RIGHT-UP][0]={false,true,false};
|
internal_panelState[RIGHT-UP][0]={false,true,false};
|
||||||
}
|
}
|
||||||
if(state&0x80&&!internal_panelState[DOWN-UP][0].bPressed){
|
if(state&0x80&&!internal_panelState[DOWN-UP][0].bPressed){
|
||||||
internal_panelState[DOWN-UP][0]={true,false,true};
|
internal_panelState[DOWN-UP][0]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x80)&&!internal_panelState[DOWN-UP][0].bReleased){
|
if(!(state&0x80)&&internal_panelState[DOWN-UP][0].bHeld){
|
||||||
internal_panelState[DOWN-UP][0]={false,true,false};
|
internal_panelState[DOWN-UP][0]={false,true,false};
|
||||||
}
|
}
|
||||||
if(state&0x8&&!internal_panelState[LEFT-UP][0].bPressed){
|
if(state&0x8&&!internal_panelState[LEFT-UP][0].bPressed){
|
||||||
internal_panelState[LEFT-UP][0]={true,false,true};
|
internal_panelState[LEFT-UP][0]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x8)&&!internal_panelState[LEFT-UP][0].bReleased){
|
if(!(state&0x8)&&internal_panelState[LEFT-UP][0].bHeld){
|
||||||
internal_panelState[LEFT-UP][0]={false,true,false};
|
internal_panelState[LEFT-UP][0]={false,true,false};
|
||||||
}
|
}
|
||||||
state=SMX_GetInputState(1);
|
state=SMX_GetInputState(1);
|
||||||
if(state&0x2&&!internal_panelState[UP-UP][1].bPressed){
|
if(state&0x2&&!internal_panelState[UP-UP][1].bPressed){
|
||||||
internal_panelState[UP-UP][1]={true,false,true};
|
internal_panelState[UP-UP][1]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x2)&&!internal_panelState[UP-UP][1].bReleased){
|
if(!(state&0x2)&&internal_panelState[UP-UP][1].bHeld){
|
||||||
internal_panelState[UP-UP][1]={false,true,false};
|
internal_panelState[UP-UP][1]={false,true,false};
|
||||||
}
|
}
|
||||||
if(state&0x20&&!internal_panelState[RIGHT-UP][1].bPressed){
|
if(state&0x20&&!internal_panelState[RIGHT-UP][1].bPressed){
|
||||||
internal_panelState[RIGHT-UP][1]={true,false,true};
|
internal_panelState[RIGHT-UP][1]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x20)&&!internal_panelState[RIGHT-UP][1].bReleased){
|
if(!(state&0x20)&&internal_panelState[RIGHT-UP][1].bHeld){
|
||||||
internal_panelState[RIGHT-UP][1]={false,true,false};
|
internal_panelState[RIGHT-UP][1]={false,true,false};
|
||||||
}
|
}
|
||||||
if(state&0x80&&!internal_panelState[DOWN-UP][1].bPressed){
|
if(state&0x80&&!internal_panelState[DOWN-UP][1].bPressed){
|
||||||
internal_panelState[DOWN-UP][1]={true,false,true};
|
internal_panelState[DOWN-UP][1]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x80)&&!internal_panelState[DOWN-UP][1].bReleased){
|
if(!(state&0x80)&&internal_panelState[DOWN-UP][1].bHeld){
|
||||||
internal_panelState[DOWN-UP][1]={false,true,false};
|
internal_panelState[DOWN-UP][1]={false,true,false};
|
||||||
}
|
}
|
||||||
if(state&0x8&&!internal_panelState[LEFT-UP][1].bPressed){
|
if(state&0x8&&!internal_panelState[LEFT-UP][1].bPressed){
|
||||||
internal_panelState[LEFT-UP][1]={true,false,true};
|
internal_panelState[LEFT-UP][1]={true,false,true};
|
||||||
}else
|
}else
|
||||||
if(!(state&0x8)&&!internal_panelState[LEFT-UP][1].bReleased){
|
if(!(state&0x8)&&internal_panelState[LEFT-UP][1].bHeld){
|
||||||
internal_panelState[LEFT-UP][1]={false,true,false};
|
internal_panelState[LEFT-UP][1]={false,true,false};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,56 +12,32 @@ class SMX_PGE : public olc::PixelGameEngine
|
|||||||
public:
|
public:
|
||||||
SMX_PGE()
|
SMX_PGE()
|
||||||
{
|
{
|
||||||
sAppName = "SMX PGE";
|
sAppName = "SMX PGE - Bad Apple";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Renderable>video;
|
||||||
|
int currentFrame{0};
|
||||||
|
double elapsedTime{0.f};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool OnUserCreate() override
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
// Called once at the start, so create things here
|
// Called once at the start, so create things here
|
||||||
|
const std::string badAppleVideoDir{"badapple"};
|
||||||
|
for(int frame=1;frame<=6572;frame++){
|
||||||
|
video.emplace_back();
|
||||||
|
video[frame-1].Load(std::format("{}/frame{}.png",badAppleVideoDir,frame));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
{
|
{
|
||||||
smx.GetPanel(RIGHT, 0).bHeld;
|
Clear(BLACK);
|
||||||
if (GetKey(RIGHT).bPressed) {
|
elapsedTime+=fElapsedTime;
|
||||||
mode = (mode + 1) % 3;
|
const int frame{int(std::clamp((elapsedTime-5)/(1/30.f),1.,6573.))};
|
||||||
}
|
DrawSprite({},video[frame-1].Sprite());
|
||||||
switch (mode) {
|
|
||||||
case 0: {
|
|
||||||
if (GetKey(SPACE).bPressed) {
|
|
||||||
paused = !paused;
|
|
||||||
}
|
|
||||||
// called once per frame
|
|
||||||
if (!paused) {
|
|
||||||
for (int x = 0; x < ScreenWidth(); x++)
|
|
||||||
for (int y = 0; y < ScreenHeight(); y++)
|
|
||||||
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand() % 255));
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
case 1: {
|
|
||||||
Clear(DARK_CYAN);
|
|
||||||
DrawRect({ 1,1 }, { 9,18 }, RED);
|
|
||||||
}break;
|
|
||||||
case 2: {
|
|
||||||
Clear(VERY_DARK_BLUE);
|
|
||||||
FillCircle(playerPos, 3,VERY_DARK_GREY);
|
|
||||||
DrawCircle(playerPos, 3);
|
|
||||||
if (GetKey(W).bHeld) {
|
|
||||||
playerPos.y -= 5*fElapsedTime;
|
|
||||||
}
|
|
||||||
if (GetKey(A).bHeld) {
|
|
||||||
playerPos.x -= 5 * fElapsedTime;
|
|
||||||
}
|
|
||||||
if (GetKey(S).bHeld) {
|
|
||||||
playerPos.y += 5 * fElapsedTime;
|
|
||||||
}
|
|
||||||
if (GetKey(D).bHeld) {
|
|
||||||
playerPos.x += 5 * fElapsedTime;
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -70,7 +46,7 @@ public:
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
SMX_PGE demo;
|
SMX_PGE demo;
|
||||||
if (demo.Construct(12, 21, 50, 50))
|
if (demo.Construct(24, 21, 50, 50,false,true))
|
||||||
demo.Start();
|
demo.Start();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -81,7 +81,7 @@
|
|||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user