|
News
Latest Updates
Recent Comments
Most Popular Downloads
Projects
Blob Wars : Blob And Conquer
Blob Wars : Metal Blob Solid
JGameLaunch
The Legend of Edgar
Project: Starfighter
Random Name Generator
Random Shooter
TANX Squadron
Virus Killer
XMAME GUI
Older Files
List of Older Downloads
Medals
Main & Signup
Recently Awarded
Player List
Games
Blob Wars : Metal Blob Solid Legend of Edgar Virus Killer
Online Manuals
Blob Wars : Blob And Conquer
Blob Wars : Metal Blob Solid
Project: Starfighter
The Legend of Edgar
Virus Killer
LBP Beta Code!
Beta Code Giveaway!
Game Tutorials
Overview and Comments
Basic Series
1.01 - Opening a Window
1.02 - Graphics
1.03 - Sound
1.04 - Input and Movement
1.05 - Simple Shooter Pt. 1
1.06 - Simple Shooter Pt. 2
1.07 - Simple Shooter Pt. 3
1.08 - Sprites and Animation
1.09 - Starfields
1.10 - A Basic Game
Intermediate Series
2.01 - Displaying a Tile Based Map
2.02 - Scrolling a Tile Based Map
2.03 - A Tile Based Map Editor
2.04 - Tile Based Map Collision Detection
2.05 - Advanced Animation
Articles
Making of TANX Squadron
Making of Starfighter
Making of Metal Blob Solid
Making of Blob And Conquer
Blob Wars Review #1
Blob Wars Review #2
Blob Wars Review #3
Blob And Conquer Review #1
Interview with Stephen J Sweeney
Gallery
3D Renders
Help and FAQs
Installation and Licensing Help
About
Contact Information
THE HONOUR OF THE KNIGHTS
The new Creative Commons Licensed
novel from Stephen J Sweeney
Visit the official website,
www.battleforthesolarsystem.com
to start reading online!
Buy Now! from Amazon.co.uk
Buy Now! from Book Depository
|
Comments for SDL Tutorial 13 (8)
TimJuly 21st, 2009 at 21:13Hi Steve,
I hope I'm addressing to the right person. Do you have an email I can contact you with? I'm trying to implement multi-layer maps to your Tiled Based Map Editor tutorial. By the way, is there a reason to use C over C++ as I see your tuts are in C?
I've modified your existing code to try to implement multi-layer for the map editor and I want to know if you have the time to look at it and point me in the right directions. My email is t1m917@hotmail.com I'm new to learning game programming and your tutorials are excellent. Thanks in advance. SteveJuly 22nd, 2009 at 08:13Tim - If you just want to create a scrollable background, then you don't need to add an extra layer to the map array. You need only draw a background as normal, using SDL_BlitSurface, and choose the appropriate portions to draw.
If you're trying to make a massive unique background, like that of the foreground map, then you could always create a whole new array to serve that purpose. You could then draw that array first and then layer the other tile set on top of it. TimJuly 22nd, 2009 at 15:25Steve,
Thanks for the response. What I really wanted to do is to be able to draw multiple images one on top of another in the editor. Currently, your editor tutorial allows only the ability to draw a tile image at location x,y and when you want to draw another image in that same location x,y it replaces the old tile image that was there before.
If I understood right, you mean all I have to do is create separate map files and draw each map files in turns going from the the first to the last? SteveJuly 23rd, 2009 at 13:01Ah, okay; I understand what you're wanting to do.
What you'll want to do is add extra dimension to the array, for the current layer.
int tile[MAX_MAP_Y][MAX_MAP_X][LAYER]
You could have 2 or 3 layers and then, when you loop around them, draw them from back to front. You could allocate some extra keys to hide or show the layers in your drawing code (such as F1, F2 and F3). RikJuly 23rd, 2009 at 13:29Actually, that should be
int tile[LAYER][MAX_MAP_Y][MAX_MAP_X]
So you can do something like
for (layer=0;layer<MAX_LAYERS;layer++) { for (y=0;y<MAX_MAP_Y;y++) { for (x=0;x<MAX_MAP_X;x++) { drawTile(tile[layer][y][x]); } } } TimJuly 25th, 2009 at 07:48Steve and Rik,
Thank you guys for the advice and the code snippet Rik. I understand what I need to do now to have multiple layer of the tile map. Creating it is fine now thanks to the both of you but the the next thing I want to know is how to have something in front of a player. With the current method I could draw images on top of another. What I want to do next is z-depth. What if I want a player to look like it's behind an object on layer 3 while player is in layer 2 and objects that are behind the player is in layer one. In the Tile Based Map Collision Detection tutorial, everything I created with the multilayer map still looks like it's behind the player although the the images I created one on top of another looks fine.
Do I have to:
1. Draw the first layer of the map to the buffer first? (that being layer 1) 2. Draw the player next? (that being layer 2) 3. Draw the last layer? (that being layer 3" 4. Do key checks, check player movements, check map inbound, etc.... 5. Blit everything from the buffer to the screen at once?
Is this the right approach or should I approach it differently?
Thanks in advance. SteveJuly 25th, 2009 at 17:45Yes, that is what you'll want to do - draw the background layers of the map first, then the player and all the other objects, and then the foreground layer.
You can do things like make it look as though the player is walking through long grass, moving behind a pillar, etc. obsrvJanuary 15th, 2010 at 02:26I can't compile it. I get this Linker Errors:
a lot of: [Linker Error] undefined reference to `SDL_SetError' a few: [Linker Error] undefined reference to `SDL_CreateRGBSurface'
|