void ChangeTextPosition(TextGlyphs* FirstLetter, Vec2 newPosition, int alignment) { TextGlyphs* nextLetter = FirstLetter; int i = 0; while(nextLetter) { nextLetter = nextLetter->NextLetter; i++; } if(alignment == Center) { newPosition.x = newPosition.x - (i * FirstLetter->Glyph->Height * 0.4f) / 2; } else if(alignment == Right) { newPosition.x = newPosition.x - (i * FirstLetter->Glyph->Height * 0.4f); } i = 0; nextLetter = FirstLetter; while(nextLetter) { if(nextLetter->Glyph) Vec2Set(&nextLetter->Glyph->Position, newPosition.x + (i * nextLetter->Glyph->Height * 0.4f), newPosition.y); nextLetter = nextLetter->NextLetter; i++; } }
static void Init( void ) { // reset block direction x_dir = 1; y_dir = 0; lasttime = 0.0f; Vec2Set( block_pos, 0.0f, 0.0f ); printf("Init::level_demo\n"); }
BOOL AK2_GridCreate( ak2GRID *G, INT W, INT H ) { INT i, x, y, size = (W - 1) * (H - 1) * 2 * 3 * sizeof(ak2VERTEX); memset(G, 0, sizeof(ak2GRID)); if ((G->V = malloc(size)) == NULL) return FALSE; memset(G->V, 0, size); for (i = 0, y = 0; y < H; y++) for (x = 0; x < W; x++, i++) { G->V[i].P = VecSet(x / (W - 1.0) * 2 - 1, 0, 1 - y / (H - 1.0) * 2); G->V[i].N = VecSet(0, 1, 0); G->V[i].T = Vec2Set(x / (W - 1.0), y / (H - 1.0)); G->V[i].C = Vec4Set(1, 1, 1, 1); } G->W = W; G->H = H; return TRUE; } /* End of 'AK2_GridCreate' function */
void InputHandling(void) { //If delete save option is up if(deleteSave) { // Mouse location data int worldX, worldY; Vec2 MouseHover; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseHover, (float)worldX, (float)worldY); //Adjust scales when mouse is on the delete save button if(PointRectCollision(&YesButton->ButtonCollider, &MouseHover)) { YesButton->ButtonSprite->ScaleX = 1.1f; YesButton->ButtonSprite->ScaleY = 1.1f; NoButton->ButtonSprite->ScaleX = 1.0f; NoButton->ButtonSprite->ScaleY = 1.0f; } //On the back button else if(PointRectCollision(&NoButton->ButtonCollider, &MouseHover)) { YesButton->ButtonSprite->ScaleX = 1.0f; YesButton->ButtonSprite->ScaleY = 1.0f; NoButton->ButtonSprite->ScaleX = 1.1f; NoButton->ButtonSprite->ScaleY = 1.1f; } //Back to normal else { YesButton->ButtonSprite->ScaleX = 1.0f; YesButton->ButtonSprite->ScaleY = 1.0f; NoButton->ButtonSprite->ScaleX = 1.0f; NoButton->ButtonSprite->ScaleY = 1.0f; } //On click if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { //Get mouse info int worldX, worldY; Vec2 MouseClick; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseClick, (float)worldX, (float)worldY); //We want a new game right meow! if(PointRectCollision(&YesButton->ButtonCollider, &MouseClick)) { if(remove(GameData)) printf("SOMETHING WENT WRONG\n"); SetNextState(GS_CharacterSelect); } //I'm so close, lets just continue! else if(PointRectCollision(&NoButton->ButtonCollider, &MouseClick)) { //Hides all the save deletion sprites deleteSave = FALSE; BlackBackground->Visible = FALSE; DeleteText->Visible = FALSE; YesButton->ButtonSprite->Visible = FALSE; NoButton->ButtonSprite->Visible = FALSE; } } } //If exit confirmation is up else if(exitGame) { //Get mouse info int worldX, worldY; Vec2 MouseClick; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseClick, (float)worldX, (float)worldY); // All for exit button if(PointRectCollision(&ExitButton->ButtonCollider, &MouseClick)) { if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { SetNextState(GS_Quit); } ExitButton->ButtonSprite->ScaleX = 1.2f; ExitButton->ButtonSprite->ScaleY = 1.2f; } else { ExitButton->ButtonSprite->ScaleX = 1.0f; ExitButton->ButtonSprite->ScaleY = 1.0f; } // All for the don't quit button if(PointRectCollision(&NoButton->ButtonCollider, &MouseClick)) { if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { //Hides all the save deletion sprites exitGame = FALSE; BlackBackground->Visible = FALSE; ExitConfirm->Visible = FALSE; ExitButton->ButtonSprite->Visible = FALSE; NoButton->ButtonSprite->Visible = FALSE; NoButton->ButtonSprite->ScaleX = 1.0f; NoButton->ButtonSprite->ScaleY = 1.0f; } else { NoButton->ButtonSprite->ScaleX = 1.2f; NoButton->ButtonSprite->ScaleY = 1.2f; } } else { NoButton->ButtonSprite->ScaleX = 1.0f; NoButton->ButtonSprite->ScaleY = 1.0f; } } //Mouse clicks for the regular buttons else if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { //Get mouse position int worldX, worldY; Vec2 MouseClick; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseClick, (float)worldX, (float)worldY); //New game button if(PointRectCollision(&NewGameButton->ButtonCollider, &MouseClick)) { //If a save file exists bring up the save game deletion stuff if(!canLoad) { SetNextState(GS_CharacterSelect); } else { deleteSave = TRUE; BlackBackground->Visible = TRUE; DeleteText->Visible = TRUE; YesButton->ButtonSprite->Visible = TRUE; NoButton->ButtonSprite->Visible = TRUE; } } //Load game button only activates if there is a save game file else if(canLoad && PointRectCollision(&LoadGameButton->ButtonCollider, &MouseClick)) { //Loads the map level with the player at the correct spot SetNextState(GS_MapLevel); } //Options button else if(PointRectCollision(&OptionsButton->ButtonCollider, &MouseClick)) { SetNextState(GS_Options); } //Roll those credits! else if(PointRectCollision(&CreditsButton->ButtonCollider, &MouseClick)) { // Load Game Function hurrr SetNextState(GS_Credits); } //No one ever wants to quit... else if(PointRectCollision(&QuitGameButton->ButtonCollider, &MouseClick)) { //Quit game :( exitGame = TRUE; BlackBackground->Visible = TRUE; ExitConfirm->Visible = TRUE; ExitButton->ButtonSprite->Visible = TRUE; NoButton->ButtonSprite->Visible = TRUE; NoButton->ButtonSprite->ScaleX = 1.0f; NoButton->ButtonSprite->ScaleY = 1.0f; ExitButton->ButtonSprite->ScaleX = 1.0f; ExitButton->ButtonSprite->ScaleY = 1.0f; } } //Mouse hover stuff else { // Mouse location data int worldX, worldY; Vec2 MouseHover; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseHover, (float)worldX, (float)worldY); //Adjust scales when mouse is on the new game button if(PointCircleCollision(&NewGameButton->ButtonCollider.Position, NewGameButton->ButtonSprite->Width / 2.0f, &MouseHover)) { NewGameButton->ButtonSprite->ScaleX = 1.1f; NewGameButton->ButtonSprite->ScaleY = 1.1f; LoadGameButton->ButtonSprite->ScaleX = 1.0f; LoadGameButton->ButtonSprite->ScaleY = 1.0f; OptionsButton->ButtonSprite->ScaleX = 1.0f; OptionsButton->ButtonSprite->ScaleY = 1.0f; CreditsButton->ButtonSprite->ScaleX = 1.0f; CreditsButton->ButtonSprite->ScaleY = 1.0f; QuitGameButton->ButtonSprite->ScaleX = 1.0f; QuitGameButton->ButtonSprite->ScaleY = 1.0f; } // Not the new game button else { //Scale back to normal size NewGameButton->ButtonSprite->ScaleX = 1.0f; NewGameButton->ButtonSprite->ScaleY = 1.0f; //Hover if mouse collision and you can load the game if(canLoad && PointRectCollision(&LoadGameButton->ButtonCollider, &MouseHover)) { LoadGameButton->ButtonSprite->ScaleX = 1.2f; LoadGameButton->ButtonSprite->ScaleY = 1.2f; } // Back to normal else { LoadGameButton->ButtonSprite->ScaleX = 1.0f; LoadGameButton->ButtonSprite->ScaleY = 1.0f; } //Options hover effect if(PointRectCollision(&OptionsButton->ButtonCollider, &MouseHover)) { OptionsButton->ButtonSprite->ScaleX = 1.2f; OptionsButton->ButtonSprite->ScaleY = 1.2f; } //Options back to normal else { OptionsButton->ButtonSprite->ScaleX = 1.0f; OptionsButton->ButtonSprite->ScaleY = 1.0f; } //Credits hover effect if(PointRectCollision(&CreditsButton->ButtonCollider, &MouseHover)) { CreditsButton->ButtonSprite->ScaleX = 1.2f; CreditsButton->ButtonSprite->ScaleY = 1.2f; } //Credits back to normal else { CreditsButton->ButtonSprite->ScaleX = 1.0f; CreditsButton->ButtonSprite->ScaleY = 1.0f; } //I guess we should make the quit button have a hover effect if(PointRectCollision(&QuitGameButton->ButtonCollider, &MouseHover)) { QuitGameButton->ButtonSprite->ScaleX = 1.2f; QuitGameButton->ButtonSprite->ScaleY = 1.2f; } //Yay! Back to normal! else { QuitGameButton->ButtonSprite->ScaleX = 1.0f; QuitGameButton->ButtonSprite->ScaleY = 1.0f; } } } // check if forcing the application to quit if (FoxInput_KeyTriggered(VK_ESCAPE)) { if(!exitGame) { exitGame = TRUE; BlackBackground->Visible = TRUE; ExitConfirm->Visible = TRUE; ExitButton->ButtonSprite->Visible = TRUE; NoButton->ButtonSprite->Visible = TRUE; NoButton->ButtonSprite->ScaleX = 1.0f; NoButton->ButtonSprite->ScaleY = 1.0f; ExitButton->ButtonSprite->ScaleX = 1.0f; ExitButton->ButtonSprite->ScaleY = 1.0f; } else { exitGame = FALSE; BlackBackground->Visible = FALSE; ExitConfirm->Visible = FALSE; ExitButton->ButtonSprite->Visible = FALSE; NoButton->ButtonSprite->Visible = FALSE; } } }
void EventPause(void) { int worldX, worldY; Vec2 MouseClick; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseClick, (float)worldX, (float)worldY); if(FoxInput_MouseDown(MOUSE_BUTTON_LEFT)) { if(PointRectCollision(&SFXSlider->ButtonCollider, &MouseClick)) { if(worldX > SFXSliderGuide->Width / 2 + SFXSliderGuide->Position.x) SFXSlider->Position.x = SFXSliderGuide->Width / 2 + SFXSliderGuide->Position.x; else if(worldX < -SFXSliderGuide->Width / 2 + SFXSliderGuide->Position.x) SFXSlider->Position.x = -SFXSliderGuide->Width / 2 + SFXSliderGuide->Position.x; else SFXSlider->Position.x = (float)worldX; SFXSlider->ButtonSprite->Position.x = SFXSlider->Position.x; SFXSlider->ButtonCollider.Position.x = SFXSlider->Position.x; SFXVolume = (SFXSlider->Position.x + SFXSliderGuide->Width / 2 - GetCameraXPosition()) / SFXSliderGuide->Width; if(SFXVolume < 0) SFXVolume = 0.0f; else if(SFXVolume > 1.0f) SFXVolume = 1.0f; volumestring = VolumetoString(volumestring, SFXVolume * 100); volumestring = strcat(volumestring, "%"); ChangeTextString(SFXText, volumestring); } else if(PointRectCollision(&BGMSlider->ButtonCollider, &MouseClick)) { if(worldX > SFXSliderGuide->Width / 2 + BGMSliderGuide->Position.x) BGMSlider->Position.x = BGMSliderGuide->Width / 2 + BGMSliderGuide->Position.x; else if(worldX < -BGMSliderGuide->Width / 2 + BGMSliderGuide->Position.x) BGMSlider->Position.x = -BGMSliderGuide->Width / 2 + BGMSliderGuide->Position.x; else BGMSlider->Position.x = (float)worldX; BGMSlider->ButtonSprite->Position.x = BGMSlider->Position.x; BGMSlider->ButtonCollider.Position.x = BGMSlider->Position.x; BGMVolume = (BGMSlider->Position.x + BGMSliderGuide->Width / 2 - GetCameraXPosition()) / BGMSliderGuide->Width; if(BGMVolume < 0) BGMVolume = 0.0f; else if(BGMVolume > 1.0f) BGMVolume = 1.0f; volumestring = VolumetoString(volumestring, BGMVolume * 100); volumestring = strcat(volumestring, "%"); ChangeTextString(BGMText, volumestring); } } // On a single mouse click if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { //Check the cheats check box and the back button if(PointRectCollision(&CheatsButton->ButtonCollider, &MouseClick)) { Cheats = !Cheats; CheckMark->Visible = !(CheckMark->Visible); } if(PointRectCollision(&LookAtButton->ButtonCollider, &MouseClick)) { LookAtMouse = !LookAtMouse; LookAtCheckMark->Visible = !(LookAtCheckMark->Visible); } } //RESUME: Nothing weird happens if(PointRectCollision(&ResumeButton->ButtonCollider, &MouseClick)) { ResumeButton->ButtonSprite->ScaleX = 1.2f; ResumeButton->ButtonSprite->ScaleY = 1.2f; if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) pause = FALSE; } else { ResumeButton->ButtonSprite->ScaleX = 1.0f; ResumeButton->ButtonSprite->ScaleY = 1.0f; } //MAIN MENU: Don't save stats if(PointRectCollision(&MainMenuButton->ButtonCollider, &MouseClick)) { if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { if(GetCurrentState() == GS_MapLevel) SetNextState(GS_MainMenu); else SetNextState(GS_MapLevel); pause = FALSE; } MainMenuButton->ButtonSprite->ScaleX = 1.2f; MainMenuButton->ButtonSprite->ScaleY = 1.2f; } else { MainMenuButton->ButtonSprite->ScaleX = 1.0f; MainMenuButton->ButtonSprite->ScaleY = 1.0f; } //RESTART: Reset stats if(GetCurrentState() != GS_MapLevel && PointRectCollision(&RestartButton->ButtonCollider, &MouseClick)) { RestartButton->ButtonSprite->ScaleX = 1.2f; RestartButton->ButtonSprite->ScaleY = 1.2f; if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { //Special Case (Please do not take this out again). if(GetCurrentState() == GS_Level31) SetNextState(GS_Level3); //Otherwise perform normal restart else SetNextState(GS_Restart); pause = FALSE; } } else if(GetCurrentState() != GS_MapLevel) { RestartButton->ButtonSprite->ScaleX = 1.0f; RestartButton->ButtonSprite->ScaleY = 1.0f; } }
void UpdateUpgradeScreenObjects(void) { float camX = GetCameraXPosition(); char CharTemp[32]; int worldX, worldY; Vec2 MouseClick; Vec2 NewPosition; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseClick, (float)worldX, (float)worldY); //Update the particles ParticleSystemUpdate(); //Check if there are upgrades if (!UpgradesToUpgrade) { if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0) UpgradesToUpgrade = TRUE; else if (CurrentPlayer.CurrentPlayerStats.Upgrades < 1) { //No upgrade points, get out UpgradeComplete = TRUE; return; } } //Title if (CurrentPlayer.CurrentPlayerStats.Strength >= UPGRADE_MAX && CurrentPlayer.CurrentPlayerStats.Agility >= UPGRADE_MAX && CurrentPlayer.CurrentPlayerStats.Defense >= UPGRADE_MAX && !allUpgradesFull) { //If no more upgrades remain, let them know allUpgradesFull = TRUE; ChangeTextString(UpgradesName, "All Upgrades Complete!"); ChangeTextZIndex(UpgradesName, 4003); } Vec2Set(&NewPosition, camX, 470); ChangeTextPosition(UpgradesName, NewPosition, Center); //Upgrades remaining if (lastUpgrades != CurrentPlayer.CurrentPlayerStats.Upgrades) { //Do some flavor text warnings for differnt UP amounts if (allUpgradesFull) sprintf(CharTemp, "Good Work! Keep Mashing!"); else if (CurrentPlayer.CurrentPlayerStats.Upgrades == 1) sprintf(CharTemp, "%i Point Remaining!", CurrentPlayer.CurrentPlayerStats.Upgrades); else if (CurrentPlayer.CurrentPlayerStats.Upgrades < 1) sprintf(CharTemp, "No Points! Level Up More!"); else sprintf(CharTemp, "%i Points to Spend!", CurrentPlayer.CurrentPlayerStats.Upgrades); ChangeTextString(UpgradesLeft, CharTemp); ChangeTextZIndex(UpgradesLeft, 4003); TextAllVisible(UpgradesLeft); lastUpgrades = CurrentPlayer.CurrentPlayerStats.Upgrades; } Vec2Set(&NewPosition, camX, 380); ChangeTextPosition(UpgradesLeft, NewPosition, Center); //Upgrade buttons, all 3 UpdateButtonPosition(UpgradeButton1, 545 + camX, 200); UpdateCollisionPosition(&UpgradeButton1->ButtonCollider, &UpgradeButton1->ButtonSprite->Position); UpdateButtonPosition(UpgradeButton2, 545 + camX, 0); UpdateCollisionPosition(&UpgradeButton2->ButtonCollider, &UpgradeButton2->ButtonSprite->Position); UpdateButtonPosition(UpgradeButton3, 545 + camX, -200); UpdateCollisionPosition(&UpgradeButton3->ButtonCollider, &UpgradeButton3->ButtonSprite->Position); //Upgrade bars UpgradeBar1->Position.x = camX; UpgradeBar1->Position.y = 200; UpgradeBar2->Position.x = camX; UpgradeBar2->Position.y = 0; UpgradeBar3->Position.x = camX; UpgradeBar3->Position.y = -200; //Particle / Haze back HazeBackground->Position.x = camX + 480; HazeBackground->Position.y = 0; SystemOne->Position.y = 0; SystemOne->Position.x = camX; SystemOne->amountTotal = -1; if (HazeBackground->Alpha < 1) HazeBackground->Alpha += 2 * GetDeltaTime(); else HazeBackground->Alpha = 1; //Upgrade bar colors //Str -- UpgradeBarColor1->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Strength); UpgradeBarColor1->Position.y = 200; UpgradeBarColor1->ScaleX = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Strength / UPGRADE_MAX); UpgradeBarColor1->ScaleY = 1.1f; //Agi -- UpgradeBarColor2->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Agility); UpgradeBarColor2->Position.y = 0; UpgradeBarColor2->ScaleX = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Agility / UPGRADE_MAX); UpgradeBarColor2->ScaleY = 1.1f; //Def -- UpgradeBarColor3->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Defense); UpgradeBarColor3->Position.y = -200; UpgradeBarColor3->ScaleX = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Defense / UPGRADE_MAX); UpgradeBarColor3->ScaleY = 1.1f; //Upgrades used placement //Str -- sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Strength); ChangeTextString(UpgradeAmount1, CharTemp); ChangeTextZIndex(UpgradeAmount1, 4003); TextAllVisible(UpgradeAmount1); Vec2Set(&NewPosition, camX - 590, 200); ChangeTextPosition(UpgradeAmount1, NewPosition, Center); //Agi -- sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Agility); ChangeTextString(UpgradeAmount2, CharTemp); ChangeTextZIndex(UpgradeAmount2, 4003); TextAllVisible(UpgradeAmount2); Vec2Set(&NewPosition, camX - 590, 0); ChangeTextPosition(UpgradeAmount2, NewPosition, Center); //Def -- sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Defense); ChangeTextString(UpgradeAmount3, CharTemp); ChangeTextZIndex(UpgradeAmount3, 4003); TextAllVisible(UpgradeAmount3); Vec2Set(&NewPosition, camX - 590, -200); ChangeTextPosition(UpgradeAmount3, NewPosition, Center); //Done upgrading button UpdateButtonPosition(MainMapButton, 400 + camX, -400); UpdateCollisionPosition(&MainMapButton->ButtonCollider, &MainMapButton->ButtonSprite->Position); //STRENGTH (No up allowed if maxed) if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton1->ButtonCollider, &MouseClick) && CurrentPlayer.CurrentPlayerStats.Strength < UPGRADE_MAX) { UpgradeButton1->ButtonSprite->ScaleX = 1.12f; UpgradeButton1->ButtonSprite->ScaleY = 1.12f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { CurrentPlayer.CurrentPlayerStats.Upgrades--; CurrentPlayer.CurrentPlayerStats.Strength++; UpgradeButton1->ButtonSprite->ScaleX = 1.16f; UpgradeButton1->ButtonSprite->ScaleY = 1.16f; PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp); } } else { if (UpgradeButton1->ButtonSprite->ScaleX > 1.0f) { UpgradeButton1->ButtonSprite->ScaleX -= GetDeltaTime() * 2; UpgradeButton1->ButtonSprite->ScaleY -= GetDeltaTime() * 2; } } //AGILITY (No up allowed if maxed) if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton2->ButtonCollider, &MouseClick) && CurrentPlayer.CurrentPlayerStats.Agility < UPGRADE_MAX) { UpgradeButton2->ButtonSprite->ScaleX = 1.12f; UpgradeButton2->ButtonSprite->ScaleY = 1.12f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { CurrentPlayer.CurrentPlayerStats.Upgrades--; CurrentPlayer.CurrentPlayerStats.Agility++; UpgradeButton2->ButtonSprite->ScaleX = 1.16f; UpgradeButton2->ButtonSprite->ScaleY = 1.16f; PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp); } } else { if (UpgradeButton2->ButtonSprite->ScaleX > 1.0f) { UpgradeButton2->ButtonSprite->ScaleX -= GetDeltaTime() * 2; UpgradeButton2->ButtonSprite->ScaleY -= GetDeltaTime() * 2; } } //DEFENSE (No up allowed if maxed) if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton3->ButtonCollider, &MouseClick) && CurrentPlayer.CurrentPlayerStats.Defense < UPGRADE_MAX) { UpgradeButton3->ButtonSprite->ScaleX = 1.12f; UpgradeButton3->ButtonSprite->ScaleY = 1.12f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { CurrentPlayer.CurrentPlayerStats.Upgrades--; CurrentPlayer.CurrentPlayerStats.Defense++; UpgradeButton3->ButtonSprite->ScaleX = 1.16f; UpgradeButton3->ButtonSprite->ScaleY = 1.16f; PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp); } } else { if (UpgradeButton3->ButtonSprite->ScaleX > 1.0f) { UpgradeButton3->ButtonSprite->ScaleX -= GetDeltaTime() * 2; UpgradeButton3->ButtonSprite->ScaleY -= GetDeltaTime() * 2; } } //MAIN MENU if(PointRectCollision(&MainMapButton->ButtonCollider, &MouseClick)) { MainMapButton->ButtonSprite->ScaleX = 1.2f; MainMapButton->ButtonSprite->ScaleY = 1.2f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { UpgradeComplete = TRUE; } } else { MainMapButton->ButtonSprite->ScaleX = 1.0f; MainMapButton->ButtonSprite->ScaleY = 1.0f; } }
Weapon* CreateDroppedWeapon(int weaponType, int weaponRarity, float width, float height, float xPos, float yPos) { Weapon *CurrentWeapon = AddWeapon(); Vec2 ColliderPos; Vec3 TextTint; int nameLen, statsLen; Vec2Set(&ColliderPos, xPos, yPos); Vec3Set(&TextTint, 0, 0, 0); CurrentWeapon->WeaponFOF = DroppedWeapon; // Friend or Foe tag CurrentWeapon->objID = GetObjectID(); CurrentWeapon->WeaponRarity = weaponRarity; CurrentWeapon->WeaponType = weaponType; CurrentWeapon->WeaponName = (char *) CallocMyAlloc(MAX_NAME_LENGTH, sizeof(char)); CurrentWeapon->WeaponStatsString = (char *) CallocMyAlloc(MAX_NAME_LENGTH, sizeof(char)); CurrentWeapon->WeaponLength = 80.0f; if(CurrentWeapon->WeaponName) CreateWeaponName(&CurrentWeapon->WeaponName, CurrentWeapon->WeaponType, CurrentWeapon->WeaponRarity); else CurrentWeapon->WeaponName = "Error: Memory Allocation Failed!"; CreateWeaponStats(CurrentWeapon->WeaponType, CurrentWeapon->WeaponRarity, &CurrentWeapon->BonusStrength, &CurrentWeapon->BonusAgility, &CurrentWeapon->BonusDefense); Vec2Set(&CurrentWeapon->Position, xPos, yPos); CurrentWeapon->WeaponSprite = CreateWeaponSprite(CurrentWeapon->WeaponType, CurrentWeapon->WeaponRarity, xPos, yPos); // Special Weapon!! if (!strcmp(CurrentWeapon->WeaponName,"Sausage Sausage of sausage")) { CurrentWeapon->WeaponSprite->SpriteTexture = LoadTexture("TextureFiles/BattleAxe.png"); CurrentWeapon->WeaponType = Axe; CurrentWeapon->BonusAgility += 12; CurrentWeapon->BonusStrength += 12; CurrentWeapon->BonusDefense += 12; } CreateCollisionBox(&CurrentWeapon->WeaponPickup, &CurrentWeapon->Position, WeaponDrop, width / 2, height, CurrentWeapon->objID); CreateCollisionBox(&CurrentWeapon->WeaponAttack, &CurrentWeapon->Position, WeaponDrop, width / 3, height / 2, CurrentWeapon->objID); CurrentWeapon->WeaponGlyphs = CreateText(CurrentWeapon->WeaponName, CurrentWeapon->WeaponPickup.Position.x, CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f + 25, 50, TextTint, Center, Plain); CreateStatsString(CurrentWeapon->WeaponStatsString, CurrentWeapon->BonusStrength, CurrentWeapon->BonusAgility, CurrentWeapon->BonusDefense); CurrentWeapon->WeaponStatsGlyphs = CreateText(CurrentWeapon->WeaponStatsString, CurrentWeapon->WeaponPickup.Position.x, (CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f - 25), 50, TextTint, Center, Plain); ChangeTextZIndex(CurrentWeapon->WeaponGlyphs, 451); ChangeTextZIndex(CurrentWeapon->WeaponStatsGlyphs, 451); nameLen = strlen(CurrentWeapon->WeaponName); statsLen = strlen(CurrentWeapon->WeaponStatsString); if(nameLen >= statsLen) { CurrentWeapon->WeaponHoverBackground = (Sprite *) CreateSprite("TextureFiles/WeaponHoverBackground.png", nameLen * 25.0f, 180, 450, 1, 1, CurrentWeapon->WeaponPickup.Position.x, (CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f));// + CurrentWeapon->WeaponGlyphs->Glyph->Height)); } else { CurrentWeapon->WeaponHoverBackground = (Sprite *) CreateSprite("TextureFiles/WeaponHoverBackground.png", statsLen * 25.0f, 180, 450, 1, 1, CurrentWeapon->WeaponPickup.Position.x, (CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f));// + CurrentWeapon->WeaponGlyphs->Glyph->Height)); } CurrentWeapon->WeaponHoverBackground->Visible = FALSE; CurrentWeapon->WeaponParticle = CreateFoxParticleSystem("TextureFiles/ParticlePlatform.png", xPos, yPos, 9, -1, 3, .15f, 270, 0, 0.3f, 0, 110, 100, 50.0f, 1.0f, 0.7f); //Start off shopless CurrentWeapon->CurrentShop = NULL; CurrentWeapon->WeaponFalling = FALSE; return CurrentWeapon; }
void WeaponOnTheRun(Weapon* CurrentWeapon) { //Check if the weapon is falling if (CurrentWeapon->WeaponFalling) { //If collision, stop the falling Platform *pList = platformList; Wall *walls = wallList; Vec2 glyphPos; int hit = 0; if (CurrentWeapon->WeaponPickup.Position.y <= (GROUNDLEVEL - 80)) { CurrentWeapon->WeaponFalling = FALSE; return; } while(pList->objID != -1) { if(pList->objID > 0) { hit = PointRectCollision(&pList->PlatformCollider, &CurrentWeapon->WeaponPickup.Position); if(hit) { CurrentWeapon->WeaponFalling = FALSE; return; } } pList++; } while(walls->objID != -1) { if(walls->objID > 0) { hit = PointRectCollision(&walls->WallCollider, &CurrentWeapon->WeaponPickup.Position); if(hit) { CurrentWeapon->WeaponFalling = FALSE; return; } } walls++; } //If not collision, MAKE IT FALL CurrentWeapon->WeaponSprite->Position.y -= 4; CurrentWeapon->WeaponPickup.Position = CurrentWeapon->WeaponSprite->Position; CurrentWeapon->WeaponHoverBackground->Position.x = CurrentWeapon->WeaponPickup.Position.x; CurrentWeapon->WeaponHoverBackground->Position.y = CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f; Vec2Set(&glyphPos, CurrentWeapon->WeaponPickup.Position.x, CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f - CurrentWeapon->WeaponGlyphs->Glyph->Height); ChangeTextPosition(CurrentPlayer.ComparisonGlyphs, glyphPos, Center); Vec2Set(&glyphPos, CurrentWeapon->WeaponPickup.Position.x, CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f); ChangeTextPosition(CurrentWeapon->WeaponStatsGlyphs, glyphPos, Center); Vec2Set(&glyphPos, CurrentWeapon->WeaponPickup.Position.x, CurrentWeapon->WeaponPickup.Position.y + CurrentWeapon->WeaponPickup.height * 1.5f + CurrentWeapon->WeaponGlyphs->Glyph->Height); ChangeTextPosition(CurrentWeapon->WeaponGlyphs, glyphPos, Center); if (CurrentWeapon->WeaponParticle) { CurrentWeapon->WeaponParticle->Position.x = CurrentWeapon->WeaponSprite->Position.x; CurrentWeapon->WeaponParticle->Position.y = CurrentWeapon->WeaponSprite->Position.y; } } }