Learning SDL – A BegINNER’S GUIDE

Transcription

December 15, 2011[LEARNING SDL – A BEGINNER’S nner‘s Guide to g Games with SDL and C rs1

December 15, 2011[LEARNING SDL – A BEGINNER’S GUIDE]Copyright 2011 brainycode.comPermission is granted to copy and distribute an electronic version of this document.Permission is NOT granted for commercial use.2

December 15, 2011[LEARNING SDL – A BEGINNER’S GUIDE]Dedication to those learning C . 6Chapter 0: Introduction . 7Purpose. 7Prerequisite . 8What is out there now on SDL? . 8Why SDL? . 9A Bit of History . 9The Components of SDL . 10Chapter 1 – Installing SDL . 14Obtaining copies of all the libraries . 14Installing to work with Code::Blocks . 17Using the Code::Blocks SDL wizard . 28Creating your own SDL Custom Template. 28Installing to work with WxDev-C . 29Creating a WxDev-Cpp SDL template file . 39Installing and Testing SDL Image . 41Installing and Testing SDL tff . 44Installing and Testing SDL mixer . 47Installing and Testing SDL net . 48Summary . 48Chapter 2 - Getting started with SDL . 49Initializing SDL . 49Initializing and Closing SDL Subsystems . 53The Video Component . 58SDL Video Structures . 59Making Improvements to our Video Programs. 64How the display screen is organized . 66Understanding how to write to the Display . 67Drawing a Line . 78A Little History on Drawing Lines . 78A Simple Algorithm – Slope-Intercept Algorithm. 79A Simple Algorithm #2 – Using Symmetry. 83SDL Rect. 843

December 15, 2011[LEARNING SDL – A BEGINNER’S GUIDE]Clipping . 87SDL VideoInfo. 89Loading Images . 91Moving a ―Ball‖ around on the screen . 94Double Buffering and Page Flipping . 101Double Buffering . 101Page Flipping . 102Displaying Other Types of Images . 104Alpha Blending . 109Other Topics. 114Summary . 114Review Questions . 115Programming Exercises . 116Circle-Drawing Algorithms . 117Chapter 3 - Sprites, A Simple View. 123Chapter 4 - Processing Events . 124Keyboard Events . 126Joystick Events. 130System Events . 131Mouse Events . 131Chapter 5 – How to organize a game . 131Creating a Game Template . 131Sample Games . 131Chapter 6 – Creating Pong . 131Using SDL TTF . 131SDL Audio . 131Some Audio Basics . 132Using SDL primitive functions . 134SDL Joystick . 136Chapter 7 – Creating MindSweeper . 136Chapter 8 – Creating Breakout. 136Chapter 9 – Creating Tetris . 136Chapter 10 – SDL Threads and Timers . 1364

December 15, 2011[LEARNING SDL – A BEGINNER’S GUIDE]Chapter 11 – Building a multiplayer online game . 136SDL NET . 136SDL MIXER . 136Chapter 12 – Building a Platform Game . 136Why I love Crisis Mountain! . 136Why I love Mario!! . 136Chapter 13 – Other libraries and tools to build games . 137Chapter 14 – What comes next? . 137Last Chapter . 137Bibliography . 138Appendix A: Places to visit on the Web . 139Appendix B – Microsoft Visual C 2010 Express . 140Appendix C – Pong, Breakout and MindSweeper . 141Pong . 141Breakout . 141MindSweeper . 142Appendix D – Unzipping files . 145Appendix E – Structs . 150What are structs? . 150Why use structs? . 150In summary . 154Things you can do with structs .

―Game Programming in C : Start to Finish‖ and ―Learn C by Making Games‖. I think both books are great additions to anyone learning to program in C and also interested in making games in the process. The only difference between them and this book is that this book is FREE and I hope a valuable resource. There are several websites you should be able to find on the Internet. One .