void Upgrade::DrawUpgrade(Core::Graphics& graphics, Vector2D mouse, float thickness) { myColor = (CheckMouse(mouse))? RGB(134, 134, 134): RGB(94,94,94); if(upgradeCooldown < .5) { upgradeCooldown += .016f; } graphics.SetColor(myColor); for(int i=0; i<BOX_SIZE; i++) { Vector2D start(position.x + i, position.y); Vector2D end(position.x + i, position.y+BOX_SIZE); graphics.DrawLine(start.x, start.y, end.x, end.y); } if(CheckMouse(mouse)) { viewText(graphics); if(Core::Input::IsPressed(Core::Input::BUTTON_LEFT)&&upgradeCooldown >= .5f && myCash.getCash() >= upgradeCost && upgradeCount < 5) { upgradeCooldown = 0; myCash.decreaseCash(upgradeCost); upgradeCount++; } } SetUpgradeCost(); DrawGraphic(graphics); graphics.SetColor(RGB(255,255,255)); if(upgradeCount > 4) { graphics.SetColor(RGB(255,0,0)); } //Draws $ DrawHorizontalBar(graphics, thickness, Letter_Size, Vector2D(costPosition.x, costPosition.y+thickness/2)); DrawVerticalBar(graphics, thickness, (Letter_Size-3*thickness)/2, Vector2D(costPosition.x, costPosition.y + thickness)); DrawHorizontalBar(graphics, thickness, Letter_Size, Vector2D(costPosition.x, costPosition.y+thickness+((Letter_Size-3*thickness)/2))); DrawVerticalBar(graphics, thickness,(Letter_Size-3*thickness)/2, Vector2D(costPosition.x+(Letter_Size-thickness), costPosition.y + thickness*2+((Letter_Size-3*thickness)/2))); DrawHorizontalBar(graphics, thickness, Letter_Size, Vector2D(costPosition.x, costPosition.y+2*thickness + (2*((Letter_Size-3*thickness)/2)-thickness/2))); DrawVerticalBar(graphics, thickness, Letter_Size, Vector2D(costPosition.x+(Letter_Size/2.5f), costPosition.y)); //Draws Cost DrawLetters(graphics, thickness); }
void ac_EnterPassword() { SDL_Event event; MENU *m = &PasswordMenu; char pass[16]; m->num = 51; m->sel = 0; memset(pass, 0, sizeof(pass)); done = 0; while(!done) { while(SDL_PollEvent(&event)) if(event.type == SDL_KEYDOWN) { if(event.key.keysym.sym == SDLK_LEFT) { if(m->sel > 0) { m->sel--; PlaySound(0); } else { m->sel = m->num - 1; } } else if(event.key.keysym.sym == SDLK_RIGHT) { if(m->sel < m->num - 1) { m->sel++; PlaySound(0); } else { m->sel = 0; } } else if(event.key.keysym.sym == SDLK_LCTRL) { if(strlen(pass) < 5) { strncat(pass, PassChars + m->sel, 1); } } else if(event.key.keysym.sym == SDLK_LALT) { if(strlen(pass) != 0) { pass[strlen(pass) - 1] = 0; } } else if(event.key.keysym.sym == SDLK_RETURN) { int i; if((i = check_pass(pass)) != -1 && (pass[4] == '1' || pass[4] == '2')) { PlayGame(NORMAL, i, 0, pass[4] & 3); CheckForRecord(); } else { PlaySound(1); MPrint("INVALID PASSWORD!!", 190, 255, 252); BlitAndWait(50); } done = 1; } else if(event.key.keysym.sym == SDLK_ESCAPE) { done = 1; } } SDL_BlitSurface(title, NULL, gamescreen, NULL); MPrint(m->header, m->y, m->col, 252); DrawLetters(m->sel); MPrint(pass, 150, 255, 252); PutBox(158, 123, 168, 135, 83); PutBox(134, 148, 184, 160, 83); MPrint("PRESS LEFT/RIGHT TO SELECT", 170, 255, 252); MPrint("<START> TO CONFIRM", 180, 255, 252); BlitAndWait(1); } done = 0; }