Are bounding box and circle collisions just not cutting it? Well, now we’re going to dive right down into pixel precision!
» Read more: SDL Per Pixel Collision
Archive for the ‘SDL Tutorials’ category
SDL Per Pixel Collision
January 28th, 2010SDL Net – Part 1 (User Tutorial)
January 7th, 2010The following user tutorial was created by Kahshoo-heem, for the purpose of expanding upon the SDLTutorials.com series, and expounding upon the use of SDL. This tutorial, though not purposely a part of the SDLTutorials.com or created for the series, may be a branch or addition to the series. Please read notes by the author for any additional code and/or framework used by the author. If you wish to submit your own tutorial to this site, please visit the “User Tutorials” page.
In this tutorial, I will show you a simple c++ library to add network resources to your game.
Firstly, we have to add the SDL_net headers and libraries to your desktop environment. If you are using a linux distro like Ubuntu, it is enough to download the libsdl-netx.x-dev package from the repositories. If not, the process is analogous of including sdl mixer, image, etc, better explained by Tim’s Tutorials.
Don’t forget, as well, to set the linker options in your IDE, adding the SDL_net library.
SDL Collision Events
August 4th, 2009Finally! The next tutorial. This is the 2nd part to the SDL Collision tutorial. We’ll be looking at collision events, the part we left unfinished in the last tutorial. To refresh your memory, a collision event is an event that is stored in queue after a collision has taken place. Take our recent shooter contest for an example. When the player fires a bullet, the bullet flies through the air, and then hits the enemy. The moment the bullet and the enemy collide, an event is triggered and stored in the queue. After all movement has taken place, the queue is iterated through, and events can appropriately respond.
» Read more: SDL Collision Events
SDL Collision
October 31st, 2008If you are still trying to catch your breath from the last tutorial, I recommend you sit down, because this next tutorial won’t be any nicer. In this tutorial we will be extending our entity class a bit further with collisions, and movement. So hold on to your pants, and get ready.
SDL Scale Surface
July 15th, 2008The following user tutorial was created by Mod J., for the purpose of expanding upon the SDLTutorials.com series, and expounding upon the use of SDL. This tutorial, though not purposely a part of the SDLTutorials.com or created for the series, may be a branch or addition to the series. Please read notes by the author for any additional code and/or framework used by the author. If you wish to submit your own tutorial to this site, please visit the “User Tutorials” page.
Today we’re going to learn something about extending the capabilities of SDL_Surfaces. If we take a look at OpenGL, what happens when we load a Surface and we render it specifying a width and height bigger than the Surface’s original width and height? It gets automatically scaled (unless you specify you want to be repeated). In SDL there is no automatic way of scaling surfaces, so we’re going to make a (relatively simple) routine that does the trick.
SDL Sokoban (User Tutorial)
June 9th, 2008The following user tutorial was created by Arseniy B., for the purpose of expanding upon the SDLTutorials.com series, and expounding upon the use of SDL. This tutorial, though not purposely a part of the SDLTutorials.com or created for the series, may be a branch or addition to the series. Please read notes by the author for any additional code and/or framework used by the author. If you wish to submit your own tutorial to this site, please visit the “User Tutorials” page.
IMPORTANT NOTE: I DON’T NAME SURFACES LIKE TIM DOES. WHEN HE CALLS IT Surf_Display, MINE IS SIMPLY SurfDisplay, WITHOUT THE UNDERSCORE. MAKE SURE YOU KNOW THIS, AND ADAPT TO THE TUTORIAL ACCORDINGLY. ALSO, WHEN I MAKE PROTOTYPES IN CLASS DEFINITIONS, THE ONLY STUFF I WRITE IN THE PARAMETERS AREA (I.E. THE PARENTHESES) IS THE TYPE OF DATA TAKEN, NOT THE NAME OF THE DATA TAKEN. THAT NAME IS ONLY IN THE ACTUAL FUNCTION DEFINITION, AT LEAST FOR ME.
This tutorial is based on everything you’ve learned by now, if you’ve been following the tutorials in order and have just finished the Maps tutorial. Get ready to get a glimpse of creating your first real game! (Not counting that fabulous tic-tac-toe.) Similarly, the code this comes from is from all the code you’ve written up to the Maps tutorial, and including it. It would be wise to make a new Code::Blocks project (or a new DevC++ project, or whatever), because this tutorial will delve a different way for a bit, and you don’t want to mess up your existing code for the upcoming Collision Detection tutorial. Speaking of that, this tutorial will introduce you to very simple collision detection, on a tile-based board.
SDL SoundBank
April 11th, 2008In this side tutorial we are going to be adding a soundbank that will load all of our sounds, and then we call play them via an ID whenever we want. This tutorial will only deal with sounds, not music, and mind you it’s a very basic tutorial that gets the job done. There is much that can be added to this class, for channels, groups and such, but we’re dealing with basics here. We’ll base this tutorial off of my SDL Events tutorial. So use those project files if you need something to work off of.
The first thing you need to do is download SDL mixer from the SDL website. It’s also included in the SDL library I provide on my website. Be sure to put the include files in the same directory as your SDL include files, and your lib files in the same directory as your SDL lib files to make things easier.
SDL Maps
March 15th, 2008As I stated in the last lesson, we’re going to be looking at making a Map class that will be tile based. In addition to the maps, we’ll be creating Areas that enhouse many Maps. While we could create one giant map, it’s far easier to manage many smaller maps, and also opens the possibility of tiling maps as well. By the way, head on over to the SDL Image tutorial if you haven’t already done so, we will be making the switch over to SDL Image and stop using SDL_LoadBMP. No more chatter, lets get started.
SDL Image
March 14th, 2008This side tutorial is rather simple, short, and sweet. I am going to show you how to stop using those pesky bitmap (BMP) files that are too big and don’t support alpha transparency, and to start using other file formats for you surfaces (I personally like PNG). If you have not read my SDL Coordinates and Bliting tutorial, I encourage you to do so now. We will be building off of that tutorial, modifying the OnLoad function of the CSurface class.
The first thing you need to do is download SDL_image, the latest version, from the main SDL website. You can also download this library from the “Libraries” section of this website, under SDL. If you don’t want to worry about finding all these libraries, the SDL package I provide is good for most SDL beginners, as it provides SDL_image, and some other useful libraries. Be sure to put the include files in the same directory as your SDL include files, and your lib files in the same directory as your SDL lib files to make things easier.
SDL Entities
February 22nd, 2008In this new tutorial, as I had promised before, we are going to take our hand at creating entities. Entities, for all gaming purposes, are anything that can be interacted with in any way, shape, or form. Some examples might be a monster or a treasure chest that you can open. In this sense, practically everything within the game that moves is an Entity. A rock that is part of a map, which never moves, is not an entity. But if you wanted that rock to move for whatever reason, then we’d make it an Entity. This tutorial will be split into 3 different tutorials. The first, this one you are reading, will deal with a basic Entity class structure. The next tutorial will veer off slightly to build a Map class via a tileset. Then, the last tutorial, which is what a lot of people have trouble with, will deal with Entity to Map collision, and Entity to Entity Collision.