Butwe'vegot a plotgiveninthisstyleoffinalfancy, andthisiswhatwe'vecomeupwithsofar.
So I'm currentlycontrollingthislittlecharacterwalkingaroundthemapandyoucanseesomeefforthasgoneintothegraphics.
Nowallofthegraphicshavebeencreatedbytheonelonecodercommunityfrompeopleonthediscordserveronthey'reallstill a workinprogressbecauseofthisis a bigproject.
I don't havethetimeorresourcesortheskill, frankly, tocreateallofthegraphicsnecessary.
We'llseethroughoutthecourseofthisprojectthatwecanreallysortoffinetunethingson a perobjectlevel.
Becauseeventhoughthisis a videoaboutanRPG, it's really a videoaboutobjectorientedprogramming.
Let's takeonthisskeleton.
Sowe'vekilledoneofthem.
Nowlet's killdeal.
Therewego.
Thisprojectisfartoobigfor a singlevideo, soitwillbesplitoverseveralvideos.
I'm notyetquitesurethereleaseschedulewillbe.
I'm stillactivelydevelopingthisbudget, nottobedifferentto a lotofmypreviousvideos.
Thisoneishighlyobjectorientedon, butthat's because I thinkpeoplearen't reallyexposedtoobjectorientedprogrammingthroughmostofthestuffthat I'vebeenworkingon.
Nodoubtsaboutthat, absolutelytheway I amgoingtoshowhow I Ioveyou.
Startexcited.
Programminginthisvideoisgoingtoupsetsomebodysolittlepersonaldisclaimerthatthisvideoisprobablynotgoingtobeanexamplebestpracticewhenusingobjectorientedtechniques, butnonetheless, forthemostpart, I thinkyou'llget a reallygoodunderstandingofhowobjectorientedprogrammingcanreallyenhance a partition, yourdevelopmentprocess.
But I willbebreakingsomerulesnowbeforewegetstarted.
Whenwestartthinkingofmaps, weknowthatthegameenginemustsupporttheloadingandtransitionbetweenmaps, butalsothelayoutofthemapsbecomes a bitof a gamedesignthing, too.
Andhowtheirbehaviorisimplementedisalsoanenginethingtoyouwon't expectthegamedesignertonecessarilydecideonthemathsandphysicsinvolvedtoimplement a particular a I.
Sowe'regoingtoleavethatintheenginecollar.
Howevertuningoftheenemies.
Thatcertainlyis a gamedesignthingbecausethatneedstofitinwiththeplotonwhattheyexpectedexperienceleveloftheplayerisonmakingthebattlesfun.
Well, that's probably a bitofboth, butthat's still a gamedesignthingtothetypesoftreasureandloots.
Well, thatcertainlygamedesign.
That's whereyoucanpotentiallyinject a littlebitofhumorintothegameonthenatureoftheupgradesisalsogettingdesignedbecausewedon't wanttogivetheplayerthemostpowerfulweaponsrightatthestartofthegame, however, upgradeshave a minimalimpactontheengine.
Allthey'regoingtodoisincreaseordecrease a statsupportingandmaintainaninventory, thoughthat's anengineresponsibility.
Whatsolid, however, intheRPGwereprobablygoingtohavemultipledynamicobjects.
Solet's saywe'vegot a nonplayingcharacter, anNPCwell, weknowthatforcutsequencesandotherthingsthatweprobablywanttomovethemaround, sothatmakeshim a dynamicobject.
Solet's nothavingtothinkaboutwhat a dynamicobjectis.
Well, weknowthatit's goingtohave a positionsomewhereintheworld.
Andbecauseit's dynamicandwehave a position, it's verylikelywe'regoingtoneedsomevelocityto.
Itcouldeffectivelyflythroughthesolidtiles, so I'm goingtocreate a flag, whichis, Ah, solidversussolidobjects.
Sothat's sortofthingsinthemapinthebackground.
Butthen I don't wantmyplaycharactertobeabletowalkthroughotherplayercharactersthatsometimesthatcouldbequiteroute.
So I'm alsogoingtohave a flag, whichissolidversusdynamic, andwe'llseebymanipulatingtheseflagsthatwecanextendtherangeofbehaviorsofwhatthedynamicobjectcanandcan't do.
Butlet's extendthisideaof a dynamicobjectevenfurtherbyconsideringthatalldynamicobjectsareinteractherbalon.
I thinkthisisanimportantdistinctiontomake, soifmyplayercharacterwalkedovertotheNPCondheinteractedwithit.
Whenweinteractwiththeteleport, weknowwecanmovetheplayertosomeotherlocationonwhenweinteractwith a signpostwedisplayinformationonthenicethinghereis I don't needtocodeallthespecialcases.
All I needtodoisprovidetheimplementationforthatparticularobjectonbecausealloftheseobjectsarefundamentally a dynamicobject.
I canstorethemallregardlessoftheirsubtypesin a singlevectoroffdynamicobjects, whichmeansall I needtodoiscalltheoninteractfunctionandthecompilerwillsortoutwhichparticularonintoactcodetoexecute.
Andthatmightnotbethecaseforus, a typicalexamplebeingthatthebeforewesawourplay a characterwalkingacrossthegrassonwalkingacrossthepathsothereisn't enoughinformationhere.
Additionally, editingthesemapsisquitetrickybecauseit's not a faithfulvisualrepresentationofwhatthemapwillultimatelylooklike.
Now, I'm not a fanofusingsettersandgetiseverywhere, particularlyforsimplebasicvariables, so I'm notgoingtoonthiscase.
Soif I wantthewidthandtheheightofthemap, I'm justgoingtomakethemaccessibledirectlybydeclaringthemispublic.
I'm goingtootherfunction, whichisgetindexon.
Thisisgoingtoreturnthetileindexfor a givenlocationindexonin.
Whysotheusualrequesttocoordinate.
Anditwillreturn a singlenumber, whichrepresentswhichtiletodisplayoutofthetilemapthat's beenassociatingwiththisphysicalmap, andwe'llsee a littlebitmoreaboutthatin a minute.
But I alsowantanotherone, whichisgetwhetherthetileissolidornot.
Inthisinstance, I'm not.
Creatingthetileis a separatestructure.
It's reallynotnecessary.
Butthesetwofunctionsimplythat I'm goingtohave a coupleof a raiseto I'm goingtocreate.
Nowyou'llnoticethatbecauseoflotsofbadpracticereasons, byincludingthisfile, we'vealsojustdefinedstringonthisbecausethisheadoffileusesAh, usingnamespace S t d.
Youreallyshouldn't doitthatway.
Butinthiscase, I'm goingtojustifyitbysimplysaying I know I'm notgoingtobeincludinganyotherpackageaspartofthisprojectfinalfunction, I'm goingtoaddis a createfunction, whichtakes a pathtotheexternalfilecontainingtheleveldata, thepointertothestrikeonthefamilyname.
The 1st 2 numbersrepresentthewidthandtheheightofthisareaonafterthewidthandheighthavebeendeclaredwiththengotpairsofnumberswhichrepresentwhichgraphictouseonwhetherornotthetileissolid.
Let's justtake a minutetolookat a tilesheet, so a tilesheetisbasically a onelineKodaformatSpritethatcontainsalloftheimageryrequiredtoassemblethemaponit's indexedbymovingalongoncheckingwhatitswidththis.
SoknowingthatIndexninerepresentsthistree, wecanstarttoseethatwe'vegot a borderoftreesaroundthelevel.
However, thesetreesareclassifiedisnotsolid.
Whyisthat.
Well, letmeintroduceyouanothertool, thistoolscreatedbyit A fromthediscordserveron.
It's a simplemapeditorfortheroleplayinggame, and I justwanttosaythisis a reallygoodexampleofhowthecommunityiscomingtogethertocreateutilitiestosupportthisproject.
Withoutthem, itjustwouldbesimplytoomuchworkformetodoonmyowninthetimescalesthat I haveavailableonTheSpite.
Editorallowsustoselectspritesfromthesheetthatwesawbeforeandplacethemaroundso I canplacetreesanywhereinthescene.
Sonowwehaveourmapbasedclass, butindividualmapsinthegamearegoingtobesubclassesoffthisclass, solet's createoneforthefirstvillage, so I'llcreate a classthatinheritspubliclyfromseemappcalledVillageOne.
However, thewaythatwedrawthemaptothescreenisnowverydifferent.
Westillneedtogetanindexthatrepresentsthetile.
When I returnedtotypeintonow, it's nolonger a CharacterColaindex.
Butinsteadofthisswitchblock, wewanttocalculatethe X and Y coordinatesoffthatindexinthespritesheet.
Sotoconvertfrom a one D to a twoday, usuallywedoittheotherwayaround.
We'regoingtousemodernanddip.
Sooursprites X location, I'llsayintoSXisequaltothelinearindex.
Modthenumberoftilesonourmap, which I knowinthiscaseisTed.
I know I'm puttingin a hardnumberhere.
In a latervideo, thiswillbeupdatedandtogettothespiketiles y positionwedivideby 10 andit's importantthatthisisallkeptintheinterviewdomainbecausethiswillgiveustherowthatthetileisonbecauseanyinformationasaftertheremainderofthisdivideisjustlostonthiswillgiveusthecolumnthattheSpriteisoninthetilesheet.
Ifwelookattheerrorinformationatthebottomand I appreciateit's a bitsmallfundamentally, saysoneormoremultiple E definedsymbolsfound, andthisissomethingwe'vealwaysbeenabletoavoidbydoingthingsin a singlefileforthepreviousvideos.
Onespidercompiling, butheatherfilescanbepulledinmultipletimesbywhicheverCPPfileneedsthisstuff, andthingslikethisshouldbedeclaredin a c p p filetoensurethatit's onlycompiledonce.
Thisisgoingtobe a singlelocationthat's responsibleforloadingalloftheartworkandextrainformationthatweneedforthegame.
I knowthatfirst, notwe'regoingtobeloadingsprites, soweneedthedefinitionovertheOLCSprite, but I wanttomakethisclass a singleton, whichmeansthefirsttimeaninstanceofthisclassiscreated.
Thefirstthing I'm goingtoneedis a functionsowecanaccessaninstanceofitself.
Andthisiswherethingsstarttoget a bitweirdtocreate a publicstaticfunctionwhichiscalledGeton, that's goingtoreturnaninstancetoitselfandyoucanseeitcreates a staticlocalvariableinthiscasecalledme.
I'm goingtouse a maponthemap, allowsyoutopairup a keywith a valueonthetypeofthekeyisgoingtobe a stringon.
Thevalueinthiscaseisgoingtobe a pointerto a Sprite.
We'llcallthis M mapspritesonlytoincludemap, butit's allforthefile.
Themapis a littlebitlikeanarray, althoughfarlessefficientbutpotentially a lotmoreuseful.
Insteadofusingnumberstoindexthelocationinbattery, wecanuseotherobjectsandinthiscase, because I knowthatwe'reonlygoingtobeaccessingspikesrelativelyinfrequentlybyaccessingthepointofdespiteinfrequently.
But I don't needtoworryabouttheperformancehitsthatthatwouldinvolveandthebenefitsaregoingtogetfromusing a maphereislike a noosefriendlynamingconventionsthroughoutthewholeprogram, whichmeansif I doenduphavingallthepeopledesigningpartsofthis, theycanstickthisfriendlynamingconvention, andtheenginedoesn't needtobealtered, andthismaystillseem a littlebitweird.
Butonce I putthisfunctioninhere, whichisgetSprite, youcanseethatweapply a nameon.
We'reusingthenameastheindextothemap, soitworksin a verysimilarwaytoanarray.
Andthisiswhere I wanttodothesingleoneoffloadofeverythingthat I'm goingtoneedforthegame.
I'm goingtostartbydefining a littleLambdafunctioncalledLoad, whichtakes a friendlynameonthefilenametotheassetthatweretryingtoloadoninthisLambdafunction.