Andas I'm justabouttocrossthestart, finishstraight, wecanseewhatlaptime I clockedinthistimewas 42.8 seconds.
I'm surewecandomuchbetterthanthatif I attempttogotoofastaroundthecornerandpushedouttotheside, so I havetousetheacceleratorquitecarefully, likesomeofmyothercodedyourselfvideos.
Thisonelookslikethere's a lotgoingon, butactuallythereisn't.
And I thinkthisisreallywhatthisvideoisaboutiswecantake a reallymundane, simplemathematicalconcept.
Butifwepresentitinaninterestingway, becomes a playablegay.
I needtobreakuptherowintowhetherit's, ah, grassclippingboardallroad, soeachcharactergoingacrosstheconsolewe'regoingtoclassifyasoneoftheother.
Tomakethings a littlesimpler, I'm goingtoassumethatthewidthofthescreenisgoingtobe a normallifeSpecsorzerofortheleft, ononefortherightsothemiddleofthescreenwillbe 10.5.
Thisisusefulbecausewe'llprobablywanttoscalethingsup, dependingonthesizeofscreen, butitalsomakessomeofthemathematics a littlesimplerlateron, too.
So I needtoworkoutwherethoseboundariesareintheexdirection.
So, forexample, I knowthatmygrassbeginsatzero, butitwillstopwhenwegettothemiddlepointofthetrack, minustheroadwithwhichisnohalfonminustheclippingboardwith.
I canthenscalethatintothescreenspaceforthecouncilin a similarmanner.
I canworkoutwheremyleftclippingboardis.
Soit's exactlythesamecalculation.
But I don't needtoincludetheclipwidththistimeonbecausewehavetheroadwithbeforeDoingtherightinsideisthesamenow, exceptwe'redoingplusesinsteadofminuses.
Soweknowthatif X isgreaterthanzeroondheexesleftthanourendleftgrassvariablethatwe'regoingtoshadethatcharactergreen, and I'm goingtousethedrawerfunctions.
ThisisprovidedbytheoneloneKodaclass, andallitdoesistakethe X and Y coordinates, andwecanusethesolidcharactertobasicallyfake a pixelonwillusetheconstant F G green, thegrass.
Soweneedtodosomescalingtoeworkoutwherethatisinconsolespacescreenwithdividedbytwowillgiveusthemiddleoffthetrack, and I wanttooffsetfromthemiddleofthetrackwherewe'regoingtoputitinthecar.
I'm alsogoingtocuriouslyadbecause I'veseenintothefuture, ofcourse, a minussevenhere, and I knowthat's goingtobethewidthofthespiteofthecar.
Positwe'vejustworkedoutonthewhitepositionisgoingtobefixedonthescreen, solet's take a quicklookatthis.
Brilliant.
Wecanseewe'venowgot a carinthemiddleoftheroad, butsomethingdoesn't lookquiteright.
We'relackingperspective.
Perspectiveisn't ascomplicatedasyoumightthinktoimplementwhatwe'regoingtodoistakethecurrentrowanddivideitbyhalfofthescreensThatbasicallygivesus a percentageonthere, fortheperspectivetendstowardzerowhen, whysmallandittendstowardsonewhenwiselargein a linearfashion.
Wecanachievethislinepositioningbyusingsomesimplemathshere, usingtheDesmondStarcomplatform, I'm graphing a sinewave, butit's a sinewavehasbeenmodifiedbytwothings.
Well, inmostmoderngames, ofcourse, thetrackis a three D model, anditmaybetemptingtodosomethingsimilar, forexample, having a wholeloadofnodesondefiningsomepropertiesbetweenthenodesinthree D space.