• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
CheddarCheese

Using the SDL_gfx library?

25 posts in this topic

Hi there. I'm new to this forum, and I am also new to C++ SDL programming.

I hope I'm in the correct place to ask these questions.

Well, this is my problem. I require the SDL rotozoom function to rotate a ship for a game I am making at school. However, to have this function I need to include the SDL_gfx library. I have no clue how to do this.

This is on a school computer, so I cannot change operating systems/programs.

I am using Windows, and I am programming on Dev C++. Does anyone know of any way to use SDL_gfx under these conditions? If so, help would be greatly appreciated.

I have done multiple searches via Google to no avail.
1

Share this post


Link to post
Share on other sites
I have only seen posts claiming that Dev C++ is old, outdated, and to avoid it at all costs. Most people will recommend Visual C++. There is a free version and also if you are a student you can use Visual Studio 2010 Professional for free (google Microsoft Dreamspark).

I don't use Dev C++ (and I doubt anyone here will recommend it). Anyway, usually you add a .LIB file(s) to the linker dependencies. In Visual Studio this is under Project Properties -> Linker -> Input -> Additional Dependencies.

Have a look here, on their FAQ:
http://www.bloodshed.net/faq.html#9
1

Share this post


Link to post
Share on other sites
You can directly add the SDL_gfx source and headers to your project if you agree with the license terms. You can do it in the interim to get your project up and running. To retain full control of your executable, you should build SDL_gfx as a DLL and link to it.

I don't know how easy this is to do in Dev-C++, but it should be possible.
1

Share this post


Link to post
Share on other sites
Thanks for the replies.

@bbr125: Unfortunatly, our school network does not have this program, and if I did make it in Visual Studio, my teacher wouldn't be able to mark it.

What are the required files for adding SDL_gfx? I know how to link other types of SDL libraries, like SDL_ttf and SDL_mixer. I require a DLL, the lib and include folders and the linker.

Like I've said before, my knowledge doesn't extend past that since I am quite new to C++.

Do any of you know where I could find these files? So far, I've come across Linux setups, or setups without some files I seem to require.

Thanks!

[Edited by - CheddarCheese on December 15, 2010 2:55:08 PM]
1

Share this post


Link to post
Share on other sites
SDL_gfx Site.

Like rip-off said you could just add it to your project, but if you want to do it the formal way, then you will need to download the zip file from the above link. You then will need to build the project and link to the created dll file.

Also, if all this is just to have a rotated sprite image, then you could build your own rotated sprite sheet, that is have a sprite with each frame being a different rotation. Something like Image Magick could automate this process.

My last point is even if you get SDL_gfx up and running, you may have to examine if the rotozoomSurface function is fast enough for real time. If it is not, then you'd prolly be better off caching all the rotations which would basically be equivalent to the sprite sheet method, outlined above.

Edit: on my machine it appears fast enough for a small 32x32 pixel sprite, so maybe it will be for you too.

[Edited by - signal_ on December 15, 2010 5:04:50 PM]
1

Share this post


Link to post
Share on other sites
Thanks for all your information! I will try to link gfx shortly.

Well, I have been doing some researching, and it appears that using rotozoom in real time slows the computer down quite a bit. Now I have a feeling that my school computers defiantly won't be able to handle it. However, I will try it out first, I suppose.

Otherwise, could you give me a rough outline of how I would rotate the ship without using rotozoom? Code based, I mean.

See, my problem is that I don't only have one ship to rotate, there will be many different ships. This would require many different sprite sheets, and presumably a lot of code. I was trying to find the faster, more efficient method of doing this.
1

Share this post


Link to post
Share on other sites
Hi, sorry to have to bump this, but I still have no idea what to do.

The link that signal_ gave me seems to have a download called: "SDL_gfx-2.0.22.tar.gz"

What exactly am I supposed to do with this file to use SDL_gfx?
1

Share this post


Link to post
Share on other sites
Quote:
Original post by CheddarCheese
The link that signal_ gave me seems to have a download called: "SDL_gfx-2.0.22.tar.gz"

What exactly am I supposed to do with this file to use SDL_gfx?


You're on windows right? If you look at the link one below the tar.gz file, it is a .zip file. You should be familiar with how to open zip files. In case you'd like to open a tar.gz file you can use something like 7zip on Windows.

So just download the zip file and unzip it. All the files and compilation directions, license, etc. will be bundled there.

1

Share this post


Link to post
Share on other sites
Quote:
Original post by signal_
You're on windows right? If you look at the link one below the tar.gz file, it is a .zip file.
Just for another perspective I can't find a zip file anywhere on that website either. But the tar.gz file is easily decompressed with 7zip (as are almost every compressed file format) so it isn't really necessary.
Quote:
Otherwise, could you give me a rough outline of how I would rotate the ship without using rotozoom? Code based, I mean.
rotozoom will probably be fine for most use-cases if you use it the right way. When you start your level and first load your images you pre-rotate the image 360/X degrees where X is the number of rotations you want to perform on your image. So if X is 16 you would rotate your image by 22.5 degrees 16 times. When you want to draw your image just choose the closest pre-rotated image to the orientation you desire. So if you have a ship and it is supposed to be rotated rotation degrees away from 'normal' you would select the pre-rotated image using code somewhat like this:
// 'constants'
int max_rotations = 16;
float degrees_per_rotation = 360.0 / max_rotations;

float rotation = 56.0; // for example
int number_of_rotations = (int)(rotation / degrees_per_rotation);

// Check which rotation is closest and wrap around
// in case the angle of rotation is greater than 360.0 degrees
if (rotation-number_of_rotations*degrees_per_rotation < degrees_per_rotation/2) {
rotation_image_array[number_of_rotations%max_rotations];
} else {
rotation_image_array[(number_of_rotations+1)%max_rotations];
}
If rotozoom uses radians just replace 360 with 2*PI (and the rotation should be converted as well).
1

Share this post


Link to post
Share on other sites
Quote:
Original post by CheddarCheese
how I would rotate the ship without using rotozoom? Code based, I mean.
To answer this specific question as writen your options for rotating are to replicate what rotozoom does in your own code which probably won't be any faster, use rotozoom directly, or modify your program to use hardware acceleration (via OpenGL in your case most likely) to rorate the images for you.
1

Share this post


Link to post
Share on other sites
Quote:
Original post by nobodynews
Just for another perspective I can't find a zip file anywhere on that website either.

I have javascript turned off in my firefox. When I opened the link I gave in IE, where I have scripts enabled, it redirects to a different page apparently. This page does not show the link for the zip file that is shown when scripts are disabled. So that accounts for the confusion.

Here is the direct link to the zip file on the site.
0

Share this post


Link to post
Share on other sites
Thank you very much for all your help.

I have one last question. To install different libraries (eg. ttf, mixer) on Dev C++, I require a 'linker', a 'library' folder and an 'include' folder. However, in the gfx file, none of these are visible. Now, I'm pretty sure there's a way to install it but which I'm oblivious, since all the other libraries I installed were off the same site. Does anyone know how to install gfx into Dev C++ using those files?
0

Share this post


Link to post
Share on other sites
There is a website I found a while back that is great for learning the basics of SDL. He has programs specific to using each library with instructions on how to install all of them.

http://www.lazyfoo.net/SDL_tutorials/
0

Share this post


Link to post
Share on other sites
I would urge you to try to convince your school to adopt a better IDE. VS2008 is free and is much more standard than Bloodshed. Another one is Eclipse.

For SDL programming, you don't even need an IDE. My inclination is to say that if your teacher knows what they are doing, it shouldn't matter much what editor you use. They should be able to inspect your code with any text editor. No IDE is required.
0

Share this post


Link to post
Share on other sites
Hi,

Thanks for your suggestions, but I have checked the Lazy Foo website and they seem to have a variety of instructions for libraries, however, gfx is not one of them. I can't use other library instructions to install gfx, since I still don't have the linker and the files are different.

As for the lack of IDE suggestion, I am still a student trying to figure out how everything works. I'm quite new to C++, and I'm trying to do all this at home without my teacher around. Plus, since we are supposed to be making a game, he wants full end results. Unfortunately, this requires me to use Dev.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by CheddarCheese
Plus, since we are supposed to be making a game, he wants full end results. Unfortunately, this requires me to use Dev.
Why's that? Is it a project requirement that Dev-C++ be used? (You might have already mentioned this, but if so I must have missed it.)
0

Share this post


Link to post
Share on other sites
@ jyk: Well, our school computers seem to have Dev C++, and a very outdated version of Visual C++, and that's about it. My teacher decided that we use Dev.

C++ has a wide range of libraries, and lots of people are using separate libraries. So it order for me to install the libraries at school, I need to know how to install them to Dev C++.
0

Share this post


Link to post
Share on other sites
I didn't mean you should change your tools right now, but you should COMPLAIN to your school/teacher about having to use Dev C++. You have paid for them to train you. They are not doing you any favors by teaching you with obscure technology.

PS. google for 'how do I install SDL_gfx with Dev C++'
0

Share this post


Link to post
Share on other sites
I have already tried to google this topic, and came here after I drew a blank. I have found that there is a Devpak SDL_gfx that I can install, but it still seems to require additional steps to work.

Does anyone know of a step by step procedure? That would help immensely.
0

Share this post


Link to post
Share on other sites
If no one knows how to do so, I only need gfx for rotation. As I've heard, there's a way to rotate without rotozoom.

If I can't install gfx, is there anywhere that I can learn how to rotate without it?
0

Share this post


Link to post
Share on other sites
Yeah this has always been a pain of using SDL_GFX ( the fact you have to compile libs your self). Here is a site that has a built lib of SDL_GFX for windows
SDL_GFX binaries for windows

Then you can add them just as you did with SDL or SDL_TTF.

I know you can do it in dev cpp since i have done it my self.
0

Share this post


Link to post
Share on other sites
@ blackcloak, thanks a lot for your find! This is the exact file that I needed. Thanks!

Thanks everyone for all your help, it was very much appreciated.
0

Share this post


Link to post
Share on other sites
Now I just need to figure out how to use rotozoom. Any sort of tutorial site out there? I will attempt to search for one.
0

Share this post


Link to post
Share on other sites
SDL_Surface * NewRotatedSDLSurface = rotozoomSurfaceXY(_ImageToDraw->GetSDLSurface(), _ImageToDraw->GetRotation(),_ImageToDraw->GetScalingFactorX(),_ImageToDraw->GetScalingFactorY() ,_ImageToDraw->GetAntiAliased());

where
//_ImageToDraw->GetSDLSurface() is a SDL_Surface *
//_ImageToDraw->GetRotation() is a double
//_ImageToDraw->GetScalingFactorX() is a double
//ImageToDraw->GetScalingFactorY() is a double
//_ImageToDraw->GetAntiAliased()
//#define SMOOTHING_OFF 0
// #define SMOOTHING_ON 1

returns a new rotated / scaled SDL_Surface
then blit NewRotatedSDLSurface to your screen
0

Share this post


Link to post
Share on other sites
Well, I ran into a new problem. I'm not sure what's wrong, as it was completely fine the day before.

When I try to run my program a pop-up error appears and tells me "The program can't start because SDL_gfx.dll is missing from you computer."

Any ideas on this one?
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0