SlideShare a Scribd company logo
Workshop India
Wilson Wingston Sharon
wingston.sharon@gmail.com
• Why?

• Learning is not just about marks.

• Its about building something.

• You cannot learn C in 2 weeks.
• You can only learn C by writing programs.
• Without writing programs OF YOUR OWN and ON YOUR
  OWN.
• We can only guide you – you have to put in some effort.
• In todays session file, you will see some files like this.

• Install all of them.

• Now see the Dev-Cpp folder?

• Copy everything in that to your
   Dev-Cpp folder (C:/Dev-Cpp). Copy the folders *inside*
this one to the one in you C drive.
• In the /game folder, you will see a folder called
  “SDL_Template(copy this folder)”

• Copy this folder to your own folder in your Exercise drive.

• After copying, rename the Folder to something like
  “SDL_1”

• In the folder you will see sdl.dev, you will have to open
  this file.
• You can open dev-cpp normally (if you need to enter
  passwrd) and then use the file>>open project or file>> to
  open this sdl.dev project file in your folder.
C game programming - SDL
Code
                For the
                File that is currently
                Open in the tab



Files that
Belong to the
Current
project
-lmingw32
-lSDLmain
-lSDL
-lSGE

• The above parameters
• Must be present in
• The linker tab

• Say OK
• Press Ctr-F11to build
• And then F9 to run the program.
• If it doesn’t work.

• Recheck your project options tab
• See if you installed everything in the folder?

• Does it complain about missing dll? See if all files in the
  project folder conform to the folder image provided 3
  slides before.
C game programming - SDL
C game programming - SDL
• Help your friends set it up

• Learning is a collaborative process. Se what mistakes
  your friends have made. Check them. Help them.

• It makes you a better programmer by exposing you to the
  mistakes that are possible in C.

• It’ll help you avoid silly mistakes if you help others by
  correcting them.
• main.cpp
  • this file contains the main() function
  • This is called the entry point of the program.


• grapics.h
  • This file contains some structures and function that I wrote.
  • You might or might not use them as per requirement of the
    program.

  • The thing is well commented and documented.
The game itself

            Here the logic that specifies how the game behaves to the user



                                    Game Engine

SDL just gives as access to graphics card.            SGE is our game engine.



                                         SDL

       Simple Direct Media Layer               Provides a layer to access graphics card



                             Graphics Card on computer
                   Harware support for drawing stuff onto the screen
• make sure you have copied the Dev-Cpp folder i gave
  you onto your Dev-Cpp installation.
• That links up all sort of libraries for SDL to function
• Otherwise you might get an error about missing SDL.h
• This must be a global object.
• Whatever we want SDL to display has to be written to this
  screen.

•
C game programming - SDL
C game programming - SDL
C game programming - SDL
screen = SDL_SetVideoMode(MX, MY, 32,
SDL_HWSURFACE|SDL_DOUBLEBUF);
The above line is important
• If you change MX and MY (in the beginning of
  graphics.h) you change the size of screen

• If you add,
  SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCR
  EEN
• To the last argument of the function, the program goes
  into full screen mode!
C game programming - SDL
Update               Draw
     graphics              game
      models             elements




Undraw
                              Get input
 what is
                               from
  not
                               user
required

                Check
                Game
                 logic
• Events are things that happen outside the game engine
  that the game must be aware of.

• Eg: Keypresses

• SDL_pollevent(&event)
  • Returns NULL when there are no events left to handle, so then
    that while loops terminates and the game continues.
  • The event object contains details about what happened and the
    rest of the code handles it!
C game programming - SDL
C game programming - SDL
C game programming - SDL
• Don’t touch the init() function.

• To add user interaction, code has to go in which function?
  •?



• To add some more drawings, code has to go where?
  •?
• Don’t touch the init() function.

• To add user interaction, code has to go in which function?
  • The event managing while loop in the main() function.



• To add some more drawings, code has to go where?
  • The render() function.
  • Or another function between init() and the eventhandler()
• Here are codes for most functions and all




• The main.cpp and graphics.h need to *share* the same
  global variable screen.
• This is done by the keyword extern; this specifies that
  this is not a different variable, but a same one that is
  declared in another file.
C game programming - SDL
• The function _putpixel
  draws a point at the MX/2
  and MY/2 position.

• Modify the code to draw a
  horizontal line.

• ______________________
  __

• Across the screen.
C game programming - SDL
• That for loop starts from i =0
• Till MX in steps of 1

• And the putpixel function
  draws a pixel at every point.



• Can you change it to vertical?
• What to do when considering to move a point.
  • What all is required to define a point?
     • X
     • Y
     • Colour.


• Keyboard handling is done on the event loop.

                       Position
       Keyboard            is
                                      Screen is   Point is
        press is       updated
                                       cleared    drawn
       checked          for the
                         point
• Keyboard presses is update as a
  struct in graphics.h called move.

• Each point will have an associated
  move variable.

• If kLR is -1/1 the point will have to
  move Left/Right.
• And so on.
C game programming - SDL
• It is the while(SDL_Pollevent(&event))

• For every loop, the event structure will have the details of
  what happens, we want to see onky keyboard events.
• These are events of event.type ==
  • SDL_KEYDOWN
  • SDL_KEYUP
  • Etc..


• Using a switch case we can write what code to happen
  when each event is fired.
C game programming - SDL
• Code comes at the level of the last
                          one.
• Case SDL_KEYUP:

• What to dowhen the key has been
released?

Set the move variable m1 kUD or KLR
to 0. Signifying no movement.
• cls(0) fills the screen with
  black;

• Updates point p1 with m1 for
  which direction to move the
  point

• Putpixel to draw the point.
• Render() runs infinitely,
   • Checks if point p1 has moved by using the m1variable
   • If moved, update the point’s x & y
   • Then clear the screen and draws the point.

• When keyboard is pressed
   • The eventloop() in main now enters the loop
   • A switch case is done on the event type to determine if it’s a keypress
     or a release.
   • When the keypress is detected the m1 variable is adjusted
   • When the keyrelease is detected the m1 variable is set to 0 so not
     movement happens.

• Compile 2.Movment folder code.
   • Again: follow dev-cpp rules for opening projects and compiling them.
• We have the point p1 that we can move
  around with the keyboard.

• Lets draw a line between p1 and MX/2,
  MY/2.

• That is a line from p1 to the center.

• Line function:
• sge_Line(*screen,x1,y1,x2,y2,color);
• sge_AALine(…) is line with anti-aliasing
C game programming - SDL
C game programming - SDL
•   I want the other points to move by using the
•   W - UP
•   S - DOWN
•   A - LEFT
•   D – Right

• Point 2 is handled by m2.
• Using switch case do the update of m2
• And update p2 with m2

• I want the line to move by both points.
• One point moves by arrow keys
• The other moves by wasd keys.
• The SGE SDL library provides some basic primitives for
  drawing.

• Drawing in this case is mathematical drawing.

• The basic shapes that are provided are:
  •   Points
  •   Lines
  •   Circle
  •   Rectangle
  •   Ellipse
  •   Polygons
C game programming - SDL
C game programming - SDL
• Try to think of creative shapes and things that you can
  draw with these functions.

• You can also make interesting mathematical loop
  shapes.

• If you don’t do the cls(0) whatever the loop draws wont
  be erased in the next iteration!.

• Try and do some more hoola!
• SDL printing things on the screen means
  you need a font!

• The font file is *something*.ttf

• These sort of fonts can be opened by SDL
  and drawn onto the screen.

• First we need to make a global font *
  variable.
• We need to initialise the font
  • We have cour.ttf right now.


• sge_TTF_Init() initialises the font
  engine.

• sge_TTF_openFont(font, size)
  returns the font object that should
  be global pointer of the same,
C game programming - SDL
C game programming - SDL
• Get text to appear one by one on the screen.



• Get text to scroll around the screen.



• Can you get keyboard input using the event loop ?
  • Do only numbers
• First we create a struct circle. (same like point except
  with radius too).
C game programming - SDL
C game programming - SDL
• Same
  KEYUP/KEYDOW
  N movement code
  to move m1 and
  m2.

• Adjust this code
  and get the second
  circle moving too.
• Instead of moving the second circle use the below
  random functions

• int sge_Random(int min, int max)
  Returns a random integer between (and including) min
  and max.

 void sge_Randomize(void)
 Seed the random number generator with a number from
 the system clock. Should be called once before the first
 use of sge_Random.
• Move the second circle randomly.

• When the first circle is touching the second circle, a
  counter should start in the corner.

• As long as the two circles are touching, counter must
  keep incrementing and the second circle keeps moves
  faster and faster.

• When the first circle leaves, the counter goes to 0 and
  stays there.

More Related Content

PPTX
OpenGL ES EGL Spec&APIs
PDF
Game Programming - Cloud Development
PDF
Developing a Multiplayer RTS with the Unreal Engine 3
PDF
Gdc 14 bringing unreal engine 4 to open_gl
PDF
libGDX: User Input and Frame by Frame Animation
PPTX
Scene Graphs & Component Based Game Engines
PDF
Implementing a Simple Game using libGDX
PDF
libGDX: User Input
OpenGL ES EGL Spec&APIs
Game Programming - Cloud Development
Developing a Multiplayer RTS with the Unreal Engine 3
Gdc 14 bringing unreal engine 4 to open_gl
libGDX: User Input and Frame by Frame Animation
Scene Graphs & Component Based Game Engines
Implementing a Simple Game using libGDX
libGDX: User Input

What's hot (8)

PDF
Digital Calipers Software Mitutoyo / Logiciel pour Pied à coulisse Mitutoyo (...
PDF
Smedberg niklas bringing_aaa_graphics
PPTX
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
PDF
OGDC 2014_Architecting Games in Unity_Mr. Rustum Scammell
PDF
Best Practices for Shader Graph
PDF
Game Programming 07 - Procedural Content Generation
PPTX
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
PPTX
ECS: Making the Entity Debugger - Unite LA
Digital Calipers Software Mitutoyo / Logiciel pour Pied à coulisse Mitutoyo (...
Smedberg niklas bringing_aaa_graphics
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
OGDC 2014_Architecting Games in Unity_Mr. Rustum Scammell
Best Practices for Shader Graph
Game Programming 07 - Procedural Content Generation
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
ECS: Making the Entity Debugger - Unite LA
Ad

Viewers also liked (20)

PDF
Srs format
PDF
Game Development with SDL and Perl
PDF
C language in our world 2015
PPTX
General Quiz by Quiz pro. co. ,VNIT
PDF
Code Refactoring - Live Coding Demo (JavaDay 2014)
PDF
TMS - Schedule of Presentations and Reports
PDF
Using Git on the Command Line
PDF
FLTK Summer Course - Part VIII - Eighth Impact
PDF
Advanced Git
PDF
Blisstering drupal module development ppt v1.2
PPT
Introduction to Git Commands and Concepts
PDF
FLTK Summer Course - Part I - First Impact - Exercises
PDF
FLTK Summer Course - Part VI - Sixth Impact - Exercises
PPTX
Manipulating file in Python
PDF
Git hooks For PHP Developers
ODP
Servicios web con Python
PDF
FLTK Summer Course - Part II - Second Impact
PDF
FLTK Summer Course - Part VII - Seventh Impact
PDF
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
Srs format
Game Development with SDL and Perl
C language in our world 2015
General Quiz by Quiz pro. co. ,VNIT
Code Refactoring - Live Coding Demo (JavaDay 2014)
TMS - Schedule of Presentations and Reports
Using Git on the Command Line
FLTK Summer Course - Part VIII - Eighth Impact
Advanced Git
Blisstering drupal module development ppt v1.2
Introduction to Git Commands and Concepts
FLTK Summer Course - Part I - First Impact - Exercises
FLTK Summer Course - Part VI - Sixth Impact - Exercises
Manipulating file in Python
Git hooks For PHP Developers
Servicios web con Python
FLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part VII - Seventh Impact
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
Ad

Similar to C game programming - SDL (20)

PPTX
Computer Graphics with OpenGL presentation Slides.pptx
PPTX
Soc research
PPT
Hill ch2ed3
PDF
BSidesDelhi 2018: Headshot - Game Hacking on macOS
PDF
lec02 .pdf
PPT
september11.ppt
PPT
Input and Interaction
PPTX
Unit 2 - Complete (1).pptx
PPTX
2D graphics
PDF
SDAccel Design Contest: Xilinx SDAccel
PDF
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
PPTX
3 CG_U1_P2_PPT_3 OpenGL.pptx
PPTX
UNIT 1 OPENGL_UPDATED .pptx
PPT
Better Interactive Programs
PPTX
Begin with c++ Fekra Course #1
PDF
Lecture 2: C# Programming for VR application in Unity
PDF
18csl67 vtu lab manual
PPTX
Micro Keyboarding
PPTX
Mini Computer Project
PDF
Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics with OpenGL presentation Slides.pptx
Soc research
Hill ch2ed3
BSidesDelhi 2018: Headshot - Game Hacking on macOS
lec02 .pdf
september11.ppt
Input and Interaction
Unit 2 - Complete (1).pptx
2D graphics
SDAccel Design Contest: Xilinx SDAccel
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
3 CG_U1_P2_PPT_3 OpenGL.pptx
UNIT 1 OPENGL_UPDATED .pptx
Better Interactive Programs
Begin with c++ Fekra Course #1
Lecture 2: C# Programming for VR application in Unity
18csl67 vtu lab manual
Micro Keyboarding
Mini Computer Project
Computer Graphics Project Report on Sinking Ship using OpenGL

More from Wingston (20)

PPTX
OpenCV @ Droidcon 2012
PPTX
05 content providers - Android
PPTX
04 activities - Android
PPTX
03 layouts & ui design - Android
PPTX
02 hello world - Android
PPTX
01 introduction & setup - Android
PPTX
OpenCV with android
PPTX
C programming - Pointers
PPTX
Introduction to Basic C programming 02
PPT
Introduction to Basic C programming 01
PPTX
Linux – an introduction
PPTX
Embedded linux
PPTX
04 Arduino Peripheral Interfacing
PPTX
03 analogue anrduino fundamentals
PPTX
02 General Purpose Input - Output on the Arduino
PPTX
Introduction to the Arduino
PPTX
4.content mgmt
PPTX
8 Web Practices for Drupal
PPTX
7 Theming in Drupal
PPTX
6 Special Howtos for Drupal
OpenCV @ Droidcon 2012
05 content providers - Android
04 activities - Android
03 layouts & ui design - Android
02 hello world - Android
01 introduction & setup - Android
OpenCV with android
C programming - Pointers
Introduction to Basic C programming 02
Introduction to Basic C programming 01
Linux – an introduction
Embedded linux
04 Arduino Peripheral Interfacing
03 analogue anrduino fundamentals
02 General Purpose Input - Output on the Arduino
Introduction to the Arduino
4.content mgmt
8 Web Practices for Drupal
7 Theming in Drupal
6 Special Howtos for Drupal

Recently uploaded (20)

PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
01-Introduction-to-Information-Management.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Structure & Organelles in detailed.
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Insiders guide to clinical Medicine.pdf
PPTX
master seminar digital applications in india
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Basic Mud Logging Guide for educational purpose
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Cell Types and Its function , kingdom of life
PDF
O7-L3 Supply Chain Operations - ICLT Program
TR - Agricultural Crops Production NC III.pdf
Pharma ospi slides which help in ospi learning
01-Introduction-to-Information-Management.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPH.pptx obstetrics and gynecology in nursing
102 student loan defaulters named and shamed – Is someone you know on the list?
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
RMMM.pdf make it easy to upload and study
Cell Structure & Organelles in detailed.
Microbial diseases, their pathogenesis and prophylaxis
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Insiders guide to clinical Medicine.pdf
master seminar digital applications in india
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Basic Mud Logging Guide for educational purpose
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Cell Types and Its function , kingdom of life
O7-L3 Supply Chain Operations - ICLT Program

C game programming - SDL

  • 2. • Why? • Learning is not just about marks. • Its about building something. • You cannot learn C in 2 weeks. • You can only learn C by writing programs. • Without writing programs OF YOUR OWN and ON YOUR OWN. • We can only guide you – you have to put in some effort.
  • 3. • In todays session file, you will see some files like this. • Install all of them. • Now see the Dev-Cpp folder? • Copy everything in that to your Dev-Cpp folder (C:/Dev-Cpp). Copy the folders *inside* this one to the one in you C drive.
  • 4. • In the /game folder, you will see a folder called “SDL_Template(copy this folder)” • Copy this folder to your own folder in your Exercise drive. • After copying, rename the Folder to something like “SDL_1” • In the folder you will see sdl.dev, you will have to open this file. • You can open dev-cpp normally (if you need to enter passwrd) and then use the file>>open project or file>> to open this sdl.dev project file in your folder.
  • 6. Code For the File that is currently Open in the tab Files that Belong to the Current project
  • 7. -lmingw32 -lSDLmain -lSDL -lSGE • The above parameters • Must be present in • The linker tab • Say OK • Press Ctr-F11to build • And then F9 to run the program.
  • 8. • If it doesn’t work. • Recheck your project options tab • See if you installed everything in the folder? • Does it complain about missing dll? See if all files in the project folder conform to the folder image provided 3 slides before.
  • 11. • Help your friends set it up • Learning is a collaborative process. Se what mistakes your friends have made. Check them. Help them. • It makes you a better programmer by exposing you to the mistakes that are possible in C. • It’ll help you avoid silly mistakes if you help others by correcting them.
  • 12. • main.cpp • this file contains the main() function • This is called the entry point of the program. • grapics.h • This file contains some structures and function that I wrote. • You might or might not use them as per requirement of the program. • The thing is well commented and documented.
  • 13. The game itself Here the logic that specifies how the game behaves to the user Game Engine SDL just gives as access to graphics card. SGE is our game engine. SDL Simple Direct Media Layer Provides a layer to access graphics card Graphics Card on computer Harware support for drawing stuff onto the screen
  • 14. • make sure you have copied the Dev-Cpp folder i gave you onto your Dev-Cpp installation. • That links up all sort of libraries for SDL to function • Otherwise you might get an error about missing SDL.h
  • 15. • This must be a global object. • Whatever we want SDL to display has to be written to this screen. •
  • 19. screen = SDL_SetVideoMode(MX, MY, 32, SDL_HWSURFACE|SDL_DOUBLEBUF); The above line is important • If you change MX and MY (in the beginning of graphics.h) you change the size of screen • If you add, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCR EEN • To the last argument of the function, the program goes into full screen mode!
  • 21. Update Draw graphics game models elements Undraw Get input what is from not user required Check Game logic
  • 22. • Events are things that happen outside the game engine that the game must be aware of. • Eg: Keypresses • SDL_pollevent(&event) • Returns NULL when there are no events left to handle, so then that while loops terminates and the game continues. • The event object contains details about what happened and the rest of the code handles it!
  • 26. • Don’t touch the init() function. • To add user interaction, code has to go in which function? •? • To add some more drawings, code has to go where? •?
  • 27. • Don’t touch the init() function. • To add user interaction, code has to go in which function? • The event managing while loop in the main() function. • To add some more drawings, code has to go where? • The render() function. • Or another function between init() and the eventhandler()
  • 28. • Here are codes for most functions and all • The main.cpp and graphics.h need to *share* the same global variable screen. • This is done by the keyword extern; this specifies that this is not a different variable, but a same one that is declared in another file.
  • 30. • The function _putpixel draws a point at the MX/2 and MY/2 position. • Modify the code to draw a horizontal line. • ______________________ __ • Across the screen.
  • 32. • That for loop starts from i =0 • Till MX in steps of 1 • And the putpixel function draws a pixel at every point. • Can you change it to vertical?
  • 33. • What to do when considering to move a point. • What all is required to define a point? • X • Y • Colour. • Keyboard handling is done on the event loop. Position Keyboard is Screen is Point is press is updated cleared drawn checked for the point
  • 34. • Keyboard presses is update as a struct in graphics.h called move. • Each point will have an associated move variable. • If kLR is -1/1 the point will have to move Left/Right. • And so on.
  • 36. • It is the while(SDL_Pollevent(&event)) • For every loop, the event structure will have the details of what happens, we want to see onky keyboard events. • These are events of event.type == • SDL_KEYDOWN • SDL_KEYUP • Etc.. • Using a switch case we can write what code to happen when each event is fired.
  • 38. • Code comes at the level of the last one. • Case SDL_KEYUP: • What to dowhen the key has been released? Set the move variable m1 kUD or KLR to 0. Signifying no movement.
  • 39. • cls(0) fills the screen with black; • Updates point p1 with m1 for which direction to move the point • Putpixel to draw the point.
  • 40. • Render() runs infinitely, • Checks if point p1 has moved by using the m1variable • If moved, update the point’s x & y • Then clear the screen and draws the point. • When keyboard is pressed • The eventloop() in main now enters the loop • A switch case is done on the event type to determine if it’s a keypress or a release. • When the keypress is detected the m1 variable is adjusted • When the keyrelease is detected the m1 variable is set to 0 so not movement happens. • Compile 2.Movment folder code. • Again: follow dev-cpp rules for opening projects and compiling them.
  • 41. • We have the point p1 that we can move around with the keyboard. • Lets draw a line between p1 and MX/2, MY/2. • That is a line from p1 to the center. • Line function: • sge_Line(*screen,x1,y1,x2,y2,color); • sge_AALine(…) is line with anti-aliasing
  • 44. I want the other points to move by using the • W - UP • S - DOWN • A - LEFT • D – Right • Point 2 is handled by m2. • Using switch case do the update of m2 • And update p2 with m2 • I want the line to move by both points. • One point moves by arrow keys • The other moves by wasd keys.
  • 45. • The SGE SDL library provides some basic primitives for drawing. • Drawing in this case is mathematical drawing. • The basic shapes that are provided are: • Points • Lines • Circle • Rectangle • Ellipse • Polygons
  • 48. • Try to think of creative shapes and things that you can draw with these functions. • You can also make interesting mathematical loop shapes. • If you don’t do the cls(0) whatever the loop draws wont be erased in the next iteration!. • Try and do some more hoola!
  • 49. • SDL printing things on the screen means you need a font! • The font file is *something*.ttf • These sort of fonts can be opened by SDL and drawn onto the screen. • First we need to make a global font * variable.
  • 50. • We need to initialise the font • We have cour.ttf right now. • sge_TTF_Init() initialises the font engine. • sge_TTF_openFont(font, size) returns the font object that should be global pointer of the same,
  • 53. • Get text to appear one by one on the screen. • Get text to scroll around the screen. • Can you get keyboard input using the event loop ? • Do only numbers
  • 54. • First we create a struct circle. (same like point except with radius too).
  • 57. • Same KEYUP/KEYDOW N movement code to move m1 and m2. • Adjust this code and get the second circle moving too.
  • 58. • Instead of moving the second circle use the below random functions • int sge_Random(int min, int max) Returns a random integer between (and including) min and max. void sge_Randomize(void) Seed the random number generator with a number from the system clock. Should be called once before the first use of sge_Random.
  • 59. • Move the second circle randomly. • When the first circle is touching the second circle, a counter should start in the corner. • As long as the two circles are touching, counter must keep incrementing and the second circle keeps moves faster and faster. • When the first circle leaves, the counter goes to 0 and stays there.