SlideShare a Scribd company logo
1 of 37
Maps Tran Minh Triet – Nguyen Khac Huy Faculty of Information Technology University of Science, VNU-HCM
Texture and Frame Scrolling One image file for one frame Many files Slow loading Hard management One image file for one sprite Only One file Loading at once
Scrolling Map
Scrolling map
Scrolling map Vertical scrolling Chicken Invaders Skyforce Horizontal scrolling Mario Contra How do they do that?
HorizontalScrolling Map Source: http://www.xnadevelopment.com/tutorials/scrollinga2dbackground/ScrollingA2DBackground.shtml
Horizontal scrolling map Create Sprite class Adding the following objects to the top of the Sprite class.  //The size of the Sprite public Rectangle Size; //Used to size the Sprite up or down from                // the original image public float Scale = 1.0f;
Horizontal scrolling map Modify the LoadContent method of the Sprite class //Load the texture using the Content Pipeline public void LoadContent(ContentManager 	theContentManager, string theAssetName)         {             mSpriteTexture = theContentManager.Load<Texture2D>(theAssetName);             Size = new Rectangle( 		0, 0, (int)(mSpriteTexture.Width * Scale), 		(int)(mSpriteTexture.Height * Scale));         }
Horizontal scrolling map Change the Draw method  	//Draw the sprite to the screen public void Draw(SpriteBatch theSpriteBatch)         {             theSpriteBatch.Draw( mSpriteTexture, Position,  new Rectangle(0, 0, SpriteTexture.Width, 		     mSpriteTexture.Height), Color.White, 0.0f, Vector2.Zero, Scale, 	       SpriteEffects.None, 0);         }
Horizontal scrolling map Adding some new Sprites to Game class         Sprite mBackgroundOne;         Sprite mBackgroundTwo;         Sprite mBackgroundThree;
Horizontal scrolling map Modify the Initialize method protected override void Initialize()        { // TODO: Add your initialization logic here             mBackgroundOne = new Sprite();             mBackgroundOne.Scale = 2.0f;             mBackgroundTwo = new Sprite();             mBackgroundTwo.Scale = 2.0f;             mBackgroundThree = new Sprite();             mBackgroundThree.Scale = 2.0f; base.Initialize();         }
Horizontal scrolling map Loading the content protected override void LoadContent()      { 	//… mBackgroundOne.LoadContent(this.Content,"Background01");             	mBackgroundOne.Position = new Vector2(0, 0); mBackgroundTwo.LoadContent(this.Content, Background02"); mBackgroundTwo.Position = new Vector2( 			mBackgroundOne.Position.X + 				mBackgroundOne.Size.Width, 0); mBackgroundThree.LoadContent(this.Content, “Background03"); 	mBackgroundThree.Position = new Vector2( 	mBackgroundTwo.Position.X + 	mBackgroundTwo.Size.Width, 0); }
Horizontal scrolling map Moving the background images across the screen in a snake like fashion Adding the code to Update method if (mBackgroundOne.Position.X < -mBackgroundOne.Size.Width) mBackgroundOne.Position.X = mBackgroundThree.Position.X + mBackgroundThree.Size.Width; if (mBackgroundTwo.Position.X < -mBackgroundTwo.Size.Width) mBackgroundTwo.Position.X = mBackgroundOne.Position.X + mBackgroundOne.Size.Width; if (mBackgroundThree.Position.X < -mBackgroundThree.Size.Width) mBackgroundThree.Position.X = mBackgroundTwo.Position.X + mBackgroundTwo.Size.Width;
Horizontal scrolling map Update the positions Vector2 aDirection = new Vector2(-1, 0);  Vector2 aSpeed = new Vector2(160, 0);  mBackgroundOne.Position += aDirection * aSpeed * 	(float)gameTime.ElapsedGameTime.TotalSeconds;  mBackgroundTwo.Position += aDirection * aSpeed * 	(float)gameTime.ElapsedGameTime.TotalSeconds;  mBackgroundThree.Position += aDirection * aSpeed * 	(float)gameTime.ElapsedGameTime.TotalSeconds;
Horizontal scrolling map Drawing the Sprites protected override  	void Draw(GameTime gameTime)        { graphics.GraphicsDevice.Clear( Color.CornflowerBlue); 	// TODO: Add your drawing code here 	spriteBatch.Begin(); 	mBackgroundOne.Draw(this.spriteBatch); 	mBackgroundTwo.Draw(this.spriteBatch); 	mBackgroundThree.Draw(this.spriteBatch); 	spriteBatch.End(); 	base.Draw(gameTime);         }
Vertical Scrolling Map
Vertical scrolling Can you think of some things you can change?  How hard would it be to make this scroll vertically?  Do you think you know what you might change?
2D Scrolling Map
[object Object]
Age of Wonder
StarCraft2D Scrolling Map ,[object Object]
Rhombus map,[object Object]
Square map - Viewport A rectangular region shown on your screen
Square map – How to do Load cell map textures protected override void LoadMapCells(int[,] matrixmap)        {             this.cells = new MapCell[MAP_SIZE_IN_CELL.Width,  					MAP_SIZE_IN_CELL.Height]; for (int i = 0; i < MAP_SIZE_IN_CELL.Width; i++)	{ for (int j = 0; j < MAP_SIZE_IN_CELL.Height; j++)	{                     Texture2D imgCell = 								Game.Content.Load<Texture2D>( 			SQUARE_MAP_IMG _PATH +  “BG0001"); // Create a new map cell this.cells[i, j] = new MapCell( 		imgCell, i * CELL_SIZE.Width, j * CELL_SIZE.Height);                 }             } }
Square map – How to do Define two points to draw the viewport // Get x-axis of the left top cell index of the viewport int i1 = (int)this._currentRootCoordinate.X / CELL_SIZE.Width; // Get y-axis of the left top cell index of the viewport int j1 = (int)this._currentRootCoordinate.Y / CELL_SIZE.Height; // Get x-axis of the right-bottom cell index of the viewport int i2 = (int)(this._currentRootCoordinate.X + Game.Window.ClientBounds.Width) / CELL_SIZE.Width;  // Get y-axis of the right-bottom cell index of the viewport int j2 = (int)(this._currentRootCoordinate.Y + Game.Window.ClientBounds.Height) / CELL_SIZE.Height;
Square map – How to do Completing the DrawBackGround method for (int i = i1; i <= i2; i++)	{ 	for (int j = j1; j <= j2; j++)	{                     try{ 		// calculating the coodinate on screen and drawing Rectangle recToDraw = new Rectangle((int)(                             this.cells[i, j].X - this._currentRootCoordinate.X),                             (int)(this.cells[i, j].Y-this._currentRootCoordinate.Y),                             CELL_SIZE.Width, CELL_SIZE.Height);                       spriteBatch.Draw(this.cells[i, j].Background,  					recToDraw, Color.White);                     } catch{ } 	} }
Rhombus map
Rhombus map Viewport What’s difference from the square map? Rhombus map How to draw a rhombus map? Find a position of 2D point
Rhombus map - Technique
Rhombus map – How to do Convert square coordinate to rhombus coordinate
Rhombus map – How to do // Abstract methods to convert coordinate public abstract Point PointToCell(Point p); public abstract Point CenterToCell(Point p); public abstract Point CellToPoint(Point cell); public abstract Point CellToCenter(Point cell);
More shape map Viewport What’s difference from? How to change coordinate? Find a position of 2D poin
Demo Rhombus map
Map Editor
Results (1)
Results (2)
Results (3)

More Related Content

What's hot

Plotting position and velocity
Plotting position and velocityPlotting position and velocity
Plotting position and velocityabidraza88
 
Geospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in PythonGeospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in PythonHalfdan Rump
 
Lecture 02 yasutaka furukawa - 3 d reconstruction with priors
Lecture 02   yasutaka furukawa - 3 d reconstruction with priorsLecture 02   yasutaka furukawa - 3 d reconstruction with priors
Lecture 02 yasutaka furukawa - 3 d reconstruction with priorsmustafa sarac
 
Flight trajectory recreation and playback system of aerial mission based on o...
Flight trajectory recreation and playback system of aerial mission based on o...Flight trajectory recreation and playback system of aerial mission based on o...
Flight trajectory recreation and playback system of aerial mission based on o...csandit
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talkshonjo2
 
DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013
DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013
DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013Patrick Raymond
 
Build Your Own 3D Scanner: Introduction
Build Your Own 3D Scanner: IntroductionBuild Your Own 3D Scanner: Introduction
Build Your Own 3D Scanner: IntroductionDouglas Lanman
 
Pengantar Structure from Motion Photogrammetry
Pengantar Structure from Motion PhotogrammetryPengantar Structure from Motion Photogrammetry
Pengantar Structure from Motion PhotogrammetryDany Laksono
 
Computer graphics
Computer graphics Computer graphics
Computer graphics shafiq sangi
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics labPriya Goyal
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Real world trigonometric applications
Real world trigonometric applicationsReal world trigonometric applications
Real world trigonometric applicationsMatt Kieltyka
 
Lecture Summary : Camera Projection
Lecture Summary : Camera Projection Lecture Summary : Camera Projection
Lecture Summary : Camera Projection 홍배 김
 

What's hot (19)

Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Plotting position and velocity
Plotting position and velocityPlotting position and velocity
Plotting position and velocity
 
Geospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in PythonGeospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in Python
 
Lecture 02 yasutaka furukawa - 3 d reconstruction with priors
Lecture 02   yasutaka furukawa - 3 d reconstruction with priorsLecture 02   yasutaka furukawa - 3 d reconstruction with priors
Lecture 02 yasutaka furukawa - 3 d reconstruction with priors
 
Flight trajectory recreation and playback system of aerial mission based on o...
Flight trajectory recreation and playback system of aerial mission based on o...Flight trajectory recreation and playback system of aerial mission based on o...
Flight trajectory recreation and playback system of aerial mission based on o...
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talks
 
DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013
DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013
DimEye Corp Presents Revolutionary VLS (Video Laser Scan) at SS IMMR 2013
 
Build Your Own 3D Scanner: Introduction
Build Your Own 3D Scanner: IntroductionBuild Your Own 3D Scanner: Introduction
Build Your Own 3D Scanner: Introduction
 
Julia Set
Julia SetJulia Set
Julia Set
 
Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
 
Pengantar Structure from Motion Photogrammetry
Pengantar Structure from Motion PhotogrammetryPengantar Structure from Motion Photogrammetry
Pengantar Structure from Motion Photogrammetry
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)
 
Real world trigonometric applications
Real world trigonometric applicationsReal world trigonometric applications
Real world trigonometric applications
 
Lecture Summary : Camera Projection
Lecture Summary : Camera Projection Lecture Summary : Camera Projection
Lecture Summary : Camera Projection
 

Similar to Maps

OpenLayers Feature Frenzy
OpenLayers Feature FrenzyOpenLayers Feature Frenzy
OpenLayers Feature FrenzyAndreas Hocevar
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
 
Opensource gis development - part 4
Opensource gis development - part 4Opensource gis development - part 4
Opensource gis development - part 4Andrea Antonello
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
 
HTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLHTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLThibaut Despoulain
 
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxasmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxfredharris32
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Creating an Uber Clone - Part VII.pdf
Creating an Uber Clone - Part VII.pdfCreating an Uber Clone - Part VII.pdf
Creating an Uber Clone - Part VII.pdfShaiAlmog1
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfarihantmobileselepun
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 
ITS 630 – Residency Project Circuit City was an American c.docx
ITS 630 – Residency Project Circuit City was an American c.docxITS 630 – Residency Project Circuit City was an American c.docx
ITS 630 – Residency Project Circuit City was an American c.docxvrickens
 
How to make an Earth with Space Background.pdf
How to make an Earth with Space Background.pdfHow to make an Earth with Space Background.pdf
How to make an Earth with Space Background.pdffitzmerl duron
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video gamedandylion13
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupMark Kilgard
 
Creating an Uber Clone - Part XXIII - Transcript.pdf
Creating an Uber Clone - Part XXIII - Transcript.pdfCreating an Uber Clone - Part XXIII - Transcript.pdf
Creating an Uber Clone - Part XXIII - Transcript.pdfShaiAlmog1
 
Developing Applications with Microsoft Virtual Earth
Developing Applications with Microsoft Virtual EarthDeveloping Applications with Microsoft Virtual Earth
Developing Applications with Microsoft Virtual Earthgoodfriday
 

Similar to Maps (20)

OpenLayers Feature Frenzy
OpenLayers Feature FrenzyOpenLayers Feature Frenzy
OpenLayers Feature Frenzy
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
Opensource gis development - part 4
Opensource gis development - part 4Opensource gis development - part 4
Opensource gis development - part 4
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
HTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLHTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGL
 
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxasmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Creating an Uber Clone - Part VII.pdf
Creating an Uber Clone - Part VII.pdfCreating an Uber Clone - Part VII.pdf
Creating an Uber Clone - Part VII.pdf
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
ITS 630 – Residency Project Circuit City was an American c.docx
ITS 630 – Residency Project Circuit City was an American c.docxITS 630 – Residency Project Circuit City was an American c.docx
ITS 630 – Residency Project Circuit City was an American c.docx
 
How to make an Earth with Space Background.pdf
How to make an Earth with Space Background.pdfHow to make an Earth with Space Background.pdf
How to make an Earth with Space Background.pdf
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping Setup
 
Creating an Uber Clone - Part XXIII - Transcript.pdf
Creating an Uber Clone - Part XXIII - Transcript.pdfCreating an Uber Clone - Part XXIII - Transcript.pdf
Creating an Uber Clone - Part XXIII - Transcript.pdf
 
Developing Applications with Microsoft Virtual Earth
Developing Applications with Microsoft Virtual EarthDeveloping Applications with Microsoft Virtual Earth
Developing Applications with Microsoft Virtual Earth
 
Player x 0 y ga.docx
Player x 0 y ga.docxPlayer x 0 y ga.docx
Player x 0 y ga.docx
 

Recently uploaded

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

Maps

  • 1. Maps Tran Minh Triet – Nguyen Khac Huy Faculty of Information Technology University of Science, VNU-HCM
  • 2. Texture and Frame Scrolling One image file for one frame Many files Slow loading Hard management One image file for one sprite Only One file Loading at once
  • 5. Scrolling map Vertical scrolling Chicken Invaders Skyforce Horizontal scrolling Mario Contra How do they do that?
  • 6. HorizontalScrolling Map Source: http://www.xnadevelopment.com/tutorials/scrollinga2dbackground/ScrollingA2DBackground.shtml
  • 7. Horizontal scrolling map Create Sprite class Adding the following objects to the top of the Sprite class. //The size of the Sprite public Rectangle Size; //Used to size the Sprite up or down from // the original image public float Scale = 1.0f;
  • 8. Horizontal scrolling map Modify the LoadContent method of the Sprite class //Load the texture using the Content Pipeline public void LoadContent(ContentManager theContentManager, string theAssetName) { mSpriteTexture = theContentManager.Load<Texture2D>(theAssetName); Size = new Rectangle( 0, 0, (int)(mSpriteTexture.Width * Scale), (int)(mSpriteTexture.Height * Scale)); }
  • 9. Horizontal scrolling map Change the Draw method //Draw the sprite to the screen public void Draw(SpriteBatch theSpriteBatch) { theSpriteBatch.Draw( mSpriteTexture, Position, new Rectangle(0, 0, SpriteTexture.Width, mSpriteTexture.Height), Color.White, 0.0f, Vector2.Zero, Scale, SpriteEffects.None, 0); }
  • 10. Horizontal scrolling map Adding some new Sprites to Game class Sprite mBackgroundOne; Sprite mBackgroundTwo; Sprite mBackgroundThree;
  • 11. Horizontal scrolling map Modify the Initialize method protected override void Initialize() { // TODO: Add your initialization logic here mBackgroundOne = new Sprite(); mBackgroundOne.Scale = 2.0f; mBackgroundTwo = new Sprite(); mBackgroundTwo.Scale = 2.0f; mBackgroundThree = new Sprite(); mBackgroundThree.Scale = 2.0f; base.Initialize(); }
  • 12. Horizontal scrolling map Loading the content protected override void LoadContent() { //… mBackgroundOne.LoadContent(this.Content,"Background01"); mBackgroundOne.Position = new Vector2(0, 0); mBackgroundTwo.LoadContent(this.Content, Background02"); mBackgroundTwo.Position = new Vector2( mBackgroundOne.Position.X + mBackgroundOne.Size.Width, 0); mBackgroundThree.LoadContent(this.Content, “Background03"); mBackgroundThree.Position = new Vector2( mBackgroundTwo.Position.X + mBackgroundTwo.Size.Width, 0); }
  • 13. Horizontal scrolling map Moving the background images across the screen in a snake like fashion Adding the code to Update method if (mBackgroundOne.Position.X < -mBackgroundOne.Size.Width) mBackgroundOne.Position.X = mBackgroundThree.Position.X + mBackgroundThree.Size.Width; if (mBackgroundTwo.Position.X < -mBackgroundTwo.Size.Width) mBackgroundTwo.Position.X = mBackgroundOne.Position.X + mBackgroundOne.Size.Width; if (mBackgroundThree.Position.X < -mBackgroundThree.Size.Width) mBackgroundThree.Position.X = mBackgroundTwo.Position.X + mBackgroundTwo.Size.Width;
  • 14. Horizontal scrolling map Update the positions Vector2 aDirection = new Vector2(-1, 0); Vector2 aSpeed = new Vector2(160, 0); mBackgroundOne.Position += aDirection * aSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; mBackgroundTwo.Position += aDirection * aSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; mBackgroundThree.Position += aDirection * aSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
  • 15. Horizontal scrolling map Drawing the Sprites protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear( Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); mBackgroundOne.Draw(this.spriteBatch); mBackgroundTwo.Draw(this.spriteBatch); mBackgroundThree.Draw(this.spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
  • 17. Vertical scrolling Can you think of some things you can change? How hard would it be to make this scroll vertically? Do you think you know what you might change?
  • 19.
  • 21.
  • 22.
  • 23. Square map - Viewport A rectangular region shown on your screen
  • 24. Square map – How to do Load cell map textures protected override void LoadMapCells(int[,] matrixmap) { this.cells = new MapCell[MAP_SIZE_IN_CELL.Width, MAP_SIZE_IN_CELL.Height]; for (int i = 0; i < MAP_SIZE_IN_CELL.Width; i++) { for (int j = 0; j < MAP_SIZE_IN_CELL.Height; j++) { Texture2D imgCell = Game.Content.Load<Texture2D>( SQUARE_MAP_IMG _PATH + “BG0001"); // Create a new map cell this.cells[i, j] = new MapCell( imgCell, i * CELL_SIZE.Width, j * CELL_SIZE.Height); } } }
  • 25. Square map – How to do Define two points to draw the viewport // Get x-axis of the left top cell index of the viewport int i1 = (int)this._currentRootCoordinate.X / CELL_SIZE.Width; // Get y-axis of the left top cell index of the viewport int j1 = (int)this._currentRootCoordinate.Y / CELL_SIZE.Height; // Get x-axis of the right-bottom cell index of the viewport int i2 = (int)(this._currentRootCoordinate.X + Game.Window.ClientBounds.Width) / CELL_SIZE.Width; // Get y-axis of the right-bottom cell index of the viewport int j2 = (int)(this._currentRootCoordinate.Y + Game.Window.ClientBounds.Height) / CELL_SIZE.Height;
  • 26. Square map – How to do Completing the DrawBackGround method for (int i = i1; i <= i2; i++) { for (int j = j1; j <= j2; j++) { try{ // calculating the coodinate on screen and drawing Rectangle recToDraw = new Rectangle((int)( this.cells[i, j].X - this._currentRootCoordinate.X), (int)(this.cells[i, j].Y-this._currentRootCoordinate.Y), CELL_SIZE.Width, CELL_SIZE.Height); spriteBatch.Draw(this.cells[i, j].Background, recToDraw, Color.White); } catch{ } } }
  • 28. Rhombus map Viewport What’s difference from the square map? Rhombus map How to draw a rhombus map? Find a position of 2D point
  • 29. Rhombus map - Technique
  • 30. Rhombus map – How to do Convert square coordinate to rhombus coordinate
  • 31. Rhombus map – How to do // Abstract methods to convert coordinate public abstract Point PointToCell(Point p); public abstract Point CenterToCell(Point p); public abstract Point CellToPoint(Point cell); public abstract Point CellToCenter(Point cell);
  • 32. More shape map Viewport What’s difference from? How to change coordinate? Find a position of 2D poin
  • 39. Q&A ?
  • 40. References Website http://www.xnadevelopment.com Ebook Learning XNA 3.0 – Aaron Reed

Editor's Notes

  1. The Size object will be used to store the height and width of the scaled sprite and the Scale object will be used to increase or decrease the size of the sprite from the original image. We are defaulting the Scale variable to 1.0 which tells the SpriteBatch to leave the image at its original size. Making Scale a larger number will increase the size of the sprite and a smaller number for scale will being to shrink the sprite.
  2. we will modify the LoadContent method to calculate and initialize the size of our Sprite
  3. Next, we want to use one of the many overrides of the SpriteBatch object to draw our image with our new Scale applied. We have added a whole lot of parameters to pass into the Draw method of the SpriteBatch, but the one we are tracking is “Scale”. This will tell the SpriteBatch object to increase or decrease the size of the sprite proportionally. Do a quick build now to make sure everything compiles. If you’re working off the source code for “Creating a 2D Sprite”, you should see the two sprites drawn to the screen.
  4. These Sprite objects will be used to move our background images across the screen.
  5. These Sprite objects will be used to move our background images across the screen. You can see we have created a new instance of each of our Sprite objects and adjusted the Scale for our background images.
  6. You can see that we load the content for each of the Sprite images we added for our backgrounds. We then position each of the images in a trail from left to right. The first image starts at 0,0 which is the top left corner of the screen and then each image is placed in a line after that. Scrolling backgrounds work by moving the background images across the screen in a snake like fashion. When an image moves all the way off the screen on the left, it is placed at the end of the snake tail so that the images can continually loop in that fashion giving you a seamless horizontally scrolling background.
  7. we need to both move the images and then check to see if the image has moved off the screen and re-position it at the end. We do that by modifying the Update method to look like this. You might expect to move the background images first, but this will actually begin to create gaps between the images. Often in game development, you have to be very aware in the order that you are doing things. If we move the images first, then check to see if they’ve moved off the screen, you have to remember that the player has never seen that happen yet because they haven’t been drawn to the screen yet! That doesn’t happen until Draw is called.
  8. So, instead, we first move images that have moved off the screen (and hopefully the player has seen this occur already) to the end of the trail of images. This is done by checking the Sprite’s current position and seeing if it’s moved further then it’s width off the screen. This means that the entire image is now out of the viewable area for the player. If this is true, then we move the image to the one it should be following. The first image follows the fifth, and then the fifth follows the fourth and so on and so on. Direction is just a -1 or 1 in the X and or Y direction. In our case, we want to move the sprites to the left, so we are decreasing in the X direction, so we use a negative one. We are not moving at all in the Y direction, so we leave that 0 for our Direction vector. Speed is how fast you want the sprite to move. We want the Sprite to move at a decent pace in the X direction and not at all for Y. You can increase or decrease the speed of the scrolling by increasing or decreasing this number. Now let’s look at the second part of the code, the movement.
  9. Finally, you multiply by time elapsed. This is done so that computers that are faster and with faster refresh rates see the same speed of scrolling that slower computers with slower refresh rates see. By default, the XNA framework tries to maintain this internally by keeping everything moving at a fixed time step, but it’s a good habit to get into. Ok, we’re re-positioning our background sprites as necessary and moving them along at a steady clip in the right direction. The only thing left to do it draw them to the screen.
  10. Introduce some games. How does the map look?
  11. A scene in Starcraft
  12. Drawing the viewport via the two points.Yep! Everthing done!  Trying to complete the code by yourself
  13. Something likes this
  14. How to draw a rhombus map?Change coordinate