Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Game.h"
- namespace GameDev2D//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- Game::Game()////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- { //VARIABLES
- g_Duration = 24.0f;
- g_Delay = 2.0f;
- g_Timer = 4.0f;
- //g_Swap=false; ask teacher bout this pls
- }
- Game::~Game()////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- }
- void Game::Update(double delta)///////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- //Variable
- double g_SwapTrack[4] = { 1, 0 , 1 , 0 };
- // DELTA / ASSIGNMENT
- g_Duration -= delta;
- //Resets g_Timer after each Rectangle and starts g_Delay
- if (g_Swap == false)
- {
- g_Delay -= delta;
- g_Timer = 4;
- }
- // Resets g_Delay and starts g_Timer
- if (g_Swap == true)
- {
- g_Timer -= delta;
- g_Delay = 2;
- }
- // SHOWS TIMER IN OUTPUT window
- Log::Message("%f", g_Duration);
- // Resets g_Swap
- for (int i = 0; i < 4; i++)
- {
- if (g_SwapTrack[i] == 1)
- {
- g_Swap = false;
- }
- }
- }
- void Game::Draw() // On is off off is on deal with it.////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- //Variable
- double g_lightoff[8] = { 1, .5, 1, .5 , 1 , .5 , 1, .5 };
- //variable
- double g_lightOn[5] = { .75f ,.75f,.75f ,.75f, .75f };
- //variable
- string g_Reload = ("Press R to reset");
- // RECTANGLE BASE
- DrawRectangle(0.0f, 0.0f, 384.0f, 384.0f, 0.0f, Color::CyanColor(g_lightOn[0]), true);
- DrawRectangle(384.0f, 0.0f, 384.0f, 384.0f, 0.0f, Color::BarnRedColor(g_lightOn[2]), true);
- DrawRectangle(384.0f, 384.0f, 384.0f, 384.0f, 0.0f, Color::RoyalYellowColor(g_lightOn[2]), true);
- DrawRectangle(0.0f, 384.0f, 384.0f, 384.0f, 0.0f, Color::ShamrockGreenColor(g_lightOn[3]), true);
- // MILLION IF STATEMENTS THAT TURN ON THE RECTANGLES
- if (g_Duration <= 0.1f)
- {
- DrawString(g_Reload, 295.0f, 500.0f, Color::GhostWhiteColor());
- }
- if (g_Duration <= 22.0f && g_Duration >= 18.0f) //blue
- {
- DrawRectangle(0.0f, 0.0f, 384.0f, 384.0f, 0.0f, Color::CyanColor(g_lightoff[0]), true);
- g_Swap = true;
- }
- if (g_Duration <= 16.0f && g_Duration >= 12.0f) //red
- {
- DrawRectangle(384.0f, 0.0f, 384.0f, 384.0f, 0.0f, Color::BarnRedColor(g_lightoff[2]), true);
- g_Swap = true;
- }
- if (g_Duration <= 10.0f && g_Duration >= 6.0f) // Ew
- {
- DrawRectangle(384.0f, 384.0f, 384.0f, 384.0f, 0.0f, Color::RoyalYellowColor(g_lightoff[4]), true);
- g_Swap = true;
- }
- if (g_Duration <= 4.0f && g_Duration >= 0) // Green
- {
- DrawRectangle(0.0f, 384.0f, 384.0f, 384.0f, 0.0f, Color::ShamrockGreenColor(g_lightoff[6]), true);
- g_Swap = true;
- }
- // STRING OUTPUTS
- //variable
- string output = to_string(g_Duration);
- string g2_Delay = to_string(g_Delay);
- string g2_Timer = to_string(g_Timer);
- string NameTag1 = ("Delay");
- string NameTag2 = ("Timer");
- DrawString(output, 355.0f, 380.0f, Color::EgyptianBlueColor());
- DrawString(g2_Delay, 150.0f, 100.0f, Color::EgyptianBlueColor());
- // Delay
- DrawString(NameTag1, 70.0f, 100.0f, Color::EgyptianBlueColor());
- DrawString(g2_Timer, 150.0f, 50.0f, Color::EgyptianBlueColor());
- // Timer
- DrawString(NameTag2, 70.0f, 50.0f, Color::EgyptianBlueColor());
- }
- void Game::HandleLeftMouseClick(float x, float y)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- }
- void Game::HandleRightMouseClick(float x, float y)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- }
- void Game::HandleKeyPress(Keyboard::Key key)////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- { //RESET FUNCTION
- if (IsKeyDown(Keyboard::R))
- {
- g_Duration = 24.0f;
- g_Delay = 2.0f;
- g_Timer = 4.0f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement