Ignore:
Timestamp:
2011-06-08 12:44:21 (9 years ago)
Author:
tekrjant
Message:

Phew..
Changes:

  • We now have a minimap
  • Camera has been modified
  • Lot of minor stuff
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2011/23/sijoseha/AdventureGame/AdventureGame/AdventureGame.cs

    r1734 r1749  
    2828        static public SpriteFont basicFont; 
    2929        Texture2D tileImage; 
     30        Texture2D miniMapBorders; 
    3031        MouseState mouseState, previousMouseState; 
    3132        KeyboardState keyState, previousKeyState; 
     
    3536        HUD gameHUD; 
    3637 
    37         Viewport mapView, hudView; 
     38        Viewport mapView, hudView, miniMapView; 
    3839 
    3940        Button saveButton; 
     
    7273            selectionBox = Content.Load<Texture2D>("selectionbox"); 
    7374            tileImage = Content.Load<Texture2D>("tilet"); 
     75            miniMapBorders = Content.Load<Texture2D>("miniMapBorders"); 
     76 
     77            mapView = new Viewport(0, 0, 
     78                graphics.PreferredBackBufferWidth - 200, 
     79                graphics.PreferredBackBufferHeight); 
     80            hudView = new Viewport(graphics.PreferredBackBufferWidth - 200, 
     81                0, 200, graphics.PreferredBackBufferHeight); 
     82            miniMapView = new Viewport(graphics.PreferredBackBufferWidth - 200, 
     83                graphics.PreferredBackBufferHeight - 200, 200, 200); 
    7484 
    7585            gameHUD = new HUD(); 
    76             gameHUD.ViewPort = new Viewport(graphics.PreferredBackBufferWidth - 200, 0, 200, graphics.PreferredBackBufferHeight); 
     86            gameHUD.ViewPort = hudView; 
    7787            gameHUD.AddButton(new Button(new Rectangle(10, 10, 150, 40), "Save", Color.YellowGreen, Color.Red, GraphicsDevice)); 
     88             
    7889            gameHUD.Buttons[0].Clicked += new ButtonClickedHandler(SaveMap); 
    79             mapView = new Viewport(0, 0, graphics.PreferredBackBufferWidth - 200, graphics.PreferredBackBufferHeight); 
    80  
    81             gameMap = new Map(this, tileImage, TILE_SIZE, 50, 20); 
    82             gameCamera = new Camera(); 
     90 
     91            gameMap = new Map(this, tileImage, TILE_SIZE, 200, 200); 
     92            gameHUD.AddMiniMap(new MiniMap(gameMap, miniMapView, miniMapBorders)); 
     93            gameCamera = new Camera(mapView); 
    8394        } 
    8495 
     
    166177                BlendState.AlphaBlend, 
    167178                null,null,null,null,gameCamera.getTransformation(mapView)); 
    168             gameMap.Draw(spriteBatch); 
     179            gameMap.Draw(spriteBatch, gameCamera); 
    169180            spriteBatch.End(); 
    170181            GraphicsDevice.Viewport = gameHUD.ViewPort; 
     
    172183            gameHUD.Draw(spriteBatch); 
    173184            spriteBatch.End(); 
    174  
     185            GraphicsDevice.Viewport = miniMapView; 
     186            spriteBatch.Begin(SpriteSortMode.Deferred, 
     187                BlendState.AlphaBlend, 
     188                null, null, null, null, gameCamera.getTransformation(miniMapView, true, gameMap.Size)); 
     189            gameHUD.DrawMinimap(spriteBatch); 
     190            spriteBatch.End(); 
     191            spriteBatch.Begin(); 
     192            spriteBatch.Draw(gameHUD.MiniMap.Borders, new Rectangle(0,0,200,200), Color.White); 
     193            spriteBatch.End(); 
    175194            base.Draw(gameTime); 
    176195        } 
Note: See TracChangeset for help on using the changeset viewer.