Added: 2 years ago
From: LusikkaMage
Views: 18,697
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (83)

Sign In or Sign Up now to post a comment!
  • Confusing!

  • @Jackson9797 Hey there-- I'm going to be working on new beginner tutorials that are clearer and easier to follow. Because you find this tutorial confusing, you could be of immense help to me in ensuring that the new tutorial is NOT confusing.

    Could you explain to me what you're having difficulty with?

  • The opening theme to this tutorial is now stuck in my head >.< apart from that, I love your tutorial series far too much.

  • my window opens and then stays open for a few seconds with a white screen rather than black and will then close by itself a few seconds later, iv gone over the code and have the same thing word for word... any ideas?

  • I get a few errors...

    `SDL_INIT_EVERYTHING' undeclared (first use this function),

    SDL/SDL.h: No such file or directory, and more.

    14 errors. Help?

  • Comment removed

  • Btw, nice tutorials.. It's really user friendly :) (Y)

  • 3:30, or put it in the %homedir%/Windows/System32 and/or %homedir%/Windows/SysWOW64 folder

  • @3:18 Unless you have Linux :3

  • So, I have a System.h file that has exactly what you put on screen at 3:00.

    For whatever reason, g++ (compiling from netbeans btw) gives me an undefined reference error. It seems to be caused by these, called in main.cpp:

    System system;

    system.Setup();

    help?

  • Comment removed

  • Comment removed

  • @videogamefanatic89 Now I get a segmentation fault caused by SDL_Flip(buffer);. any ideas?

  • i just get this error ld.exe||cannot find -lSDL_image|

    ||=== Build finished: 1 errors, 0 warnings ===|

  • @TompanX Download the SDL_image lib..

    libsdl(DOT)org/projects/SDL_im­age/release/SDL_image-1.2.10. zip

    Remove spaces.

  • when I build it it just ses "pikcin - Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping...

    Nothing to be done." what should I do?

  • @TompanX What IDE are you using? What Operating System?

  • @LusikkaMage Just fixed some guy Im subbed to just made a video about how to fix it XD

  • is it just me or is this really really laggy? cos i try dragging the window around and it just freezes up. i'm thinking it's probably to do with having SDL_Flip in the loop. i'm using the g++ compiler on ubuntu

  • I don't know why the code given in the tutorial works for you, but I had to make a few tweaks. First, If I don't initialize the event before the loop (with the poll event function), the program will fail to run properly (maybe just cause i use visual studio, but idk). Second, after fixing that, leaving everything else as is, the program pops up as a full screen. to counter this, you can change your if statement to check for a true variable instead of a false one. Hope this helps :p.

  • does sdl do double buffering for you?

  • You may want to check out the new Allegro 5. It is a HUGE leap forward from the Allegro 4 series and is an entirely new beast. It's a really nice library now. I liked it before, but now it is SO much better and modern, event driven and not as much of a CPU hog, has support for native interfaces, 3D acceleration, you name it... I like it MUCH better than SDL. It's just as portable as SDL as well, only it has sound, music, JPG, PNG, OGG etc... support built in.

  • Is it legitimate to use a function to free the SDL surfaces and to quit SDL, at the end of main? for example: void sdlCleanup() { SDL_FreeSurface(buffer); SDL_FreeSurface(screen); SDL_Quit(); } Also, the memory leaks you mention in one of your videos. Is the memory still allocated after you restart your OS? or would it then be freed? If i create an array of structures (for example: mystruct myarray[10][5];) would this memory need freeing? most greatfull for any help. great tutorial
  • @4Teddybears If the surfaces are in-scope when the function is called, then yes. However, if you're not passing the surfaces to the function, it won't know where it is (unless the surfaces are global, which is a really bad idea).

    What I do is I have an "ImageManager" class, which stores an array of surfaces inside. When the class hits the destructor, it destroys all the surfaces.

    Only dynamically allocated memory needs freeing.

  • @LusikkaMage

    Thanks. My Surfaces are global. Why is this such a bad idea?

  • @4Teddybears Google, "Why global variables are bad".

    It's part of the design: It leads to spaghetti code and destroys structure.

  • amazing toturial this just explains everything, but hey, is c++ one of the best langauges to start with, cause java and flash are great for gaming too?, so is c++ best?

  • @razorbunny555 C++ is still used to make professional games today, but it is by no means the best language to learn for hobbyist programming. As a computer-science major in college, it's what we used, and what I had been learning for years.

  • @LusikkaMage java looks alot like c++, is this true?

  • @razorbunny555 They have a lot of similarities; the syntax is similar and they're both object oriented. So in a way, yes. But C++, Java, and C# all have their differences.

  • @LusikkaMage Thanks :).

  • @razorbunny555

    can't believe your eyes eh?

  • @4Teddybears still wondering ;).

  • @razorbunny555 It depends on what you want to do. If you wish to create web based games you may prefer Java (or even learning to use Flash), but for PC games, C++ is common. If you learn C++ you can easily pick up C#, Java and many others. C# and Java are a lot like C++ and based on it so it's the best place to start and commercial games generally do use C++.

  • @NeilRoy65 i'm a great java programmer,, though i am getting 14 years old soon and i am learning java's for 2 years now, soo yeah, i might do java's for my work later on. it's the only thing i like. (other coding languages like c++ too!)

  • A good book to buy to get started is "Beginning C++ Through Game Programming". I picked this up through Amazon.ca, but I already have a good grasp of C programming (and I am still hesitant to use classes! lol) but this book made classes especially a lot easier to comprehend. You don't need to use them for allegro programming though, I've created a full game (Deluxe Pacman) with Allegro and mostly just C code with a little C++ flexibility. Just not classes. ;)

  • fffffuuuuuuuuuuuu-

  • Is anyone using Visual Studio 2010? I get a runtime error when i create the SDL_Event variable and the compiler will complain that i am using an unitialized variable and i am copying it from the tutorial. I tried setting it eqaul to NULL but then its a compiler error. how do i initialize the event variable or is there another way to do this?

  • gonna try and follow ur tutorials , find some good but they always stopped before i got to learn enough.

  • I have done The allegro version but im getting a [Build Error] [example.exe ] Error 1 please help!! :) I thing it has somthing to do with missing Dll file becuse I dont have enyone in my folder :( I want to run my exe!! :P

  • I think there is an error in the else particularly the SDL_SetVideoMove. I got a compiler error but when I changed it to SDL_SetVideoMode it worked fine. Thanks for the tutorial btw. I really wanna be a game programmer and this is a big help for me to start.

  • i think you messed up on the code a bit :P

    at 1:42 u have fullscreen set to false and you made it so that it will go to fullscreen mode when fullscreen is false and windowed mode when fullscreen is true.

    i think this should explain why people are just seeing black screens and not a window like it is in the video

    again I'm watching these videos to learn so you might know something that i don't and you did that on purpose :P

    great lessons btw

  • Wait, when I compile, it's just a big black screen with only my cursor, is that supposed to happen? Like I don't have a head bar like you do, it's just a black screen and all I could do is move my cursor. I have to hit the windows key to exit the program. Also is it a necessity to memorize all that code :P

  • @Soap360 Yes, at this point it's supposed to be a blank window.

    No, you don't generally memorize the code. This is the point of Object-Oriented Programming. Put it in a class for you to reuse in all of your programs.

  • @Soap360 Yeah, You've probably figured it out by now, but for anyone else, It's the if statement which is reversed.

    Obviously If fullscreen is false you dont want The SDL_FULLSCREEN part.

    Cut that and put it after else instead.

  • What's the advantage of using a class instead of a function? Except for that you can protect some values..?

  • @ThePearI I think my comment was a bit vague there... What I mean is "What is the advantage of having a class for initializing?" I just have a function.

  • So this has been bugging me for a while but i have to ask; why do some console projects use int main (int argc, char *args[]) while other console apps just use void main(), what's the difference?

  • @Grenadiac111 The argc/args stuff is a throwback to when we used to boot programs from the prompt, and would throw it flags (or, arguments). They're not really used much anymore, and I don't really like using them in my prompt programs either.

    Many IDEs require main to not be void, though, and some libraries (SDL...) require having the args/argv in main's header.

  • @LusikkaMage Thanks alot that would explain why SDL wouldn't complie without it, but my engine would. P.s. Great vids.

  • I'm assuming that .Done() is a function we have to create ourselves? Otherwise wouldn't that give us an error if it's not a part of SDL that is..?

  • @ThePearI It is a function we write ourselves.

  • how come my SDL_Init( SDL_INIT_EVERYTHING) is getting an error... I did everything right ;_;

  • @dabeatmaster123 What compile error are you getting?

  • @LusikkaMage It says 'SDL_Init' undeclared[first use this function]

  • i had to use somethin different on linker options but i am on ubuntu

  • @whiteninjastudios Are you just compiling via the command line?

  • @LusikkaMage no i am using codeblocks ide on my ubuntu and gentoo machine

  • I deleted the else statement because it gave my compiler build errors.

    main.cpp:16: error: SDL_SetVIdeoMode was not declared in this scope

    So I deleted line 15 & 16 and got rid of the "| SDL_FULLSCREEN" and it worked inside of a window.

  • This reminds me of metal gear solid 2 when you had to take pictures of metal gear.

  • As console program typing in the stuff after SDL_Event makes the program run as a unresposive blackscreen without any X. Tried running as a win32 app instead but it just gave me a bunch of 'unresolved external symbol' errors

  • Nevermind the win32 stuff forgot to set dependencies, it now acts just like the console version, goes black and requires a process shutdown.

  • i've never seen a programming tutorial more fun or comprehensible than this serie

  • For some reason when i type

    "SDL_Event event;"

    "while (event.type != SDL_QUIT)"  and,

    "SDL_PollEvent (&event)"

    the word "event" always apears in blue and i get an error.

    does it mean this word is reserved for something els?, if so, which words should i leave as "event" and which should i change?

  • Getting comfortable with classes will make everything much clearer, but yes you can change it to anything you want as long as you remember what you changed it to.

  • having some trouble here, got to the end and have this error message "Error 1 fatal error C1083: Cannot open include file: 'SDL/SDL.h': No such file or directory..." any ideas on how to fix this?

  • Looks like you don't have the SDL library set up correctly. Make sure all the files are in the Include and Lib folders, and make sure the linker is set up.

  • You had the full screen check backwards :p

    it should be, you set it to fullscreen if the bool was false. if( fullscreen == false )  { buffer = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );} else { buffer = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE | SDL_FULLSCREEN );}

  • While I was preaching about how you got it backwards I got something backwards...

    "You set it to fullscreen if the bool was false, it should be:" is what I meant to say.

  • At 1:48 in your else block,

    'buffer = SDL_SetVideoMove( 640, 480, 32, SDL_SWSURFACE );'

    Supposed to be SDL_SetVideoMode* right?

    Fixed my compiler error.

  • Love the music!

  • I am not actually a SDL expert, but i believe if you use:

    SDL_Init(SDL_INIT_EVERYTHING);

    atexit(SDL_QUIT);

    //the code goes here

    it would be better than:

    SDL_Init(SDL_INIT_EVERYTHING);

    // the code goes here

    SDL_Quit();

    because, there's a benefit of doing it this way, because if you detect an error somewhere, you can use the exit function and not worry about cleaning SDL, as the program will do it for you.

  • In C you could do that, in C++ you'd just use a destructor instead.

    int main(int argc, char *argv[])

    { Game objGame; // Initiates

    } // Out of scope: destructor called.

  • when ever I go to build my code (compile) I'm using codeblocks by the way... iI click build and it gives me a box saying yould you like to build this project since it has not been built yet.. I clikc "Yes" and the box pops up again! it also gives me an error saying "Linking Stage Skippied (build target has no objective fiels to link) Nothing to be done. Any idea what I forgot to do?

  • In Code::Blocks you have to add the files to the project, if you didn't already. In case you did, right-click the C++ file(s) and select 'Properties'. Then click on the 'Build' tab and check 'Compile file' and 'Link file'. Normally, this is done automatically once you add the file to the project.

  • Wow, I've never used Double Buffering, I was wondering how to fix that flickering too, thanks =D

  • Are you using SDL and getting flickering? o.0

  • It's better to put your DLL's in the system32 folder.

  • only if you're confident you'll only ever use that 1 version of SDL, otherwise later on it'll mess you up.

  • Not nessecerally if your going to distribute your game youll need the DLL's in the game folder to distribute - worst thing ever when youve jsut installed a game and then BANG missing DLL :(

  • I always keep my dlls in the specific project's folder.

    This way, I never forget to distribute them with the project. ^^;

    Also, it checks the local folder before system 32, which would be good if the person had an outdated dll in their system folder.

  • some people use linux

  • On Linux you're still able to use Code::Blocks, although there are other IDEs like Anjuta and KDevelop. The hardcore option, which is also available on Windows through MinGW, is to use Makefiles.

    Just check lazyfoo for information about how to install SDL for Linux.

  • SDLdotDLL ... I like how fast you say that :)

  • o.O

    *sexily* SDL-dot-DLL ;o

  • Just what I needed thank you (=

Loading...
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more