Beginner's Guide to Game Programming

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Beginner's Guide to Game Programming

Post by Moosader »

My latest tutorial I've been working on has been entitled
"Beginner's Guide to Game Programming: A Problem-Solving Approach"
(phew, sounds like a book title x_x)
And I need some peer reviews before I get into the videos.
Right now it's incomplete and has stuff highlighted that I need to update (like on page 30 I don't remember if I need a copy constructor for the struct I wrote, lulz), but will hopefully be done soon (hopefully my wrist stops hurting so bad so I can type better)

What is it?
Episode 1: Makin' Pickin' Sticks is... a guide on making Pickin' Sticks.
The guide assumes you know your C++, and covers newb topics in both Allegro and SDL, such as graphics, keyboard input, sound, text, timers, and then towards the end goes into the more general things like random numbers, bounding-box collision detection, design docs, and super-basic game structure.

The goal of it is to teach people all the building blocks they need to actually write the game, but not just record myself code it start to finish... Have them do the hard part. ;)
I feel that that way, they are learning better by doing than by watching.

Of course, questions are always open and I intend to post extra videos answering major questions. The whole points is to get people used to the basics though.

I think in the future it will gravitate away from a specific library and more towards "Here's how you'd do physics", "Here's how you do maps", type theory, etc.



Anyways. I haven't felt very articulate lately so I'm not sure if the guide comes off as really dull, or hard to understand. I would just like some peoples to read through it and give constructive criticism before I move on to doing the video versions.

Download here:
http://moosader.com/tutfiles/GameProgramming_1.pdf
User avatar
thejahooli
Chaos Rift Junior
Chaos Rift Junior
Posts: 265
Joined: Fri Feb 20, 2009 7:45 pm
Location: London, England

Re: Beginner's Guide to Game Programming

Post by thejahooli »

My only complaint would be that you dont explain the code for allegro and sdl (e.g page 10) so for someone that has never done any of either of them will probably find it quite confusing.
I'll make your software hardware.
User avatar
Amarant
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Wed Nov 05, 2008 9:52 am

Re: Beginner's Guide to Game Programming

Post by Amarant »

You don't need a copy constructor for that struct, the compiler will automatically generate code that performs a shallow copy. And since it doesn't contain any pointers that should be more than enough.

One thing you should probably adjust is the drawing code you use in the allegro examples. In these examples you call 'release_screen' but you never call 'acquire_screen' beforehand. Also the documentation states the following regarding 'acquire_screen': "You never need to call the function explicitly as it is low level, and will only give you a speed up if you know what you are doing" indicating that you could just leave out the call to 'release_screen'.

So where you have:

Code: Select all

blit( buffer, screen, 0, 0, 0, 0, screenWidth, screenHeight );
release_screen();
clear_bitmap( buffer );
you could replace it with either:

Code: Select all

acquire_screen();
blit( buffer, screen, 0, 0, 0, 0, screenWidth, screenHeight );
release_screen();
clear_bitmap( buffer );
or:

Code: Select all

blit( buffer, screen, 0, 0, 0, 0, screenWidth, screenHeight );
clear_bitmap( buffer );
Note, that the code you provide actually causes a crash/lockup of the program on linux (something I noticed when trying to compile your Goat Puncher code).

References:
http://www.allegro.cc/manual/api/bitmap ... ire_bitmap < acquire_screen calls this.
http://www.allegro.cc/manual/api/bitmap ... ase_bitmap < release_screen calls this.
177
User avatar
hurstshifter
ES Beta Backer
ES Beta Backer
Posts: 713
Joined: Mon Jun 08, 2009 8:33 pm
Favorite Gaming Platforms: SNES
Programming Language of Choice: C/++
Location: Boston, MA
Contact:

Re: Beginner's Guide to Game Programming

Post by hurstshifter »

Excellent guide. Doesn't get too detailed but I think its better that way; clean and simple!


Check on page 21 in the SDL code for WAV files though. It looks like you meant to add in the proper code there but never got back to it? I'm guessing this is why you wrote "ASDF" on each line before a section. Its all video related functions.
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Beginner's Guide to Game Programming

Post by Moosader »

hurstshifter wrote:Excellent guide. Doesn't get too detailed but I think its better that way; clean and simple!


Check on page 21 in the SDL code for WAV files though. It looks like you meant to add in the proper code there but never got back to it? I'm guessing this is why you wrote "ASDF" on each line before a section. Its all video related functions.
Yeah, I've left those blank for the moment because I haven't been able to sit down in a place I have internet access to work on it.


And yeah, the acquire screen thing someone told me was bad to use, but I didn't really know the extent of it. Thanks for the info Ama.
User avatar
resatti
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 11
Joined: Thu Oct 02, 2008 5:14 pm
Location: N/A
Contact:

Re: Beginner's Guide to Game Programming

Post by resatti »

Moosader, Why did you put what i said about god and russia and tetris at the end of the post :shock:

theres nothing wrong with it or anything

its just.... ....i said that...





COOL
Click here to see the hidden message (It might contain spoilers)
PART 1
R: What do you want for breakfast, L?

L: Well, let's see. I want tacos, waffles, and snickerdoodle.

A: Snickerdoodle?

R: Tacos and waffles don't go together, L.

L: I know that, R. A, snickerdoodle is a German cookie.

A: Well, whay didn't you say so, L? My butt just got equiped with a cookie gun!

R and L: Gun?

R: Run, L, A is gonna shoot us with his...

...whatever it is called!!!! Come on, L!

(L gets hit in the back of the head with a cookie and becomes unconsis.)

R: L!?

(Cookies fly everywhere, but R manages to escape)

A: It's going out of control!!!!! I can't stop it! Ohh......

(A explodes with a loud and thunderous BAM POP SLASH!)

The house (which belongs to L) no longer existed. A blew up and left R wondering what happened to A and L. R checked out the scene and saw no trace of A or L. There were many questions to be asked: Where is L and A? Is L and A alive? How did A get a cookie gun in his a**? No one knew the answer.

Countinued...
Spoiler'd. --Mar
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: Beginner's Guide to Game Programming

Post by programmerinprogress »

resatti wrote:Moosader, Why did you put what i said about god and russia and tetris at the end of the post :shock:

theres nothing wrong with it or anything

its just.... ....i said that...





COOL

it's her signature

Now after that formality...

I read through your tutorial, seemed pretty consistent, if I was starting to program in SDL or allegro, I would find it to be a really good resource ;)

The point about the missing audio section for SDL, I have never encountered anyone actually mention MIDI in an SDL project, I don't think it's part of SDL_mixer, and i've never seen it anywhere, so i'll be interested to see if you manage to find any additional libraries that enable that sort of functionality...

Apart from that, very fluent, well laid out, and incredibly helpful ;)
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Beginner's Guide to Game Programming

Post by K-Bal »

Looks very good ;) Go, write the book now! :D
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Beginner's Guide to Game Programming

Post by Moosader »

resatti wrote:Moosader, Why did you put what i said about god and russia and tetris at the end of the post :shock:

theres nothing wrong with it or anything

its just.... ....i said that...





COOL
Lol. I just liked the whole "God exists and Tetris is proof" thing, so I put it in my sig. :P
programmerinprogress wrote: The point about the missing audio section for SDL, I have never encountered anyone actually mention MIDI in an SDL project, I don't think it's part of SDL_mixer, and i've never seen it anywhere, so i'll be interested to see if you manage to find any additional libraries that enable that sort of functionality...
Ahh. I haven't used midis myself, and I couldn't research it without internet so I left it as-is. Will fix doomdoomdoom.

I also updated the Pickin' Sticks page http://moosader.com/game-pickin-sticks.html as more of a "directory" of Pickin Sticks related/inspired games, though I probably should have designed it a little better (it loads a bunch of YouTube files. Maybe I'll just use screenshots)
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Beginner's Guide to Game Programming

Post by Moosader »

I've started to update the videos on youtube, and update the written version simultaneously as I get to incomplete sections.

The playlist is here: http://www.youtube.com/view_play_list?p ... 6F495BD17E

Actually I'd really appreciate some feedback from some comments I've gotten from people and want to know if it's something to be concerned with or not.
jSaurabh wrote:It's better to put your DLL's in the system32 folder.
Many people have argued against this so far, as so have I. What do you guys think?
infinityk wrote:non power of two textures/images should be not much of an issue these days.
A bunch of people also supported this but I know it can occasionally cause some issues if your textures aren't. I've only has issues when using XNA on certain laptops, and nobody's seemed to complain with my Allegro stuff (A lot of sprites I've used are 48x96). What do you guys think?
eatcomics wrote:why is my internet suddenly so freaking slow?!?!?!?!?!?
Why is eatcomics' internet so freaking slow?!
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Beginner's Guide to Game Programming

Post by avansc »

umm. i think its a bad idea to put them in system32. reason being is that there can be version differences. so you can make your app work and break something else in that process.
keeping them in your project folder is fine. and imo a better practice.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Bakkon
Chaos Rift Junior
Chaos Rift Junior
Posts: 384
Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana

Re: Beginner's Guide to Game Programming

Post by Bakkon »

I just keep the DLLs with the executable, so if I want to distribute my program to someone else, it's easy to zip up the folder and ship it off without bugging someone to put stuff in their system32 folder. Also, version differences, as above.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Beginner's Guide to Game Programming

Post by eatcomics »

I do the same thing bakkon. It's way more convenient for the user, and convenience is the key to success, you wanna make things as simple as possible to set up... Because most people just wanna play....
Image
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Beginner's Guide to Game Programming

Post by avansc »

you can make installers that put the correct dll's in the correct places, i dont think its about convenience, its about compatibility and not fuxing up the compatibility of already working applications that may be dependent on the same named but different versions of a specific DLL or library.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Beginner's Guide to Game Programming

Post by dandymcgee »

avansc wrote:you can make installers that put the correct dll's in the correct places, i dont think its about convenience, its about compatibility and not fuxing up the compatibility of already working applications that may be dependent on the same named but different versions of a specific DLL or library.
Well I think it's both really. I run many of my applications from my flash drive on computers where I don't have access to install anything (school), so having the .DLLs in my project's folder is very handy.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply