Been doing SDL tutorials [C++]

..to learn how to create 2D games

Page 1 of 1

9 Replies - 2930 Views - Last Post: 16 July 2009 - 05:07 AM Rate Topic: -----

#1 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Been doing SDL tutorials [C++]

Posted 09 July 2009 - 10:45 PM

Hi guys,

I mentioned a few days ago that I wanted to start learning SDL with C++.

I have been reading the tutorials at Lazy Foo's Productions, http://lazyfoo.net/S...rials/index.php, and I'm up to Lesson 6 already.

Lesson 1 through 5 have been great and I've been really going through them, not just copy and pasting. I even made my own pictures to work with instead of using the ones the author made.

My concern is that, even with only 5 tutorials done so far, it is a LOT to take in. Every time I move on to the next one, I have to reference the previous tutorial for the syntax of each SDL function.

At the current time, I am starting to catch on. I know I have to take care of my header files, the screen attributes, and create the surfaces I will be working with ( and set them to NULL ).


Do you feel that from practice and repetition I will eventually "learn" SDL and remember the syntax?

Made this for you guys...
Note its not just an image being blitted to the screen, the character is another surface with a magenta background that I color keyed out. (lol @ magenta in his eyes, looks like his eyes are bleeding)

Posted Image

This post has been edited by Xioshin: 09 July 2009 - 10:52 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Been doing SDL tutorials [C++]

#2 mono15591  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 406
  • Joined: 05-November 08

Re: Been doing SDL tutorials [C++]

Posted 10 July 2009 - 02:44 AM

Looks great :D

I just started SDL and actually I found the same site that your using.

now to your question
I would assume that if something is repeated enough that you will remember it, but for me it's hard to memorize if I don't understand what I'm memorizing. I would say understand what you're writing before you get too far in the lessons or else learning SDL might go slower than you initially hoped for.

I've done the first 4 tutorials and I found myself looking back too, but now I've stopped moving forward and all I'm doing is staring at the code so far and making sure I know what each line of code is doing

This post has been edited by mono15591: 10 July 2009 - 03:07 AM

Was This Post Helpful? 0
  • +
  • -

#3 Kanvus  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 452
  • Joined: 19-February 09

Re: Been doing SDL tutorials [C++]

Posted 10 July 2009 - 03:29 AM

you will know sdl after making 3 different things(yes, 3 exactly):

intro screen with music and start game/quit buttons u can click or select with enter and mouse keys

a screen with 1 fully operating sprite on it that can shoot something(ill post my hawkman one cus captain america is fame hog)

and lastly a ball that bounces off the walls forever, which is as simple as collision gets


are we allowed to upload? iono hawkman alone.rar
yes there are a few bugs with his dumb arrows but all in all its a good sprite. arrow keys to move and space to shoot


what you should keep in mind is that lazyfoo's functions are good but not sdl standard so they can be
changed as long as you know what the heck SDL_Rect and stuff means. imo the reason why you see
his tutorials as hard to remember is because he gives safe code, meaning for everything he tests to see if
it works and if it isnt, he exits out of the program. if you delete all the if's and just leave the actual init
functions, the code would look a whole lot shorter
Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 994
  • View blog
  • Posts: 4,158
  • Joined: 14-February 08

Re: Been doing SDL tutorials [C++]

Posted 10 July 2009 - 03:35 AM

View PostKanvus, on 10 Jul, 2009 - 02:29 AM, said:

you will know sdl after making 3 different things(yes, 3 exactly):

intro screen with music and start game/quit buttons u can click or select with enter and mouse keys

a screen with 1 fully operating sprite on it that can shoot something(ill post my hawkman one cus captain america is fame hog)

and lastly a ball that bounces off the walls forever, which is as simple as collision gets


Not sure I agree with you there, Kanvus.

What you mentioned is the real basics of a game, as in things you couldn't do without. Making fluid gameplay and good collision detection takes some experience and time.

@Xioshin
Don't rush things, there is a lot to learn.
Was This Post Helpful? 0
  • +
  • -

#5 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: Been doing SDL tutorials [C++]

Posted 10 July 2009 - 04:35 AM

Great replies from all of you. After work I will check out your upload, but like stayscrisp said, there IS a lot to learn and I realize this; I don't want to rush it.

Having a blast so far, though!!
Was This Post Helpful? 0
  • +
  • -

#6 Kanvus  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 452
  • Joined: 19-February 09

Re: Been doing SDL tutorials [C++]

Posted 11 July 2009 - 12:19 AM

its 2d for gods sake. the reason i didnt say it was a whole lot is because the last 62% of lazyfoo's tutorials applies to all game programming and not just sdl. you could learn the same thing with almost every library especially xna. i think we can agree it won't take over 2 months to go through sdl 14 tutorials by someone who writes them so well. if we were talking about nehe then yes, it takes a lifetime per tutorial cus theyre long
Was This Post Helpful? 0
  • +
  • -

#7 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 994
  • View blog
  • Posts: 4,158
  • Joined: 14-February 08

Re: Been doing SDL tutorials [C++]

Posted 11 July 2009 - 03:48 AM

Going through a tutorial is not the same as learning it, and you didn't say anything about time needed you said that there was only a few things you needed to know.

Quote

you will know sdl after making 3 different things(yes, 3 exactly):


2D games aren't that easy, saying they are is just not true. The jump from 2D to 3D is quite big but what you learned in 2D will almost definitely benefit your 3D games.

So I stand by what I said, take it slow, try things out, don't just copy the tutorials, try and implement things yourself using the tutorials as a step in the right direction.

This post has been edited by stayscrisp: 11 July 2009 - 03:49 AM

Was This Post Helpful? 0
  • +
  • -

#8 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 113
  • View blog
  • Posts: 688
  • Joined: 16-February 09

Re: Been doing SDL tutorials [C++]

Posted 12 July 2009 - 08:04 PM

I think using SFML (http://sfml-dev.org) would be more beneficial as it maintains OOP structure and this may help you in the future.
Was This Post Helpful? 0
  • +
  • -

#9 Fib  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 161
  • View blog
  • Posts: 554
  • Joined: 12-March 09

Re: Been doing SDL tutorials [C++]

Posted 15 July 2009 - 07:58 AM

I think once you finish 2 or 3 complete games, whether they are good or not, you will get the hang of it. For me, learning by repitition is the best way. I'm sure it's the same for a lot of people. So after you've completed a couple games, you will probably know a lot of the functions from memory, or if not, then you will surely be able to find and implement the function very quickly. Don't worry, you will get the hang of it as long as you keep doing it.
Was This Post Helpful? 1
  • +
  • -

#10 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1376
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: Been doing SDL tutorials [C++]

Posted 16 July 2009 - 05:07 AM

Rather than just going through the tutorials one after the other, try just jumping straight in.

Plan your logic. In your main game loop, draw and update the screen, and handle events.
As you go through, reference the tutorials that you feel you need.

The way I started was by taking a picture of mario, and moving it with the cursor keys.

Also, one thing you might find useful (which I haven't seen in the lazy foo' tuts) is SDL_EnableKeyRepeat(int delay, int interval) which allows a player to hold the key instead of continuously pressing it.

Example,

main {
	init the screen // look at the start of main() in this tut: http://lazyfoo.net/SDL_tutorials/lesson02/index.php
	while(player is alive) {
		draw the background // same tut as last time, look how to blit images to the screen
		draw the player 
		if(poll event) {
			handle key events // http://lazyfoo.net/SDL_tutorials/lesson08/index.php
		}
		is the player dead?
		break;
	}
}


Good luck. :)

edit,
Also, you could try following the code behind pong, which was one of the first things I wrote with SDL.
http://www.dreaminco...dex.php?cat=164 (ignore the first one or two posts, they're more recent topics)

This post has been edited by gabehabe: 16 July 2009 - 05:09 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1