void FilterItemID(ref int ID) { while (BuildingBlocks.GetRectangleForTile(ID, DrawPurpose.Show, 0, 0, 0, 0, AnimationStatus).Width == 1 && BuildingBlocks.GetRectangleForTile(ID, DrawPurpose.Show, 0, 0, 0, 0, AnimationStatus).Height == 1) { ID++; if (ID == 8) { ID++; } if (ID >= 3000) { ID = 0; } } /*if (ID == 8) * { * ID = 10; * } * if (ID == 34) * { * ID = 52; * } * if (ID == 66) * { * ID = 100; * } * if (ID == 122) * { * ID = 162; * }*/ }
void FilterItemIDMinus(ref int ID) { while (BuildingBlocks.GetRectangleForTile(ID, DrawPurpose.Show, 0, 0, 0, 0, AnimationStatus).Width == 1 && BuildingBlocks.GetRectangleForTile(ID, DrawPurpose.Show, 0, 0, 0, 0, AnimationStatus).Height == 1) { ID--; if (ID == 8) { ID++; } if (ID < 0) { ID = 0; } } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { Vector2 TilePressed = MouseToWorld(new Vector2(Mouse.GetState().X, Mouse.GetState().Y)); GraphicsDevice.Clear(Color.FromNonPremultiplied(0, 255, 255, 255)); // TODO: Add your drawing code here spriteBatch.Begin(SpriteSortMode.Immediate, null, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(scale_screen)); // Draw Level int nVisibleTilesX = ScreenWidth() / nTileDrawWidth; int nVisibleTilesY = ScreenHeight() / nTileHeight; // Calculate Top-Leftmost visible tile float fOffsetX = fCameraPosX - (float)nVisibleTilesX / 2.0f; float fOffsetY = fCameraPosY - (float)nVisibleTilesY / 2.0f; // Clamp camera to game boundaries if (fOffsetX < 0f) { fOffsetX = 0; } if (fOffsetY < 0f) { fOffsetY = 0; } if (fOffsetX > nLevelWidth - nVisibleTilesX) { fOffsetX = nLevelWidth - nVisibleTilesX; } if (fOffsetY > nLevelHeight - nVisibleTilesY) { fOffsetY = nLevelHeight - nVisibleTilesY; } // Get offsets for smooth movement float fTileOffsetX = (fOffsetX - (int)fOffsetX) * nTileWidth; float fTileOffsetY = (fOffsetY - (int)fOffsetY) * nTileHeight; // Draw visible tile map for (int x = -3; x < nVisibleTilesX + 3; x++) { for (int y = -3; y < nVisibleTilesY + 3; y++) { int sTileID = GetTile(x + fOffsetX, y + fOffsetY); int sTileID_Below = GetTile(x + fOffsetX, y + fOffsetY + 1); int sTileID_Above = GetTile(x + fOffsetX, y + fOffsetY - 1); int sTileID_ToL = GetTile(x + fOffsetX - 1, y + fOffsetY); int sTileID_ToR = GetTile(x + fOffsetX + 1, y + fOffsetY); int sTileID_BG = GetTileBG(x + fOffsetX, y + fOffsetY); if (sTileID_BG != 0) { spriteBatch.Draw(Tiles_Page1, new Rectangle((int)(x * nTileDrawWidth - fTileOffsetX), (int)(y * nTileHeight - fTileOffsetY), nTileDrawWidth, nTileHeight), BuildingBlocks.GetRectangleForTile(sTileID_BG, DrawPurpose.Tile, sTileID_Below, sTileID_Above, sTileID_ToL, sTileID_ToR, AnimationStatus), Color.White); } if (sTileID != 0) { spriteBatch.Draw(Tiles_Page1, new Rectangle((int)(x * nTileDrawWidth - fTileOffsetX), (int)(y * nTileHeight - fTileOffsetY), nTileDrawWidth, nTileHeight), BuildingBlocks.GetRectangleForTile(sTileID, DrawPurpose.Tile, sTileID_Below, sTileID_Above, sTileID_ToL, sTileID_ToR, AnimationStatus), Color.White, 0f, Vector2.Zero, GetTileFlipping(x + fOffsetX, y + fOffsetY), 0f); } } } // Draw Player Vector2 GamertagSize = (bIsSuperSupporter ? sf_namess : sf).MeasureString(sGamerTag); spriteBatch.DrawString((bIsSuperSupporter ? sf_namess : sf), sGamerTag, new Vector2((int)(((fPlayerPosX - fOffsetX) * nTileDrawWidth) - (GamertagSize.X) / 2) + 15, (int)(((fPlayerPosY - fOffsetY) * nTileHeight) - (GamertagSize.Y) / 2) - 30), Color.Black); spriteBatch.DrawString((bIsSuperSupporter ? sf_namess : sf), sGamerTag, new Vector2((int)(((fPlayerPosX - fOffsetX) * nTileDrawWidth) - (GamertagSize.X) / 2) + 14, (int)(((fPlayerPosY - fOffsetY) * nTileHeight) - (GamertagSize.Y) / 2) - 31), (sGamerTag.StartsWith("@") ? (sGamerTag == "@iProgramInCpp" ? Color.Goldenrod : Color.Purple) : Color.White)); DrawPlayerSprite((int)((fPlayerPosX - fOffsetX) * nTileDrawWidth), (int)((fPlayerPosY - fOffsetY) * nTileHeight), nTileDrawWidth, nTileHeight, spriteMan, nDirModX * nTileWidth, nDirModY * nTileHeight, nTileWidth, nTileHeight); Fill(new Rectangle((int)((int)Math.Floor(TilePressed.X - fOffsetX) * nTileDrawWidth - fTileOffsetX), (int)(Math.Floor(TilePressed.Y - fOffsetY) * nTileHeight - fTileOffsetY), nTileWidth, nTileHeight), Color.FromNonPremultiplied(0, 0, 0, 100)); // Grid if (gameState == GameState.EditMode && IsGridEnabled) { for (int x = -3; x < nVisibleTilesX + 3; x++) { for (int y = -3; y < nVisibleTilesY + 3; y++) { Fill(new Rectangle((int)(x * nTileDrawWidth - fTileOffsetX + 31), (int)(y * nTileHeight - fTileOffsetY), 1, 32), Color.Black); Fill(new Rectangle((int)(x * nTileDrawWidth - fTileOffsetX), (int)(y * nTileHeight - fTileOffsetY + 31), nTileDrawWidth, 1), Color.Black); } } } //Debug info spriteBatch.DrawString(sf, "X Speed: " + fPlayerPosX.ToString(), new Vector2(10, 50), Color.Black); spriteBatch.DrawString(sf, "Y Speed: " + fPlayerPosY.ToString(), new Vector2(10, 70), Color.Black); spriteBatch.DrawString(sf, "Selected Item: " + SelectedItem.ToString(), new Vector2(10, 100), Color.Black); spriteBatch.DrawString(sf, "Start Item: " + StartingDrawItem.ToString(), new Vector2(10, 120), Color.Black); //spriteBatch.DrawString(sf, "mex timespan: " + bDead.ToString(), new Vector2(10, 140), Color.Black); //spriteBatch.DrawString(sf, "POSX " + fPlayerPosX.ToString(), new Vector2(10, 10), Color.White); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, null, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(1f)); if (gameState == GameState.EditMode && IsUIEnabled) { spriteBatch.Draw(MakerHeader, new Rectangle(0, 0, 800, 50), Color.White); spriteBatch.Draw(checkmarkTexture, GridCheckBox, new Rectangle((IsGridEnabled) ? 16 : 0, 0, 16, 16), Color.White); spriteBatch.DrawString(sf, "Enable Grid Lines", new Vector2(40, 22), Color.Black); int CurrentDrawnItem = StartingDrawItem; for (int x = 0; x < 17; x++) { FilterItemID(ref CurrentDrawnItem); spriteBatch.Draw(Tiles_Page1, new Rectangle(150 + x * 36, 10, nTileWidth, nTileHeight), BuildingBlocks.GetRectangleForTile(CurrentDrawnItem, DrawPurpose.Show, 0, 0, 0, 0, AnimationStatus), Color.White); CurrentDrawnItem += 2; FilterItemID(ref CurrentDrawnItem); } spriteBatch.Draw(HideShowUIBtn, (IsUIEnabled ? HideUICheckBox : ShowUICheckBox), new Rectangle(0, (IsUIEnabled ? 0 : 16), 50, 16), Color.White); spriteBatch.Draw(NextTexture, NextBox, Color.White); } else if (gameState == GameState.EditMode && !IsUIEnabled) { spriteBatch.Draw(HideShowUIBtn, (IsUIEnabled ? HideUICheckBox : ShowUICheckBox), new Rectangle(0, (IsUIEnabled ? 0 : 16), 50, 16), Color.White); } else { spriteBatch.Draw(Tiles_Page1, new Rectangle(30, 30, nTileWidth, nTileHeight), BuildingBlocks.GetRectangleForTile(112, DrawPurpose.Show, 0, 0, 0, 0, AnimationStatus), Color.White); spriteBatch.DrawString(sf_s2, " x " + GemsCount.ToString(), new Vector2(66, 31), Color.Black); spriteBatch.DrawString(sf_s2, " x " + GemsCount.ToString(), new Vector2(65, 30), Color.White); spriteBatch.DrawString(sf_s2, "Play Mode", new Vector2(30 + 1, 400 + 1), Color.Black); spriteBatch.DrawString(sf_s2, "Play Mode", new Vector2(30, 400), Color.White); //spriteBatch.DrawString(sf_s2, "Super Growtopia Maker", new Vector2(30 + 1, 400 + 1), Color.Black); //spriteBatch.DrawString(sf_s2, "Super Growtopia Maker", new Vector2(30, 400), Color.Yellow); } //spriteBatch.DrawString(sf, "Player Position X: " + fCameraPosX.ToString(), new Vector2(10, 10), Color.Black); //spriteBatch.DrawString(sf, "Player Position Y: " + fCameraPosY.ToString(), new Vector2(10, 30), Color.Black); spriteBatch.End(); base.Draw(gameTime); }