MAEK GAEM III: SDL ● Simple DirectMedia Layer ● Input/Graphics/Audio using OpenGL ● Not nearly as difficult as OpenGL ● Cross Platform and Open Sauce ●

Slides:



Advertisements
Similar presentations
Using 2D sprite with OpenGL 2003 team Koguyue. Overview Motivation and basic concepts Advantages with using OpenGL Basic requirements of implementation.
Advertisements

Sprites A sprite is a 2D image or animation that is integrated into a larger scene. Originally, sprites were created by special hardware that would super-impose.
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Mission Technology Introduction to Scratch! June 2007.
Flappy bird guide for Scratch
Donald Heer 2/14/2011. Overview  Input Types Keyboard Mouse  Examples  The Arcade What inputs does the arcade have?
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Graphics and Multimedia. Introduction The language contains many sophisticated drawing capabilities as part of namespace System.Drawing and the other.
Designing Web Pages Getting to know HTML... What is HTML? Hyper Text Markup Language HTML is the major language of the Internet’s World Wide Web. Web.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech Oct 2010.
Virtual painting project By: Leetal Gruper Tsafrir Kamelo Supervisor: Michael Kolomenkin Advisor from 3DV systems: Sagi Katz.
FORMATTING PICTURES. Once you've added pictures to your documents, you can format them in various ways. The picture tools in Word 2010 make it easy to.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Pygame Dick Steflik.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
SDL Programming Introduction. Initialization 2  The first thing you must do is initialize SDL  int SDL_Init( SDL_INIT_EVERYTHING )  This will return.
Introduction to Scratch!
Lecture 02: Intro to SDL Topics: Downloading / Installing SDL Linking (in general and for SDL) SDL basics References:
BFTAW BDPA Workshop Introduction to GIMP Chris
BFTAW BDPA Workshop Introduction to GIMP Chris
Tennis for Two, 1958, by William Higinbotham, Brookhaven National Lab CSE 380 – Computer Game Programming Graphics Device Management.
Images Data Representation. Objectives  Understand the terms bitmap & pixel  Understand how bitmap images are stored using binary in a computer system.
Exploring Computer Science 2/23/15 2/23 Develop a Scratch story project -Brainstorming 2/24 Develop a Scratch story project –Developing 2/25 Develop a.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
1 Web Developer Foundations: Using XHTML Chapter 4 Key Concepts.
Photoshop I I450 Technology Seminar. Adobe Photoshop Illustrator Acrobat InDesign ImageReady.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Computer Graphics Bitmaps & Sprites CO2409 Computer Graphics Week 3.
Exploring Computer Science 2/9/15 2/9Moving Scratch 2/10Moving Scratch worksheet 2/11 Scratch Baseball Game 2/12Scratch Alphabet Learning Game 2/13Game.
OpenGL-ES 3.0 And Beyond Boston What is EGL? EGL handles: –provides available surface specifications –context management –surface binding –render.
به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.
Agenda Last class: Memory, Digitizing Numbers Today: Digitizing: Text
Programming Video Games
Game Maker Terminology
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Game Maker – Getting Started What is Game Maker?.
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Why program retro machines? Aren't they obsolete? Why not do something more constructive?
1 A first OpenGL program Brian Farrimond Robina Hetherington.
12/5/2015 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
Book report by Mrs. Theriault How can I create cool effects? Change the background: right click on the background of the slide. Click on the pull down.
Conditionals-Mod8-part41 Conditionals – part 4 Replace background Barb Ericson Georgia Institute of Technology May 2007.
Overview  Basic requirements of implementation  Image resource  Texture mapping  Advanced requirements of implementation  KGL sprite class.
2/16/2016 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
CompSci 44.1 Game Package Introduction to Jam’s Video Game Package.
XNA ● Proprietary Microsoft framework ● C#. Interface.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
- File>New>Record width and Height’s pixel that you desire Moving GIF animation -Choose File > Place> -Navigate to the file you want to insert and then.
Multimedia and weBLOGging Grade 7-9 | Cahaya Bangsa Classical School (C) 2010 Digital Media Production Facility 03 - Still Picture 01 – Basics.
●Cross-platform multimedia devlopment library for games (thats what we talk about), demos, MPEG players.... anything multimedia you can think of. ●SDL.
Sound and more Animations
Representing images.
MOM! Phineas and Ferb are … Aims:
Let’s Learn 2. Installing Pygame
8. Installing Pygame

Chapter 5 Working with Images
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Making the Applications Interesting
8. Starting Pygame Let's Learn Python and Pygame
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Chapter 7 The Game Loop and Animation
Presentation transcript:

MAEK GAEM III: SDL ● Simple DirectMedia Layer ● Input/Graphics/Audio using OpenGL ● Not nearly as difficult as OpenGL ● Cross Platform and Open Sauce ● Bindings for over 20 languages

Download/Setup ● ● How to get it all set up will depend on your IDE. ● Once you build your game, you (usually) just need to package it with SDL.dll

Get it Up ● We have to do some initialization before we can do anything serious ● SDL_Init( SDL_INIT_VIDEO ); That was easy ● You can initialize a number of subsystems with this method (video, audio, timer, etc.)

Screen Initialization ● Nearly every video-oriented method using SDL requires passing in a pointer to a surface object. ● SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0, SDL_HWSURFACE | SDL_DOUBLEBUF ); ● But what does that mean? ● Firstly, the screen resolution's width and height ● Then the bits per pixel. Cool! 0 is the current default for the user's computer ● All the extra flags go last. You can look 'em up

Drawing Boring Rectangles ● You can fill simple rectangles with color ● SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) ● First arg: Your surface from earlier ● Second Arg: The Rectangle you where you want to color the screen. NULL will fill the entire screen in ● Third Arg: Use SDL_MapRGB (or SDL_MapRGBA if you want to do alpha blending). I'll go into detail in a sec.

SDL_MapRGB ● Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b); ● Last three arguments are pretty obvious. Just enter the Red Green and Blue values (from 0 to 255) to get the color you want. ● What's this PixelFormat shit? It's an attribute of your screen object. Just pass in a screen->format and you'll be good to go.

Rectangle Elaboration ● There's not too much to talk about. You need rectangles for drawing to the screen, but you can use them for whatever you want, be it collisions, keeping track of player position, whatever. ● Make one like this: SDL_Rect rectongle; ● Has an attribute for x & y position, and width & height ● rectongle.x = 200; rectongle.y = 30; ● rectongle.w = 20; rectongle.h = 20;

Fuck Colors, I Want Pictures! ● You can add textures as surface objects, but load in pictures using SDL_LoadBMP. ● LoadBMP just takes a filepath. Pretty easy, yeah? ● Ex: SDL_Surface* pic = SDL_LoadBMP(“poop.bmp”) ● There's a couple things to do now: Set transparency, and draw it to our surface

Sprite Sheet ● A spritesheet is a collection of pictures in a single image used in animation to simulate movement. ● When drawing to the screen, you select a rectangular area on the sheet you wish to draw ● You should also select a color for the background to make transparent

Transparency ● Here's How: SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key); ● As you know by now, pass in the surface pointer ● Pass in SDL_SRCCOLORKEY to the second arg (const) ● That just means that the next argument is going to be the color we want to be transparent ● For the last arg, use MapRGB to pick a transparent color. Pick something that you aren't using in the actual image. ● Magenta is a common one (RGB 255, 0, 255)

Shit it to the Screen ● SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); ● *src is a pointer to the source surface (your image) and *dst is the desination surface (screen object) ● *srcrect is the source Rectangle. This is the area inside the image that you want to draw. ● *dstrect is the destination Rectangle. This is where you want to draw it on the screen

Quick Notes ● If using doublebuffering, make sure to call SDL_Flip(SDL_Surface* screen) after every time you draw to the screen. This swaps the video buffers. ● Also call SDL_FreeSurface(SDL_Surface* surface) to cleanup after use. Do this for every surface you create

Input ● SDL sends KEY_DOWN and KEY_UP events, so here's what we're going to do: SDL_Event event; if (SDL_PollEvent(&event)) //poll for a key event { if (event.type == SDL_KEYDOWN) //if key is pressed or released, handle it { HandleEvent(event); } if (event.type == SDL_KEYUP) { HandleEvent(event); }