RaspberryPiGamingSecondEdition
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
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
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
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
Summary
A.GamesList
GamesavailableviaApt-Get
RaspberryPi2
Index
RaspberryPiGamingSecondEdition
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
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
ManuJoseph
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.
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.
www.PacktPub.com
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.
Whysubscribe?FullysearchableacrosseverybookpublishedbyPacktCopyandpaste,print,andbookmarkcontentOndemandandaccessibleviaawebbrowser
FreeaccessforPacktaccountholdersIfyouhaveanaccountwithPacktatwww.PacktPub.com,youcanusethistoaccessPacktLibtodayandview9entirelyfreebooks.Simplyuseyourlogincredentialsforimmediateaccess.
PrefaceHi!WelcometothewonderfulworldoftheRaspberryPi.Inafewshortyears,theRaspberryPihasamassedarichdiversityofsoftware,cultivatedbyitsincrediblecommunity.
Inthisbook,wearegoingtoexploretheentertainmentcapabilitiesoftheRaspberryPi.Fromprogrammingyourownvideogames,torelivingclassicmomentswithyourfavoritegamesystems,I’mpositiveRaspberryPigamingwillhelpyouunlockthecapabilitiesofyourdevice.
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.
WhatyouneedforthisbookYouwillneed:
ARaspberryPiAnSDcard(4GBorhigher)AcomputerrunningOSX,Windows,orLinuxAnetworkconnection
WhothisbookisforIfyouaresomeonewholovestoplaygamesandareinterestedinlearningmoreaboutthecapabilitiesofyourRaspberryPi,thisbookisforyou.BasicknowledgeofRaspberryPiprogrammingisexpected.
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.
ReaderfeedbackFeedbackfromourreadersisalwayswelcome.Letusknowwhatyouthinkaboutthisbook—whatyoulikedordisliked.Readerfeedbackisimportantforusasithelpsusdeveloptitlesthatyouwillreallygetthemostoutof.
Tosendusgeneralfeedback,simplye-mail<[email protected]>,andmentionthebook’stitleinthesubjectofyourmessage.
Ifthereisatopicthatyouhaveexpertiseinandyouareinterestedineitherwritingorcontributingtoabook,seeourauthorguideatwww.packtpub.com/authors.
CustomersupportNowthatyouaretheproudownerofaPacktbook,wehaveanumberofthingstohelpyoutogetthemostfromyourpurchase.
DownloadingthecolorimagesofthisbookWealsoprovideyouwithaPDFfilethathascolorimagesofthescreenshots/diagramsusedinthisbook.Thecolorimageswillhelpyoubetterunderstandthechangesintheoutput.Youcandownloadthisfilefrom:https://www.packtpub.com/sites/default/files/downloads/9337OS_ColoredImages.pdf.
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.
PiracyPiracyofcopyrightedmaterialontheInternetisanongoingproblemacrossallmedia.AtPackt,wetaketheprotectionofourcopyrightandlicensesveryseriously.IfyoucomeacrossanyillegalcopiesofourworksinanyformontheInternet,pleaseprovideuswiththelocationaddressorwebsitenameimmediatelysothatwecanpursuearemedy.
Pleasecontactusat<[email protected]>withalinktothesuspectedpiratedmaterial.
Weappreciateyourhelpinprotectingourauthorsandourabilitytobringyouvaluablecontent.
QuestionsIfyouhaveaproblemwithanyaspectofthisbook,youcancontactusat<[email protected]>,andwewilldoourbesttoaddresstheproblem.
Chapter1.GettingStartedwiththeRaspberryPiTheRaspberryPiisaninexpensive,feature-richmoderncomputercreatedbytheRaspberryPiFoundation.SincethereleaseoftheModelBin2012,thecommunitysurroundingthecomputerhasgrown,allowingforanincredibleamountofprojectsandsoftwaretobecreatedforthedevice.Theserangefromprogramminglanguages,educationalapplications,hardwareprototypes,andofcourse,videogames.
Inthischapter,youwilllearnthefollowingtopics:
ThedifferentflavorsofaRaspberryPiSettingupanSDcardHookingupyourRaspberryPi
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.
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.
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.
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.
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!
UsingNOOBSTheRaspberryPiFoundationhascreatedapieceofsoftwarecalledNewOutOftheBoxSoftware,oftenabbreviatedasNOOBS.Thisisasmalloperatingsystem,whichisusedtoinstallotherOSsontoyourRaspberryPi.
InstallingNOOBSismucheasierthanotherinstalls:
1. DownloadNOOBSfromhttp://www.raspberrypi.org/downloadsandunzipthefile.2. InserttheSDcardintoyourcomputer’sSDcardreader.3. DraganddroptheNOOBSfilesontotheSDcardandyouaredone!
Atthefirstboot,youwillbepresentedwithalistofOSsavailabletobeinstalled.ChooseRaspbianandpressEnter.
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!
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.
8. Ifitisasecurednetwork,youwillbeaskedforapassword.9. EnterthepasswordandclickonAdd.
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.
SummaryInthischapter,youlearnedhowtocreateyourRaspberryPi’sSDcard,hookituptoyourTVandotheraccessories,andconnectittotheInternet.Now,it’stimetohavefunwiththesoftwareonyourRaspberryPi.
Inthenextchapter,youwilllearnhowtocreateyourownvideogameusingtheScratchprogramminglanguage.
Chapter2.ScratchThischapterwillintroduceyoutotheamazingandfunworldofprogramming.Learningtoprogramandcodewillallowyoutobringyourideastocreation.Ifyouhaveeverwantedtomakeagame,buthadnoideawheretostart,thisistheplace.
Inthischapter,youwilllearnthebasicsneededtomakeyourownvideogameontheRaspberryPi.Youwilllearnhowto:
LaunchScratchDefineyourgame’sobjectivesDrawacharacterMakeyourcharacterinteractandmoveDesignandprogramaFlappyBird-stylegameDesignandcreatea2playerPingPonggame
WhatisScratch?ScratchisaprogramminglanguageandapplicationdevelopedbytheMassachusettsInstituteofTechnology(MIT)asaneasy-to-use,educational,andfunenvironmenttolearntocodeandtomakevideogamesandapplications.Itisdifferentfrommostotherprogramminglanguages.Itiscompletelyvisual;ratherthantypingoutlinesofcode,allyouhavetodoisdraganddropvisualblockstocreateyourprogram.
Gamesthatmighthavetakendaystobecreatedearliercanbecreatedinminutes,rightinfrontofyoureyes.Now,youaregoingtocreatesomegamestoo!
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.
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!
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.
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.
CreatinganewprojectBeforewebegin,let’screateanewprojectforourFlappyBirdclone.Todoso,clickontheFilemenuandthenclickonNew.AbrandnewScratchprojectwillappear.
MakingthevariablesNowthatweknowwhatweneed,wecanstartbycreatingourvariables:
1. ClickontheVariablesbutton,andthenclickonMakeavariable.Itwillaskyouforaname,anddisplaytwooptions:ForallspritesandForthisspriteonly.EnsurethatyouclickonForallsprites.
2. Ourfirstvariablewillbenamedscore.TypethisandclickonOK.Thescorevariablewillbeusedtokeeptrackofhowmanywallsyouhavepassed.Itwillgoupbyoneeachtime.
Now,makethreemorevariableswiththefollowingnames:
scroll:Thiswillbeusedtokeeptrackofwheretheflooris,sinceitwillbemovingtime:ThiswillkeeptrackofhowmanysecondshavepassedsinceyoustartedthegamepipeX:Thiswillkeeptrackofwherethepipeisacrossthescreen
SettingthestageWithourvariablescreated,itisnowtimetocreateourgame’sbackgroundsusingthefollowingsteps:
1. ClickonStageintherightcolumn,andthenclickonBackgrounds.2. ClickonEdit.YouwillnowbeinPaintEditor.3. Clickonacolor,thenthepaintcan(filltool),andclickanywhereonthewhitearea.
ThenclickonOK.Youhavenowchangedthebackgroundofyourgame.
4. ClickonCopythreetimes,andthenediteachbackgroundtobeadifferentcolor.5. Now,clickonScripts.Wewilladdthefirstscriptstoourgame.
Thisstagehastwoscripts:
Whenthegreenflagisclicked,itsetsthebackgroundtothenextbackground,waitsforonesecond,andthensetsittothenext.Itwillrepeatthisforeveruntilthegameisover.Thesecondscriptalsowaitsforthegreenflagtobeclicked.Itthensetsthevariabletimeto0,andadds1toiteverysecondusingaforeverblock.Theforeverblockrepeatswhat’sinsideofituntilthegameisstopped.
Ifyouclickonthegreenflag,youshouldseethebackgroundchange.Nowwouldbeagoodtimetosaveyourgameaswell.ClickonFile,thenchooseSave.GiveyourgameanameandclickonOK.
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:
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:
Bysettingxtoscroll+480,youwillnowhaveasecondfloorthatfollowsthefirstfloorandcontinuallyrepeats.
Youcanaddsomecolorandsomegrasstothecostumetoaddtothescrollingeffect.
CreatingthepipesThepipesarerelativelystraightforward.Itisonesprite,withthreecostumes,andonescripttomakeitscrollacrossthescreen.
1. ClickonCreatenewspriteanddrawapipe.Mineisjustalongblackrectanglegoingallthewayfromthebottomtothetopoftheeditor.
2. UsetherectangletooltoselectaportionofthepipeandpressDelete.Younowhavetheareatoflythrough.
3. Copythecostumetwomoretimes.Thistimerefillintheholeandcreateanewoneatadifferentspotinthepipe.
Now,let’smakethepipescripts!
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!
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.
Now,let’sworkonthescriptsforourbat!
Whenthegreenflagisclicked,setthescorevariableto0,switchtothecostumewiththebatwingsup,setthesizetobe10percentoftheoriginalspritesize,gotothetopmostlayer,andthenmovetothosexandypositions.Playaroundbychangingthesizeofyourbatandexperimentingwiththexandypositions.Changingthesewillaffectthedifficulty
ofyourgame.
Now,weenterourforeverloop.Eachtimethisloopoccurs,wesetthespritetobethebatwithwingsup,andmoveitdownby1onthestage.Thisnextblockintroducesustouserinput.Itsaysthatifthespacekeyispressedonyourkeyboard,thenitshouldswitchtothebatwithwingsdownandmoveupthestageby5.Youcanchangethekeytobeanythingonyourkeyboard.Youcanalsochangethe5toincreaseordecreasetheheightatwhichthebatfliesperbuttonpress.
Thenexttwoifblocksfollowthesameformula.IfyourbatspritetouchesFloor1,Floor2,orthepipes,thenGameOverwillappearnexttothespriteandthegamewillstop.
Finally,ifthexpositionofthebatisequaltothevalueofpipeX,thenyoushouldchangethescoreby1,sinceitindicatesthatyouhavepassedthroughoneofthepipessuccessfully.
Now,tryoutyourgame!
EnhancingthegameNowthatyouhavecreatedyourFlappyBirdclone,youshouldtrytoenhanceandmodifyit.Herearesomeideas:
AddamultiplayeroptionCreateagameoverscreenbymakinganewbackgroundandsettingittothescreenthatappearswhenyoutouchapipeMakeascrollingbackgroundTrymakingthepipesscrollfasterorappearatrandomtimes
Whenyouareready,wecanmoveontothenextgame.
PingPongIt’stimetogobackintime,andrecreateagamethathelpedtolaunchthevideogameindustry.IthasgonebymanynamessuchasPong,PingPong,andTableTennis,butthebasicgameplayhasstayedthesame.Twopaddles,oneball,andanepicbattletogettheballpasttheotherplayer.
So,let’sbreakdownthisgame.Wewillrequire:
OnepaddlefortheleftplayerOnepaddlefortherightplayerOnebouncingballTwovariablestokeepscoreforeachplayer.
Let’sgetstarted!
MakingthepaddlesAftercreatinganewproject,youwillbepresentedwiththewhitestageandaScratchysprite.
1. Right-clickonScratchyandclickondelete.Now,clickonPaintnewsprite.
2. DrawalongblackrectangleandclickonOK.NamethisspriteLeft.
Wearegoingtocreatethreesimplescriptsforthispaddle,asfollows:
3. Thefirstscriptensuresthattheleftpaddlepointsintheproperdirectionandthensetsitssizeto60percent.Youshouldexperimentwiththesizetodeterminewhatfeels
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.
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
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!
SummaryInthischapter,youlearnedhowtostartScratch,createcharacters,design,andprogramtwofungames.YouhaveonlyscratchedthesurfaceofwhatispossiblewiththeScratchprogramminglanguage.
Whilemakinggamesisalotoffun,sometimesyoumightneedtoplaysomeforinspiration.Luckily,theRaspberryPihassomegreatgamesandemulatorsavailable.Thenextchapterwillintroduceyoutodistributionsmadejustforgaming.
Chapter3.RaspberryPiGamingOperatingSystemsTheRaspberryPi,whileapowerfullittledevice,isnothingwithoutsoftwaretorunonit.Settingupemulators,games,andanoperatingsystemcanbeadauntingtaskforthosewhoarenewtousingLinux.Luckily,therearedistributions(operatingsystemimages)thathandleallofthisforus.Inthischapter,wewilldemonstratethreedistributionsthathavebeenspeciallymadeforgaming.
Inthischapter,youwilllearn:
WheretodownloadmultiplegamingoperatingsystemsfromSimilaritiesanddifferencesbetweenPiPlay,RetroPie,andChameleonPiHowtoaccessRaspberryPi’ssharedfoldersonyourcomputerCopyinganduploadinggamefilestoyourRaspberryPi
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:
Onceit’sfinishedbooting,youwillbepresentedwiththePiPlaymenuscreen:
Here,youwillseeallthedifferentemulatorsandtoolsyouhaveavailable.PiPlayincludesanextensivecontrollersetuptool.BypressingTabkeyorbutton3onyourcontroller,apopupwindowwillappear.SelectControllerSetupandfollowtheonscreenguidetoproperlyconfigureyourcontroller:
Atthemoment,thereisn’tmuchtodobecauseyouhaven’tloadedanygamesfortheemulators.TheeasiestwaytoloadyourgamefilesintoPiPlayistousethewebfrontend.IfyouconnectyourPitoyournetwork,anIPaddressshouldappearatthetoprightofyourscreen.AnotherwaytofindoutyourIPaddressisbyrunningthecommandifconfigonthecommandline.
Navigateyourcomputer’swebbrowsertothisaddress,andthePiPlayfrontendwillappear:
Here,youcanreboot,shutdown,anduploadnumerousfilestothePiviaadraganddropinterface.Simplyselecttheemulatoryouwanttouploadfilesto,findyourgamefile,anddragitontothebox.Inafewmoments,thefilewillbeuploaded.
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)
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:
RetroPiealsosupportsnumerousjoysticksandcontrollers.WhenyoufirstrunEmulationStationanditdetectsagamecontroller,itwilllaunchasetupscreen.Thiswillallowyoutoconfigureyourcontrollerforthemenu.
Afteryourcontrollerisconfigured,youwillbeatthemenuscreen,whereyoucanselectyoursystemandgametobeplayed.
Whenyoufirstgettothemenu,youwillnoticethatithasfewoptionsavailable.ThisisbecauseEmulationStationdoesnotdisplayemulatorsthatdonothaveanygamefiles
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.
2. Double-clickonroms,thenonthesystemyouwishtocopygamesto.
3. Tocopyyourgamefiles,draganddropyourgamefilesintothefolder.
4. OnOSX,selectGo,selectConnecttoServer,andentertheserver’sIPaddress,forexample,smb://192.168.0.63.
5. AfterclickingonConnect,youwillbeaskedtologinasRegisteredUserorasGuest.ChooseGuest.
6. Then,clickonConnectagainanddouble-clickontheromsmenuchoice.Theromsfolderisnowsharedtoyourcomputer.YouwillnowhaveaccesstoallthegamefilefoldersforRetroPie:
7. Now,simplydraganddropyourgamefilestotheproperfolder,andgetreadytoplay!
ThesecondwayisviaUSBdrive.RetroPiekeepsaservicerunninginthebackgroundthatdetectswhenanewUSBdriveisinserted.Theservicechecksforromsandgamefilesonthedriveviafoldersmatchingthesystemnames.TheservicewillautomaticallycreatetheblankfoldersthefirsttimeyouinsertyourUSBdrive.Justcopyyourfilestothecorrectfolder,andtheywillbemovedtoyourSDcard.
ChameleonPiChameleonPiisanotherready-to-useRaspberryPidistributionthatfocusesontheemulationofoldercomputers.TheChameleonPiprojectwasoriginallyconceivedtobringolderandretrostylecomputerstotheRaspberryPidevice.TodownloadChameleonPivisit:
http://chameleon.enging.com/
ChameleonPiincludesthefollowingsystems:
ZXSpectrumCommodore64Oric-1OricAtmosAppleIIseriesZX81IBMPCAtari800Atari800XLAtari2600CommodoreVic-20Commodore128AmstradCPC464AtariSTGameboyNESSNESMegadrive/Genesis
AfterbootingupyourRaspberryPiwiththeChameleonPiimage,youshouldseethefollowingsplashscreen:
Afterloading,theChameleonPithemainmenuwillbedisplayed:
ChameleonPioffersasimilarwaytogetgamefilesontotheSDcardasRetroPiedoes.ThefirstisviaSAMBAshares.ThebigdifferencebetweenthetwoisthatChameleonPi’spasswordprotectsthefolders.Bydefault,theusernameiszxandthepasswordisspectrum.Onceloggedin,youwillseealistoffoldersrepresentingeachsystem.
TheotherwayisviatheUSBdrive.UnlikeRetroPie,wherethefilesarecopiedfromtheUSBdrivetotheSDcard,ChameleonPiusesyourUSBdriveasexternalstorage.Ifyouinsertafreshlyformatteddrive,ChameleonPiwillcreateafolderstructureforyourgames.CopyyourfilesintothecorrespondingfolderonyourUSBdrive,andtheninsertitintotheRaspberryPi.ThenexttimeyouuseChameleonPi,yourgamefileswillappear.
SummaryInthischapter,youhavebeenintroducedtothreedifferentgame-basedRaspberryPidistributions.Whileallthreesharealotincommon,theygoaboutimplementinggamingintheirownuniqueways.Tryallthree,andusetheonethatfitsyourgamingstylethebest.
Inthenextchapter,youwilllearnhowtoaccesstheRaspberryPiAppStoresowecanplaywithevenmoregames.
Chapter4.EmulatorsInthischapter,wewilldiveintoemulationontheRaspberryPi.Butwhatisemulation?Emulationistheactofduplicatingthefunctionalityofonesystemontoanother.ThismeansthatwecanmaketheRaspberryPipretendtobesomethingelse,suchasaSuperNintendo,oraCommodore64,oraSegaGenesis.Byutilizingdifferentemulationsoftware,ourRaspberryPicanbeallthesethingsandmore.
Youwilllearn:
HowtoinstallapplicationsusingtheRaspberryPiAppStoreHowtodownloadapplicationsfromtheInternetHowtoinstallprogramsfromtheRaspbianrepositories
Let’sstartwiththeRaspberryPiAppStore.
RaspberryPiAppStoreItseemsthatagrowingtrendisforeachdevicetohaveitsownlittleecosystemforapplications.TheRaspberryPiisnodifferent,andeachcopyofRaspbianhasaccesstothePiStore.ThisAppStoreisforyoutodownloadgamesandapplicationsmadespecificallyfortheRaspberryPi.
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.
Anydevelopercansignupanduploadtheirgamestothestore.Pricingforgamesstartsatfreeofchargeandcangoupfromthere.Oncethegamehasbeenmadeavailableinthestore,anyuserwithanaccountcanpurchaseit.Allgamesandappsarestoredunderthe/usr/local/bin/indiecityfoldertoplaythemoffline.
Don’tworryaboutformattingyourSDcardandlosingyourgames.WhenyoulogintoyourPiStoreaccountyoucanre-downloadallyourpurchases.
EmulatorsTherearenumerousemulatorsavailablefortheRaspberryPi.SomeoftheseareavailablethroughtheAppStore,othersyouneedtodownloadfromawebsiteandmanuallyinstall,andthentherearesomewhichcanbeinstalledviaRaspbian’spackagemanager.
Emulatorsrecreatehowagameconsoleworks,buttheydon’temulatethegamesthemselves.Thatrequiresthegamedata.Whenwerefertogamefilesinthisbook,wearereferringtotheRead-OnlyMemory(ROM)thatavideogame’sdataisstoredon.Thesecanbecartridges,CDsandDVDs,floppydisks,andothertypesofmedia.Manyareavailableasfilesyoucandownload.Pleasebeawarethatcopyrightmaystillexistonthesefilesandthatnotallarefreelyavailable.
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.
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.
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!
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!
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!
PCSX_ReARMedPCSX_ReARMedisaPlayStationemulatorfortheRaspberryPi.Ascrazyasthisseems,theRaspberryPicanplayPlayStationgames!ThereasonforthisisthattheRaspberryPihasaverypowerfulgraphicschipthatrunsOpenGLEScode.PCSX_ReARMedhasbeenwrittentotakeadvantageofOpenGLES,whichgivesusagreatemulator.
PCSX_ReARMedisavailableforfreeonthePiStore.Makeuseofthefollowingstepstodownloadit:
1. OnceyouareonthedesktopandloggedintothePiStore,clickontheGamestab.YoucanalsosearchforPCSX_Rearmed.
2. ClickonPlay/Downloadtobegintheinstallationprocess.
3. Wheninstructed,pressanykeytofinishtheinstallation.4. Toruntheprogram,gotoMyLibrary,clickonpcsx_reARMed,andpressLaunch
intheright-handpanel.
5. ClickonExecuteandthePCSX_ReARMedgamewindowwillappear.6. Youdon’tneedtoplaceyourgamesinanyspecificdirectoryforthisemulator.When
youselectLoadCDimage,youcanbrowsetheRaspberryPi’sfilesystemforyourgamefile.
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.
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.
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
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.
ThePCSX_ReARMedcontrolscanbeseenandeditedwithinthecontrolsonthemainscreen.
PicoDrivecontrolscanbeeditedfromwithinthemainmenu.
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.
SummaryYoulearnedhoweasyitistousetheRaspberryPi’sPiStoreapplication,whichisincludedineverycopyofRaspbian.Fromsettingupyouraccount,topurchasingnewgames,thePiStoreisagreatresource.YoualsoinstalledsomeemulatorsonyourPiusingthevariousinstallationmethodsavailableinLinux,andplayedsomeclassicvideogames.
Inthenextchapter,wewillintroducestandalonegamesthathavebeenportedovertotheRaspberryPi.
Chapter5.PortedGamesNowthatwehaveplayedsomegamesviaanemulator,wearereadytoplaysomegamesthatwereportedtoworkontheRaspberryPi.Aportisapieceofsoftwarethatiscodedanddevelopedforaspecificenvironmentbuthasbeentransportedandrebuiltforadifferentone.Thiscommonlyoccurswithconsolegames.AgamewillbewrittenforaMicrosoftconsole,andthenportedovertoSony’sorNintendo’sconsole.ItalsohappenswhenaconsolegameisportedovertothePC.
Thischapterwillfocusonthosegamesthathavebeenreleasedforotherplatforms,andthenportedovertotheRaspberryPi.
Youwilllearnhowto:
InstallandplayCaveStoryInstallandplayDoomInstallandplayOpenArena,andcreateamultiplayerserverforitInstall,createyourownworld,andprogramscriptsforMinecraft
CaveStoryCaveStoryisafreewareMetroid/Castlevaniastyleplatformer.ItisamassiveplatformadventurealongthelinesofMetroid,Castlevania,andTerraria.Withalongengrossingstoryline,ahardbutnotfrustratingdifficultylevel,andabeautifulsetting,thegameisperfecttositbackandloseafewhourswith.ItwasoriginallyreleasedonthePCforMicrosoftWindowsin2004.Overtheyears,ithasbeenportedtotheNintendoWii,DSi,3DS,MacOSX,andLinux.
TheRaspberryPiportispossiblebecausetheoriginalCaveStoryenginewasreverseengineeredandanewopensourceenginecalledNXEnginewascreated.
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.
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
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.
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.
ControlsHereisalistofthedefaultkeysinDoom:
Action Key
Turnleft Leftarrow
Turnright Rightarrow
Forward Uparrow
Back Downarrow
Action Space
Fire Ctrl
Changeweapon Press2through7
Menu Esc
OpenArenaWhatPrBoomistoDoom,OpenArenaistoQuake3Arena.Quake3ArenaisanotherinnovatoroftheFPSgenre.Ithelpedlaunchahugelycompetitivemultiplayerenvironmentaswellasaraceforabettergraphicscardtochurnoutmoreframespersecond.TheQuake3enginehasbeenusedforastaggeringnumberofgames.SinceidSoftwareopensourcedtheengine,itiscapableofrunningontheRaspberryPi.OpenArenaisaprojecttodevelopacompletelyfreeversionofQuake3Arena.Usingentirelynewsprites,3Dmodels,textures,andlevels,anyonecandownloadOpenArenatotheircomputerandplayforfree.
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.
SingleplayermatchForasingleplayercampaign,performthefollowingsteps:
1. FromtheOpenArenamainmenu,clickonSINGLEPLAYER.2. Selectoneofthemapiconsfromthelist.Theopponentsinthearenawillbelistedat
thebottom.3. Clickonfighttoloadthearenaandstartthematch.
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).
ControlsThefollowingisalistofthedefaultkeysinOpenArena:
Action Key
Strafeleft A
Straferight D
Forward W
Back S
Jump Space
Fire Leftmouseclick
Changeweapon Press1through9oruseyourmousewheel
Menu Esc
Aim Mouseclick
Minecraft:PiEditionMinecraftisasandbox-stylegamemadebythegamecompanyMojang.Becauseitisasandbox,thereisnorightorwrongwaytoplayit.Theconceptbehindthegameisthatyouexploreandbuildusingdifferentkindsofblocksinarandomlycreatedworld.IthasbeencomparedtoavirtualLEGOset.Ifyoucanthinkit,youcanbuilditinMinecraft.
ItwasoriginallydevelopedfortheWindowsPC,buthassincebeenportedtoOSX,iOS,Android,andvariousgameconsoles.MojangdevelopedandreleasedaporttotheRaspberryPiasafreedownload.
InstallingandrunningIfyouarerunningthelatestversionofRaspbian,Minecraftisnowincludedbydefault.IfyouarerunninganolderversionofRaspbian,youcaninstallMinecraftusingapt-get,asfollows:
1. Atthecommandline,typesudoapt-getupdate.2. Then,typesudoapt-getinstallminecraft-pi.3. Fromthedesktop,double-clickontheMinecraftPiEditionicon,orfromadesktop
terminal,typeminecraft-piandpressEnter.
CreatinganewMinecraftworldTocreateanewMinecraftworld,performthefollowingactions:
1. WithMinecraftrunning,clickonStartGame.2. SelectCreatenew.3. Afterafewmoments,youwillenterintoabrandnewMinecraftworldenvironment.
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:
TherearemanymorethingsyoucandowithbothPythonandtheMinecraftAPI.FromcreatingfunctionsthatwillbuildafortresstousingloopstostacktonsofTNTblocks,youcanprogramtheentireworld.
FormoreAPIdocumentation,visit:
http://www.stuffaboutcode.com/p/minecraft-api-reference.html
MultiplayerMinecraftMinecraft:PiEditionisamultiplayergame.IfyouhaveotherpeoplerunningRaspberryPisonyournetwork,alltheyneedtodoisclickonJoinGameinthemainmenu,andallthecurrentlyrunningMinecraftworldswillbeavailableforthemtojoin.
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
SummaryInthischapter,youlearnedhowtodownloadandinstallsomegames,whichwereremadefortheRaspberryPi.Youlearnedhowtoinstallgamesviaapt-getlikePrBoom,downloadgamesfromtheInternetlikeCaveStory,setupamultiplayerserverforOpenArena,andprogramyourownMinecraftworld.
Inthenextchapter,wewilldiscussgamesmadejustforLinuxandtheRaspberryPi.
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
FreeCivFreeCivisafree,opensource,turn-basedstrategygamethatisinfluencedbythelongrunningcivilizationseriesofgames.InFreeCiv,youtakeontheroleleadingyourchosencivilizationoutoftheStoneAgeandintotheSpaceAge.Youmustexplore,buildout,andresearchnewskillsandabilities,allwhiletryingtodefeattherivalcivilizationsthataredoingthesamething.FreeCivhasbeenindevelopmentforover18yearsandboastsalargecommunitywithyearsofinformationandresources.
FreeCivfeaturesvariousdifficultiesofAI,singleplayerandmultiplayercapabilities,randomlygeneratedmaps,rulefine-tuning,andtonsofotherthingstomakeeachgameatotallydifferentexperience.
InstallingandrunningInstallingFreeCivisverysimple.Followthesesteps:
1. Atthecommandline,typesudoapt-getinstall-yfreeciv-client-gtk.ThiswillinstallFreeCiv,aswellastheFreeCivserver.
2. Oncetheinstallisfinished,makesureyouareonthedesktopenvironmentbytypingstartxandpressingEnter.
3. Onceyouareonthedesktop,clickonthemenubuttonatthebottom-leftandhighlightGames.Underthesubmenu,youwillseetheFreecivoption.Clickonit.
4. FreeCivshouldnowhavelaunchedandyouwillbepresentedwithafewoptions.
5. SelectStartNewGameandyouwillbepresentedwiththegamesetupscreen.Here,youwillabletosetthegameoptions,choosetheamountofplayers,andpickwhichnationyouwillbeplayingas.
6. ClickonStarttobeginthegame.
HostingaFreeCivserverPlayingFreeCivagainsttheAIisagreatwaytolearnandgetgoodatthegame,butthegamereallyshineswhenyouincludeyourfriends(orsoontobeenemies).
TheRaspberryPiservesasagreatplatformtohostamultiplayerFreeCivgame.Justusethefollowingsteps:
1. Fromthedesktopmenu,selectGamesandthenclickonFreecivserver.Acommandwindowwillopenandautomaticallystartanewgame.
2. Now,loadFreeCiv,andclickonConnecttoNetworkGame.Yourgameservershouldappearinthelistofavailablegames.
3. Double-clickonthedesiredgametojoinit.
4. Whenyouareready,clickonStartandthegamewillbegin!GoodLuck!
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
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
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
SuperTuxSuperTuxisanotherfreeandopensourceLinuxgame.BeingreminiscentoftheSuperMarioBros.series,itisaside-scrollingactiongame,wherethegoalofthegameistorescuePennybygettingfromoneendoftheleveltotheother,whilekillingoravoidingenemies,andcollectingpower-ups.SuperTuxincludes26levels,butthereisalsoaleveleditoravailable,soyoucanmakeyourownstages.
InstallingandrunningSuperTuxisincludedintheRaspbiansoftwarerepositories,andcanbeplayedontheterminalordesktopenvironmentusingthefollowingsteps:
1. Atthecommandline,typesudoapt-getinstall-ysupertux.2. Torunthegame,typesupertuxandpressEnter.Thegameshouldnowfillyour
entirescreen.
3. UsetheupanddownarrowkeystoselectStartGame,thenpressEntertobeginplayingSuperTux.
LearningthecontrolsHereisalistofthekeysthatyouwouldrequireinthegame:
Action Keyboard
Left Leftarrow
Right Rightarrow
Activate/Enter Uparrow
Duck Downarrow
Jump Space
Useability Leftcontrol
Menu Esc
NjamNjamisalsoafreeopensourcegamebasedonclassicmazegameslikePac-Man.Thegoalofthegameistoeatallthedotswhileavoidingtheobstacles.Ifyoueatoneofthepower-ups,yougaininvincibilityforashortperiodoftime.Njamincludesanarrayoflevels,leveleditors,andmultiplayercapabilities.
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.
LearningthecontrolsHereisalistofkeysthatyouwouldrequireinthegame:
Action Keyboard
Up Uparrow
Down Downarrow
Left Leftarrow
Right Rightarrow
Exit Esc
Galaga:HyperspaceGalaga:Hyperspaceisagamebasedonclassicshoot‘emupgameslikeGalagaandGalaxian.Thegoalofthegameistodestroyeachwaveofalienswhileavoidingthebulletstheyhurlyourway.Eachwavegetsmoreandmoredifficult,andyoucanonlygethitoncebeforelosingalife.
InstallingandrunningGalaga:HyperspaceisavailableintheRaspbiansoftwarerepositories,andcanonlybeplayedonthedesktopenvironmentusingthefollowingsteps:
1. Atthecommandline,typesudoapt-getinstall-yxgalaga.2. Torunthegame,makesureyouareonthedesktopenvironmentbytypingstartx
andthenpressingEnter.3. Onceyouareonthedesktop,clickonthemenubuttonatthebottom-leftand
highlightGames.Underthesubmenu,Galagawillbeanoption.Clickonittostartthegame.
LearningthecontrolsHereisalistofthekeysthatyouwouldrequireinthegame:
Action Keyboard
Left Leftarrow
Right Rightarrow
StartGamewithkeyboardcontrols K
StartGamewithmousecontrols M
QuitGalaga:Hyperspace Q
Quitcurrentgame q
FindinggamesviatherepositoriesThegamesmentionedabovearejustthetipoftheicebergwhenitcomestoLinuxgaming.TheRaspbianrepositoriesincludeatonofpackages,andthereareafewcommandsyoushouldknowinordertosearchthroughit.
Theapt-cachesearchkeywordcommandwillsearchthereposforthekeywordyouspecify,anddisplayalistofresultsinthecommandterminal.Forexample:apt-cachesearchgamewilldisplaypagesofresults.Youcanthenwhittledowntheresultsbyspecifyingmultiplekeywords.Let’ssaywewanttofindaPac-Manclone:apt-cachesearchpacmanwillreturnalistofgamesthatincludePac-Maninthedescription.Theapt-cachesearchpacmanconsolecommandwillfurtherrefinethesearchandwillreturnoneresultthatmatchesyourquery,pacman4console.
SummaryInthischapter,youlearnedaboutgamesthatweremadespecificallyforLinuxandthatrunonRaspberryPi.Therearedozensmoregamesavailableintherepositoriesthatyoucaninstallandtryout.Fromroguelikestoarcaderemakes,thereposholdhoursoffun.
Inthenextchapter,wewilldiscussthevariousinputmethodsavailablefortheRaspberryPi,includingarcadesticks,Bluetoothcontrollers,andgamingconsoledevices.
Chapter7.ControllersInthischapter,wewillgothroughmanyofthetypesofgaminginputdevicesthatwecanconnecttoourRaspberryPi.Fromfightsticks(orjoysticks),gamepads,consolecontrollers,tobuildingyourown,thereareallsortsofoptionsavailable.
Inthischapter,youwilllearnhowto:
EnableBluetoothconnectivitySetupXboxandPlayStationcontrollersUseaUSBencoderUsetheGPIOpinstobuildyourowncontrollerTroubleshootproblemcontrollers
ControllersontheRaspberryPiBeforewebegin,youwillwanttoinstallthejoystickpackagetoyourdevice.Typesudoapt-get–yinstalljoystickatthecommandlineandpressEnter.Thejoystickpackageincludesanapplicationcalledjstest,whichwillhelpyouidentifyandtroubleshootyourcontrollers.
WhenacontrollerisconnectedandrecognizedbytheRaspberryPi,anewentrywillbemadeinthe/dev/input/folder.Thisfoldercontainsalistofallconnectedinputdevices.Youshouldseefileslikeevent0,mouse0,andkb0dependingonwhathasbeenconnected.Whenyourcontrollerisconnected,youshouldseeanewitemcalledjs0.The0attheendoftheitemindicatestheorderinwhichitwasconnected.Youcanhavemultipleitemsconnected,andtheywilleachgetanincreasingnumber.
GamepadsGamepadsareoneofthesimplesttypesofcontrollersfortheRaspberryPi.Theycancomeindifferentshapes,sizes,andcanhavedifferentcombinationsofbuttons.Thesetypesofcontrollersareusuallymodeledafterpopularconsoles,andmadetolooklikeNES,SNES,Genesis,orPlayStationgamepads.Themajoradvantageoftheseisthattheyarecompact,handheld,andveryportable.
AslongasthegamepadisconnectedviaUSB,itwillbePlugandPlayontheRaspberryPi.
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.
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.
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.
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.
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.
USBencodersAttheheartofeveryArcadestickisaUSBencoder.IttakestheactionofhittingabuttonandturnsitintoaninputforyourRaspberryPi.Someencodersemulateakeyboard,whileothersactasanactualjoystick.Usinganencoder,youcanveryeasilybuildyourowncustomizedcontroller.
Therearehundredsofdifferentencodersoutthere,butthemostcommononesarecalledtheNoDelay,ZeroDelay,andXinMoboard.Alloftheseboardsactasajoystick,andareverysimpletowireup.
ThisisanexampleofaNoDelayUSBjoystickencoderboard.The8buttonsarewireduptothebuttonpinsonthebottomoftheboard.Eachbuttonhasacommonandgroundpin.Whenthebuttonispusheddown,theconnectioniscompleted,sendingthesignaltotheboard.Thejoystickusesthe4slotsatthetopoftheboardforup,down,left,andrightmovements.Theboardcanalsoacceptjoysticksthatonlyuse5pins.Thosearecommonwithballtopsticks.TheboardincludesaUSBcablethatplugsintothepinsonthefar-leftoftheboard.
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
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.
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
fixestheissue.Ifnot,yourBluetoothdonglemightnotbesupported.
SummaryYouhavenowlearnedaboutdifferentgamepadsandjoysticks.Youhavelearnedhowtobuildyourown,andhowtoconnectthemdirectlytotheRaspberryPihardware.YoualsoknowhowtoconnectnonstandardcontrollerssuchastheXboxandDualShock3.YoucannowtroubleshootyourcontrollersandyouhavelearnedmoreabouttheinnerworkingsofRaspbianandLinux.
Inthenextchapter,wewillgooversomegeneraltroubleshootingtipsfortheRaspberryPi.
Chapter8.TroubleshootingSofar,welearnedhowtomakeourowngame,installnumerousemulatorsandvideogames,hookupperipherals,connectjoysticks,andusethehardwarepins.However,whathappenswhensomethinggoeswrong?ThischapterwillguideyouthroughsomeofthecommonissuesyoumightfacewithaRaspberryPi.
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.
CommontroubleshootingHerearesomeofthecommonerrorsandthemeanstotroubleshootthem:
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.
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/
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.
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.
TheDualShock3controllerdoesnotconnectInthiscase,
EnsurethattheDualShock3batteryisfullycharged.
NoteChargingcantakeover2hourstofullycomplete.
Usingasmallpin,presstheresetbuttononthebackofthecontroller.UseapoweredUSBhubforyourBluetoothdongle.UseaMicroUSBcabletoensurethatthecontrollerworkswhenpluggedin.
IgetanerrorwhencompilingRetrogameThemostcommoncauseoferrorsisforgettingapieceofsyntax.
Checkwhethereachlinehastheproperamountofcommas.
Forexample:{17,KEY_DOWN},
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
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/
GamesavailableviaApt-GetThefollowingisthelistofgamesthatareavailableviaApt-Get:
20,000LightYearsIntoSpace3DChess4-DigitAbuseACM(Aliens:ColonialMarines)AirstrikeAllegrodemoAngryDrunkenDwarvesAtomAtomicTanksBattleforWesnothBattleTanksBattleballBeneathaSteelSkyBlobWars:MetalBlobSolidBlockOut2DeSmuMEFeedingFrenzyFlareFlightoftheAmazonQueenFreeCivFreeCraftFreeDinkFreesweepFunnyBoatFuseGalagaGalaga:HyperspaceGNUShogiHexxagonKETM(KillEverythingThatMoves)LincityLittleCraneMancalaMednafenMicropolisMinecraft:PiEditionMonsterzNetHackOpenTTD
OvergodPrBoomPydanceRafkillSnake4SopwithSpaceAryaryaSpaceZeroSpoutStaxStellaSuperTuxTaguaTeddyTetzleTINTTriplaneVavoomXSoldierXtronYahtzeeSharp
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.
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)
BBluetoothconnectivity
SonyDualShock3controllers,settingup/SonyDualShock3controllersBluetoothdongle
URL/SonyDualShock3controllers
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
DDoom
about/DoomPrBoom/Doomcontrols/Controls
DualShock3controllerconnection,troubleshooting/TheDualShock3controllerdoesnotconnect
EEmulationStation
executionerror,troubleshooting/EmulationStationreturnsanerrorwhenItrytolaunchit
emulatorsabout/EmulatorsMednafen/MednafenFCEUX/FCEUX(NES)PiSNES/PiSNES(SNES)MAME4ALL/MAME4ALLFinalBurnAlpha/FinalBurnAlphaPCSX_ReARMed/PCSX_ReARMedPicoDrive/PicoDrive(Genesis/MegaDrive)Stella/Stella(Atari2600)
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
GGalaga*Hyperspace
about/Galaga:Hyperspaceinstalling/Installingandrunningexecuting/Installingandrunningcontrols/Learningthecontrols
gamepadsabout/Gamepads
gamessearching,viarepositories/Findinggamesviatherepositories
GPIOpinsabout/GPIOpinsRetrogame/GPIOpins
HHDMI
connection,troubleshooting/ConnectingviaHDMIdoesn’twork
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
Jjoystickpackage
installing/ControllersontheRaspberryPi
LLinux
SDcard,creating/CreatingtheSDcardinLinux
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
NNintendoEntertainmentSystem(NES)
about/FCEUX(NES)Njam
about/Njaminstalling/Installingandrunningexecuting/Installingandrunningcontrols/Learningthecontrols
NOOBSusing/UsingNOOBSinstalling/UsingNOOBSURL,fordownloading/UsingNOOBS,NothinghappenswhenIapplypowerabout/NothinghappenswhenIapplypower
NXEngineabout/CaveStory
OOpenArena
about/OpenArenainstalling/Installationsingleplayermatch/Singleplayermatchmultiplayermatch/Multiplayermatchserver,creatingformultiplayermatch/Runningaserverserver,joiningformultiplayermatch/Joiningaserver
overclockabout/Someofthegamesseemslow
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
QQuake3Arena
about/OpenArenacontrols/Controls
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
systemsandconsoles/RetroPieURL/RetroPieEmulationStationsplashscreen/RetroPiegamecontroller,configuring/RetroPiegamecontroller,settingup/RetroPiegamefiles,copyingwithSAMBAshares/RetroPiegamefiles,copyingviaUSBdrive/RetroPieversusChameleonPi/ChameleonPi
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
Ttroubleshooting
controllers/TroubleshootingcontrollersEmulationStationexecutionerror/EmulationStationreturnsanerrorwhenItrytolaunchitinadequatepowersupply/NothinghappenswhenIapplypoweroverclocking/SomeofthegamesseemslowHDMIconnectionissue/ConnectingviaHDMIdoesn’tworkHDMIconnection/ConnectingviaHDMIdoesn’tworkDualShock3controllerconnection/TheDualShock3controllerdoesnotconnectRetrogamecompilationerror/IgetanerrorwhencompilingRetrogame
UUSBdrive
gamecontroller,configuring/RetroPieused,forcopyinggamefilesontoPi/RetroPie
USBencodersabout/USBencoders
Vvariable
about/Somepointersandterminology
WWiFiaccesspoint
RaspberryPi,connectingto/ConnectingtoaWi-FiaccesspointWiFiadapter
URL/ConnectingtoaWi-FiaccesspointWin32DiskImager
about/SettingupanSDcardURL/CreatingtheSDcardinWindows
WindowsSDcard,creating/CreatingtheSDcardinWindows
XXbox360controllers
about/Xbox360controllersxboxdrv
about/Xbox360controllersinstalling/Xbox360controllersusing/Xbox360controllers
Xpositionabout/Somepointersandterminology
YYposition
about/Somepointersandterminology