raspberry pi gaming second edition - tentacle.netprophet/raspberrypi/raspberry pi/1784399337... ·...

249

Upload: dinhnguyet

Post on 01-Apr-2018

251 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 2: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 3: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RaspberryPiGamingSecondEdition

Page 4: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

TableofContents

RaspberryPiGamingSecondEdition

Credits

AbouttheAuthor

AbouttheReviewers

www.PacktPub.com

Supportfiles,eBooks,discountoffers,andmore

Whysubscribe?

FreeaccessforPacktaccountholders

Preface

Whatthisbookcovers

Whatyouneedforthisbook

Whothisbookisfor

Conventions

Readerfeedback

Customersupport

Downloadingthecolorimagesofthisbook

Errata

Piracy

Questions

1.GettingStartedwiththeRaspberryPi

ThedifferentflavorsofaRaspberryPi

SettingupanSDcard

CreatingtheSDcardinWindows

CreatingtheSDcardinMacintoshOSX

CreatingtheSDcardinLinux

UsingNOOBS

HookingupyourRaspberryPi

ConnectingtoaWi-Fiaccesspoint

Summary

Page 5: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

2.Scratch

WhatisScratch?

UnderstandingtheScratchinterface

MakingScratchymove

Somepointersandterminology

Let’sbuildaFlappyBirdclone!

Creatinganewproject

Makingthevariables

Settingthestage

Makingthefloor

Creatingthepipes

Workingwiththemaincharacter

Enhancingthegame

PingPong

Makingthepaddles

Followingthebouncingball

Summary

3.RaspberryPiGamingOperatingSystems

PiPlay

RetroPie

ChameleonPi

Summary

4.Emulators

RaspberryPiAppStore

UsingtheAppStore

Emulators

Mednafen

FCEUX(NES)

PiSNES(SNES)

MAME4ALL

FinalBurnAlpha

Page 6: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PCSX_ReARMed

PicoDrive(Genesis/MegaDrive)

Stella(Atari2600)

Controls

Summary

5.PortedGames

CaveStory

Installingandrunning

Controls

Doom

Installingandrunning

Controls

OpenArena

Installation

Singleplayermatch

Multiplayermatch

Runningaserver

Joiningaserver

Controls

Minecraft:PiEdition

Installingandrunning

CreatinganewMinecraftworld

UsingtheMinecraft:PiEditionApplicationProgrammingInterface

MultiplayerMinecraft

Controls

Summary

6.LinuxGames

FreeCiv

Installingandrunning

HostingaFreeCivserver

Learningthecontrols

Page 7: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SuperTux

Installingandrunning

Learningthecontrols

Njam

Installingandrunning

Learningthecontrols

Galaga:Hyperspace

Installingandrunning

Learningthecontrols

Findinggamesviatherepositories

Summary

7.Controllers

ControllersontheRaspberryPi

Gamepads

Arcadesticks

Xbox360controllers

SonyDualShock3controllers

USBencoders

GPIOpins

Installingandbuilding

Troubleshootingcontrollers

Summary

8.Troubleshooting

Usingraspi-config

Commontroubleshooting

EmulationStationreturnsanerrorwhenItrytolaunchit

NothinghappenswhenIapplypower

Someofthegamesseemslow

ConnectingviaHDMIdoesn’twork

TheDualShock3controllerdoesnotconnect

IgetanerrorwhencompilingRetrogame

Page 8: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Summary

A.GamesList

GamesavailableviaApt-Get

RaspberryPi2

Index

Page 9: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 10: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RaspberryPiGamingSecondEdition

Page 11: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 12: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RaspberryPiGamingSecondEditionCopyright©2015PacktPublishing

Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.

Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyoftheinformationpresented.However,theinformationcontainedinthisbookissoldwithoutwarranty,eitherexpressorimplied.Neithertheauthor,norPacktPublishing,anditsdealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecauseddirectlyorindirectlybythisbook.

PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthecompaniesandproductsmentionedinthisbookbytheappropriateuseofcapitals.However,PacktPublishingcannotguaranteetheaccuracyofthisinformation.

Firstpublished:September2013

Secondedition:February2015

Productionreference:1170215

PublishedbyPacktPublishingLtd.

LiveryPlace

35LiveryStreet

BirminghamB32PB,UK.

ISBN978-1-78439-933-7

www.packtpub.com

Page 13: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 14: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreditsAuthor

SheaSilverman

Reviewers

DustinLarmeir

MattMurray

HarishPillay

DanPurdy

CommissioningEditor

PramilaBalan

AcquisitionEditor

OwenRoberts

ContentDevelopmentEditor

SamanthaGonsalves

TechnicalEditor

PrajaktaMhatre

CopyEditors

PranjaliChury

MerilynPereira

AdithiShetty

ProjectCoordinator

SanchitaMandal

Proofreaders

SimranBhogal

LindaMorris

Indexer

MariammalChettiyar

ProductionCoordinators

ManuJoseph

NileshR.Mohite

CoverWork

Page 15: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ManuJoseph

Page 16: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 17: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

AbouttheAuthorSheaSilvermanhasbeenusingcomputerssincehewastwoyearsold.Hehasalwaysbeendrawntotechnology,videogames,education,andthepublicsector.HeisanemployeeattheCenterforDistributedLearningatUCF,wherehespendshistimeresearchinganddevelopingnewwaystoenhanceonlinelearning.HeisamemberoftheOrlandomakerspaceFamiLABandanalumnioftheUniversityofCentralFlorida.HisarticleentitledHacking,Learning,andtheRaspberryPiwaspublishedin2600:TheHackerQuarterly,hewasatechnicalreviewerforRaspberryPiNetworkingCookbook,PacktPublishing,andistheauthorofRaspberryPiGaming,PacktPublishing.

Youcanfindmoreinformationabouthimathttp://www.sheasilverman.com.

Iwouldliketothankmywonderfulwife,Kristene,whoprovidesunendingencouragementandsupporttomyprojects.Iwouldliketothankmyfriendsandfamilyfortheirongoingsupport,especiallymygrandmaforalwaysbelievinginme.Finally,IwouldliketothankLiz,Eben,andtheRaspberryPiFoundationforthecreationoftheRaspberryPi,aswellasthethewonderfulcommunitythathasflourishedsinceitsrelease.

Page 18: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 19: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

AbouttheReviewersDustinLarmeirhasworkedinthewebhostingandcloudindustryfornearly10years,supportingLinuxsystemsandthevirtualizationinfrastructure.Heisanavidtechnologyenthusiastandloveslearningnewconceptsaswellasteachingothers.

I’dliketothankmywifeforallofhersupportthroughtheyearsinmypursuitofacareerintechnology.

MattMurrayisacreativetechnologistwholovesallthingstech,art,andeducation-related.Heholdsabachelor’sdegreeincomputeranimationandisaself-taughtprogrammer,whostartedattheageof14.Inmorerecentyears,Matthasbeentinkeringwithmoreandmorehardware-relatedprojectswithahopetohelpbridgevirtualworldswithourown.

Iwouldliketothankmypatientwifeandkids.

HarishPillayhasbeenintheICTindustryforover30years.HeiscurrentlywithRedHat,workingoncommunity-relatedengagementsatthegovernment,corporate,andenddeveloperlevels.HarishholdsanMSEEandaBSCS,bothfromOregonStateUniversity.HarishfoundedtheSingaporeLinuxUsersGroupin1993.In2005,hewasinductedintotheCouncilofOutstandingEarlyCareerEngineersbytheCollegeofEngineering,OregonStateUniversity.In2009,hewaselevatedtoFellowoftheSingaporeComputerSociety.In2013,hewasnamedDistinguishedPartnerbySPRINGSingapore,thenationalstandardsandqualityagencyinSingaporeforhisworkandcontributionstoITstandardsinSingaporeandattheInternationalStandardsOrganization(ISO).

Eternalgratitudetomysoulmate,Usha,andourtwosons,AjayandAmrish,fortheirunconditionalloveandsupportforallthecrazythingsthatIdo.

DanPurdyisaLondon-basedfrontenddeveloper.HegraduatedfromtheUniversityofHuddersfieldwithadegreeinmusictechnologyandaudiosystemsandthenworkedasatechnicalengineeratatopLondonrecordingstudio,wherehehelpedmaintaintheirvastarrayofequipmentandprovidedtechnicalassistanceonavarietyofprojects.Duringthistime,hedevelopedandbuiltseveralwebapplicationstocentralizeanddigitizemanyofthestudios’processes,whilealsoexperimentingwithRaspberryPi.Hedevelopedseveralstandaloneapplicationsandgames,rangingfromkiosk-styledisplaysandtakecounterstoaidassistantsandclientstoabarcodereadingmicrophoneloggingsystem.Projectsaredocumented,alongwithtutorials,onhisblogathttps://www.danpurdy.co.uk.

Danhassincemovedontoworkasafull-timedeveloperatadigitalagencyinLondon,workingonenterprise-levelwebapplications,e-commercesites,andprototypeswhilecontinuingtoexperimentwithnewframeworksandtechnologies.HealsocontinuestodevelopanddocumentnewRaspberryPiprojects.

Page 20: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 21: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

www.PacktPub.com

Page 22: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Supportfiles,eBooks,discountoffers,andmoreForsupportfilesanddownloadsrelatedtoyourbook,pleasevisitwww.PacktPub.com.

DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFandePubfilesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandasaprintbookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwithusat<[email protected]>formoredetails.

Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signupforarangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooksandeBooks.

https://www2.packtpub.com/books/subscription/packtlib

DoyouneedinstantsolutionstoyourITquestions?PacktLibisPackt’sonlinedigitalbooklibrary.Here,youcansearch,access,andreadPackt’sentirelibraryofbooks.

Page 23: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Whysubscribe?FullysearchableacrosseverybookpublishedbyPacktCopyandpaste,print,andbookmarkcontentOndemandandaccessibleviaawebbrowser

Page 24: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FreeaccessforPacktaccountholdersIfyouhaveanaccountwithPacktatwww.PacktPub.com,youcanusethistoaccessPacktLibtodayandview9entirelyfreebooks.Simplyuseyourlogincredentialsforimmediateaccess.

Page 25: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 26: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PrefaceHi!WelcometothewonderfulworldoftheRaspberryPi.Inafewshortyears,theRaspberryPihasamassedarichdiversityofsoftware,cultivatedbyitsincrediblecommunity.

Inthisbook,wearegoingtoexploretheentertainmentcapabilitiesoftheRaspberryPi.Fromprogrammingyourownvideogames,torelivingclassicmomentswithyourfavoritegamesystems,I’mpositiveRaspberryPigamingwillhelpyouunlockthecapabilitiesofyourdevice.

Page 27: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

WhatthisbookcoversChapter1,GettingStartedwiththeRaspberryPi,willexplainthevariousdifferencesbetweentheRaspberryPimodels,showyouhowtosetupanSDcardforuseinyourdevice,andfinallyhowtohookupyourRaspberryPi.

Chapter2,Scratch,willintroducetheprogramminglanguageandprogrammingconceptsrequiredtobuildagame.Bytheendofthischapter,youwillhavemadetwogamesreminiscentofFlappyBirdandPingPong.

Chapter3,RaspberryPiGamingOperatingSystems,guidesyouthroughthedifferentoperatingsystemsthatarededicatedtovideogaming.Thesedistributionshavebeenspeciallysetuptoofferafunout-of-the-boxexperience.

Chapter4,Emulators,explainsthevariousgamingconsolesthatareavailabletobeemulatedontheRaspberryPi.YouwillalsolearnhowtoaccesstheRaspberryPiAppStoreandusethebuilt-insoftwarerepository.

Chapter5,PortedGames,showsyouhowtoinstallandusegamesthatwereoriginallyforothersystemsbuthavenowbeenreprogrammedtorunontheRaspberryPi.

Chapter6,LinuxGames,exploresthosegamesthatarenativetotheLinuxoperatingsystem.

Chapter7,Controllers,willintroduceandexplaintheworldofcontrollers,gamepads,andarcadesticks,andhowtheycaninterfacewiththeRaspberryPi.YouwillalsolearnhowtohookupyourfavoriteconsolegamepadstoyourPi.

Chapter8,Troubleshooting,willguideyouthroughthecommonissuesthatcropupwhenutilizingaRaspberryPi.

Appendix,GamesList,providesyouwithalistofthenativeLinuxgamesthatareavailableintheRaspbianrepositories.

Page 28: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 29: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

WhatyouneedforthisbookYouwillneed:

ARaspberryPiAnSDcard(4GBorhigher)AcomputerrunningOSX,Windows,orLinuxAnetworkconnection

Page 30: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 31: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

WhothisbookisforIfyouaresomeonewholovestoplaygamesandareinterestedinlearningmoreaboutthecapabilitiesofyourRaspberryPi,thisbookisforyou.BasicknowledgeofRaspberryPiprogrammingisexpected.

Page 32: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 33: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ConventionsInthisbook,youwillfindanumberoftextstylesthatdistinguishbetweendifferentkindsofinformation.Herearesomeexamplesofthesestylesandanexplanationoftheirmeaning.

Codewordsintext,databasetablenames,foldernames,filenames,fileextensions,pathnames,dummyURLs,userinput,andTwitterhandlesareshownasfollows:“Inthecommandprompt,typestartxtolaunchthedesktopenvironment.”

Whenwewishtodrawyourattentiontoaparticularpartofacodeblock,therelevantlinesoritemsaresetinbold:

1. Runsudochownpi/opt/retropie/configs/all/retroarch.cfg.2. Thenruncd/opt/retropie/emulators/RetroArch/installdir/bin.3. Finally,runsudo./retroarch-joyconfig-j0>>

/opt/retropie/configs/all/retroarch.cfg.

Anycommand-lineinputoroutputiswrittenasfollows:

mc.setBlock(player.x+1,player.y,player.z,block.GOLD_BLOCK)

Newtermsandimportantwordsareshowninbold.Wordsthatyouseeonthescreen,forexample,inmenusordialogboxes,appearinthetextlikethis:“AfterclickingonConnect,youwillbeaskedtologinasRegisteredUserorasGuest.ChooseGuest.”

NoteWarningsorimportantnotesappearinaboxlikethis.

TipTipsandtricksappearlikethis.

Page 34: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 35: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ReaderfeedbackFeedbackfromourreadersisalwayswelcome.Letusknowwhatyouthinkaboutthisbook—whatyoulikedordisliked.Readerfeedbackisimportantforusasithelpsusdeveloptitlesthatyouwillreallygetthemostoutof.

Tosendusgeneralfeedback,simplye-mail<[email protected]>,andmentionthebook’stitleinthesubjectofyourmessage.

Ifthereisatopicthatyouhaveexpertiseinandyouareinterestedineitherwritingorcontributingtoabook,seeourauthorguideatwww.packtpub.com/authors.

Page 36: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 37: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CustomersupportNowthatyouaretheproudownerofaPacktbook,wehaveanumberofthingstohelpyoutogetthemostfromyourpurchase.

Page 38: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

DownloadingthecolorimagesofthisbookWealsoprovideyouwithaPDFfilethathascolorimagesofthescreenshots/diagramsusedinthisbook.Thecolorimageswillhelpyoubetterunderstandthechangesintheoutput.Youcandownloadthisfilefrom:https://www.packtpub.com/sites/default/files/downloads/9337OS_ColoredImages.pdf.

Page 39: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ErrataAlthoughwehavetakeneverycaretoensuretheaccuracyofourcontent,mistakesdohappen.Ifyoufindamistakeinoneofourbooks—maybeamistakeinthetextorthecode—wewouldbegratefulifyoucouldreportthistous.Bydoingso,youcansaveotherreadersfromfrustrationandhelpusimprovesubsequentversionsofthisbook.Ifyoufindanyerrata,pleasereportthembyvisitinghttp://www.packtpub.com/submit-errata,selectingyourbook,clickingontheErrataSubmissionFormlink,andenteringthedetailsofyourerrata.Onceyourerrataareverified,yoursubmissionwillbeacceptedandtheerratawillbeuploadedtoourwebsiteoraddedtoanylistofexistingerrataundertheErratasectionofthattitle.

Toviewthepreviouslysubmittederrata,gotohttps://www.packtpub.com/books/content/supportandenterthenameofthebookinthesearchfield.TherequiredinformationwillappearundertheErratasection.

Page 40: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PiracyPiracyofcopyrightedmaterialontheInternetisanongoingproblemacrossallmedia.AtPackt,wetaketheprotectionofourcopyrightandlicensesveryseriously.IfyoucomeacrossanyillegalcopiesofourworksinanyformontheInternet,pleaseprovideuswiththelocationaddressorwebsitenameimmediatelysothatwecanpursuearemedy.

Pleasecontactusat<[email protected]>withalinktothesuspectedpiratedmaterial.

Weappreciateyourhelpinprotectingourauthorsandourabilitytobringyouvaluablecontent.

Page 41: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

QuestionsIfyouhaveaproblemwithanyaspectofthisbook,youcancontactusat<[email protected]>,andwewilldoourbesttoaddresstheproblem.

Page 42: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 43: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter1.GettingStartedwiththeRaspberryPiTheRaspberryPiisaninexpensive,feature-richmoderncomputercreatedbytheRaspberryPiFoundation.SincethereleaseoftheModelBin2012,thecommunitysurroundingthecomputerhasgrown,allowingforanincredibleamountofprojectsandsoftwaretobecreatedforthedevice.Theserangefromprogramminglanguages,educationalapplications,hardwareprototypes,andofcourse,videogames.

Inthischapter,youwilllearnthefollowingtopics:

ThedifferentflavorsofaRaspberryPiSettingupanSDcardHookingupyourRaspberryPi

Page 44: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ThedifferentflavorsofaRaspberryPiTheRaspberryPiFoundationhasreleasedfourmajormodelsoftheRaspberryPicomputer.TheytheareModelA,ModelB,ModelB+,andModelA+.TheRaspberryPi’sCPUistheBroadcomBCM2835chip.ItcontainsanARMprocessorrunningat700MHzandapowerfulgraphicschip.TheboardfeaturesHDMIandComposite(RCA)videooutputs,USBports,twoexpansionslots,aMicroUSBportforpower,andanarrayofGPIO(General-purposeinput/output)pinstointeractwiththeoutsideworld.

Sinceallmodelssharethesamebasichardwareplatform,alltheexamplesinthisbookareapplicabletoalltheversions.

ModelA ModelA+ ModelB ModelB+

USB 1 1 2 4

Ethernet 0 0 1 1

Videooutputs HDMI/Composite HDMI/Compositevia

3.5mmjack HDMI/Composite HDMI/Compositevia3.5mmjack

Memory 256MB 256MB 512MB 512MB

Storage SDcard MicroSDcard SDcard MicroSDcard

Powerusage 300mA 300mA 700mA 600mA

Price $25 $20 $35 $35

DifferencesLowcostsolution.DoesnothavebuiltinEthernetandithasonlyone1USBport.

Newestboard.Lowpower,lowcost,andmuchsmallerformfactor.

Originalboard.Balancesfeaturesandprice.

NewrevisiontotheBboard.Hasanewlayout,4USBports,andmoreGPIOpins.

Page 45: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 46: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SettingupanSDcardTheRaspberryPiusesSDcardstocontainitsoperatingsystemandmainstoragespace.ARaspberryPiSDcardcontainstwopartitions,whichareexplainedasfollows:

Thefirstone,isthebootpartition.ThisspacecontainstheLinuxkernel,requiredbootupfiles,andmostimportantly,theconfig.txtfile.ThisfileallowsyoutochangetheboottimeparametersandcustomizesomeofthefunctionsoftheRaspberryPi.Theseoptionsincludeover-clockingthedevice,changingmonitorsettings,andthememorysplitbetweenCPUandGPU,amongnumerousotheroptions.ThesecondpartitioncontainsaLinuxpartition,whichholdsallofyourapplications,configurations,andoperatingsystemfiles.

PreloadedSDcardimagesareavailable,whichmakeitquickandeasytogetyourRaspberryPiupandrunning.

ChoosinganSDcardisanimportantstep.Therearemanydifferentcombinationsofcardsizesandcardspeeds.4GBistheminimumsizerequiredformanyoftheoperatingsystems(OS).Irecommendthatyoustartoutwithan8GBcard.YouwillalsoseecardsmarkedwithClass4,Class6,andClass10.Thisisthespeedatwhichthecardcanbereadandwrittento.IhavefoundthatthebestbangforthebuckisaClass6card,butdon’tworrytoomuchaboutwhichoneyouchoose.

Beforewebegin,youwillneedtodownloadasuitableRaspberryPiOS.WewillbeusingtheofficialoperatingsystemcalledRaspbian.Youcandownloaditfrom

http://www.raspberrypi.org/downloads.

NoteWarning!ddandWin32DiskImagercanbeusedtooverwriteyourcomputer’sownharddriveorotherdrivesconnectedtoyourcomputer.DoubleandtriplecheckthatthedriveyouselectisyourSDcard.

Page 47: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreatingtheSDcardinWindowsTocreatetheSDcardinWindows,youwillneedtodownloadtheprogramcalledWin32DiskImagerbyvisitinghttp://sourceforge.net/projects/win32diskimager/.

Onceyouaredonewiththedownloading,performthefollowingsteps:

1. UnziptheRaspbianimagebydouble-clickingontheRaspbian.zipfile.2. Selectaplaceonyourharddrivetosavetheextractedfile.3. ClickonExtractfiles….4. InserttheSDcardintoyourcomputer’sSDcardreader.5. RunWin32DiskImager.

6. SelecttheRaspberryPiimageonyourharddrive.7. SelectthedriveletterunderthedevicethatcorrespondstotheSDcard.8. ClickonWrite.

Page 48: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreatingtheSDcardinMacintoshOSXOSXincludeseverythingyouneedtocreatetheSDcardoutofthebox.Wewilluseautilitycalleddd:

1. Double-clicktheRaspbianimageZIPfile.ItwillautomaticallyextractintothesameplaceastheZIPfile.

2. InserttheSDcardintoyourcomputer’sSDcardreader.3. Opentheterminalapplication(locatedintheApplications|Utilitiesfolder).4. FindthenameofyourSDcardbytypingdiskutillist.

5. UnmountyourSDcardbytypingdisktuilumountdisk<disk>,thatis,/dev/disk2.

6. CopytheOSimagefromyourharddrivetotheSDcardbytypingddif=/path/to/os/image.imgof=<disk>where<disk>is/dev/disk2,andpath/to/os/image.imgistheplacetowhichyousavedtheimage.

7. Itcantakeanywherefrom15minutestooveranhourfortheimagetobewrittentotheSDcard.Itwilllooklikenothingishappeninguntilitfinishescopying.Whenitisdone,youwillseeamessageshowinghowlongittooktotransferinseconds.

TipYoucanpressCtrl+Tatanytimetoseethecurrentstatus.

Page 49: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 50: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreatingtheSDcardinLinuxLikeOSX,Linuxincludeseverythingyouneedoutofthebox:

1. InserttheSDcardintoyourcomputer’sSDcardreader.2. Usingtheterminalofyoursystem,findthenameofyourSDcardbytypingsudo

fdisk–l.3. Ifrequired,youcanunmountyourSDcardbytypingumount<disk>(whichwillbe

listedfromtheearliercommand,IE/dev/disk2).4. CopytheOSimageonyourharddrivetotheSDcardbytypingdd

if=/path/to/os/image.imgof=<disk>.

NowthatyouhavecreatedyourRaspberryPiSDcard,it’stimetosetupourdevice!

Page 51: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

UsingNOOBSTheRaspberryPiFoundationhascreatedapieceofsoftwarecalledNewOutOftheBoxSoftware,oftenabbreviatedasNOOBS.Thisisasmalloperatingsystem,whichisusedtoinstallotherOSsontoyourRaspberryPi.

InstallingNOOBSismucheasierthanotherinstalls:

1. DownloadNOOBSfromhttp://www.raspberrypi.org/downloadsandunzipthefile.2. InserttheSDcardintoyourcomputer’sSDcardreader.3. DraganddroptheNOOBSfilesontotheSDcardandyouaredone!

Atthefirstboot,youwillbepresentedwithalistofOSsavailabletobeinstalled.ChooseRaspbianandpressEnter.

Page 52: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 53: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

HookingupyourRaspberryPiIt’sveryeasytoproperlysetupaRaspberryPi.IfyoucanbuildaLegoset,youcanbuildyourRaspberryPicomputer.Thefollowingstepswillhelpyouinthis:

1. PlaceyourSDcardintotheSDcardslotontheundersideoftheRaspberryPi.2. ConnecttheHDMIorRCAcabletotherespectiveconnectorontheRaspberryPi,

andplugtheotherendintoyourmonitor.3. PlugtheEthernetcableintotheEthernetjack(notapplicabletoModelAandA+)on

theRaspberryPiandtheotherendintoyourrouterorswitch.4. ConnecttheUSBmouseandkeyboardtothetwoUSBportsavailableonthe

RaspberryPi.IfyouareusingModelA,connectaUSBhubtoyourRaspberryPiandthemouseandkeyboardtothehub.

5. Plugthepowersupply’sMicroUSBconnectorintotheMicroUSBportontheRaspberryPitoturniton.

6. AredLED,bytheUSBports,willlightuptoindicatethatthepoweristurnedon.7. Onyourscreen,asquarerainbowimagewillappearforabriefmoment,followedby

somequickmovingtextoragraphicloadingscreen.

Congratulations!YouhavesuccessfullybootedupyourRaspberryPi!

Page 54: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ConnectingtoaWi-FiaccesspointTheRaspberryPiandRaspbiancaneasilyconnecttotheInternetviaEthernet,butwhenusingaUSBwirelessdevice,youcanalsoconnecttoaWi-Finetwork.RaspbianincludesagraphicalutilitytomakeconnectingtoaWi-Fiaccesspointeasy.Gothroughthefollowingsteps:

1. BootupyourRaspberryPi.2. Attheloginscreen,enteryourusernameandpassword(defaultispiandraspberry,

respectively).3. Inthecommandprompt,typestartxtolaunchthedesktopenvironment.4. Usingyourmouse,double-clickontheWiFiConfigiconthatisonthedesktop.5. TheWi-Ficonfigurationtoolwillappearshortly.

6. ClickonScantoscanforavailablewirelessnetworksaroundyou.7. Double-clickontheoneyouwishtoconnectto.

Page 55: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

8. Ifitisasecurednetwork,youwillbeaskedforapassword.9. EnterthepasswordandclickonAdd.

Page 56: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

10. TheStatus:DisconnectedmessageshouldnowchangetoStatus:Completed.

11. Youarenowconnectedtoyourwirelessnetwork.

Notewpa_guisavesyourconnectioninformation.IfyoulogoutorrebootyourRaspberryPi,itwillautomaticallytrytoconnecttoapreviouslyaddedaccesspoint.

Ifyoudonotseewlan0appearinthewpa_gui,orifyourRaspberryPiisunstable,youmightneedtouseapoweredUSBhub.Youshouldconnectyourdevicetoapoweredhub,andthenconnectthehubtotheRaspberryPi.Thiswillensurethatthecorrectamountofpowerisreceived.

YoucanalsocheckwhetheryourWi-Fiadapterissupportedbyvisitinghttp://elinux.org/RPi_USB_Wi-Fi_Adapters.

Page 57: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 58: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryInthischapter,youlearnedhowtocreateyourRaspberryPi’sSDcard,hookituptoyourTVandotheraccessories,andconnectittotheInternet.Now,it’stimetohavefunwiththesoftwareonyourRaspberryPi.

Inthenextchapter,youwilllearnhowtocreateyourownvideogameusingtheScratchprogramminglanguage.

Page 59: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 60: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter2.ScratchThischapterwillintroduceyoutotheamazingandfunworldofprogramming.Learningtoprogramandcodewillallowyoutobringyourideastocreation.Ifyouhaveeverwantedtomakeagame,buthadnoideawheretostart,thisistheplace.

Inthischapter,youwilllearnthebasicsneededtomakeyourownvideogameontheRaspberryPi.Youwilllearnhowto:

LaunchScratchDefineyourgame’sobjectivesDrawacharacterMakeyourcharacterinteractandmoveDesignandprogramaFlappyBird-stylegameDesignandcreatea2playerPingPonggame

Page 61: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

WhatisScratch?ScratchisaprogramminglanguageandapplicationdevelopedbytheMassachusettsInstituteofTechnology(MIT)asaneasy-to-use,educational,andfunenvironmenttolearntocodeandtomakevideogamesandapplications.Itisdifferentfrommostotherprogramminglanguages.Itiscompletelyvisual;ratherthantypingoutlinesofcode,allyouhavetodoisdraganddropvisualblockstocreateyourprogram.

Gamesthatmighthavetakendaystobecreatedearliercanbecreatedinminutes,rightinfrontofyoureyes.Now,youaregoingtocreatesomegamestoo!

Page 62: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

UnderstandingtheScratchinterfaceBeforewebeginwritingourfirstgame,youneedtounderstandtheScratchinterface.Scratchisnotonlyapowerfulprogramminglanguage,butalsoafull-featuredapplication.TowriteScratchprogramsusethefollowingsteps:

1. OpentheScratchapplication.ThisisincludedonallcopiesoftheofficialRaspberryPioperatingsystem,Raspbian.

2. Inthecommandline,typestartxtoactivatethedesktopenvironment.3. Onceatthedesktop,double-clickontheScratchicon.4. Scratchshouldnowopenanddisplayabrandnewproject,whichisreadyforyouto

begin.

Thefirstthingsyouwillnoticeisthattherearethreecolumns.Onthefarrightside,youshouldseeawhitesquarewithahappylookingcat.HisnameisScratchy.HeisalsothemascotofScratch.Thispaneliswherealltheactiontakesplace.Thisisyourgamescreen.

Thecolumninthemiddleiswhereallyourcodewillbeplaced.Atthemomentthereisnothinginhere,butthiswillsoonchange.

TheleftcolumncontainseverysingleavailablecommandintheScratchlanguage.Touseoneofthesepiecesofcode,justclickononeanddragittothemiddlecolumn.

Forourfirstexample,wewillmakeScratchymove.

Page 63: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MakingScratchymoveLet’sgetreadytocreateourfirstprogram:

1. ClickonScratchyinthewhitepaneltomakesureheisselected.YouwillseeSprite1highlightedinthepanelbelow.SpritesarewhatthesecharactersarecalledinScratch.

2. Now,clickontheControlbuttonfromtheleftsideinthefirstcolumn.3. ClickontheWhen<greenflag>clickeditemanddragittothemiddlecolumn.4. Next,clickonMotionanddragthemove10stepsitemtothemiddlecolumn.5. MoveitundertheWhen<greenflag>clickeduntilawhitelineappearsbetween

them,andthenletgoofthemousebutton.

6. Now,clickonthegreenflagbuttonabovethegamepanel,andyoushouldseeScratchymoveabit.

Congratulations!YouhavejustmadeyourfirstapplicationinScratch.Let’sgetreadytomakeourfirstgame!

Page 64: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SomepointersandterminologyBeforewestartworkingonourawesome,exciting,andfungames,hereareafewpointersandtipsforworkingwithScratch:

Variable:Youcanthinkofavariableasaboxthatcanstorethings.InScratch,eachvariablecanstoreanitem,beitanumber,aname,orsomeothervalue.Stage:Thisisthebackgroundofthegamewindow.Youcansetthestagebackgroundtobeanumberofdifferentimages,andevenincludescriptsonthestage.Xposition:Thisiswhereaspriteisonthexaxisofthestage.Thexaxisgoesleftandright(horizontally).YPosition:Thisiswhereaspriteisontheyaxisofthestage.Theyaxisgoesupanddown(vertically).Sprite:Thisisanythingonthegamestage.Itcanbeacharacter,awall,anenemy,apowerup,andsoon.Spriteshavetheirowncostumesandcode.Costume:Thisreferstowhataspritelookslike.Youcanhavemultiplecostumesforasprite.Ifstatement:Thissimplyasksatrueorfalsequestion.Ifit’strue,dothenextstep.Astatementthatsays2=2whichistrue,soitcontinues.If…elsestatement:Liketheearliercommand,anif…elsestatementwillcheckwhetherthestatementistrue,andifitisnot,itwilldowhateverisintheelseblock.Foreverloops:Foreverloopsareblocksofcodethatwillcontinuouslydoasetofcommands.Onceitreachestheend,itrestartsfromthebeginningoftheblockandperformsthemoverandover.

TipIfyoudon’tknowwheretofindtherightcommandfromtheexampleinstructions,lookatthecolorofthecommand.Thecolorsmatchtheactionbuttons.

Page 65: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 66: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Let’sbuildaFlappyBirdclone!YourfirstgameisgoingtobeaFlappyBirdclone.Whilethismightseemlikeacomplicatedtask,itreallycanbebrokendowntoafeweasyscripts.

NoteFlappyBirdisagreatstartinggame.Ithasaclearobjective,usesmuchoftheScratchfunctionality,isrelativelysimpletocreate,andyoucanuseyourimaginationbydrawingyourownsprites,backgrounds,andpipes.

WhatkindofagameisFlappyBird?Itisagamewhereyourgoalistokeeponpressingabuttontomakeabirdriseasitisconstantlyfallingwhilenavigatingitswaythroughthepipesofvaryingheightsthatarecomingatit.

Itcanbebrokendownasfollows:

EverybuttonpressmakesthebirdgoupontheyaxisEverysecondthebuttonisn’tpressedthebirdgoesdowntheyaxisApipestartsattherightendofthexaxisandmoveslefttowardthebirdWhenthepipereachesthefarleftcornerwithouttouchingthebird,youearnapointandthepipedisappearsIfthebirdtouchesthegroundorthepipe,thenthegameisover

So,nowweknowweneedaminimumoftwosprites:abirdandapipe.

Whatelsewillweneed?Wewillneedabackground,afloor,somevariables,andafewcostumes.

Page 67: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreatinganewprojectBeforewebegin,let’screateanewprojectforourFlappyBirdclone.Todoso,clickontheFilemenuandthenclickonNew.AbrandnewScratchprojectwillappear.

Page 68: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MakingthevariablesNowthatweknowwhatweneed,wecanstartbycreatingourvariables:

1. ClickontheVariablesbutton,andthenclickonMakeavariable.Itwillaskyouforaname,anddisplaytwooptions:ForallspritesandForthisspriteonly.EnsurethatyouclickonForallsprites.

2. Ourfirstvariablewillbenamedscore.TypethisandclickonOK.Thescorevariablewillbeusedtokeeptrackofhowmanywallsyouhavepassed.Itwillgoupbyoneeachtime.

Now,makethreemorevariableswiththefollowingnames:

scroll:Thiswillbeusedtokeeptrackofwheretheflooris,sinceitwillbemovingtime:ThiswillkeeptrackofhowmanysecondshavepassedsinceyoustartedthegamepipeX:Thiswillkeeptrackofwherethepipeisacrossthescreen

Page 69: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SettingthestageWithourvariablescreated,itisnowtimetocreateourgame’sbackgroundsusingthefollowingsteps:

1. ClickonStageintherightcolumn,andthenclickonBackgrounds.2. ClickonEdit.YouwillnowbeinPaintEditor.3. Clickonacolor,thenthepaintcan(filltool),andclickanywhereonthewhitearea.

ThenclickonOK.Youhavenowchangedthebackgroundofyourgame.

4. ClickonCopythreetimes,andthenediteachbackgroundtobeadifferentcolor.5. Now,clickonScripts.Wewilladdthefirstscriptstoourgame.

Page 70: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Thisstagehastwoscripts:

Whenthegreenflagisclicked,itsetsthebackgroundtothenextbackground,waitsforonesecond,andthensetsittothenext.Itwillrepeatthisforeveruntilthegameisover.Thesecondscriptalsowaitsforthegreenflagtobeclicked.Itthensetsthevariabletimeto0,andadds1toiteverysecondusingaforeverblock.Theforeverblockrepeatswhat’sinsideofituntilthegameisstopped.

Ifyouclickonthegreenflag,youshouldseethebackgroundchange.Nowwouldbeagoodtimetosaveyourgameaswell.ClickonFile,thenchooseSave.GiveyourgameanameandclickonOK.

Page 71: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 72: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MakingthefloorThefloorofthegameservestwopurposes.Thefirst,istomakeitlooklikeyouaremovingbecausethefloorscrollsacrossthestage.Thesecond,istobeanavoidableobject.Ifyoutouchthefloor,thegameisover.Ourfloorisactuallygoingtobetwosprites.

Let’sstartwiththefirstone:

1. Ontheright-handsideofthewindowisanoptiontocreateanewsprite.Youhavethreeoptions:Paintnewsprite,Choosenewspritefromfile,orGetasurprisesprite.

2. CreateanewspritebyclickingonthePaintnewspritebutton.3. Now,usethelinetool anddrawalineallthewayfromthelefttotheright.Then

fillitinwithacolorusingthebuckettool .

4. ClickonOK.NameyourspriteFloor1byclickingonthenametextboxinthemiddlecolumn.

Now,let’screatethescriptsasfollows:

Page 73: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Thefirstfloorspritehasthreescripts:

Thefirstscriptsetsthescrollvariableto0,andthenuntilthegameisover,itdecreasesby1.Thesecondscriptputsthefloorintoposition.Aftersettingthefloortobethefront-mostitem,itsetstheypositionto-180.Thisputsitatthebottomofthestage.Itthensetsthexpositionofthefloortothecurrentvalueofthescrollvariable.Thiswillmakeitmove.

Youwillinitiallydragthesetxto0motiontothescriptscolumn.Youwillthendragthevariablescrolloverthe0tochangeit.

Thethirdscriptresetsthescrollvariableto0ifitreachestheendofthescreen.

Pressthegreenflagbuttontowatchthefloorscroll.Itseemslikethere’sasmallproblemthough:thefloorisn’tlongenough.Itscrollsoffthescreenwithnothingbehindituntilitreachestheend.Don’tworrythough.It’sasimplefix!

1. Right-clickonFloor1andthenclickonDuplicate.2. Youshouldnowhaveacompletecopyofyourfloorsprite.Youshouldrenameitto

Floor2.Now,clickonitandchooseScripts.Wehavetomakeafewadjustments.3. DeletethefirstandthirdscriptfromFloor2.Youcandothisbyclickingand

draggingthemtothefirst(leftmost)column.4. Now,edittheremainingscripttolooklikethis:

Page 74: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Bysettingxtoscroll+480,youwillnowhaveasecondfloorthatfollowsthefirstfloorandcontinuallyrepeats.

Youcanaddsomecolorandsomegrasstothecostumetoaddtothescrollingeffect.

Page 75: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreatingthepipesThepipesarerelativelystraightforward.Itisonesprite,withthreecostumes,andonescripttomakeitscrollacrossthescreen.

1. ClickonCreatenewspriteanddrawapipe.Mineisjustalongblackrectanglegoingallthewayfromthebottomtothetopoftheeditor.

2. UsetherectangletooltoselectaportionofthepipeandpressDelete.Younowhavetheareatoflythrough.

3. Copythecostumetwomoretimes.Thistimerefillintheholeandcreateanewoneatadifferentspotinthepipe.

Now,let’smakethepipescripts!

Page 76: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Thefollowingstepsexplainthemakingofpipescripts:

1. Whenthegreenflagisclicked,movethepipetothetopofthelayer,andthenbackthreelayers.Thiswillmakeitappearbehindthefloor.

2. Thesetsizeisanewcommand.Thisallowsyoutomakethespritebiggerorsmaller.Experimentwiththesizeuntilyouarehappywithhowitlooks.Youcanalsochangethistoaffectthedifficultyofthegame.Ifyoudon’tseetheholeinthemiddleofthewall,itmaybebecausethesizeissettoohigh.

3. Then,setyto0,whichputsthewallrightinthemiddleofthescreen,andxto300,whichmovesitoffthescreentotheright.

4. SetthepipeXvariableto300.Wewillusethatvariablelater.5. Inourforeverloop,subtract1frompipeX.ThencheckwhetherpipeXislessthan

-240.Thisallowsustocheckwhereitisonthescreen.Ifitislessthan-240(whichputsthepipetotheleftofthescreen),resetthepositionofthepipetothefarright,bysettingpipeXbackto300.Then,changethecostumetothenextone.

6. Finally,setthexpositionofthepipetopipeX.Wenowhaveascrollingpipe!

Page 77: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

WorkingwiththemaincharacterNow,it’stimetomakeourmaincharacter!Thisspriteisgoingtoneedtwocostumes:onewiththewingsupandonewiththewingsdown.Luckily,Scratchalreadyincludescostumes,soyoudon’thavetodrawityourself(butfeelfreetodosoifyouwant!).

1. Ifyouhaven’tremovedScratchyyet,right-clickontheScratchyspriteiconintherightcolumn,andselectdelete.

2. Underthegamestage,you’llseetheChoosenewspritefromfileoption.Clickonthatoption.

3. Apopupwillbedisplayedshowingalistoffolders;choosethefolderAnimals.4. Formyexample,Ichoosebat1-aasshowninthefollowingscreenshot:

5. Double-clickonit,andyouwillseeitappearonyourstageandinthespritepanel.Selectit,andthenclickonCostumes.

6. Next,inNewcostume,selectImportandchoosebat1-b.Yourspritenowhasthecostumesthatitneedstolooklikeit’sflying.

7. Ifyoufeellikedrawingyourowncostumeforyoursprite,selectPaintinstead.

Page 78: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Now,let’sworkonthescriptsforourbat!

Whenthegreenflagisclicked,setthescorevariableto0,switchtothecostumewiththebatwingsup,setthesizetobe10percentoftheoriginalspritesize,gotothetopmostlayer,andthenmovetothosexandypositions.Playaroundbychangingthesizeofyourbatandexperimentingwiththexandypositions.Changingthesewillaffectthedifficulty

Page 79: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ofyourgame.

Now,weenterourforeverloop.Eachtimethisloopoccurs,wesetthespritetobethebatwithwingsup,andmoveitdownby1onthestage.Thisnextblockintroducesustouserinput.Itsaysthatifthespacekeyispressedonyourkeyboard,thenitshouldswitchtothebatwithwingsdownandmoveupthestageby5.Youcanchangethekeytobeanythingonyourkeyboard.Youcanalsochangethe5toincreaseordecreasetheheightatwhichthebatfliesperbuttonpress.

Thenexttwoifblocksfollowthesameformula.IfyourbatspritetouchesFloor1,Floor2,orthepipes,thenGameOverwillappearnexttothespriteandthegamewillstop.

Finally,ifthexpositionofthebatisequaltothevalueofpipeX,thenyoushouldchangethescoreby1,sinceitindicatesthatyouhavepassedthroughoneofthepipessuccessfully.

Now,tryoutyourgame!

Page 80: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

EnhancingthegameNowthatyouhavecreatedyourFlappyBirdclone,youshouldtrytoenhanceandmodifyit.Herearesomeideas:

AddamultiplayeroptionCreateagameoverscreenbymakinganewbackgroundandsettingittothescreenthatappearswhenyoutouchapipeMakeascrollingbackgroundTrymakingthepipesscrollfasterorappearatrandomtimes

Whenyouareready,wecanmoveontothenextgame.

Page 81: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 82: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PingPongIt’stimetogobackintime,andrecreateagamethathelpedtolaunchthevideogameindustry.IthasgonebymanynamessuchasPong,PingPong,andTableTennis,butthebasicgameplayhasstayedthesame.Twopaddles,oneball,andanepicbattletogettheballpasttheotherplayer.

So,let’sbreakdownthisgame.Wewillrequire:

OnepaddlefortheleftplayerOnepaddlefortherightplayerOnebouncingballTwovariablestokeepscoreforeachplayer.

Let’sgetstarted!

Page 83: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MakingthepaddlesAftercreatinganewproject,youwillbepresentedwiththewhitestageandaScratchysprite.

1. Right-clickonScratchyandclickondelete.Now,clickonPaintnewsprite.

2. DrawalongblackrectangleandclickonOK.NamethisspriteLeft.

Wearegoingtocreatethreesimplescriptsforthispaddle,asfollows:

3. Thefirstscriptensuresthattheleftpaddlepointsintheproperdirectionandthensetsitssizeto60percent.Youshouldexperimentwiththesizetodeterminewhatfeels

Page 84: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

rightforyourgame.4. Thenexttwoscriptscontroltheverticalmovementoftheleftpaddle.Again,

experimentwiththeamountofmovementthateachbuttonpressdoestochangethedifficultyofyourgame.

5. Whenyouhavesettheseup,right-clickonyourleftpaddlespriteandclickonDuplicate.

6. RenamethenewspritetoRight.Wenowhavethebeginningformakingourrightpaddle.Youwillbemakingafewadjustments,sothatasecondplayerwillcontrolthepaddle.

Wechangethedirectioninwhichthepaddleispointingtoensurethatitfacestherightdirection.Youthenneedtochangethekeysthatyouwillbeusingforthesecondplayertomovethepaddleupanddown.Inthisexample,weusetheupanddownarrowkeys.

Onthestageitself,draganddropyourpaddlesintotheproperpositions.Theleftpaddleshouldbeontheleft-handsideofthestage,butnottouchingthewall,whiletherightpaddleshouldbeontheright-handside,whilealsoleavingagapbetweenthepaddleandthewall.

Whenyouhavemadeyourchoices,clickonthegreenflagbuttonandtestyourgame.Thepaddlesshouldbeabletomoveupanddown.

Page 85: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FollowingthebouncingballNow,it’stimetocreatetheheartoftheprogram:theball!

Togetstarted,let’screateanewsprite:

1. Startbyimportingaspritefromthelibrary.Therearenumerousroundball-likecostumestochoosefrom.Whenyouarehappywithyourcostume,double-clickonit.RenameyournewspritetoBall.

2. Now,youwillneedtomaketwovariables.NamethemLeftScoreandRightScoreandsetthemtobeusedbyallsprites.

3. Whenthegreenflagisclicked,setthesizeoftheballto20percent,andsetbothleftscoreandrightscoreto0.

4. Movetheballtothecenterofthescreen,anduseanewblocktopointtheballinarandomdirection.Randomnumbersarelikepickinganumberoutofahat.Youdon’tknowwhichoneyouwillgetaheadoftime.Usingarandomblock,wecangiveScratchtwonumbers,asmallnumberandalargenumber,anditwillpickarandomnumberinbetweenthese.Bymakingtheballpointinarandomdirection,weaddtothechallengeandskilllevelofthegame.

5. Now,ontotheforeverblock.Eachtimeitloops,wewanttomovetheball5steps.We

Page 86: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

nowhaveanothernewblock,Ifonedge,bounce.Thisblocktellstheballthatifithastouchedtheouteredgesofthescreen,itshouldbounceawayfromit.

6. Wenowhavetwoifstatements.Thesecomeintoeffectiftheballtoucheseithertheleftortherightpaddle.Ifittoucheseither,wehavetheballpointintheoppositedirection,andthenpickarandomdirectiontomovein.

7. Thelasttwoifstatementsarethemostimportantones.Thesecheckwhethertheballhasgonebehindeitherofthepaddles.Ifithas,itawardsapointtotheotherpaddle,andmovestheballbackintothemiddleofthestage.Thegamethencontinues!

YounowhavethebeginningofyourPingPonggame!Wherecanyougofromhere?Hereareafewideas:

Addabackgroundthatrepresentsatennismatch.Havethegameendwhenonesidescoresenoughpoints.Havethecomputerplayasoneofthepaddles.

Therestisuptoyou!Havefunandexperiment!

Page 87: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 88: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryInthischapter,youlearnedhowtostartScratch,createcharacters,design,andprogramtwofungames.YouhaveonlyscratchedthesurfaceofwhatispossiblewiththeScratchprogramminglanguage.

Whilemakinggamesisalotoffun,sometimesyoumightneedtoplaysomeforinspiration.Luckily,theRaspberryPihassomegreatgamesandemulatorsavailable.Thenextchapterwillintroduceyoutodistributionsmadejustforgaming.

Page 89: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 90: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter3.RaspberryPiGamingOperatingSystemsTheRaspberryPi,whileapowerfullittledevice,isnothingwithoutsoftwaretorunonit.Settingupemulators,games,andanoperatingsystemcanbeadauntingtaskforthosewhoarenewtousingLinux.Luckily,therearedistributions(operatingsystemimages)thathandleallofthisforus.Inthischapter,wewilldemonstratethreedistributionsthathavebeenspeciallymadeforgaming.

Inthischapter,youwilllearn:

WheretodownloadmultiplegamingoperatingsystemsfromSimilaritiesanddifferencesbetweenPiPlay,RetroPie,andChameleonPiHowtoaccessRaspberryPi’ssharedfoldersonyourcomputerCopyinganduploadinggamefilestoyourRaspberryPi

Page 91: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PiPlayPiPlayisanopensourcepremadedistributionthatcombinesnumerousemulators,games,andacustomfrontendthatservesastheGUIfortheRaspberryPi.Createdin2012,PiPlaystartedasPiMAME.Originally,PiMAMEwasaversionofRaspbianthatincludedtheAdvanceMAMEandAdvanceMENUfrontend.ThedistributionwassettoautologinandstartupAdvanceMENUatbootup.ThisprojectwasfoundedbecauseofthenumerousissuesuserswerefacingtogetMAMEtocompileandrunontheirowndevices.Asmoreandmoreemulatorswerereleased,PiMAMEbegantoincludethemintheimage,andchangeditsnametoPiPlay,asitwasn’tjustforarcadeemulationanymore.

Currently,PiPlaycontainsthefollowingemulatorsandgames:

AdvanceMAME(Arcade)MAME4ALL(Arcade)FinalBurnAlpha(CapcomandNeoGeo)PCSX_ReARMed(PlayStation)Dgen(Genesis)SNES9x(SuperNintendo)FCEUX(NES)Gearboy(Gameboy)GPSP(GameboyAdvance)ScummVM(point-and-clickgames)Stella(Atari2600)NXEngine(CaveStory)VICE(Commodore64)Mednafen(GameGear,NeoGeoPocketColor,SegaMasterSystem,TurboGrafx16/PC-Engine)

TodownloadthelatestversionofPiPlay,gotohttp://piplay.organdclickontheDownloadoption.FollowthedirectionsfromChapter1,GettingStartedwiththeRaspberryPi,toburnthePiPlayimagetoyourSDcard.Whenthisiscompleted,inserttheSDcardintoyourRaspberryPiandturniton.

Withinafewmoments,youshouldseeanimagelikethisonyourscreen:

Page 92: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Onceit’sfinishedbooting,youwillbepresentedwiththePiPlaymenuscreen:

Here,youwillseeallthedifferentemulatorsandtoolsyouhaveavailable.PiPlayincludesanextensivecontrollersetuptool.BypressingTabkeyorbutton3onyourcontroller,apopupwindowwillappear.SelectControllerSetupandfollowtheonscreenguidetoproperlyconfigureyourcontroller:

Page 93: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Atthemoment,thereisn’tmuchtodobecauseyouhaven’tloadedanygamesfortheemulators.TheeasiestwaytoloadyourgamefilesintoPiPlayistousethewebfrontend.IfyouconnectyourPitoyournetwork,anIPaddressshouldappearatthetoprightofyourscreen.AnotherwaytofindoutyourIPaddressisbyrunningthecommandifconfigonthecommandline.

Navigateyourcomputer’swebbrowsertothisaddress,andthePiPlayfrontendwillappear:

Here,youcanreboot,shutdown,anduploadnumerousfilestothePiviaadraganddropinterface.Simplyselecttheemulatoryouwanttouploadfilesto,findyourgamefile,anddragitontothebox.Inafewmoments,thefilewillbeuploaded.

Page 94: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 95: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 96: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RetroPieRetroPieisaprojectbasedonLibretro,RetroArch,andEmulationStation.EmulationStationisanopensourcefrontendthatmakesiteasytomanageover30videogameconsolesandapplications,andyourassociatedgamefiles.Itincludesabuilt-injoysticksetuptoolandcanautomaticallydownloadassociatedmetadataforyourfiles.Thismetadataincludesitemssuchasboxartandgameinfo,whichgivesyourcollectionapolishedfinish.

Libretroisanotheropensourceproject.Itisdesignedtobringmultipleemulatorsintoonemainpackage.Insteadofhavingaseparateapplicationforeachsystem,Libretroturnstheseemulatorsintoacore,whichhooksintothelibrary.Byhavingacommonlibraryforeachemulatortohookinto,acohesiveeasy-to-useplatformiscreatedfortheuser.RetroArchisthemainfrontendfortheLibretrolibrary.

TheRetroPieprojectcombinesthebestoftheemulation,gaming,andfrontendsystemsintoaneasy-to-useplatformfortheRaspberryPi.

RetroPieincludesallofthesesystemsandconsoles:

Amiga(UAE4All)AppleII(LinApple)AppleMacintosh(BasiliskII)ArmstradCPC(CPC4RPi)Arcade(PiFBA,Mame4All-RPi)Atari800Atari2600(RetroArch)AtariST/STE/TT/FalconC64(VICE)CaveStory(NXEngine)Doom(RetroArch)DukeNukem3DFinalBurnAlpha(RetroArch)GameBoyAdvance(gpSP)GameBoyColor(RetroArch)GameGear(Osmose)Intellivision(RetroArch)MAME(RetroArch)MAME(AdvMAME)NeoGeo(GnGeo)NeoGeo(Genesis-GX,RetroArch)SegaMasterSystem(Osmose)SegaMegadrive/Genesis(DGEN,Picodrive)SegaMega-CD(Picodrive)Sega32X(Picodrive)NintendoEntertainmentSystem(RetroArch)

Page 97: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

N64(Mupen64Plus-RPi)PCEngine/TurboGrafx16(RetroArch)Playstation1(RetroArch)ScummVMSuperNintendoEntertainmentSystem(RetroArch,PiSNES,SNES-Rpi)SinclairZXSpectrum(Fuse)PC/x86(rpix86)ZMachineemulator(Frotz)

RetroPieishostedathttp://blog.petrockblock.com/retropie/.TheRetroPieforums,blog,andadditionalinformationarealsoavailablehere.OnceyouhavedownloadedtheSDcardimage,followtheinstructionsinChapter1,GettingStartedwiththeRaspberryPi,tomoveittoyourSDcard.AfewmomentsafterbootingupyourRaspberryPi,youshouldbepresentedwithascreensimilartothefollowing:

AftertheRaspberryPihasfinishedbootingup,youwillbepresentedwiththeEmulationStationsplashscreen:

Page 98: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RetroPiealsosupportsnumerousjoysticksandcontrollers.WhenyoufirstrunEmulationStationanditdetectsagamecontroller,itwilllaunchasetupscreen.Thiswillallowyoutoconfigureyourcontrollerforthemenu.

Afteryourcontrollerisconfigured,youwillbeatthemenuscreen,whereyoucanselectyoursystemandgametobeplayed.

Whenyoufirstgettothemenu,youwillnoticethatithasfewoptionsavailable.ThisisbecauseEmulationStationdoesnotdisplayemulatorsthatdonothaveanygamefiles

Page 99: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

available.OnceyoucopyaROMover,thesystemwillappear.

Tosetupyourcontrollerforthegamesystems,youwillneedtoexitbackouttotheterminal.Thencompletethefollowingsteps:

1. Runsudochownpi/opt/retropie/configs/all/retroarch.cfg.2. Then,runcd/opt/retropie/emulators/RetroArch/installdir/bin.3. Finally,runsudo./retroarch-joyconfig-j0>>

/opt/retropie/configs/all/retroarch.cfg.4. Youwillthenbepromptedtopressyourcontrollerbuttons.5. Whenthisiscomplete,runsudoreboottorebootyourRaspberryPi.

Yourcontrollerwillnowbeconfigured.

RetroPiehastwowaystocopygamefilesontothePi.ThefirstisusingSAMBAshares.Theseareessentiallyfolderssharedoveryournetwork.ThefollowingstepswillexplainhowtouseSAMBAsharestocopygamefilesontothePi:

1. OnWindows,youcanaccessthefoldersbygoingtothenetworktab,orbyenteringtheIPaddressofyourPiintothefoldermenustartingwithtwobackslashes,forexample,\\192.168.0.63.

Page 100: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

2. Double-clickonroms,thenonthesystemyouwishtocopygamesto.

Page 101: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

3. Tocopyyourgamefiles,draganddropyourgamefilesintothefolder.

Page 102: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

4. OnOSX,selectGo,selectConnecttoServer,andentertheserver’sIPaddress,forexample,smb://192.168.0.63.

5. AfterclickingonConnect,youwillbeaskedtologinasRegisteredUserorasGuest.ChooseGuest.

Page 103: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

6. Then,clickonConnectagainanddouble-clickontheromsmenuchoice.Theromsfolderisnowsharedtoyourcomputer.YouwillnowhaveaccesstoallthegamefilefoldersforRetroPie:

7. Now,simplydraganddropyourgamefilestotheproperfolder,andgetreadytoplay!

ThesecondwayisviaUSBdrive.RetroPiekeepsaservicerunninginthebackgroundthatdetectswhenanewUSBdriveisinserted.Theservicechecksforromsandgamefilesonthedriveviafoldersmatchingthesystemnames.TheservicewillautomaticallycreatetheblankfoldersthefirsttimeyouinsertyourUSBdrive.Justcopyyourfilestothecorrectfolder,andtheywillbemovedtoyourSDcard.

Page 104: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 105: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ChameleonPiChameleonPiisanotherready-to-useRaspberryPidistributionthatfocusesontheemulationofoldercomputers.TheChameleonPiprojectwasoriginallyconceivedtobringolderandretrostylecomputerstotheRaspberryPidevice.TodownloadChameleonPivisit:

http://chameleon.enging.com/

ChameleonPiincludesthefollowingsystems:

ZXSpectrumCommodore64Oric-1OricAtmosAppleIIseriesZX81IBMPCAtari800Atari800XLAtari2600CommodoreVic-20Commodore128AmstradCPC464AtariSTGameboyNESSNESMegadrive/Genesis

AfterbootingupyourRaspberryPiwiththeChameleonPiimage,youshouldseethefollowingsplashscreen:

Page 106: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Afterloading,theChameleonPithemainmenuwillbedisplayed:

ChameleonPioffersasimilarwaytogetgamefilesontotheSDcardasRetroPiedoes.ThefirstisviaSAMBAshares.ThebigdifferencebetweenthetwoisthatChameleonPi’spasswordprotectsthefolders.Bydefault,theusernameiszxandthepasswordisspectrum.Onceloggedin,youwillseealistoffoldersrepresentingeachsystem.

Page 107: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

TheotherwayisviatheUSBdrive.UnlikeRetroPie,wherethefilesarecopiedfromtheUSBdrivetotheSDcard,ChameleonPiusesyourUSBdriveasexternalstorage.Ifyouinsertafreshlyformatteddrive,ChameleonPiwillcreateafolderstructureforyourgames.CopyyourfilesintothecorrespondingfolderonyourUSBdrive,andtheninsertitintotheRaspberryPi.ThenexttimeyouuseChameleonPi,yourgamefileswillappear.

Page 108: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 109: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryInthischapter,youhavebeenintroducedtothreedifferentgame-basedRaspberryPidistributions.Whileallthreesharealotincommon,theygoaboutimplementinggamingintheirownuniqueways.Tryallthree,andusetheonethatfitsyourgamingstylethebest.

Inthenextchapter,youwilllearnhowtoaccesstheRaspberryPiAppStoresowecanplaywithevenmoregames.

Page 110: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 111: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter4.EmulatorsInthischapter,wewilldiveintoemulationontheRaspberryPi.Butwhatisemulation?Emulationistheactofduplicatingthefunctionalityofonesystemontoanother.ThismeansthatwecanmaketheRaspberryPipretendtobesomethingelse,suchasaSuperNintendo,oraCommodore64,oraSegaGenesis.Byutilizingdifferentemulationsoftware,ourRaspberryPicanbeallthesethingsandmore.

Youwilllearn:

HowtoinstallapplicationsusingtheRaspberryPiAppStoreHowtodownloadapplicationsfromtheInternetHowtoinstallprogramsfromtheRaspbianrepositories

Let’sstartwiththeRaspberryPiAppStore.

Page 112: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RaspberryPiAppStoreItseemsthatagrowingtrendisforeachdevicetohaveitsownlittleecosystemforapplications.TheRaspberryPiisnodifferent,andeachcopyofRaspbianhasaccesstothePiStore.ThisAppStoreisforyoutodownloadgamesandapplicationsmadespecificallyfortheRaspberryPi.

Page 113: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

UsingtheAppStoreWewillnowlaunchtheAppStore,createanaccount,anddownloadsomeapplicationsusingthefollowingsteps:

1. Atthecommandline,enterstartxtostartthedesktopenvironment.2. Onthedesktop,double-clickonthePiStoreicon.3. ClickontheLogInlinkinthetop-rightcornerofthewindow.

4. Ifyoudon’thaveanaccountyet,createonenow,andthenloginwiththeemailaddressandpasswordyouusedtoregister.

5. Youcansearchforsoftwareusingthesearchbarorclickonacategorytobringupapplicationsandgamesspecifictothatarea.

6. ClickontheFreeDownloadand/orBuyNowbuttonwhenyouhavefoundaselectionyouwouldliketoaddtoyourlibrary.

7. Theselecteditemwillbedownloadedandautomaticallyinstalled.8. IntheMyLibrarytab,clickontheitemyouwanttorun,andthenclickonthe

Launchbutton.

Page 114: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Anydevelopercansignupanduploadtheirgamestothestore.Pricingforgamesstartsatfreeofchargeandcangoupfromthere.Oncethegamehasbeenmadeavailableinthestore,anyuserwithanaccountcanpurchaseit.Allgamesandappsarestoredunderthe/usr/local/bin/indiecityfoldertoplaythemoffline.

Don’tworryaboutformattingyourSDcardandlosingyourgames.WhenyoulogintoyourPiStoreaccountyoucanre-downloadallyourpurchases.

Page 115: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 116: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

EmulatorsTherearenumerousemulatorsavailablefortheRaspberryPi.SomeoftheseareavailablethroughtheAppStore,othersyouneedtodownloadfromawebsiteandmanuallyinstall,andthentherearesomewhichcanbeinstalledviaRaspbian’spackagemanager.

Emulatorsrecreatehowagameconsoleworks,buttheydon’temulatethegamesthemselves.Thatrequiresthegamedata.Whenwerefertogamefilesinthisbook,wearereferringtotheRead-OnlyMemory(ROM)thatavideogame’sdataisstoredon.Thesecanbecartridges,CDsandDVDs,floppydisks,andothertypesofmedia.Manyareavailableasfilesyoucandownload.Pleasebeawarethatcopyrightmaystillexistonthesefilesandthatnotallarefreelyavailable.

Page 117: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MednafenMednafenisaprogramthatconsistsofmultiplesystememulators.ItcanemulatetheAtariLynx,NeoGeoPocketColor,WonderSwan,GameBoyColor,andtheTurboGrafx-16withgreatperformance.

InstallingMednafenfromtheterminaliseasy.Wewilluseapt-get,whichisthedefaultpackagemanagerforRaspbian.Theapt-getcommandmakesiteasytoinstallandupdatecommonLinuxutilitiesandprograms.

NoteBeforeusingapt-gettoinstallanapplication,youshouldrunsudoapt-getupdate.Thiswillkeepthelistofavailableapplicationsuptodate.

Let’sseehowtousetheapt-getcommand:

1. Inthecommandprompt,typesudoapt-getinstallmednafenandpressEnter.2. Theapt-getcommandwillnowsearchtherepositoriesfortheapplication,download

thepackage,andinstallitonyoursystem.Whenitiscompleted,typemednafenandpressEnter.Youwillbegreetedwithtextthatexplainshowtousetheprogram.

3. Thisversionisbestrununderthedesktop,sotypestartxinthecommandprompt,andpressEnter.

4. Youwillwanttobringuptheterminalappbydouble-clickingonLXTerminalfromthedesktop.Youwillalsoneedtosupplyagamefiletotestwith.

5. Fromtheterminal,typemednafen/path/to/gamenameandpressEnter,forexample,mednafen/home/pi/homebrew.zip.

6. Mednafenwillreadthegamefile,selectthecorrectsystem,andbringupthegamewindow.

YouarenowreadytoplaygamesusingMednafen.

Page 118: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FCEUX(NES)FCEUXisanemulatordesignedtorungamesfortheNintendoEntertainmentSystem(NES).TheNESisarguablythemostpopularandwellknowngamingsysteminvideogamehistory.Releasedin1984,theNESintroducedsuchpopulartitlesasSuperMarioBros,TheLegendofZelda,MegaMan,andMetroid.Hundredsofgameswereproducedforthis8-bitsystem,manyofwhichcanbeplayedontheRaspberryPi.ThefollowingstepswillshowyouhowtouseFCEUXforrunningthegame:

1. WewillstartbydownloadingFCEUX.Typewgethttp://raspberrypigaming.com/files/fceux.zipintoyourterminal.

2. Next,typeunzipfceux.zipandpressEnter.Ifyougettheerrorsayingunzipnotfound,typesudoapt-get-yinstallunziptoinstalltheunzipprogram.

3. Thefilefceuxshouldnowbeinyourdirectory.Runtheemulatorbytyping./fceux/path/to/game/rom,forexample,./fceux/home/pi/smb.nes.

Page 119: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PiSNES(SNES)PiSNESisaportoftheSNES9xprojectandisanemulatordesignedtorungamesfortheSuperNintendoEntertainmentSystem(SNES).TheSNESwasreleasedin1991,andfeatured16-bitgraphics,whichwasincredibleforitstime.ThegamesreleasedontheSNESarestillhighlysoughtafter;collectorsandplayersallaroundtheworldstillenjoygamessuchasFinalFantasy,StarFox,MegaManX,F-Zero,SuperMarioWorld,andhundredsofothergreatgames.Whatmakesthisemulationpossible,isthefactthatPiSNEStakesadvantageoftheRaspberryPi’sgraphicschip,andoffloadsmuchoftheprocessingtothat.

PiSNESisnotavailableinthePiStoreortherepositories,sowemustdownloaditfromtheprojecthomepage.Wewillbeusingwgettodownloadtheprojectfilesasfollows:

1. First,wewillcreateafolderforPiSNES.Typemkdirpisnesinaterminal.2. Now,enterintothepisnesdirectorywithcdpisnes.3. Now,typewgethttp://raspberrypigaming.com/files/pisnes.zip.Ifthat

doesn’twork,gotohttps://code.google.com/p/pisnes/forthelatestdownload.4. Unzipthefilebyrunningunzippisnes.zip.5. Placeyourgamefilesintheromsdirectory.6. Now,runPiSNESwith./snes9x.gui.7. Amenuwillappearwithyouravailablegames.Havefun!

Page 120: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MAME4ALLMAME4ALLisaportoftheMAMEprojectfortheRaspberryPi.MAMEstandsforMultipleArcadeMachineEmulator,andasitsnameimplies,itiscapableofrunningalargenumberofarcadegames.

MAME4ALLisnotavailableinthePiStoreortherepositories,sowemustdownloaditfromtheprojecthomepage.Wewillbeusingwgettodownloadtheprojectfilesasfollows:

1. First,wewillcreateafolderforMAME4ALL.Typemkdirmame4allinaterminal.2. Now,enterintothemame4alldirectorywithcdmame4all.3. Next,typewgethttp://raspberrypigaming.com/files/mame4all_pi.zip.Ifthat

doesn’twork,gotohttps://code.google.com/p/mame4all-pi/forthelatestdownload.4. Unzipthefilebyrunningunzipmame4all_pi.zip.5. Placeyourgamefilesintheromsdirectory.6. Now,runMAME4ALLbytyping./mame.7. Amenuwillappearwithyouravailablegames.Havefun!

Page 121: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FinalBurnAlphaFinalBurnAlphaisaprojectdesignedtoemulatemanyarcadegames,mostnotablythosethatrunontheNeoGeo,CapcomCPS-1,andCPS-2platforms.

FinalBurnAlphaisnotavailableinthePiStoreortherepositories,sowemustdownloaditfromtheprojecthomepage.Wewillbeusingwgettodownloadtheprojectfiles.

1. First,wewillcreateafolderforFinalBurnAlpha.Typemkdirfbainaterminal.2. Now,enterintothefbadirectorywithcdfba.3. Next,typewgethttp://raspberrypigaming.com/files/fba.zip.Ifthatdoesn’t

work,gotohttps://code.google.com/p/pifba/forthelatestdownload.4. Unzipthefilebyrunningunzipfba.zip.5. Placeyourgamefilesintheromsdirectory.6. Now,runFinalBurnAlphawith./fbacapex.7. Amenuwillappearwithyouravailablegames.Havefun!

Page 122: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PCSX_ReARMedPCSX_ReARMedisaPlayStationemulatorfortheRaspberryPi.Ascrazyasthisseems,theRaspberryPicanplayPlayStationgames!ThereasonforthisisthattheRaspberryPihasaverypowerfulgraphicschipthatrunsOpenGLEScode.PCSX_ReARMedhasbeenwrittentotakeadvantageofOpenGLES,whichgivesusagreatemulator.

PCSX_ReARMedisavailableforfreeonthePiStore.Makeuseofthefollowingstepstodownloadit:

1. OnceyouareonthedesktopandloggedintothePiStore,clickontheGamestab.YoucanalsosearchforPCSX_Rearmed.

2. ClickonPlay/Downloadtobegintheinstallationprocess.

Page 123: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

3. Wheninstructed,pressanykeytofinishtheinstallation.4. Toruntheprogram,gotoMyLibrary,clickonpcsx_reARMed,andpressLaunch

intheright-handpanel.

Page 124: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

5. ClickonExecuteandthePCSX_ReARMedgamewindowwillappear.6. Youdon’tneedtoplaceyourgamesinanyspecificdirectoryforthisemulator.When

youselectLoadCDimage,youcanbrowsetheRaspberryPi’sfilesystemforyourgamefile.

Page 125: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PicoDrive(Genesis/MegaDrive)PicoDriveisanemulatorthatrunsgamesmadefortheSegaGenesis(alsoknownastheMegaDriveinJapanandEurope).TheGenesisisa16-bitgamingconsolethatcameoutin1989.Itwasknownforitsmanygreatarcadeports,suchasAlteredBeastandMortalKombat,aswellasaseriesthathasspannednumerousreleasesandconsoles,SonicTheHedgehog.TodownloadPicoDrivegothroughthefollowingsteps:

1. Typewgethttp://raspberrypigaming.com/files/picodrive.tgzinyourterminal.

2. Next,typetarzxfvpicrodrive.tgzandpressEnter.Alonglistoffileswillstreamacrossthescreen.

3. Youshouldnowhaveadirectorycalledpicodrive.Enterthedirectorybytypingcdpicodrive.

4. Runtheemulatorbytyping./PicoDrive.ThePicoDrivemenushouldappearonyourscreen:

5. UsethemenuoptionLoadnewROM/ISO,whichwilltraverseyourRaspberryPi’sdirectoriesandselectyourROMfiletobeplayed.

Page 126: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Stella(Atari2600)Now,forthegranddaddyofallgamingsystems,theAtari2600.Itwasreleasedin1977andusheredinthevideogamecraze.Forthefirsttime,populararcadegamescouldbebroughthome,newpropertiescouldbecreated,andawholenewmarketopenedup.FromarcadeportssuchasPacManandDonkeyKongtotheoriginalgamessuchasPitfall,andeveninfamousgamessuchasE.T.,theAtari2600hasaveryrichhistoryofgaming.StellaisanemulatorthataimstobringthisconsoletotheRaspberryPiusingthefollowingsteps:

1. Theinstallationissupersimple;justtypesudoapt-getinstallstellatoinstallStellaontheconsoleandpressEnter.

2. Afterafewmoments,apt-getshouldfinish,andStellawillbeinstalled.3. TorunStella,justtypestellaandpressEnter.

4. UsethearrowsandtabkeystonavigateyourPiforgamefiles.Then,highlighttheSelectbuttonandpressEnter.

Page 127: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ControlsNowthatyouhaveinstalledsomeemulators,youwillwanttoknowhowtocontrolthegames.HereisacheatsheetforthedefaultkeysinPiSNES:

PiSNEScontrols Keyboard

Up Uparrow

Down Downarrow

Left Leftarrow

Right Rightarrow

A D

B C

X S

Y X

LeftBumper A

RightBumper F

Start Enter

Select Tab

Toquit Esc

ThefollowingtableisacheatsheetforthedefaultkeysinFinalBurnAlpha:

FinalBurnAlphacontrols Keyboard

Up Uparrow

Down Downarrow

Left Leftarrow

Right Rightarrow

Button1 Ctrl

Button2 Alt

Button3 Space

Button4 Shift

Page 128: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Button5 Z

Button6 X

Start Enter

Coin Tab

Toquit Esc

BecausePiSNESandFinalBurnAlphawereportedtotheRaspberryPibythesameperson,theysharesimilarconfigurationfiles.Withintheirrespectivedirectories,youwillfindaconfigurationfilethatallowsyoutochangethecontrolscheme.PiSNESiscalledsnes9x.cfg,andFinalBurnAlphaiscalledfba2x.cfg.Thekeyboardsectionusesnumberstorepresenteachkey.Youcanfindthembyreadingtheoutputof/usr/include/SDL/SDL_keysym.h.

ThefollowingtableisacheatsheetforthedefaultkeysinMAME4ALL:

MAME4ALLControls Keyboard

Up Uparrow

Down Downarrow

Left Leftarrow

Right Rightarrow

Button1 Ctrl

Button2 Alt

Button3 Space

Button4 Shift

Button5 Z

Button6 X

Start 1

Coin 5

Toquit Esc

TochangethecontrolsinMAME4ALL,presstheTabkeytobringuptheconfigurationmenu.Thiswillallowyoutogloballymapthecontrolstoyourgamepad,keyboard,joystick,orindividualgames.

Page 129: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ThePCSX_ReARMedcontrolscanbeseenandeditedwithinthecontrolsonthemainscreen.

PicoDrivecontrolscanbeeditedfromwithinthemainmenu.

Page 130: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ThefollowingtableisacheatsheetforthedefaultkeysinStella:

Stella Keyboard

Up Uparrow

Down Downarrow

Left Leftarrow

Right Rightarrow

Reset F2

Selectgametype F1

Fire/Action SpaceorCtrl

Selectgame Enter

Toquit Esc

ToeditStella’scontrols,highlightandselectOptions,andthenclickonInputSettings.

Page 131: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 132: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 133: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryYoulearnedhoweasyitistousetheRaspberryPi’sPiStoreapplication,whichisincludedineverycopyofRaspbian.Fromsettingupyouraccount,topurchasingnewgames,thePiStoreisagreatresource.YoualsoinstalledsomeemulatorsonyourPiusingthevariousinstallationmethodsavailableinLinux,andplayedsomeclassicvideogames.

Inthenextchapter,wewillintroducestandalonegamesthathavebeenportedovertotheRaspberryPi.

Page 134: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 135: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter5.PortedGamesNowthatwehaveplayedsomegamesviaanemulator,wearereadytoplaysomegamesthatwereportedtoworkontheRaspberryPi.Aportisapieceofsoftwarethatiscodedanddevelopedforaspecificenvironmentbuthasbeentransportedandrebuiltforadifferentone.Thiscommonlyoccurswithconsolegames.AgamewillbewrittenforaMicrosoftconsole,andthenportedovertoSony’sorNintendo’sconsole.ItalsohappenswhenaconsolegameisportedovertothePC.

Thischapterwillfocusonthosegamesthathavebeenreleasedforotherplatforms,andthenportedovertotheRaspberryPi.

Youwilllearnhowto:

InstallandplayCaveStoryInstallandplayDoomInstallandplayOpenArena,andcreateamultiplayerserverforitInstall,createyourownworld,andprogramscriptsforMinecraft

Page 136: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CaveStoryCaveStoryisafreewareMetroid/Castlevaniastyleplatformer.ItisamassiveplatformadventurealongthelinesofMetroid,Castlevania,andTerraria.Withalongengrossingstoryline,ahardbutnotfrustratingdifficultylevel,andabeautifulsetting,thegameisperfecttositbackandloseafewhourswith.ItwasoriginallyreleasedonthePCforMicrosoftWindowsin2004.Overtheyears,ithasbeenportedtotheNintendoWii,DSi,3DS,MacOSX,andLinux.

TheRaspberryPiportispossiblebecausetheoriginalCaveStoryenginewasreverseengineeredandanewopensourceenginecalledNXEnginewascreated.

Page 137: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningInstallingCaveStoryisverysimple.Itcanbedonebyperformingthefollowingsteps:

1. First,weneedtodownloadCaveStory.Atthecommandline,typewgethttp://raspberrypigaming.com/files/cavestory.zip.Youcanalsofindthesourcecodeathttp://nxengine.sourceforge.net/andhttps://github.com/ssilverm/cavestory_rpi.

2. Next,rununzipcavestory.zip.Thefileswillbeextractedtoafoldercalledcavestory_rpi-master.

3. Enterthedirectorybytypingcdcavestory_rpi-master.4. Now,let’srunCaveStorybytyping./nx.

Page 138: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ControlsHereisalistofthedefaultkeysinCaveStory:

Action Key

Left Leftarrow

Right Rightarrow

Up Uparrow

Down Downarrow

Jump Z

Fire X

Prevweapon A

Nextweapon S

Inventory Q

Map W

Quit Esc

Options F3

Page 139: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 140: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

DoomWhenyouthinkofafirst-personshooter(FPS),moderngameslikeCallofDutyorHalomightcometomind,butbeforethesewasDoom.ThegreatgrandfatherofthemodernFPS,Doom,createdbyidSoftware,tookthePCgamingworldbystorm.Foritstime,Doomhadamazinggraphics,multiplayercapabilities,user-createdlevels,andintroducedtheconceptofshareware.Itincludedthefirstchapterofthegameforfree,butifyouwantedtofinishthestoryandbeatthegame,youwereaskedtopurchasethegame.Doommadehistory.WhenidSoftwareopensourcedtheDoomengine,playersanddevelopersquicklyscouredthecode.Theymadeupdates,patchedbugs,addednewfeatures,andmostimportantly,portedthegametomultiplesystems.

Doomisstillbeingdevelopedtoday.Ifwetakeadvantageofmoderncapabilitiesandmodern3Dgraphicscards,theoriginalgamecanbemadetolookbetter.ForRaspberryPi,wewillgofortheclassicstyle.

PrBoomisaLinuxportoftheDoomenginethatincludestheFreedoomcampaign.FreedoomisatotallynewsetoflevelstoplayintheDoomuniverse.

Page 141: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningWewillinstallPrBoomusingapt-get,asfollows:

1. Atthecommandline,typesudoapt-getinstallprboom.2. PressYwhenitaskstoinstall.3. Now,let’srunPrBoombytypingprboomandpressingEnter.

4. YouaregoingtobepresentedwiththeFreedoomcampaign.PressEntertobeginandthenchooseyourdifficultylevel.

TheawesomeDoomcommunityhascreatedhundredsofcampaigns.TheyarestoredinfilescalledWADs.Ifyouwanttochangethecampaign,downloadsomeWADfilestoyourRaspberryPiandrunPrBoomwiththecommandprboom–file/path/to/game.wad.

Page 142: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ControlsHereisalistofthedefaultkeysinDoom:

Action Key

Turnleft Leftarrow

Turnright Rightarrow

Forward Uparrow

Back Downarrow

Action Space

Fire Ctrl

Changeweapon Press2through7

Menu Esc

Page 143: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 144: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

OpenArenaWhatPrBoomistoDoom,OpenArenaistoQuake3Arena.Quake3ArenaisanotherinnovatoroftheFPSgenre.Ithelpedlaunchahugelycompetitivemultiplayerenvironmentaswellasaraceforabettergraphicscardtochurnoutmoreframespersecond.TheQuake3enginehasbeenusedforastaggeringnumberofgames.SinceidSoftwareopensourcedtheengine,itiscapableofrunningontheRaspberryPi.OpenArenaisaprojecttodevelopacompletelyfreeversionofQuake3Arena.Usingentirelynewsprites,3Dmodels,textures,andlevels,anyonecandownloadOpenArenatotheircomputerandplayforfree.

Page 145: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallationOpenArenaisavailableontheRaspberryPiAppStore.MakeuseofthefollowingstepstoinstallOpenArena:

1. Fromthecommandline,enterstartxtolaunchthedesktopenvironment.2. Fromthedesktop,launchthePiStoreapplicationbydouble-clickingonthePiStore

icon.3. Atthetop-rightoftheapplication,therewillbealoginlink.Clickthelinkandlogin

withyourregisteredaccount.4. NavigatetoExplore|Games|Fighting.5. ClickontheOpenArenaresult.6. Attheapplicationinfopage,clickonthePlay/Downloadbuttonontheright-hand

sideofthescreen.7. OpenArenawillautomaticallybedownloadedandawindowwillappearshowing

theinstallationprogress.8. Pressanybuttontoclosethewindowonceithasfinishedinstalling.9. WhenyouclickonLaunchtoplaythegame,yourRaspberryPiwillrebootand

automaticallylaunchOpenArenaonthecommandline.

Page 146: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SingleplayermatchForasingleplayercampaign,performthefollowingsteps:

1. FromtheOpenArenamainmenu,clickonSINGLEPLAYER.2. Selectoneofthemapiconsfromthelist.Theopponentsinthearenawillbelistedat

thebottom.3. Clickonfighttoloadthearenaandstartthematch.

Page 147: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MultiplayermatchFPSarefunontheirownwithbots,buttoreallyenjoythefullexperience,youneedtoplaywithotherpeople.Sadly,theRaspberryPiversionisnotcompatiblewiththePCservers,somostofthemultiplayergamesyouseeonlinewillnotwork.Thegoodnewsisthatyoucancreateyourownserver!

RunningaserverTostartyourownserver,performthefollowingactions:

1. Fromthecommandline,changeintotheOpenArenadirectorybytypingcd/usr/local/bin/indiecity/InstalledApps/openarena/Full/.

2. Executetheoadedicatedscriptbyrunning./oadedicated.sh.3. AfterOpeningIPSocketappears,pressEnter.4. Inthecommandprompt,typemapoa_dm3andpressEnter.5. TheOpenArenadedicatedserverwillnowberunningonyourlocalnetwork.6. OtherPiusingOpenArenacannowconnecttoyourRaspberryPi’sIPaddress.

JoiningaserverTojoinaservercreatedbyanotheruser,performthefollowingactions:

1. FromtheOpenArenamainmenu,clickonMULTIPLAYER.2. Edityourplayernameandcustomizeyourcharacterasrequired.3. Clickonnext.4. OpenArenawillsearchforserversonyourlocalnetwork.5. Ifyourlocalgamedoesnotappear,clickonspecifyandentertheIPaddressofthe

serveryouwishtojoin.IftheserverisrunningonthesamePiyouwishtoplayon,youcanenter127.0.0.1(Thisiscalledaloopbackaddress.Itmeansconnectingtoitself).

Page 148: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ControlsThefollowingisalistofthedefaultkeysinOpenArena:

Action Key

Strafeleft A

Straferight D

Forward W

Back S

Jump Space

Fire Leftmouseclick

Changeweapon Press1through9oruseyourmousewheel

Menu Esc

Aim Mouseclick

Page 149: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 150: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Minecraft:PiEditionMinecraftisasandbox-stylegamemadebythegamecompanyMojang.Becauseitisasandbox,thereisnorightorwrongwaytoplayit.Theconceptbehindthegameisthatyouexploreandbuildusingdifferentkindsofblocksinarandomlycreatedworld.IthasbeencomparedtoavirtualLEGOset.Ifyoucanthinkit,youcanbuilditinMinecraft.

ItwasoriginallydevelopedfortheWindowsPC,buthassincebeenportedtoOSX,iOS,Android,andvariousgameconsoles.MojangdevelopedandreleasedaporttotheRaspberryPiasafreedownload.

Page 151: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningIfyouarerunningthelatestversionofRaspbian,Minecraftisnowincludedbydefault.IfyouarerunninganolderversionofRaspbian,youcaninstallMinecraftusingapt-get,asfollows:

1. Atthecommandline,typesudoapt-getupdate.2. Then,typesudoapt-getinstallminecraft-pi.3. Fromthedesktop,double-clickontheMinecraftPiEditionicon,orfromadesktop

terminal,typeminecraft-piandpressEnter.

Page 152: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CreatinganewMinecraftworldTocreateanewMinecraftworld,performthefollowingactions:

1. WithMinecraftrunning,clickonStartGame.2. SelectCreatenew.3. Afterafewmoments,youwillenterintoabrandnewMinecraftworldenvironment.

Page 153: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

UsingtheMinecraft:PiEditionApplicationProgrammingInterfaceNowthatyouhavecreatedyourMinecraftworld,youcanexplore,fightcreepers,createyourowncastle,andwhateverelseyourmindcanthinkof.TheRaspberryPiEditionincludessomethingextra—aprogramminginterface.YoucanusethePythonprogramminglanguagetohookintoMinecraftandeditthegameworldwithlinesofcode.

TousetheMinecraftAPI,performthefollowingactions:

1. StartthePythoninteractiveshellbyrunningpythonontheterminal.2. Youwillsee>>>,whichiswhereyouwillenterthePythoncommands.3. Enterthefollowingcommands:

frommcpiimportminecraft

frommcpiimportblock

mc=minecraft.Minecraft.create()

mc.postToChat("IamusingtheAPI!")

4. YoushouldnowseeIamusingtheAPImessageappearinyourMinecraftwindow.

5. Enterthefollowingcommands:

player=mc.player.getPos()

player

6. AnoutputsimilartoVec3(46.0,1.0,-14.0)shouldappear.7. Enterthenextcommand:

mc.setBlock(player.x+1,player.y,player.z,block.GOLD_BLOCK)

8. Agoldenblockshouldappeardirectlyinfrontofyou:

Page 154: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

TherearemanymorethingsyoucandowithbothPythonandtheMinecraftAPI.FromcreatingfunctionsthatwillbuildafortresstousingloopstostacktonsofTNTblocks,youcanprogramtheentireworld.

FormoreAPIdocumentation,visit:

http://www.stuffaboutcode.com/p/minecraft-api-reference.html

Page 155: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MultiplayerMinecraftMinecraft:PiEditionisamultiplayergame.IfyouhaveotherpeoplerunningRaspberryPisonyournetwork,alltheyneedtodoisclickonJoinGameinthemainmenu,andallthecurrentlyrunningMinecraftworldswillbeavailableforthemtojoin.

Page 156: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ControlsHereisalistofthedefaultkeysinMinecraft:

Action Key

Forward W

Left A

Down S

Right D

Inventory E

Jump Space

Fly/Fall Doublespace

Menu Esc

Placeblock Leftmouseclick

Removeblock Rightmouseclick

Selectquickinventory 1–9ormousewheel

Page 157: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 158: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryInthischapter,youlearnedhowtodownloadandinstallsomegames,whichwereremadefortheRaspberryPi.Youlearnedhowtoinstallgamesviaapt-getlikePrBoom,downloadgamesfromtheInternetlikeCaveStory,setupamultiplayerserverforOpenArena,andprogramyourownMinecraftworld.

Inthenextchapter,wewilldiscussgamesmadejustforLinuxandtheRaspberryPi.

Page 159: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 160: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter6.LinuxGamesSofar,wehavegoneoveremulationandportedgames.Whatwehaven’ttalkedaboutyet,isgamesthatweremadewithLinuxinmind.Thesearegamesthatweredesignedfor,andnativeto,theLinuxoperatingsystem.Usuallyfreeandopensource,theyaregamesthathavecommunitiesbuiltaroundthem,andwelcomeotherstosubmitcodebackintothegame.

ThischapterwillfocusonafewofthosefreeopensourcegamesavailableintheRaspbianrepository.

Inthischapter,youwilllearn:

Howtoinstall,run,andsetupanetworkserverforFreeCivHowtoinstallandplaySuperTux,aSuperMarioBros.cloneHowtoinstallandplayNjam,aPac-MancloneHowtoinstallandplayGalaga:Hyperspace,aGalaga/Galaxianclone

Page 161: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FreeCivFreeCivisafree,opensource,turn-basedstrategygamethatisinfluencedbythelongrunningcivilizationseriesofgames.InFreeCiv,youtakeontheroleleadingyourchosencivilizationoutoftheStoneAgeandintotheSpaceAge.Youmustexplore,buildout,andresearchnewskillsandabilities,allwhiletryingtodefeattherivalcivilizationsthataredoingthesamething.FreeCivhasbeenindevelopmentforover18yearsandboastsalargecommunitywithyearsofinformationandresources.

FreeCivfeaturesvariousdifficultiesofAI,singleplayerandmultiplayercapabilities,randomlygeneratedmaps,rulefine-tuning,andtonsofotherthingstomakeeachgameatotallydifferentexperience.

Page 162: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningInstallingFreeCivisverysimple.Followthesesteps:

1. Atthecommandline,typesudoapt-getinstall-yfreeciv-client-gtk.ThiswillinstallFreeCiv,aswellastheFreeCivserver.

2. Oncetheinstallisfinished,makesureyouareonthedesktopenvironmentbytypingstartxandpressingEnter.

3. Onceyouareonthedesktop,clickonthemenubuttonatthebottom-leftandhighlightGames.Underthesubmenu,youwillseetheFreecivoption.Clickonit.

4. FreeCivshouldnowhavelaunchedandyouwillbepresentedwithafewoptions.

Page 163: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

5. SelectStartNewGameandyouwillbepresentedwiththegamesetupscreen.Here,youwillabletosetthegameoptions,choosetheamountofplayers,andpickwhichnationyouwillbeplayingas.

6. ClickonStarttobeginthegame.

Page 164: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 165: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

HostingaFreeCivserverPlayingFreeCivagainsttheAIisagreatwaytolearnandgetgoodatthegame,butthegamereallyshineswhenyouincludeyourfriends(orsoontobeenemies).

TheRaspberryPiservesasagreatplatformtohostamultiplayerFreeCivgame.Justusethefollowingsteps:

1. Fromthedesktopmenu,selectGamesandthenclickonFreecivserver.Acommandwindowwillopenandautomaticallystartanewgame.

2. Now,loadFreeCiv,andclickonConnecttoNetworkGame.Yourgameservershouldappearinthelistofavailablegames.

3. Double-clickonthedesiredgametojoinit.

Page 166: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

4. Whenyouareready,clickonStartandthegamewillbegin!GoodLuck!

Page 167: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 168: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

LearningthecontrolsFreeCivisacomplicatedgame,asyoucanseefromthecontrollistbelow.Yourmouseandmenuoptionswillusuallybeenough;sodon’tgetdiscouragedbythesheeramountofoptions.Mostoftheseyouwon’tneeduntilyougetthroughafewgames.ThesecontrolswereretrievedfromtheofficialFreeCivwebsite:

http://freeciv.wikia.com/wiki/Keyboard_Reference

Reports

Cities F4

Demographics F11

Economy F5

Mapview F1

Messages F9

Nations F3

Research F6

Spaceship F12

TopFiveCities F8

Units F2

WondersoftheWorld F7

General

CloseDialog/Abort Esc

EditWorklists Ctrl+l

EditorMode Ctrl+e

FindCity Ctrl+f

Gamemenu F10

QuitGame Ctrl+q

Revolution Shift+Ctrl+r

SaveGame Ctrl+s

TaxRates Ctrl+t

Page 169: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ToggleFogofwar(inEditorMode) Ctrl+m

TurnDone Shift+return

Unitcommands

AutoExplore x

AutoSettler a

BuildAirport e

BuildCity b

BuildFortress F

BuildIrrigation i

BuildMine m

BuildRoads/Rails r

ChangeForesttoPlains i

ChangeForesttoSwamp m

ChangeJungletoForest m

ChangeJungletoGrassland i

CleanNuclearFallout n

CleanPollution p

ConnectRail/Road R

ConnectIrrigation I

Diplomat/SpyActions d

DisbandUnit D

Done Space

ExplodeNuke N

Fortifyunit(s) f

Goto g

GotoBuildCity B

Go/AirlifttoCity t

Page 170: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

LoadTransporter l

MakeHomecity h

Patrol q

ReturntonearestCity G

SelectUnitsofthesametype v

SelectUnitsofthesametypeonthesametile V

SentryUnit(s) s

TransformTerrain o

Unload u

UnloadTransporter T

UpgradeUnit U

Wait w

Wakeupothers Shift+w

Viewcommands

CenterViewonUnit c

CityGrowth Ctrl+r

CityNames Ctrl+n

CityOutlines Ctrl+y

CityProduction Ctrl+p

CityTraderoutes Ctrl+d

CityWorkerOutput Ctrl+w

FullScreenMode Alt+Enter

MapGrid Ctrl+g

NationalBorders Ctrl+b

Page 171: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 172: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SuperTuxSuperTuxisanotherfreeandopensourceLinuxgame.BeingreminiscentoftheSuperMarioBros.series,itisaside-scrollingactiongame,wherethegoalofthegameistorescuePennybygettingfromoneendoftheleveltotheother,whilekillingoravoidingenemies,andcollectingpower-ups.SuperTuxincludes26levels,butthereisalsoaleveleditoravailable,soyoucanmakeyourownstages.

Page 173: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningSuperTuxisincludedintheRaspbiansoftwarerepositories,andcanbeplayedontheterminalordesktopenvironmentusingthefollowingsteps:

1. Atthecommandline,typesudoapt-getinstall-ysupertux.2. Torunthegame,typesupertuxandpressEnter.Thegameshouldnowfillyour

entirescreen.

3. UsetheupanddownarrowkeystoselectStartGame,thenpressEntertobeginplayingSuperTux.

Page 174: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

LearningthecontrolsHereisalistofthekeysthatyouwouldrequireinthegame:

Action Keyboard

Left Leftarrow

Right Rightarrow

Activate/Enter Uparrow

Duck Downarrow

Jump Space

Useability Leftcontrol

Menu Esc

Page 175: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 176: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

NjamNjamisalsoafreeopensourcegamebasedonclassicmazegameslikePac-Man.Thegoalofthegameistoeatallthedotswhileavoidingtheobstacles.Ifyoueatoneofthepower-ups,yougaininvincibilityforashortperiodoftime.Njamincludesanarrayoflevels,leveleditors,andmultiplayercapabilities.

Page 177: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningNjamisavailableintheRaspbiansoftwarerepositories,andcanbeplayedontheterminalordesktopenvironmentusingthefollowingsteps:

1. Atthecommandline,typesudoapt-getinstall-ynjam.2. Torunthegame,typenjamandpressEnter.Thegameshouldnowfillyourentire

screen.

3. Njamoffersasingle-playergame,two-playercooperativemode,two-playerduelmode,anda4-playernetworkgame.Toplayalocalgame,justselectOneplayergameorTwoplayergame.Youwillthenselectamapandstartplaying.

4. Playinganetworkgameiseasyaswell.Ifyouarehostingthegame,justselectHostnetworkduel.TheotherplayerswillneedtoselectJoinnetworkduelfromtheircopiesofNjam,andenterinyourIPaddress.Onceeveryonehasreadiedup,pressthespacebartostartthegame.

Page 178: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 179: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

LearningthecontrolsHereisalistofkeysthatyouwouldrequireinthegame:

Action Keyboard

Up Uparrow

Down Downarrow

Left Leftarrow

Right Rightarrow

Exit Esc

Page 180: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 181: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Galaga:HyperspaceGalaga:Hyperspaceisagamebasedonclassicshoot‘emupgameslikeGalagaandGalaxian.Thegoalofthegameistodestroyeachwaveofalienswhileavoidingthebulletstheyhurlyourway.Eachwavegetsmoreandmoredifficult,andyoucanonlygethitoncebeforelosingalife.

Page 182: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

InstallingandrunningGalaga:HyperspaceisavailableintheRaspbiansoftwarerepositories,andcanonlybeplayedonthedesktopenvironmentusingthefollowingsteps:

1. Atthecommandline,typesudoapt-getinstall-yxgalaga.2. Torunthegame,makesureyouareonthedesktopenvironmentbytypingstartx

andthenpressingEnter.3. Onceyouareonthedesktop,clickonthemenubuttonatthebottom-leftand

highlightGames.Underthesubmenu,Galagawillbeanoption.Clickonittostartthegame.

Page 183: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

LearningthecontrolsHereisalistofthekeysthatyouwouldrequireinthegame:

Action Keyboard

Left Leftarrow

Right Rightarrow

StartGamewithkeyboardcontrols K

StartGamewithmousecontrols M

QuitGalaga:Hyperspace Q

Quitcurrentgame q

Page 184: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 185: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FindinggamesviatherepositoriesThegamesmentionedabovearejustthetipoftheicebergwhenitcomestoLinuxgaming.TheRaspbianrepositoriesincludeatonofpackages,andthereareafewcommandsyoushouldknowinordertosearchthroughit.

Theapt-cachesearchkeywordcommandwillsearchthereposforthekeywordyouspecify,anddisplayalistofresultsinthecommandterminal.Forexample:apt-cachesearchgamewilldisplaypagesofresults.Youcanthenwhittledowntheresultsbyspecifyingmultiplekeywords.Let’ssaywewanttofindaPac-Manclone:apt-cachesearchpacmanwillreturnalistofgamesthatincludePac-Maninthedescription.Theapt-cachesearchpacmanconsolecommandwillfurtherrefinethesearchandwillreturnoneresultthatmatchesyourquery,pacman4console.

Page 186: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 187: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryInthischapter,youlearnedaboutgamesthatweremadespecificallyforLinuxandthatrunonRaspberryPi.Therearedozensmoregamesavailableintherepositoriesthatyoucaninstallandtryout.Fromroguelikestoarcaderemakes,thereposholdhoursoffun.

Inthenextchapter,wewilldiscussthevariousinputmethodsavailablefortheRaspberryPi,includingarcadesticks,Bluetoothcontrollers,andgamingconsoledevices.

Page 188: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 189: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter7.ControllersInthischapter,wewillgothroughmanyofthetypesofgaminginputdevicesthatwecanconnecttoourRaspberryPi.Fromfightsticks(orjoysticks),gamepads,consolecontrollers,tobuildingyourown,thereareallsortsofoptionsavailable.

Inthischapter,youwilllearnhowto:

EnableBluetoothconnectivitySetupXboxandPlayStationcontrollersUseaUSBencoderUsetheGPIOpinstobuildyourowncontrollerTroubleshootproblemcontrollers

Page 190: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ControllersontheRaspberryPiBeforewebegin,youwillwanttoinstallthejoystickpackagetoyourdevice.Typesudoapt-get–yinstalljoystickatthecommandlineandpressEnter.Thejoystickpackageincludesanapplicationcalledjstest,whichwillhelpyouidentifyandtroubleshootyourcontrollers.

WhenacontrollerisconnectedandrecognizedbytheRaspberryPi,anewentrywillbemadeinthe/dev/input/folder.Thisfoldercontainsalistofallconnectedinputdevices.Youshouldseefileslikeevent0,mouse0,andkb0dependingonwhathasbeenconnected.Whenyourcontrollerisconnected,youshouldseeanewitemcalledjs0.The0attheendoftheitemindicatestheorderinwhichitwasconnected.Youcanhavemultipleitemsconnected,andtheywilleachgetanincreasingnumber.

Page 191: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

GamepadsGamepadsareoneofthesimplesttypesofcontrollersfortheRaspberryPi.Theycancomeindifferentshapes,sizes,andcanhavedifferentcombinationsofbuttons.Thesetypesofcontrollersareusuallymodeledafterpopularconsoles,andmadetolooklikeNES,SNES,Genesis,orPlayStationgamepads.Themajoradvantageoftheseisthattheyarecompact,handheld,andveryportable.

AslongasthegamepadisconnectedviaUSB,itwillbePlugandPlayontheRaspberryPi.

Page 192: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ArcadesticksArcadesticks,alsoknownasfightsticks,areaverypopularchoicetoconnecttothePi.Fightstickscomeinhundredsofvariations,andcanbecustom-built,custom-configured,upgraded,andmodified.Inalllikelihood,youwon’tfindtwoprofightsticksthatare100percentthesame.

Thereasonbehindthis,isthateachpersonhastheirownpreferencewhenitcomestobuttons,joysticks,andencoders.SomepeopleprefertheAmericanstyleHappbuttons,whileothersswearbytheSanwaJapanesestylebuttons.Therearethosewhopreferballtopjoystickswhileothersusebatstylejoysticks.

Thegreatpartaboutthis,isthatthebuttonsizesandjoysticksaregenerallyinterchangeable.Buttonscanbeswappedaround,andjoystickscommonlyusetwodifferentscrewvariations.

Justlikegamepads,ArcadesticksconnecteasilytotheUSBportofaRaspberryPiandshouldbejustPlugandPlay.

Page 193: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Xbox360controllersXbox360controllerscomeintwovarieties:wiredandwireless.WiredXbox360controllersarePlugandPlayinthelatestversionofRaspbian.

Whenyoupluginyourcontroller,theguidelightswillblinkonandoffrepeatedly.IfyouwishtohaveitfunctionlikeanactualXboxcontroller,whereonlythesingle-playerguidelightisactivated,youwillneedtouseafreeopensourceprogramcalledxboxdrv.Xboxdrvallowsyoutocustomizebuttons,activateacontroller,andusethewirelessUSBadapterforXbox360controllers.Followthegivenstepstoinstallxboxdrv:

1. Typesudoapt-get–yinstallxboxdrvonthecommandlineandpressEnter.2. Totestwhetheritworks,pluginyourXboxcontroller,typesudoxboxdrv--

kernel-detach-driverandpressEnter.3. Thelightsonthecontrollershouldstopblinkingandbereplacedwithonesolidlight.4. Pressinganybuttonwillcauseyourscreentolistthecurrentstatusofeachbutton.5. PressCtrl+Ctoclosexboxdrv.

Page 194: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Tousexboxdrvnormally,typesudoxboxdrv--kernel-detach-driver--silent&andpressEnter.Thiswillactivatexboxdrv,suppressthescreenoutputwheneverabuttonispressed,andlaunchitinthebackground,soyoucanstilluseyourPiforotherthings.Justrunthroughthefollowingsteps:

1. Toactivatexboxdrvatlogin,typenano~/.profile.2. Usethearrowkeystogototheendofthefile.3. Typesudoxboxdrv--kernel-detach-driver--silent&.4. PressCtrl+XandthenpressYtosavethefile.5. Now,whenyoulogintoyourPi,xboxdrvwillautomaticallylaunchandsetupyour

Xboxcontroller.

IfyouwanttorunmultipleXboxcontrollersonthesamePi,youwillneedtolaunchanotherinstanceofxboxdrv.

Page 195: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SonyDualShock3controllersSonyDualShock3controllersareveryneat.TheycanbeconnectedtotheRaspberryPiviaUSBorBluetooth,andhavemotionsensorsthatarereadasdifferentaxes.TheDualShock3isPlugandPlaycompatiblewithRaspbian,whenusingtheUSBcable.

SimplyhookupaMicroUSBcableendtothecontroller,andastandardUSBcableendtothePiandyouwillbereadytogo.ThePiwillalsochargethecontroller’sinternalbattery.Ifyouareusingmorethanonecontroller,oryouexperienceoddbehavior,switchtoapoweredUSBhub.

SettingitupforBluetoothconnectivityrequiresthatyouperformthefollowingsteps:

1. First,ensurethatyouhaveaRaspberryPicompatibleBluetoothdongle.Mostinexpensivedongleswillwork,butalistofworkingproductsisavailableathttp://elinux.org/RPi_USB_Bluetooth_adapters.

2. Typesudoapt-get-yinstallbluez-utilsbluez-compatbluez-hcidumplibusb-devlibbluetooth-dev.Thisinstallwilltakeafewminutes.

3. Aftertheinstallisfinished,typehciconfigandmakesureyourBluetoothdongleislisted.

Page 196: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

4. Now,youwillneedtodownload,compile,andinstallsixad.Downloadsixadbytypingwgethttp://sourceforge.net/projects/qtsixa/files/QtSixA%201.5.1/QtSixA-

1.5.1-src.tar.gz.Ifthepageisunavailablehere,itisalsolocatedathttp://raspberrypigaming.com/files/QtSixA-1.5.1-src.tar.gz.

5. Now,typetarzxfvQtSixA-1.5.1-src.tar.gzandpressEnter.Thiswillextractthecontents.

6. ChangetothenewlycreateddirectorybytypingcdQtSixA-1.5.1-src/sixad.7. Now,typemakeandpressEnter.Thiswillturnthesourcecodeintoacomputer

program(compiling)andwilltakeafewminutes.8. Next,typesudomakeinstallandpressEnter.Thisinstallssixadintotheproper

locations,andallowsyoutoruntheprogrambytypingsixadwithoutbeinginacertainfolder.

9. Now,typesixad--startandpressEnter.10. WhenpromptedtopressthePSkeyonyourcontroller,pressit.Youshouldseea

messageindicatingaconnectiontoyourDualShock.

11. PressCtrl+Ctoexit.Yourcontrollerwillstillbepaired.

Topaircontrollersatbootup,youwillneedtoaddthesixadprogramtoyourprofile.Makeuseofthefollowingsteps:

1. Typenano~/.profileatthecommandline.2. Usethearrowkeystogototheendofthefile.3. Typesixad--start&.4. PressCtrl+X,thenpressYtosavethefile.5. Now,whenyoulogintoyourPi,sixadwillautomaticallylaunchandasktopairwith

yourcontroller.

Page 197: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

USBencodersAttheheartofeveryArcadestickisaUSBencoder.IttakestheactionofhittingabuttonandturnsitintoaninputforyourRaspberryPi.Someencodersemulateakeyboard,whileothersactasanactualjoystick.Usinganencoder,youcanveryeasilybuildyourowncustomizedcontroller.

Therearehundredsofdifferentencodersoutthere,butthemostcommononesarecalledtheNoDelay,ZeroDelay,andXinMoboard.Alloftheseboardsactasajoystick,andareverysimpletowireup.

Page 198: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ThisisanexampleofaNoDelayUSBjoystickencoderboard.The8buttonsarewireduptothebuttonpinsonthebottomoftheboard.Eachbuttonhasacommonandgroundpin.Whenthebuttonispusheddown,theconnectioniscompleted,sendingthesignaltotheboard.Thejoystickusesthe4slotsatthetopoftheboardforup,down,left,andrightmovements.Theboardcanalsoacceptjoysticksthatonlyuse5pins.Thosearecommonwithballtopsticks.TheboardincludesaUSBcablethatplugsintothepinsonthefar-leftoftheboard.

Page 199: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

GPIOpinsTheRaspberryPiincludespinscalledGPIOthatcanbeconnecteddirectlytoafewbuttonsandajoystick,similartotheencoderboardswesawpreviously.

GPIOlayoutbyraspberrypi.org

TheprecedinglayoutisofModelAandModelB.ModelA+andB+includeevenmorepinsbutarebackwardscompatiblewiththeAandBpinlayout.Thepinsweareinterestedinaretheyellowandblack-labeledpins.Theotherpins—1,3,4,and17arepowerpins.Becausethebuttonsdon’trequirepower,wecansafelyignorethese.Allofyourbuttons’groundwiresshouldconnecttoacommongroundpin.TheotherwiresshouldindividuallybeconnectedtoanindependentyellowGPIOpin.

Whilepin8and10looklikeproperGPIOpins,theyareactuallyserialports,soyoushouldavoidusingthem.

Onceyouhaveconnectedthewires,youwillneedtoinstallanapplicationthatwillreadfromtheGPIOpinsandoutputakeyboardcommand.

Adafruit(http://www.adafruit.com/)hasreleasedautilitycalledRetrogamethatdoesjustthis.ItisasmallCprogramthatyoucanedit,thenbuild,andruntoreadinputfromyourGPIO.

Bydefault,Retrogamehassetthefollowingcontrolstothesepins:

Controls Pins

Left 2

Right 3

Down 4

Up 17

Z 27

Page 200: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

X 22

R 23

Q 18

InstallingandbuildingToinstallRetrogamemakeuseofthefollowingsteps:

1. DownloadRetrogamebytypinggitclonehttps://github.com/adafruit/Adafruit-Retrogame.gitandpressEnter.

2. ChangetothenewdirectorybytypingcdAdafruit-Retrogame.Ifyouneedtomakechangestothepinnumbersorkeys,typenanoretrogame.candscrolltoaroundline75.Youwillseealinesayingstarthere.EditthepinnumbersandKEY_commands,asinstructed.

3. BuildRetrogamebytypingmakeretrogameandpressEnter.4. Whenithasfinishedbuilding,typesudo./retrogametotestyourGPIOenabled

buttons.

Torunitatbootup,Adafruitrecommendsthatyouaddittoyourrc.localfile,asfollows:

1. Typesudonano/etc/rc.localandpressEnter.2. Gototheverylastlinebeforeexit0.Ourentryneedstobemadebeforethis.3. Typethepathtoyourretrogameapplication,forexample,/home/pi/Adafruit-

Retrogame/retrogame&.4. PressCtrl+XandthenYtosavethefile.5. Youwillnowhavetoaddaudevrule,sothatotherapplicationscanseethenew

buttons.Udevisessentiallyadevicemanager.Settinguptheruleswillletotherapplicationsknowhowtouseyourdevice.

6. Typesudonano/etc/udev/rules.d/10-retrogame.rulesandpressEnter.7. Then,typeSUBSYSTEM=="input",ATTRS{name}=="retrogame",

ENV{ID_INPUT_KEYBOARD}="1"

8. PressCtrl+X,thenYtosaveyournewudevrules.9. Now,restartyourRaspberryPi,andyourGPIOcontrollerwillbeready.

Page 201: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 202: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

TroubleshootingcontrollersThereareafewcommonproblemsthatcancropupwhenusingdifferenttypesofcontrollersonyourPi.Themostcommonone,isthatyoujustcan’tseemtogetyourgametorecognizeanyinput.Yourfirststepshouldbetocheck/dev/inputandensurethatthereisajsX(wherexisthejoysticknumber)fileinthedirectory.

IfyouseeyourjsXfile,typejstest/dev/input/jsX.Youshouldnowbeabletopressthebuttonsonyourcontrollerandseethedifferentinput.

Ifyoudon’tseeanythinginhere,disconnectyourcontroller,thenplugitbackinandrundmesg.Youshouldseesometextscrollbyreallyquickly.Theverylastlinesshouldshowthatyouhavepluggedinyourjoystick.

Ifyoudon’tseeyourcontrollerindmesg,tryusingapoweredUSBhub.Yourcontrollermightneedextrapower.

Whenrunninghciconfig,ifnothingappears,itmightbebecauseyourUSBBluetoothdongleisn’tgettingenoughpower.TryconnectingittoapoweredUSBhubandseeifthis

Page 203: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

fixestheissue.Ifnot,yourBluetoothdonglemightnotbesupported.

Page 204: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 205: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryYouhavenowlearnedaboutdifferentgamepadsandjoysticks.Youhavelearnedhowtobuildyourown,andhowtoconnectthemdirectlytotheRaspberryPihardware.YoualsoknowhowtoconnectnonstandardcontrollerssuchastheXboxandDualShock3.YoucannowtroubleshootyourcontrollersandyouhavelearnedmoreabouttheinnerworkingsofRaspbianandLinux.

Inthenextchapter,wewillgooversomegeneraltroubleshootingtipsfortheRaspberryPi.

Page 206: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 207: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Chapter8.TroubleshootingSofar,welearnedhowtomakeourowngame,installnumerousemulatorsandvideogames,hookupperipherals,connectjoysticks,andusethehardwarepins.However,whathappenswhensomethinggoeswrong?ThischapterwillguideyouthroughsomeofthecommonissuesyoumightfacewithaRaspberryPi.

Page 208: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Usingraspi-configTheraspi-configtoolisabasicutilitythatisincludedineachcopyofRaspbian.Itisamenu-basedGUIthatenablesyoutoeasilymodifyyourRaspberryPisettings.

Torunraspi-config,typesudoraspi-configonthecommandline.

Theraspi-configtooloffersthefollowingoptions:

Expandfilesystem:ThisoptionwillresizetheOStousealloftheavailableSDcardspace.Changeuserpassword:ThiswillpromptyouforanewpasswordfortheuserPi.Enableboottodesktop/Scratch:Thisallowsyoutoswitchbetweenbootingtothecommandprompt,Scratch,orthedesktop.Internationalizationoptions:Thisoptionallowsyoutochangeyourtimezoneandyourkeyboardlayout.Enablecamera:IfyouhavetheRaspberryPicameramodule,checkthistoyes.AddtoRastrack:ThisoptionenablesotherpeopletoknowyourPi’slocation.Overclock:YoucanchangeyourRaspberryPi’sspeedhere.Advancedoptions:

Therearemanyadvancedoptionsinraspi-configwhichareexplainedasfollows:

Overscan:Ifyouseeblackbarsonyourmonitor,oryourscreenmightbealittleoff;useoverscantocorrectit.Hostname:ThissetsyourRaspberryPi’snetworkname(Default:raspberrypi).Memorysplit:ThischangesthememoryavailabletotheGPU,whileleavingtheresttoyourapplications.Theminimumis16MB.

NoteIfyouhaveModelAorA+themaximumsplitcanbe192MB,andonModelBorB+,youcangoto448MB.Iwouldn’trecommendgoinghigherthan128MB,asyouwanttodevoteenoughRAMtoLinux.

SSH:ThisoptionallowsyoutoremotelyconnecttoyourRaspberryPi.SPI:ThisenablesautoloadingoftheSPImodule.Yourhardwareshouldletyouknowifyouneedthis.I2C:ThisenablesautoloadingoftheI2Cmodule.Serial:Thisoptionenablesanddisablesdatagoingtotheserialpins.Audio:Thiswillsetwhereaudioisoutputfrom;HDMIoraudiojack.Update:Thiswillupdateraspi-configtothelatestversion.

Page 209: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 210: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CommontroubleshootingHerearesomeofthecommonerrorsandthemeanstotroubleshootthem:

Page 211: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

EmulationStationreturnsanerrorwhenItrytolaunchitInsuchasituation,runsudoapt-get-yinstalllibsdl1.2-devlibboost-filesystem-devlibfreeimage-devlibfreetype6-devlibsdl-mixer1.2-devttf-

dejavu.

ThiswillinstalltherequireddependenciesthattheEmulationStationrequirestorun.

EmulationStation,aswellasothergames,mightrequiredependenciesthathavenotbeenloadedduringtheinstall.Forexample,libsdl1.2-dev,libboost-filesystem-dev,libfreeimage-dev,libfreetype6-dev,libsdl-mixer1.2-dev,andttf-dejavuarecommonlibrariesthatareusedinanumberofgamesthatmightnothavebeeninstalled,orneedtobeupdated.

Page 212: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

NothinghappenswhenIapplypowerInthisparticularinstance,tryoutthefollowingthings:

Makesurethepowersupplyisratedfor5Vwithatleast1A(1000mA).Itwouldhelpifyoucangetupto2.1A(2100mA).Checkwhetherthepowerlightsareilluminatedontheboard.EnsurethatthemonitorisonandpluggedintotheRaspberryPi.CheckthattheSDcardisformattedproperly.

Mostofthetime,aRaspberryPiwillfailtoboot,orexperienceproblemsduringuse,becauseofaninadequatepowersupply.ManyMicroUSBchargersaremanufacturedwithminimalqualityassurance,soifyoudoexperienceissues,thefirstthingtodowouldbetotryadifferentbrandofcharger.MostbrandedcellphonechargerswillproperlypoweraRaspberryPi.

Ifthisdoesn’tfixtheissue,thenextstepistotestouttheSDcard.AproperlyformattedSDcardwillhaveasmallbootdrivethatisreadablebyWindows,MacOSX,andLinuxoperatingsystems.Ifyoucannotseethebootdrive,oranyfilesinsideit,thenitismostlikelythatyourSDcardhasn’tbeenproperlyimaged.

YoucanalsotryusingtheNOOBSsoftwarethattheRaspberryPiFoundationoffers.ThisisasetoffilesthatyoucandraganddroptoanyfreshlyformattedSDcard.WhenyoubootuptheRaspberryPiwiththatSDcard,itwillattempttoinstallanoperatingsystemontoitself.TogettheNOOBSpackage,visit:

http://www.raspberrypi.org/downloads/

FormoreinformationonusingNOOBScheckout:

http://www.raspberrypi.org/introducing-noobs/

Page 213: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SomeofthegamesseemslowYoucanoverclockyourRaspberryPitoekeoutextraperformanceandspeed.

Warning:overclockingcancorruptyourSDcard,requiringyoutoreloadRaspbianonit.IfyourRaspberryPiseemstobeunresponsive,rebootandholddowntheShiftkeytotemporarilyresettheoverclocksettings.GothroughthefollowingstepstooverclockyourRaspberryPi:

1. Runsudoraspi-configfromthecommandline.2. SelectOverclockfromthemainmenu.3. Selectthelowestoverclock.4. Rebootandchecktheperformance.5. Ifitisstillslow,selectthenextoverclocksetting.6. Ifthegamestillrunsatanunacceptableperformance,thebestbetistoposttothe

RaspberryPiforums.AstheRaspberryPiplatformmatures,newenhancementsandperformancetweakswillbeavailable.

Bydefault,theRaspberryPirunsat700MHzbuthasthecapabilitytobeoverclockedtoahigherspeed.MostRaspberryPishavebeennotedtobeworkingfineat900MHzandsomeevenhigherthan1GHz.OverclockingtheCPUwithraspi-configautomaticallythrottlesthespeed,asrequired.So,whennotinuse,itreducespowerdownto700MHz.Evenwiththethrottle,overclockingcanmakeyoursystemunstableandcanleadtoSDcardcorruption.Ifyoursystemfailstobootafteroverclocking,holdingdownShifttriestoturnofftheoverclockinginthesoftware.Ifthisdoesnotwork,youcaneditthe/boot/config.txtfileandsetarm_freq=700todisableoverclocking.Ifallelsefails,youcanreimageyourSDcard.Alloverclockinginformationisstoredinconfig.txt,andreimagingyourcardwillresetit.

Page 214: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

ConnectingviaHDMIdoesn’tworkEdittheconfig.txtfileandsethdmi_safe=1.

Typesudonano/boot/config.txt,intheterminalFindthe#hdmi_safe=1lineRemovethe#fromthelinePressCtrl+X,thenpressYtosavethefileRebootyourRaspberryPi

TurntheTVonbeforeturningontheRaspberryPi.TryadifferentHDMIcable.

ThebootdrivecontainsaTEXTfilenamedconfig.txt.ThisfilestoresalloftheconfigurationparametersandisreadeachtimeyourRaspberryPipowerson.Editingthisfileallowsyoutofine-tuneyourRaspberryPiandcanalsohelpresolvevariousissuesthatcancropupduringuse.YoucanalsoeditthisfileonyourPCorMacbyputtingtheSDcardintothecomputer.

IfyouhavetroublegettinganimagetoappearonyourTVthroughHDMI,themostcommonfixistoeditconfig.txtandsethdmi_safe=1.ThischangesandbooststheHDMIsignal,sothatitismorelikelytosyncwithyourTV.AnothersimplechangeistoensurethattheTVisonandconnectedbeforeyoupowerontheRaspberryPi.

Page 215: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

TheDualShock3controllerdoesnotconnectInthiscase,

EnsurethattheDualShock3batteryisfullycharged.

NoteChargingcantakeover2hourstofullycomplete.

Usingasmallpin,presstheresetbuttononthebackofthecontroller.UseapoweredUSBhubforyourBluetoothdongle.UseaMicroUSBcabletoensurethatthecontrollerworkswhenpluggedin.

Page 216: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

IgetanerrorwhencompilingRetrogameThemostcommoncauseoferrorsisforgettingapieceofsyntax.

Checkwhethereachlinehastheproperamountofcommas.

Forexample:{17,KEY_DOWN},

Page 217: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 218: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SummaryInthischapter,youhavelearnedhowtotroubleshootdifferentailmentsthatcanafflictyourRaspberryPi.Youhavelearnedhowtooverclockyourprocessor,edityourconfig.txttoenabledifferentmodes,resetyourcontroller,andmakesureyouhaveaproperpoweredPi.

Anextrapieceofadvice:Don’tbeafraidtotinkerandexperimentwithyourRaspberryPi.Itisveryhardtodamagethehardware.Ihaveyettohurtone.Ifeverythingseemsbroken,reformatyourSDcardandstartover.

Ifallelsefails,wearepartofalargecommunityofenthusiaststhatwanttowatchyousucceed.Jointheforumsathttp://raspberrypi.org.Therearemanywhowillbewillingtohelp.

Also,ensurethatyoucheckouttheseguidesformoreinformation:

E-LinuxRu-PiTroubleshootingguideathttp://elinux.org/R-Pi_TroubleshootingE-LinuxR-PiConfigguideathttp://elinux.org/RPiconfig

Page 219: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 220: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

AppendixA.GamesListThisappendixcontainsoflistofsomeofthegamesavailablefromtherepositories.ThislistiscollatedfromtheRaspberryPigamingsubforum.

CheckoutthefollowingURLsformoreupdatesonavailablegames:

http://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794http://www.raspians.com/Knowledgebase/1-debian-wheezy-games-repository-sudo-apt-get-install/

Page 221: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

GamesavailableviaApt-GetThefollowingisthelistofgamesthatareavailableviaApt-Get:

20,000LightYearsIntoSpace3DChess4-DigitAbuseACM(Aliens:ColonialMarines)AirstrikeAllegrodemoAngryDrunkenDwarvesAtomAtomicTanksBattleforWesnothBattleTanksBattleballBeneathaSteelSkyBlobWars:MetalBlobSolidBlockOut2DeSmuMEFeedingFrenzyFlareFlightoftheAmazonQueenFreeCivFreeCraftFreeDinkFreesweepFunnyBoatFuseGalagaGalaga:HyperspaceGNUShogiHexxagonKETM(KillEverythingThatMoves)LincityLittleCraneMancalaMednafenMicropolisMinecraft:PiEditionMonsterzNetHackOpenTTD

Page 222: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

OvergodPrBoomPydanceRafkillSnake4SopwithSpaceAryaryaSpaceZeroSpoutStaxStellaSuperTuxTaguaTeddyTetzleTINTTriplaneVavoomXSoldierXtronYahtzeeSharp

Page 223: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to
Page 224: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RaspberryPi2Asofthiswriting,theRaspberryPiFoundationhasintroducedabrandnewboardcalledthePi2.WhilesharingthelayoutandpriceoftheModelB+,thePi2hasbeenheavilyupgraded.

ThebiggestchangeisthemovefromanARMv6runningat700MHz,toaquad-coreARMv7runningat900MHz.TheARMv7isaprettybigupgrade;itiswhatmostAndroidreleasesarecompiledforandtheminimumversionforotherLinuxdistributions.MicrosofthasevenmentionedreleasingacustomizedversionofWindows10fortheRaspberryPi.TheothermajorupgradeisthattheRAMhasbeenincreasedfrom512MBto1GB.

ThePi2isalsobackwardscompatiblewithsoftwarewrittenfortheoriginalPi.InordertomoveyourPi’sSDcardtothenewestPi2,followthesesteps:

OntheModelA,B,orB+runthesecommands:

1. First,runthesudoapt-getupdatecommand.2. Afterthatrunthesudoapt-getupgradecommandtoruntheupgrades.3. Next,runthesudoapt-getdist-upgradecommand.4. Finally,runthesudoapt-getinstallraspberrypi-ui-modscommand.

Afterthesetasksarecompleted,youroperatingsystemwillbeupdatedandyoucansafelymoveyourSDcardbetweenthePi2andoriginalRaspberryPi.

Page 225: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

IndexA

AdafruitURL/GPIOpins

ApplicationProgrammingInterface(API),Minecraftusing/UsingtheMinecraft:PiEditionApplicationProgrammingInterfaceURL,fordocumentation/UsingtheMinecraft:PiEditionApplicationProgrammingInterface

AppStoreabout/RaspberryPiAppStoreusing/UsingtheAppStore

apt-cachesearchkeywordcommandabout/Findinggamesviatherepositories

Apt-Getgameslist/GamesavailableviaApt-Get

apt-getcommandused,forinstallingMednafen/Mednafen

Arcadesticksabout/Arcadesticks

Atari2600about/Stella(Atari2600)

Page 226: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

BBluetoothconnectivity

SonyDualShock3controllers,settingup/SonyDualShock3controllersBluetoothdongle

URL/SonyDualShock3controllers

Page 227: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

CCaveStory

about/CaveStoryinstalling/InstallingandrunningURL,forsourcecode/Installingandrunningcontrols/Controls

ChameleonPiabout/ChameleonPiURL,fordownloading/ChameleonPisystems/ChameleonPisplashscreen/ChameleonPigamefiles,copyingviaSAMBAshares/ChameleonPiversusRetroPie/ChameleonPigamefiles,copyingviaUSBdrive/ChameleonPi

controllersusing/ControllersontheRaspberryPigamepads/GamepadsArcadesticks/ArcadesticksXbox360controllers/Xbox360controllersSonyDualShock3controllers/SonyDualShock3controllersUSBencoders/USBencodersGPIOpins/GPIOpinstroubleshooting/Troubleshootingcontrollers

costumeabout/Somepointersandterminology

Page 228: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

DDoom

about/DoomPrBoom/Doomcontrols/Controls

DualShock3controllerconnection,troubleshooting/TheDualShock3controllerdoesnotconnect

Page 229: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

EEmulationStation

executionerror,troubleshooting/EmulationStationreturnsanerrorwhenItrytolaunchit

emulatorsabout/EmulatorsMednafen/MednafenFCEUX/FCEUX(NES)PiSNES/PiSNES(SNES)MAME4ALL/MAME4ALLFinalBurnAlpha/FinalBurnAlphaPCSX_ReARMed/PCSX_ReARMedPicoDrive/PicoDrive(Genesis/MegaDrive)Stella/Stella(Atari2600)

Page 230: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

FFCEUX

about/FCEUX(NES)using/FCEUX(NES)

FinalBurnAlphaabout/FinalBurnAlphadownloading/FinalBurnAlphaURL,fordownloading/FinalBurnAlphacontrols/Controls

first-personshooter(FPS)about/Doom

FlappyBirdclonebuilding/Let’sbuildaFlappyBirdclone!newproject,creating/Creatinganewprojectvariables,creating/Makingthevariablesstage,setting/Settingthestagefloor,creating/Makingthefloorpipes,creating/Creatingthepipesmaincharacter,creating/Workingwiththemaincharacterenhancing/Enhancingthegame

foreverloopsabout/Somepointersandterminology

FreeCivabout/FreeCivinstalling/Installingandrunningexecuting/Installingandrunningserver,hosting/HostingaFreeCivservercontrols/LearningthecontrolsURL,forcontrollist/Learningthecontrols

Page 231: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

GGalaga*Hyperspace

about/Galaga:Hyperspaceinstalling/Installingandrunningexecuting/Installingandrunningcontrols/Learningthecontrols

gamepadsabout/Gamepads

gamessearching,viarepositories/Findinggamesviatherepositories

GPIOpinsabout/GPIOpinsRetrogame/GPIOpins

Page 232: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

HHDMI

connection,troubleshooting/ConnectingviaHDMIdoesn’twork

Page 233: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Iif…elsestatement

about/Somepointersandterminologyifstatement

about/Somepointersandterminologyinadequatepowersupply

troubleshooting/NothinghappenswhenIapplypowerinstallation,CaveStory

about/Installingandrunninginstallation,FreeCiv

about/Installingandrunninginstallation,Galaga*Hyperspace

about/Installingandrunninginstallation,Mednafen

apt-getcommand,using/Mednafeninstallation,Minecraft

about/Installingandrunninginstallation,Njam

about/Installingandrunninginstallation,NOOBS

about/UsingNOOBSinstallation,OpenArena

about/Installationinstallation,PrBoom

about/Installingandrunninginstallation,Retrogame

about/Installingandbuildinginstallation,Stella

about/Stella(Atari2600)installation,SuperTux

about/Installingandrunninginstallation,xboxdrv/Xbox360controllersinterface,Scratch

about/UnderstandingtheScratchinterface

Page 234: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Jjoystickpackage

installing/ControllersontheRaspberryPi

Page 235: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

LLinux

SDcard,creating/CreatingtheSDcardinLinux

Page 236: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

MMacintoshOSX

SDcard,creating/CreatingtheSDcardinMacintoshOSXMAME4ALL

about/MAME4ALLdownloading/MAME4ALLURL,fordownloading/MAME4ALLcontrols/Controls

Mednafenabout/Mednafeninstalling,apt-getcommandused/Mednafen

Minecraftabout/Minecraft:PiEditioninstalling/InstallingandrunningnewMinecraftworld,creating/CreatinganewMinecraftworldApplicationProgrammingInterface(API),using/UsingtheMinecraft:PiEditionApplicationProgrammingInterfacemultiplayergame/MultiplayerMinecraftcontrols/Controls

MultipleArcadeMachineEmulator(MAME)about/MAME4ALL

Page 237: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

NNintendoEntertainmentSystem(NES)

about/FCEUX(NES)Njam

about/Njaminstalling/Installingandrunningexecuting/Installingandrunningcontrols/Learningthecontrols

NOOBSusing/UsingNOOBSinstalling/UsingNOOBSURL,fordownloading/UsingNOOBS,NothinghappenswhenIapplypowerabout/NothinghappenswhenIapplypower

NXEngineabout/CaveStory

Page 238: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

OOpenArena

about/OpenArenainstalling/Installationsingleplayermatch/Singleplayermatchmultiplayermatch/Multiplayermatchserver,creatingformultiplayermatch/Runningaserverserver,joiningformultiplayermatch/Joiningaserver

overclockabout/Someofthegamesseemslow

Page 239: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

PPCSX_ReARMed

about/PCSX_ReARMeddownloading/PCSX_ReARMedcontrols/Controls

PicoDriveabout/PicoDrive(Genesis/MegaDrive)downloading/PicoDrive(Genesis/MegaDrive)controls/Controls

PingPongabout/PingPongbuilding/PingPongpaddles,creating/Makingthepaddlesbouncingball,creating/Followingthebouncingball

PiPlayabout/PiPlayemulatorsandgames/PiPlayURL,fordownloading/PiPlaydownloading/PiPlaymenuscreen/PiPlaygamefiles,loading/PiPlayfrontend/PiPlay

PiSNESabout/PiSNES(SNES)URL,fordownloading/PiSNES(SNES)downloading/PiSNES(SNES)controls/Controls

pointers,Scratchvariable/Somepointersandterminologystage/SomepointersandterminologyXposition/SomepointersandterminologyYPosition/Somepointersandterminologysprite/Somepointersandterminologycostume/Somepointersandterminologyifstatement/Somepointersandterminologyif…elsestatement/Somepointersandterminologyforeverloops/Somepointersandterminology

PrBoomabout/Doominstalling/Installingandrunning

Page 240: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

QQuake3Arena

about/OpenArenacontrols/Controls

Page 241: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

RRaspberryPi

ModelA/ThedifferentflavorsofaRaspberryPiModelB/ThedifferentflavorsofaRaspberryPiModelB+/ThedifferentflavorsofaRaspberryPiModelA+/ThedifferentflavorsofaRaspberryPiURL,fordownloading/SettingupanSDcardsettingup/HookingupyourRaspberryPiconnecting,toWiFiaccesspoint/ConnectingtoaWi-FiaccesspointAppStore/RaspberryPiAppStoretroubleshooting/Commontroubleshooting

raspi-configtoolusing/Usingraspi-config

raspi-configtool,advancedoptionsoverscan/Usingraspi-confighostname/Usingraspi-configmemorysplit/Usingraspi-configSSH/Usingraspi-configSPI/Usingraspi-configI2C/Usingraspi-configserial/Usingraspi-configaudio/Usingraspi-configupdate/Usingraspi-config

raspi-configtool,optionsexpandfilesystem/Usingraspi-configchangeuserpassword/Usingraspi-configenableboottodesktop/Scratch/Usingraspi-configinternationalizationoptions/Usingraspi-configenablecamera/Usingraspi-configaddtoRastrack/Usingraspi-configoverclock/Usingraspi-config

Read-onlymemory(ROM)about/Emulators

repositoriesgames,searchingvia/Findinggamesviatherepositories

Retrogameabout/GPIOpinscontrols/GPIOpinsinstalling/Installingandbuildingbuilding/Installingandbuildingcompilationerror,troubleshooting/IgetanerrorwhencompilingRetrogame

RetroPieabout/RetroPie

Page 242: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

systemsandconsoles/RetroPieURL/RetroPieEmulationStationsplashscreen/RetroPiegamecontroller,configuring/RetroPiegamecontroller,settingup/RetroPiegamefiles,copyingwithSAMBAshares/RetroPiegamefiles,copyingviaUSBdrive/RetroPieversusChameleonPi/ChameleonPi

Page 243: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

SSAMBAshares

used,forcopyinggamefilesontoPi/RetroPieScratch

about/WhatisScratch?interface/UnderstandingtheScratchinterfacefirstprogram,creating/MakingScratchymovepointers/SomepointersandterminologyFlappyBirdclone,building/Let’sbuildaFlappyBirdclone!PingPong,building/PingPong

SDcardsettingup/SettingupanSDcardbootpartition/SettingupanSDcardLinuxpartition/SettingupanSDcardcreating,inWindows/CreatingtheSDcardinWindowscreating,inMacintoshOSX/CreatingtheSDcardinMacintoshOSXcreating,inLinux/CreatingtheSDcardinLinuxNOOBS,using/UsingNOOBS

SegaGenesis/MegaDriveabout/PicoDrive(Genesis/MegaDrive)

sixadURL,fordownloading/SonyDualShock3controllers

SonyDualShock3controllersabout/SonyDualShock3controllerssettingup,forBluetoothconnectivity/SonyDualShock3controllers

spriteabout/Somepointersandterminology

stageabout/Somepointersandterminology

Stellaabout/Stella(Atari2600)installing/Stella(Atari2600)controls/Controls

SuperNintendoEntertainmentSystem(SNES)about/PiSNES(SNES)

SuperTuxabout/SuperTuxinstalling/Installingandrunningexecuting/Installingandrunningcontrols/Learningthecontrols

Page 244: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Ttroubleshooting

controllers/TroubleshootingcontrollersEmulationStationexecutionerror/EmulationStationreturnsanerrorwhenItrytolaunchitinadequatepowersupply/NothinghappenswhenIapplypoweroverclocking/SomeofthegamesseemslowHDMIconnectionissue/ConnectingviaHDMIdoesn’tworkHDMIconnection/ConnectingviaHDMIdoesn’tworkDualShock3controllerconnection/TheDualShock3controllerdoesnotconnectRetrogamecompilationerror/IgetanerrorwhencompilingRetrogame

Page 245: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

UUSBdrive

gamecontroller,configuring/RetroPieused,forcopyinggamefilesontoPi/RetroPie

USBencodersabout/USBencoders

Page 246: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

Vvariable

about/Somepointersandterminology

Page 247: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

WWiFiaccesspoint

RaspberryPi,connectingto/ConnectingtoaWi-FiaccesspointWiFiadapter

URL/ConnectingtoaWi-FiaccesspointWin32DiskImager

about/SettingupanSDcardURL/CreatingtheSDcardinWindows

WindowsSDcard,creating/CreatingtheSDcardinWindows

Page 248: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

XXbox360controllers

about/Xbox360controllersxboxdrv

about/Xbox360controllersinstalling/Xbox360controllersusing/Xbox360controllers

Xpositionabout/Somepointersandterminology

Page 249: Raspberry Pi Gaming Second Edition - tentacle.netprophet/raspberrypi/Raspberry Pi/1784399337... · Nilesh R. Mohite Cover Work. Manu Joseph. About the Author ... You can upgrade to

YYposition

about/Somepointersandterminology