Andactually, Davidand I didoneontheCSUthesandboxafterday.
Soifyou'relookingfor a quickwaytospend a codingenvironmentintheWebbrowser, gotosandboxdotCS 50 dotiosuperawesomewebsitethatwetalkedaboutyesterday.
Sotodaywe'regoingtogobackintogamedevelopedThelastgamethatwedidactuallywasminesweeper, I think, whichwas, I thinkover a weekagomighthavebeentwoweeksago.
Actuallybeendoing a wholebunchofdifferentstuff, actually, a lotofWebdevelopment, butindeed, we'regoingtogobackintogamestoday.
Andyouknow, onceyouhaveallyourcardsthathavelaidoutinthisway, it's veryeasytotakethosecardsthatsortoflaythemoutinthatsortofascendingorderatthesetoplevelhere, forexample, thisfour I couldeasilyjustbringoverif I if I hadthethreeofheartshere.
I couldbringthatfourpartsmoreeasilytothetopthanifitwereinsortofdescendingorder.
Orrather, a sendingorderlayingfromthekingdown.
Richardfromtheaceupwards.
So, thankstoeverybodywhohasbeeninthechathere, havethedialoguehere.
Andinthatcourse, weendupusing a lotofopengameartdotorg's stuff.
Um, excusemeforjustonesecond.
Letmemakesureeverythingisokay.
Um, I apologise.
Letmejustmakesuremymikeisgoodonbattery, but I justwanttomakesurethatit's 100% okayfortherestofthestreambecausethisone's goingtorun a littlelong, sogivemejust a second.
Youmighthearmecutoutmyaudio.
Allright.
Weshouldbebackupwith a freshbattery.
Soawesome.
I wanttomakesurewedon't diesuddenlyonstreetwheneveryone's wonderingwhy I'm completelygone.
ASU's 50 dotio, ifyou'recurious, allowsyoutospendup a temporaryprogrammingenvironmentfromscratch, whichhas a lotofawesomepreinstalledlanguagesandenvironmentsandlibrariesandstuff.
Sodefinitelycheckthatout.
Ifyoudidn't wantyesterday's stream.
Andifyouhave a Marchesaextreme, definitelydososothatyoucouldget a senseofjusthowitworksandthethingsthatyoucandowithit.
Soopengamearedotorg's, as I wassayingearlieris a platform, a websitethathas a bunchofcompletelyfreegamergameprogramming, artwork, spritesandthree D modelsandalsothingslikeaudio, whichcanbekindofimportanttoifyou'renot a sounddesignerandmaybeyouwantsomefreeaudioassets, youcoulddefinitelycheckthatout.
Um, butwhatwewantto d'ohis I don't wanttomake a bunchofcardsfromscratchbecausewhenwedidn't mindsweeper, I endedupdoing a bunchofsortofmakingmindsfromscratch, andthatwasokay.
Itwas a prettysimplesetofspritestodevelop, butcards a littlemorecomplicated, andtheyallhavesuits, and I don't reallywanttobebotheredwithactuallymaking, and I kindofwanttomakeitlooknicetobeginwith.
So I knowthatthereis a packofnicelookingcardsthatwecanusehere.
Soif I goovertoSimonTypeCasino, I endeduplookingatthisinadvancejustto, um, sortofprecuratethekindsofartpackagesthatwemightwanttouse.
There's a nicepackagecalledBoardGamepackedbyKenny.
Andactually, Kennyis a artistthat I use a lotintheGamescoursewhokindlymakes a lotofhisartworkavailablehereforfree.
I'm clickingontheboardgamepack, andthis, I think, isactually a fairlyhighresolutionpieceofartwork.
Yeah, they're 68 playingcards.
Theydon't necessarilyspecifytheresolutionhere, but I'm justgonnadownloaditthere's a linkrighthere.
Mostoftheartwork, as I saidonthisWebpages, verykindlymadeavailable.
Andthisisactuallyplaying a versionwhereyoulaythreecardsoutat a timefromthedeckandwe'rejustgonnabedoingonecardat a time, whichismoreoftheWindowsversionofhowit's implementedonandalso a littlebiteasiertowin.
I thinkyouhave a 90 somethingpercentchancetowin, asopposedto a 75% chancetowin.
Butthesearethefourdeckswhereyou'resupposedtolayoutyourcardsfrom a stickinginthedifferentsuits.
Sonotonlyarewegonnawanttoshowfaceupcardsbutalsohave a cardbackingsothatweknowwe'redrawing a cardorwedon't knowwhatthecardisyetsokindofanimportantconsideration.
Um, letmegoaheadandcheckbackonthat.
Sowegooverhere, I canseewehaveallthecards, theindividualcards, whichisgreat.
Soitwillwantthatwecanseethatthey'renumberedarelabeledin a prettyconsistentway.
I'm goingtocreate a newfinderwindowgoingtosetupmyprojectwith a J.
Harvard.
Devin, thiscaseovertostreams.
I'm goingtomakesolitaire.
I'm gonnaloadthisinthe V s codeandlet's makesurethisisblownup.
Soitlooksnice.
I'm goingtocreate a newfolder.
Sothisismyprojectfolderandloveto D.
Whatyoutypicallywanttodoishave a projectfolderwithinwhichthereis a singlemainLouiefile.
Thisistheentrypointofyourprogram.
Muchlikeitisin, forexample, Seewhereyouhaveit.
MainvoidinLuis.
Youhave a maindotLouis, So I'm gonnacreate a maindotbutthisis a folder.
First, I'm gonnacreategraphics.
Then I'm goingtocreateoutsideofgraphics a newfilecalledMaindaLua, whichlaterwillfillwithoursourcecodeinadvance.
I knowthisisgoingtobe a relatively, um, notsupercomplexcodebase, butit's gonnahavemultiplemodules.
I'm gonnacreate a sourcefolderwhichisgonnacontainallofmyLouisfilesinthefutureandwithingraphics.
Thisisthefolderthatactuallycareaboutrightnow.
I wanttocopyandpastefromhereplayingcardsthat P and G gonnabringitovertomygraphicspacethatrightinthereand I'm gonnaopenthisin a seasprite, whichis a graphiceditorthat I liketouse, whichhasprettygoodSpriteartwork, support.
Andnowwhat I'm gonnadoand I justshrink a littlebit.
I don't mindhowitlookshere.
Actually, youcanseethatkindof, um, zoomedoutandgaveit a morepixelatedlook.
Andsothisiskindof a previewofwhatitwilllooklikewhenweactuallydownsampleeverything, anditlooksokay.
Honestly, itdoesn't lookbadatall, so I'm notsurewhattheresolutionis.
Atthispoint.
I think I, um, subtractedit, or I shrunkitdownbyhalftwice.
Soif I wereto, umlet's sayspritesizelocktheratio.
Let's let's shrinkitdownbyhalf.
Right.
Okay.
Neighborsnearestneighborfiltering.
Andsothisisactuallywhatitlookslike a nativesize, Soitlooksokay.
Divideevenlyinto 5 12 So 123456 Soif I actuallymaybe I cropit, don't cropit.
No, Maybenot.
I thinkwe'llendupdoinginsteadisjustbecause I think I thinkifwejustusethealgorithmwe'veusedinpriorstreamswherewesortofgothroughoutthespreadsheet, figuringoutthesizeofthecardswewant.
Let's see, thecardsthemselveswere 1 40 by 1 90 Weshrunkitdownbyhalf, sothey'reactually 70 by 95 now, whichistheoneconsiderationweneedtoeTobeconsciousaboutisthefactthatwhenweendupstackingthings, wecouldhave, theoretically, a deckthatstartswith a thathas 123456 blankcardsandthenfromKingdowntoAce.
Thatwouldbe a totalofthat's, what, 13 cards, 13 carsplussixcards.
So 19 cardstimesthatbywell, actually, we'reonlyrevealing a certainsmallamountofthecard.
Thisisprobably, what, 10 pixels, 20 pixels?
I thinkwe'llprobablyallbeokay.
Makesure I'm keepingupwiththechathere, doyou?
Didyoucreatethiscardspritestosays L'm one?
No, I didnotcreatethecardsprites, soweactuallygot.
It's actuallyifyougototheopengameartdotorg's sashcontentslashboardgamepackhere, you'llfindit, butit's a cardpackor a casinopack, generallyspeakingbyanartistnamedKennywhoactuallyreallyenjoyedtheartworkofand I use a lotofmygamesclass, buthehas a lotofdifferentthemedartpacksinthisparticularone.
Hehappenstohave a bunchofcardsjustlikethis, and I liketheaesthetictheydon't samplenicelyintomorepixelatedartwork.
Sousingthat.
Andrightnow, we'resortoffiguringouthowmuchweakendown, samplethatartworksothatwecanuseitin a smaller, pixelatedgameandhaveallofthecardsvisibleonscreen, nomatterwhatthedecksizeorthetableausize, whichwilllookat.
Sowe'rejustdoing a littlebitofpreliminaryinvestigationhere, but I thinkwe'lltrythis.
Wecanalwaysresamplethis, so I'm gonnasavethis.
Sonowwe'veshrunkitdownbyhalfeffectively, and I'm gonnagobackintohere, andwecanseethatnowinsteadof 10.
24 by 2048 itshouldbe 5 12 by 10.
24 whichyoucanseerighthere.
Thatshouldbe a goodsize.
Andthenwell, in a choppingthisupintobitsandpiecesinmaindotLittleratherin a youtillthatlow, whichwillimplementagainfromscratch, recognizesaround 45 17 95 0 theaspectratio.
If I'm pronouncingthatcorrectly, hopefully I am, umawesome.
Sothat's howweendupquittingourapplication.
I think I shouldbeabletojusttestthisnowif I runmyproject, which I justdidwithcommand L I'm using V s codewiththepixelbitestudiospluginforloveto d.
Sodownloadthatandyoucan't suppressalltellorcommand l onyourmachineanditwillverynicelyinconvenientlyletyourunlovewithoutneedingtogotoyourcommandlineortodraganddropittoyourexecutable.
That's superconvenienton.
AndalsothankyoutoEcho's 2165 forthefollow.
Sowecanseehereatthetopofourwindow.
I doindeedseethewordssolitaire.
Andif I pressescape, itdoesindeedquittheapplication.
Soeverythingisworkingasexpected.
I'm goingtodoanothersanitycheck.
I'm goingtosaylovedotgraphicstockdraw.
I'm gonnareferencethat G texturestablethat I createdearlier, and I'm goingtoreferencethecardsSpritethatwewerestoringinthattable.
Ifyou'reunfamiliar, tablesairjustessentiallyhashtablesordictionariesorobjectsfromJavascript, theyfunctionidenticallytothosewith a coupleofothercaveats.
ButthisisLouiswayofstoringsortof a raiseorhashtables.
Theyfunctionin a multipurposesortofway.
Sonowif I presscommand l wedoindeedseeallofthecardsthatwereinthattexture.
Wewanttobeabletosay, I wanttojustdrawthekingofspadesorthesixofheartsandgivenpoint.
Soweneedtodo a coupleofthingsbeforethisispossible, but I haven't writtenthisfunctionfromscratchin a littlewhile, sowe'llseehoweffectivelywecandothis.
I typicallyliketogointoyoutillthat.
Lou, I liketomake a utilmoduleforutilityfunctionsandsay, I want a utilityfunctionthatwilltake a texture, a spreadsheet, asit's called, andchopitupandstoreitas a groupofseparatesubtextures.
Inthiscase, they'recalledquadsinLewisandLove, ratherinloveto D.
ButinyoutilldotLou, uh, I'm goingtoprobablyfirstrightutilityfunctionsandthenmaybe a functioncalled I typicallyliketosaygeneratequadsandhaveittake a textureand a whipand a height, andinthiscaseis a littlebitdifferentbecauseusually I assumethatthetexturefitsthedimensionsofthewell.
Andsonow, inthiscase, I cansay, umbasically, G coir G frameswillsayGee, quads, justtokeepthesortoflanguageconsistent, I'llultimatelycreate a tablecalled G quadsand I'llsaycards I wantedtomapeffectivelytomyothertexture.
I wannabeabletoreferencemytexture, and I wanttobeabletoreferencethequadsthatgeneratefromthetexturealltheseparatesubtextures, theindividualcards, inthiscaseSo I cansaygeneratequads, G texturescards.
Andwe'vesawearlierthattheywereWhatwasit?
Um, wefigureditout.
Itwasseven.
Wasitwasit 70 70 by, um, 95 right?
70 by 95?
Andactuallyusingthesehardcodednumbersis a baddesigndecision, so I'm Instead I'm goingtogotosourcetocreate a newfilecalledconstancedotLulaandThisistypicallywhatyoushoulddo.
Inthiscase, it's gettingthenumber 95 soitjustknowsatruntimethat's a numberandknowswhattodowithit, whatitcandowithit.
We'llgiveyouanerrorifyoutrytodocertainthingswithit, forexample, adding a stringtoit.
Itwillgiveyouanerror.
Crashyourprogram, butthereisnotypinglikeyoumightseein C orJava, sothereisn't really a waytoenforcethatwillusethesevariablesasConstancebutbycapitalizingthemandusinganunderscore.
Butnow I cansay, insteadof 70 and 95 cardwithandcartheightandthingsare a lotmorereadable.
Now I cantellthat I wanttospicethistexture, thiscardtextureonmycardwithandcardheightandnotsomerandomvaluecalled 70 and 95 whichhadnorealmeaningpriortothispoint.
Um, sonow I actuallyneedtoimplementthefunction.
Currently, it's anemptyfunction, so I'm gonnaendupneedingtoreturn a tableofquads.
I knowthat, andwecangotothelovetothedocumentation, actually, andseewhat a quadis.
Soloveto D quad.
Thisisimportant.
Basically a qualityjust a rectangleinthiscase, a quadrilateral a polygonwithfoursidesandfourcornerswithtexture.
Coordinateinformationandyouknowyoucoulddefineitas a square.
Youcoulddefineitas a rectangleofyounolongerwidthandheightorlongerheightthanwit.
Ifyoulookatthespreadsheetonebyonehere, rightbygoingintothisandsortofcreating a rectanglehereanderectingwillhearanderectingwillhearsortofinvisiblerectangleweaken, tellloveto D whenwedraw.
Giventhatquadjusttheareadefinedbythatquad, whichisreallynice, andthisishowyougetspritesfrom a compoundedspreadsheet.
A morecomplicated, um, drawingthatyoumademewanttoputeverythinginsideofinsteadofhavingseparateindividualsprites, whichweverycouldn't, whichwecouldhaveveryeasilydonehere.
Wecouldhaveeasilyjustdrawntheseindividually.
Youknow, the 456 ofhearts, etcetera.
Theproblemis, ifyouwanttodownscaleallofthesenowwehavetoindividuallygoinand, youknow, maybeimporttheseinto a spritesdivideby 23 saveitgetskindofbulky.
Wecouldautomatethiswiththescript, butit's typicallymoreidiomaticingamedevelopment, moremorecommontouse a spreadsheet.
Sobacktoourcode, I cansayingeneratequads.
I know I'm gonnawant a tabletoreturn, right.
So I cansaylocalquadtablegetsanemptytable.
I'm gonnareturnquadtableattheend.
And, uh, localjustmeansthisis a variablethatexistsinthisfunction.
Don't makeitgloballyaccessible.
If I makeit, if I justsayquadtablethewaythatLouitworksthisquadtablevariableactuallybeavailableanywhereinourapplication, whichisnotgenerallygood.
So I hatetospendtoomuchtimeonthis, butAndalso, anotherinterestingthingis, Okay, theyonlyneedonejokeraction.
That's fair.
I wasgonnasaytheyonlyhaveonejoker.
Typicaldeckhas I think, twojokersorfourjokers.
But I shouldfixthis.
Thereasonthatactuallyfixthisisbecauseifyouwantthealgorithmtogenerateallthecarsin a sequenceand I wantallofthosecardsThio, I coulddothisincode.
Isitreallyworthit?
Yeah, it's gooddesign.
I probablyshoulddoitsowell, I needtoDioisgoingtohearand, um, notdothat, buttake a marqueetoolkindofbringingthisoverhere, which I thinkthisiscorrectandsomethinglikethat.
Andthenif I comein C thistime, let's movethisaround.
I can't.
Oh, perfect.
I justmovethis.
So I'm movingoverhere.
Takethis.
Zoominallthewayoverhere.
Isthattoomuch?
Maybetoomuch.
No, I don't wanna I don't wannaactuallyshrinkit.
Let's goaheadandtothis.
Isthiscorrect?
I thinkthat's correct.
Andsonowif I movethisovertowherewehaveournowourspace, it's movingdownoverhererightoverhere.
Okay.
Perfect.
Andthennow, if I bringthisalso, Kenny, ifyou'rewatching, maybefixyourfixtheorderingofyourspreadsheet, lovetheartwork, but I'm notsurewhyit's outoforder.
Sowhat I wastryingtosaybefore, before I realizedthattheSpritesheetwasactuallyslightlymessedupisthatinsteadofgoinghorizontalrows, youknow, goingrowbyrowwillactuallygovertically.
Oh, youknowwhat I didstartmyeditorinJavascriptmode.
I wonderifthat's causingfunkinessanyway, startedwithjobs.
Goodproject.
I'm notsureifthatendsupscrewing V s caughtupinthiscase, buthopefullynot.
Um, here's whereweactuallygenerate a quadinourspreadsheet.
So I cansay, um, tabledotinsertquadtable.
Sowe'regoingtoinsertintoquadtableinNewQuad.
We'regonnacallit, loved a graphicsdotnewquad, andittakesin.
Thisis a nicethingabout V s code.
Isithasthisintel a sensesortofthingforus, whichtellsustheargumentsthatnewquadtakes.
Sowhat?
X and A Y, whichisgonnabe X y andthen a widthand a height, so x y andthenourwitisgoingtobe a cardwithandtheheightisgonnabecardheightandthenthatshouldjustworkhereasweneedit.
Thio, I think.
Oh, and I thinkthelastthingitneedsactuallyistexture.
Getdimensions.
Forsomereason.
Underneaththehood, whenyougenerate a quad, itneeds a referencebacktoitssourceimage, specificallythedimensions.
I don't remembertheexactreasonwhy I lookedatthe C codeforwhythisis, Butyoucanlookatthequotethecodesopensourceforlefttodaysoyoucanlookandseeifyou'recurious.
I don't rememberoffhandexactlywhythatisthecase.
Um, andthisis a littlebittoomuchroom, sowecanjustdothatnow.
Thisshouldwork.
If I goovertomaindotlewis, forexample, and I passedintow.
Love, doctrafficstop.
Draw a quad.
Soif I say G cardsquadszeroRatherone.
Becauserememberlovetables.
AironeIndex.
It's veryweirdthingaboutLuis, butnormallyinlanguages, a raiseandotherdatastructuresofzeroindexinlieu.