Programming with SDL

Total Page:16

File Type:pdf, Size:1020Kb

Programming with SDL PROGRAMMING Creating a game with SDL Creating a game Programming with SDL In this, the first in a series of articles, type fonts (TTF). Most of these libraries have been submitted by end users and Steven Goodwin looks at SDL.What it do not form part of the main SDL pack- age. This is not a problem in itself, but if is. How it works. And more impor- your primary purpose is to use SDL for cross-platform development work, be tantly, how to use it to write a brand sure to check the libraries’ availability new game, Explorer Dug. for your particular platform, since not all are fully supported. BY STEVEN GOODWIN The Windows heritage of SDL is very evident within the API, as much of the Figure 1:The opening image terminology (and many of the functions) have very close equivalents in DirectX. DL stands for Simple DirectMedia for Linux, using the SDL project, by com- However, it does not emulate Windows Layer and is a cross-platform API panies that otherwise, are unwilling (or in any way. Instead, every call to the SDL Sfor programming multi-media unable) to release their source code to graphics API, for example, will make applications, such as games. It provides the world. direct use of a driver from the host oper- a stable base on which developers may Some of the most notable releases have ating system, rather from an emulated work, without being concerned with come from the aforementioned Loki system. how the hardware will deal with it – or Games and include Civilization: Call to On Windows, this means DirectX. even what hardware it is running on. Power, Descent 3 and Unreal Tourna- Under Linux, this functionality will Sam Lantinga started the SDL project ment. be provided by one of the graphic driver in 1998 as a way of porting a Windows Good SDL implementations are cur- libraries, such as X11 or DGA. MTRR application to the Macintosh. Soon after rently available for Linux (i386, PPC and (Memory Type Range Register, [2]) beginning the SDL project he went PS2), BSD, Windows, Macintosh OS 9 / control, for accelerated full-screen appli- to work for (the sadly lamented) Loki X, Solaris, IRIX and BeOS. Code for other cations, is also supported. See Box 1: Software, and then to Blizzard Entertain- platforms, such as the Amiga, Atari and Drivers. ment. SymbianOS, also exist, but are not cur- On a similar note, the audio API can Throughout this time he has continued rently supported directly by the core enlist the services of OSS, ESD or aRts to to work on SDL and, in the true spirit of developers. provide music and sound effects. By an open community, has been supported accessing, as opposed to emulating, the (with various platform ports and bug We Built This City system drivers, a high level of perfor- fixes) by a loose knit group of developers As an API, SDL consists of five different mance can be achieved across all across the Internet. subsystems: video, audio, CDROM, joy- platforms. SDL is available under the Lesser GNU stick input and timers. Each one is Public License (LGPL), and as such does targeted at a different area of develop- Box 1: Drivers not require the source code of any appli- ment, and can be initialised and used SDL isn’t limited to X11 as an output driver. It cation using it to be released. independently of the others. In addition, can also use dga,fbcon and even aalib! To Although this might raise political con- SDL promotes the use of libraries that make use of this facility,you must make sure siderations for some people, it has meant can provide new functionality to the that the appropriate driver is compiled into the release of several commercial games basic API. SDL (which may require another ./configure, The two most common libraries are make, make install of the package).You can When builders go down SDL_mixer (which provides better audio then use the environment variable the pub they talk about handling), and SDL_Image which pro- SDL_VIDEODRIVER to indicate which driver football. Presumably you want to use. For example: vides support for a wider selection of therefore, when foot- HOR graphic file formats, including GIF, JPG, export SDL_VIDEODRIVER=aalib T ballers go down the ./explore pub they talk about PNG and TGA. The main SDL website [1] A list of the drivers provided with SDL can be builders! When Steven Goodwin goes lists 76 different libraries currently in found by typing: down the pub he doesn’t talk about production, providing a wide range of THE AU football. Or builders. He talks about ./configure --help | grep U feature sets from basic graphic primi- computers. Constantly… enable-video tives, to networking and support for true 66 August 2003 www.linux-magazine.com Creating a game with SDL PROGRAMMING Do The Digs Dug tar xfz SDL-1.2.5.tar.gz will search. All other SDL header files SDL has many uses, and has bestowed are incorporated inside this one, to limit life upon emulators, music editors, DivX and installed with the equally familiar: maintenance. We will also need to link players and video processing tools. How- the main SDL library (libSDL) into our ever, it is within the field of games that ./configure application. Initially we shall only be SDL has risen above its peers. There are make using functionality from this library. hundreds of SDL games available on the make install We’ll add other libraries as time goes on, Internet and most of these are available and our requirements grow. Until then, with full source code. We shall be adding By default, this will place the required both of the above demands can be satis- to this collection with a small platform library and include files into /usr/local/ fied on the command line with: game called Explorer Dug. It will be pro- lib and /usr/local/include/SDL respec- grammed in ‘C’ (as it is probably the tively, although this can be changed by gcc -I/usr/include/SDL -lSDL U most widely understood), although SDL starting the process with: test/testsprite.c itself can be written in many others, such as PHP, Ruby, Perl, Java and LISP. ./configure -prefix=/put/sdl/U If you change (or forget!) the location of We shall primarily focus on the features somewhere/else your include and library paths, you can of SDL and how to use them to produce use the sdl-config program to provide a game. We shall also highlight the areas There are a wealth of other configuration this information (see Box 2: SDLCON- of game development that require more options available here which allow you FIG). work from us, the programmer. OK? to enable (or disable) various drivers Good! Let’s start… (such as ALSA), or include framebuffer All Around the World support. Apart from providing additional Our first foray into SDL programming Thunderball drivers, you should have little cause to will be the games “Welcome” screen. The first task is to download and install re-./configure since SDL is very stable This introduces a number of fundamen- SDL. The current stable version is 1.2.5, and easy to setup, and invariably works tal concepts, such as surfaces, blitting and is available from [3] as a gzipped out of the box. and screen updates, that will reoccur tarball. In addition to the source code The SDL package also contains a com- throughout any SDL application you distribution there are two different prehensive set of man pages (section 3) write. binary versions available: runtime and detailing the parameters and available As you read the code, you will notice development. Naturally, the latter pro- flags for each function. that every SDL function and structure vides better debugging facilities which is begins with the SDL_ prefix. In addition, more useful for us, as developers. How- Build that wall we shall wrap these functions up inside ever, I recommend working from source The SDL package comes with a small our own (all prefixed with ‘ex’) to encap- as this allows us better customisation, test suite that checks the integrity of sulate more functionality and provide a and full use of a debugger to step into each subsystem. These are held in the common place where game code and the SDL code itself. This is not only help- test directory, and provided the install SDL code meet. This will help in debug- ful in tracking down bugs, but can also succeeded, should ‘just work’. In cases ging. be very illuminating – especially some of where things do not work as expected, The first stage is to initialise SDL. the comments! look for the error messages each test out- There are two functions to do this, The tar.gz is unpacked in the usual puts to the command line as this can tell SDL_Init and SDL_InitSubSystem. way: you if there’s a problem with your hard- SDL_Init can initialise one (or more) ware, or its setup. Fortunately, if your subsystems and should always be the Box 2: SDLCONFIG machine is capable of running a desktop, first SDL function in your program. sdl-config is a small program that comes it should be up to spec for anything Although you can initialise additional bundled with SDL to report the base,or pre- you’ll be doing with SDL! subsystems later you must always start fix,location of your SDL installation. It can All SDL programs can start with either with an SDL_Init, because this contains also be used to give you the correct flags for the line: other initialisation components that both the compiler and linker.
Recommended publications
  • How to Play to Descent 3 in a Virtual Machine?
    How to play to Descent 3 in a virtual machine? Tutorial VM #001 Check by : Mzero Author : Darkers Version 1.1 Page 1 sur 66 Summary Content How to play to Descent 3 in a virtual machine? ...................................................................................... 1 I. Introduction .................................................................................................................................... 3 II. Requirements .................................................................................................................................. 4 III. VirtualBox Installation ................................................................................................................ 7 IV. Create a Virtual Machine .......................................................................................................... 11 V. Install Windows XP ....................................................................................................................... 17 VI. Configure Windows XP ............................................................................................................. 29 VII. Update Windows XP ................................................................................................................. 35 VIII. Additional Software installation .............................................................................................. 44 IX. Install Descent 3 .......................................................................................................................
    [Show full text]
  • Overload Level Editor Download for Pc Pack
    Overload Level Editor Download For Pc [pack] Overload Level Editor Download For Pc [pack] 1 / 2 Official Bsaber Playlists · PC Playlist Mod · BeatList Playlist Tool · Quest Playlist Tool ... Rasputin (Funk Overload) ... Song ID:1693 It's a little scary to try to map one of the greats, but King Peuche ... Since there's not a way to do variable BPM in our current edit… 4.7 5.0 ... [Alphabeat – Pixel Terror Pack] Pixel Terror – Amnesia.. May 18, 2021 — Have you experienced overwhelming levels of packet loss that impacted your network performance? Do you find ... SolarWinds Network Performance Monitor EDITOR'S CHOICE ... Nagios XI An infrastructure and software monitoring tool that runs on Linux. ... That rerouting can overload alternative routers. Move Jira Software Cloud issues to a new project, assign issues to someone else, ... Download all attachments in the attachments panel · Switch between the strip ... This avoids notification overload for everyone working on the issues being edited. ... If necessary, map any statuses and update fields to match the destination ... Research & Development Pack] between March 9th and April 3rd, 2017" - Star Trek ... Download Star Trek Online Kelvin Timeline Intel Dreadnought Cruiser Aka The ... The faction restrictions of this starship can be removed by having a level 65 KDF ... Star Trek Online - Paradox Temporal Dreadnought - STO PC Only. This brand new pack contains 64 do-it-yourself presets, carefully initialized and completely empty ... 6 Free Download Latest Version for Windows. 1. ... VSTi synthesizer that takes the definitions of quality and performance to a higher level. ... Sep 23, 2020 · Work with audio files and enhance, edit, normalize and otherwise ...
    [Show full text]
  • Amnesia the Dark Descent Download Mac Free Full Game
    Amnesia the dark descent download mac free full game Continue See more screenshots of Amnesia: Dark Descent, First Man Survival Horror. The game is about immersion, discovery and life through a nightmare. An experience that o should your core. Using a fully physically simulated world, cutting edge 3D graphics and a dynamic sound system, the game pulls no punches when trying to immerse you. Once the game starts, you'll be in control from start to finish. There are no cut scenes or time jumps, no matter what happens, what happens to you first hand. Amnesia: A dark descent throws you head into a dangerous world where danger can lurk around every corner. Your only defenses are hiding, running or using your mind. Other languages Look for similar items by category Of Feedback Open Mac App Store for buying and downloading apps. The last remaining memories disappear into darkness. Your mind is a mess, and only a sense of hunting remains. You have to run away. Woke up... Amnesia: Dark Descent, the first man survival horror. The game is about immersion, discovery and life through a nightmare. An experience that o should your core. Equipment requirements: - Intel processor.- ATI/AMD or NVIDIA graphics card, no other types of hardware are supported. If your computer does not meet the requirements, the game will freeze, crash or not run at all. March 4, 2015 Version 1.3.1 - Fixes various crash problems associated with additional gamepad support in 1.3.- Fixed the ability to re-switch buttons.- Updated launcher to properly limit SSAO samples to 32x.
    [Show full text]
  • Linux Games Page 1 of 7
    Linux Games Page 1 of 7 Linux Games INTRODUCTION such as the number of players and the size of the map, then you start the game. Once the game is running clients may Hello. My name is Andrew Howlett. I've been using Linux join the game. Clients connect to the game using TCP/IP, since 1997. In 2000 I cutover to Linux for all my projects, so it is very easy to play multi-player games over the except I dual-booted Windows to play games. I like to play Internet. Like many Free games, clients are available for computer games. About a year ago I stopped dual booting. many platforms, including Windows, Amiga and Now I play computer games under Linux. The games I Macintosh. So there are lots of players out there. If you play can be divided into four groups: Free Games, native don't want to play against other humans, then Freeciv linux commercial games, Windows Emulated games, and includes some nasty AIs. Win4Lin enabled games. This presentation will demonstrate games from each of these four groups. BZFlag Platform BZFlag is a tank combat game along the same lines as the old BattleZone game. Like FreeCiv, BZFlag uses a client/ Before I get started, a little bit about my setup so you can server architecture over TCP/IP networks. Unlike FreeCiv, relate this to whatever you are running. This is a P3 900 the game contains no AIs – you must play this game MHz machine. It has a Crystal Sound 4600 sound card and against other humans (? entities ?) over the Internet.
    [Show full text]
  • October 1999
    OCTOBER 1999 GAME DEVELOPER MAGAZINE ON THE FRONT LINE OF GAME INNOVATION GAME PLAN DEVELOPER 600 Harrison Street, San Francisco, CA 94107 t: 415.905.2200 f: 415.905.2228 w: www.gdmag.com Graphics Fly... Publisher Cynthia A. Blair cblair@mfi.com EDITORIAL Will Developers Fry? Editorial Director Alex Dunne [email protected] Managing Editor his heard at a Siggraph panel: pricing” — $5,000 or less per product, Kimberley Van Hooser [email protected] “Consumer graphics cards in no royalties). These will be inexpensive Departments Editor two years will be more power- tools that even junior developers can Jennifer Olsen [email protected] ful than any graphics card learn in a few weeks, and which can be Art Director T Laura Pool lpool@mfi.com available today at any price.” That’s integrated into a game quickly. Where Editor-At-Large quite a bold prediction, but I agree. will we get these dream tools? That Chris Hecker [email protected] Graphics hardware has entered a phe- brings me to my second point. Contributing Editors nomenal technological growth spurt, At Siggraph, it was evident that the Jeff Lander [email protected] Paul Steed [email protected] thanks in part to the demands of graphics research community desires Omid Rahmat [email protected] today’s games. The latest crop of con- closer ties to the game development Advisory Board sumer 3D chips, such as Nvidia’s industry. The problem is, researchers Hal Barwood LucasArts GeForce 256 (formerly known as NV10), don’t know how to build those relation- Noah Falstein The Inspiracy Brian Hook Verant Interactive 4 boasts features that were found exclu- ships with us, how to identify what Susan Lee-Merrow Lucas Learning sively on high-end workstation cards aspects of their research we might find Mark Miller Harmonix Dan Teven Teven Consulting only a year ago.
    [Show full text]
  • Human-Level AI's Killer Application: Interactive Computer Games
    AI Magazine Volume 22 Number 2 (2001) (© AAAI) Articles Human-Level AI’s Killer Application Interactive Computer Games John E. Laird and Michael van Lent I Although one of the fundamental goals of AI is to communication with natural language, com- understand and develop intelligent systems that monsense reasoning, creativity, and learning. have all the capabilities of humans, there is little If this is our dream, why isn’t any progress active research directly pursuing this goal. We pro- being made? Ironically, one of the major rea- pose that AI for interactive computer games is an sons that almost nobody (see Brooks et al. emerging application area in which this goal of [2000] for one high-profile exception) is work- human-level AI can successfully be pursued. Inter- active computer games have increasingly complex ing on this grand goal of AI is that current and realistic worlds and increasingly complex and applications of AI do not need full-blown intelligent computer-controlled characters. In this human-level AI. For almost all applications, article, we further motivate our proposal of using the generality and adaptability of human interactive computer games for AI research, review thought is not needed—specialized, although previous research on AI and games, and present more rigid and fragile, solutions are cheaper the different game genres and the roles that and easier to develop. Unfortunately, it is human-level AI could play within these genres. We unclear whether the approaches that have then describe the research issues and AI techniques been developed to solve specific problems are that are relevant to each of these roles.
    [Show full text]
  • Adding Anticipation to a Quakebot
    From: AAAI Technical Report SS-00-02. Compilation copyright © 2000, AAAI (www.aaai.org). All rights reserved. It Knows What You’re Going To Do: Adding Anticipation to a Quakebot John E. Laird University of Michigan 1101 Beal Ave. Ann Arbor, Michigan 48109-2110 [email protected] Abstract hyperblaster first and directly confront the enemy, The complexity of AI characters in computer games is expecting that your better firepower will win the day. continually improving; however they still fall short of Each of these tactics can be added manually for specific human players. In this paper we describe an AI bot for the locations in a specific level of a game. We could add tests game Quake II that tries to incorporate some of those that if the bot is ever in a specific location on a specific missing capabilities. This bot is distinguished by its ability level and hears a specific sound (the sound of the enemy to build its own map as it explores a level, use a wide picking up a weapon), then it should set an ambush by a variety of tactics based on its internal map, and in some specific door. Unfortunately, this approach requires a cases, anticipate its opponent's actions. The bot was developed in the Soar architecture and uses dynamical tremendous effort to create a large number of tactics that hierarchical task decomposition to organize it knowledge work only for the specific level. and actions. It also uses internal prediction based on its own Instead of trying to encode behaviors for each of these tactics to anticipate its opponent's actions.
    [Show full text]
  • Mesh-Qi Implementation Guide
    MESH-QI IMPLEMENTATION GUIDE Mentorship and Enhanced Supervision for Healthcare and Quality Improvement Authors Anatole Manzi, Catherine Kirk, Lisa R. Hirschhorn Editors Jennifer Goldsmith Collaborators Peter Drobac, Aphrodis Ndayisaba, Vanessa Redditt, Hema Magge, Neil Gupta, Gedeon Ngoga, Neo Tapela, Corrado Cancedda, Michael Rich, Joia Mukherjee, Joselyn Baker, Sheila Davis, Sara Stulac, Stephanie Smith, Giuseppe Raviola, Hildegarde Mukasakindi, Gene Kwan, Ashwin Vasan, and Ministry of Health and district hospital officials. Acknowledgements We are grateful for the contributions of the editors and all collaborators, MESH-QI mentors and technical advisors, PIH’s Communications and Global Learning and Training teams. The MESH-QI program was developed with tremendous financial support from the Doris Duke Charitable Foundation as well as the Hickey Foundation. We would like to acknowledge the support of our partners in the Rwandan Ministry of Health who are integral to MESH-QI’s success and the staff at the health centers who are committed to continuous improvement of the care and health of the populations in Southern Kayonza and Kirehe. Recommended citation Manzi, A., Kirk, C. Hirschhorn LR, Mentorship and Enhanced Supervision for Healthcare and Quality Improvement (MESH-QI) Implementation Guide. Partners In Heath 2017. Partners In Health is a 501(c)(3) nonprofit corporation and a Massachusetts public charity. © Partners In Health, 2017. This work is licensed under a Creative Commons Attribution. Partners In Health 800 Boylston Street, Suite 300, Boston, MA 02199 Phone: +1 (857) 880-5100 Fax: +1 (857) 880-5114 DESIGN one2tree • Rena Sokolow GRAPHICS cbdesign • Cindy Babaian COVER Women’s health mentor Leoncie Mukanzabikeshimana with mother and newborn at Rusumo Health Center, Kirehe, Rwanda.
    [Show full text]
  • Line Detection for Moth Flight Simulation
    The University of Saskatchewan Department of Computer Science Technical Report #2006-05 Line Detection for Moth Flight Simulation Brennan Rusnell Mark Eramian August 18, 2008 Contents 1 Introduction i 2 Theory v 3 Experimental Method vi 3.1 UIRemoval....................................... vii 3.2 EdgeRemoval..................................... ........ vii 3.3 HorizonCalculation .............................. ........... vii 3.4 OcclusionDetection .............................. ........... viii 3.5 VerticalEdgeDetermination . ............. ix 4 Setup x 4.1 Installation .................................... .......... x 4.2 Configuration.................................... x 4.3 Execution ....................................... xi 5 Analysis xii 5.1 HorizonOrientation .............................. ........... xii 5.2 OrthogonalEdges................................. .......... xii 6 Conclusion xvi 7 Acknowledgments xviii Bibliography xix i List of Tables 5.1 This data shows how the proposed methodology’s approximation to the horizon orientation compares to the actual horizon, which was manually computed.................. xiii 5.2 Terms/calculations used in analysis. The numbers generated by these calculations facilitate quantitative analysis of the proposed methodology. .................. xiv 5.3 The data in this table shows the correctness and completeness of the proposed methodology fororthogonaledgedetection. ............ xv 5.4 Overall data from Table 5.3. The values from Table 5.3 were summed and used in the equations from Table 5.2
    [Show full text]
  • Juiciness Exploring and Designing Around Experience of Feedback in Video Games
    Juiciness Exploring and designing around experience of feedback in video games Simeon Atanasov [email protected] Thesis-project, Interaction Design Master Supervisor: Simon Niedenthal Examiner: Jonas Löwgren Examination date: 31 May 2013 K3, MAH, Malmö, Sweden Spring term 2013 1. Introduction...................................................................................................................................................................5 2. Contribution summary...................................................................................................................................................6 3. Theoretical framework...................................................................................................................................................6 3.1. Emotion and beauty in design ............................................................................................................................................ 6 3.2. What is “aesthetics”?........................................................................................................................................................... 8 3.3. “Shared” aesthetics in video games................................................................................................................................... 9 3.4. Experience. From Interaction design to video games. ................................................................................................... 13 3.5. Experiential Qualities........................................................................................................................................................
    [Show full text]
  • Download/90/67> [22 May 2015] Hofstee, E
    An analysis of its origin and a look at its prospective future growth as enhanced by Information Technology Management tools. Master in Science (M.Scs.) At Coventry University Management of Information Technology September 2014 - September 2015 Supervised by: Stella-Maris Ortim Course code: ECT078 / M99EKM Student ID: 6045397 Handed in: 16 August 2015 DECLARATION OF ORIGINALITY Student surname: OLSEN Student first names: ANDERS, HVAL Student ID No: 6045397 Course: ECT078 – M.Scs. Management of Information Technology Supervisor: Stella-Maris Ortim Second marker: Owen Richards Dissertation Title: The Evaluation of eSports: An analysis of its origin and a look at its prospective future growth as enhanced by Information Technology Management tools. Declaration: I certify that this dissertation is my own work. I have read the University regulations concerning plagiarism. Anders Hval Olsen 15/08/2015 i ABSTRACT As the last years have shown a massive growth within the field of electronic sports (eSports), several questions emerge, such as how much is it growing, and will it continue to grow? This research thesis sees this as its statement of problem, and further aims to define and measure the main factors that caused the growth of eSports. To further enhance the growth, the benefits and disbenefits of implementing Information Technology Management tools is appraised, which additionally gives an understanding of the future of eSports. To accomplish this, the thesis research the existing literature within the project domain, where the literature is evaluated and analysed in terms of the key research questions, and further summarised in a renewed project scope. As for methodology, a pragmatism philosophy with an induction approach is further used to understand the field, and work as the outer layer of the methodology.
    [Show full text]
  • TR-068 Base Requirements for an ADSL Modem with Routing Issue: 2.0 Issue Date: March 2005
    TECHNICAL REPORT TR-068 Base Requirements for an ADSL Modem with Routing Issue: 2.0 Issue Date: March 2005 © The Broadband Forum. All rights reserved. Base Requirements for an ADSL Modem with Routing TR-068 Notice The Broadband Forum is a non-profit corporation organized to create guidelines for broadband network system development and deployment. This Broadband Forum Technical Report has been approved by members of the Forum. This Broadband Forum Technical Report is not binding on the Broadband Forum, any of its members, or any developer or service provider. This Broadband Forum Technical Report is subject to change, but only with approval of members of the Forum. This Technical Report is copyrighted by the Broadband Forum, and all rights are reserved. Portions of this Technical Report may be copyrighted by Broadband Forum members. This Broadband Forum Technical Report is provided AS IS, WITH ALL FAULTS. ANY PERSON HOLDING A COPYRIGHT IN THIS BROADBAND FORUM TECHNICAL REPORT, OR ANY PORTION THEREOF, DISCLAIMS TO THE FULLEST EXTENT PERMITTED BY LAW ANY REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY: (A) OF ACCURACY, COMPLETENESS, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; (B) THAT THE CONTENTS OF THIS BROADBAND FORUM TECHNICAL REPORT ARE SUITABLE FOR ANY PURPOSE, EVEN IF THAT PURPOSE IS KNOWN TO THE COPYRIGHT HOLDER; (C) THAT THE IMPLEMENTATION OF THE CONTENTS OF THE DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. By using this Broadband Forum Technical Report, users acknowledge that implementation may require licenses to patents.
    [Show full text]