SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
Let'smakeagamefor
thePlaydate
Alsocalled"theGameBoy
redesignedfortheageofNetflix"
GiorgioPomettini(@pomettini)
1
What'sinthistalk
Settingupadevenvironment
Lualanguageoverview
Makingaplayermovingonthe
screen
HowtousetheCrank(duh)
Wheretolookforhelp
Profit(yesreally!)
2
Briefhistory
CreatedbyPanic,anotableMac
softwarehouse,asawayto
celebratetheir20thbirthday
AnnouncedonMay2019
StartedshippingonApril2022
$179(w/taxes&shipping:€280)
Comeswith24exclusivegames
forfree(seasonone)
3
Techspecs
Display
Monochrome1-bitmemoryLCDdisplay,400x240pxresolution(similartoane-ink)
Refreshedat30fpsbydefault,maximum50fps
Controls
Eight-wayd-pad,twoprimarybuttons
Collapsiblecrank,accelerometer
Sound:Internalspeaker,microphone,headphonejack
Connectivity:Wi-Fi,Bluetooth
Memory&Storage:16MB(yes,megabytes!)RAM,4GBflashstorage
4
Devenvironments
Pulponyourbrowser
PlaydateSDKwhichsupportsLuaorC
VisualStudioCodeonWindows,MacandLinux
NovaonMac(recommendedbut$$$)
PlaydateSimulator(includedintheSDK)
APlaydate(ifyouhaveone)
5
Pulp
PulpisanonlinegamemakerforPlaydate(inspiredbyBitsy)
It’sanall-in-onegamestudio:itincludessprite,animation,musicandaleveleditor
UsesPulpScript,whichisafriendlyscriptinglanguage
However,sincePulpgamesarelimitedinscope,we'llusethePlaydateSDKinstead
6
7
PlaydateSimulator
DownloadthePlaydateSDK
LaunchthePlaydateSimulator
8
VisualStudioCodesetup
MakesureyouhaveVisualStudioCodeinstalled
DownloadthePlaydateextension
ForktheVisualStudioCodetemplateforWindowsorforMacOS
Specifyourproject’sSourcefolder.Itwilluse./Sourceor./sourcebydefault
Ctrl/Cmd+Shift+P→RunappinPlaydateSimulator
9
Novasetup
MakesureyouhaveNovainstalled
InstallthePlaydateextension
Clickontheprojectnameinthetopleftofthewindowtooolbar
IntheBuild&Runsectionoftheresultingdialog,clicktheplusbutton
ChoosePlaydateSimulatorfromthelistofoptionstocreateanewconfiguration
Specifyourproject’sSourcefolder.Itwilluse./Sourceor./sourcebydefault
PresstheRunbuttonintheupperleftcornerofthewindowtoinvokethePlaydate
Simulatorandrunyourgame
10
11
Helloworld!
-- main.lua
print("Hello world!")
12
BriefintrotoLua
Luaisadynamicallytypedlanguage
Therearenotypedefinitionsinthelanguage,eachvaluecarriesitsowntype
Primitives
"Hello world" -- string
10.4 -- number
true -- boolean
nil -- nil
print -- function
13
Functions
Functionscanbothcarryoutaspecifictaskorcomputeandreturnvalues
function add(a, b)
return a + b
end
print(add(10, 20)) -- Returns 30
Inthatsyntax,afunctiondefinitionhasaname(add),alistofparameters(aandb),
andabody,whichisalistofstatements
14
Tables
Thetabletypeareassociativearrays
AssociativearraysaresimilartoPHParraysorJavascriptobjects,theyarekey/value
containersthatcanalsobeusedaslists
Tableshavenofixedsize,youcanaddasmanyelementsasyouwanttoatable
dynamically
-- Create a table and store its reference in `player'
player = {}
player["hp"] = 100
print(player["hp"]) -- Prints 100
print(player.hp) -- Prints 100 (Same as above)
15
Tables
Eachtablemaystorevalueswithdifferenttypesofindicesanditgrowsasitneedsto
accommodatenewentries
a = {}
a[10] = "Hello"
a["x"] = "World"
print(a[10]) -- Prints "Hello"
print(a.x) -- Prints "World"
print(a[20]) -- Prints nil (undefined)
Tablefieldsevaluatetoniliftheyarenotinitialized
16
Loops
-- A numeric for has the following syntax
for i = 1, 5 do
print(i)
end
-- Output:
-- 1
-- 2
-- 3
-- 4
-- 5
Watchout:InLua,indicesstartsat1(ugh!)
17
Loops
ThebasicLualibraryprovidespairs,ahandyfunctionthatallowsyoutoiterateover
theelementsofatable
a = {}
a[10] = "Hello"
a["x"] = "World"
for key, value in pairs(a) do
print(key .. " - " .. value) -- Concats strings with ..
end
-- Output:
-- 10 - Hello
-- x - World
18
Conditionals
-- If statements are not so different from other languages
if a < 0 then a = 0 end
-- If else statement
if a < b then
return a
else
return b
end
-- But I personally prefer the inlined style
if a < b then return a else return b end
19
Scoping
InLua,everyvariableisglobalbydefault(uselocaltoavoidconflicts,overridingandbugs)
a = 0 -- Global scope
local b = 0 -- Local scope
do -- New scope (can be a function, a loop, etc)
a = 5
b = 5
local c = 5
end
print(a) -- Prints 5
print(b) -- Prints 0
print(c) -- Prints nil
20
LoadingaSprite
-- Importing Playdate core libs
import "CoreLibs/graphics"
import "CoreLibs/sprites"
gfx = playdate.graphics -- Shortcut to gfx library
player = gfx.sprite:new() -- Creates a new sprite object
player:setImage(gfx.image.new('player')) -- 'player.png' is being loaded
player:moveTo(200, 120) -- Moving the sprite in the center
player:addSprite() -- Adds the sprite to the display list
function playdate.update()
gfx.sprite.update() -- Calls update() on every sprite
end
21
22
-- Make the player sprite five time bigger
player:setScale(5)
23
-- Rotating a sprite (in degrees)
player:setRotation(135)
24
-- Flipping a sprite (on the horizontal side)
player:setImageFlip(gfx.kImageFlippedX)
25
TransformingaSprite
-- Setting the z-index for the sprite (high value = draw first)
player:setZIndex(10)
-- Sprites that aren’t visible don’t get their draw() method called
player:setVisible(false)
Formoresprite-relatedmethodshavealookattheirInsidePlaydatesection
26
Movingasprite
function playdate.leftButtonDown()
player:moveTo(player.x - 10, player.y) -- Player is moving to the left
end
function playdate.rightButtonDown()
player:moveTo(player.x + 10, player.y) -- Player is moving to the right
end
function playdate.upButtonDown()
player:moveTo(player.x, player.y - 10) -- Player is moving up
end
function playdate.downButtonDown()
player:moveTo(player.x, player.y + 10) -- Player is moving down
end
27
UsingtheCrank
Forplaydate.cranked(),changeistheanglechangeindegrees
acceleratedChangeischangemultipliedbyavaluethatincreasesasthecrank
movesfaster,similartothewaymouseaccelerationworks
-- Moves player horizontally based on how you turn the crank
function playdate.cranked(change, acceleratedChange)
player:moveTo(player.x + change, player.y)
end
28
29
OOP
Luadoesnotofferbuilt-insupportforobject-orientedprogrammingofanykind
CoreLibsprovidesabasicobject-orientedclasssystem
Objectisthebaseclassallnewsubclassesinheritfrom
-- Base class is Animal
class('Animal').extends()
-- Cat is a subclass of Animal
class('Cat').extends(Animal)
30
OOP
Classesareprovidedwithaninitfunction
Thesubclassdecideshowmanyandwhattypeofargumentsitsinitfunctiontakes
function Cat:init(age, weight)
Cat.super.init(self, age)
self.weight = weight
end
Theinitfunctionwillcallitssuperclass’simplementationofinit
31
OOP
Let'smakeanexamplebyputtingtheplayerlogicinitsclass
-- player.lua
import "CoreLibs/graphics"
import "CoreLibs/sprites"
gfx = playdate.graphics
class("Player").extends(gfx.sprite)
function Player:init(x, y)
Player.super.init(self)
self:setImage(gfx.image.new('player'))
self:moveTo(x, y)
self:addSprite()
end
32
OOP
Looksbetternow,don'tyouthink?
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "player" -- We need to import the player file
gfx = playdate.graphics
player = Player(200, 120)
function playdate.update()
gfx.sprite.update()
end
33
players = { Player(100, 120), Player(200, 120), Player(300, 120) }
34
Documentation
InsidePlaydateistheofficialdocumentationinonehandywebpage
35
Wheretoputyourgame
UnfortunatelyPlaydatedoesn'thaveastore(yet)so
Youcanself-hostitonyourwebsiteor
Putitorsellitonwebsitessuchasitch.io
PS:Panicisofferingfundingforgames,checktheGamePitchFormformoreinfo
36
37
Wheretolookforhelp
PlaydateDeveloperForum
PlaydateSquadakathemostactiveDiscordserver
/r/PlaydateConsoleand/r/PlaydateDeveloper
Andifyouwanttolearnmore
SquidGodDevforexcellentvideotutorials
AwesomePlaydatecrowd-sourcedawesomeness
/PlaydateSDK/Examplefolder
38
Demo
Sourcecode
39
ThingsIdidn'tcover(yet)
Collisions
Audio
Accelerometer
Fonts
Debugging
Deployingonarealdevice(maybeforpart2?)
ButyoucanfindallyouranswersonInsidePlaydate
40
Thankyou!
Slidesavailableathttps://github.com/Pomettini/Slides
Questions?
41

Mais conteúdo relacionado

Semelhante a Let's make a game for the Playdate

Semelhante a Let's make a game for the Playdate (20)

Денис Ковалев «Python в игровой индустрии»
Денис Ковалев «Python в игровой индустрии»Денис Ковалев «Python в игровой индустрии»
Денис Ковалев «Python в игровой индустрии»
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overview
 
pygame sharing pyhug
pygame sharing pyhugpygame sharing pyhug
pygame sharing pyhug
 
JRC Seminar (History of Video Game Industry)
JRC Seminar (History of Video Game Industry)JRC Seminar (History of Video Game Industry)
JRC Seminar (History of Video Game Industry)
 
The Ring programming language version 1.5.2 book - Part 48 of 181
The Ring programming language version 1.5.2 book - Part 48 of 181The Ring programming language version 1.5.2 book - Part 48 of 181
The Ring programming language version 1.5.2 book - Part 48 of 181
 
All About Gaming - By Sai Krishna A & Roopsai N
All About Gaming - By Sai Krishna A & Roopsai NAll About Gaming - By Sai Krishna A & Roopsai N
All About Gaming - By Sai Krishna A & Roopsai N
 
Spec00420
Spec00420Spec00420
Spec00420
 
VR Base Camp: Scaling the Next Major Platform
VR Base Camp: Scaling the Next Major PlatformVR Base Camp: Scaling the Next Major Platform
VR Base Camp: Scaling the Next Major Platform
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
 
Android game development
Android game developmentAndroid game development
Android game development
 
Fun With Ruby And Gosu Javier Ramirez
Fun With Ruby And Gosu Javier RamirezFun With Ruby And Gosu Javier Ramirez
Fun With Ruby And Gosu Javier Ramirez
 
Shall We Play A Game - BSides Cape Town 2018
Shall We Play A Game - BSides Cape Town 2018Shall We Play A Game - BSides Cape Town 2018
Shall We Play A Game - BSides Cape Town 2018
 
The Ring programming language version 1.2 book - Part 50 of 84
The Ring programming language version 1.2 book - Part 50 of 84The Ring programming language version 1.2 book - Part 50 of 84
The Ring programming language version 1.2 book - Part 50 of 84
 
The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196
 
RST2014_Perm_PlayKey
RST2014_Perm_PlayKeyRST2014_Perm_PlayKey
RST2014_Perm_PlayKey
 
Project natal
Project natalProject natal
Project natal
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
 
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185
 
The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.9 book - Part 80 of 210The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.9 book - Part 80 of 210
 

Mais de Giorgio Pomettini (6)

Rapid prototyping with ScriptableObjects
Rapid prototyping with ScriptableObjectsRapid prototyping with ScriptableObjects
Rapid prototyping with ScriptableObjects
 
Fate spazio al mio nuovo sito web: VR room scale su browser con A-Frame e HTC...
Fate spazio al mio nuovo sito web: VR room scale su browser con A-Frame e HTC...Fate spazio al mio nuovo sito web: VR room scale su browser con A-Frame e HTC...
Fate spazio al mio nuovo sito web: VR room scale su browser con A-Frame e HTC...
 
Primi passi con ARKit & Unity
Primi passi con ARKit & UnityPrimi passi con ARKit & Unity
Primi passi con ARKit & Unity
 
Fist Of Fury (Roads): Come ho tradotto un gioco in Cinese in 48 ore
Fist Of Fury (Roads): Come ho tradotto un gioco in Cinese in 48 oreFist Of Fury (Roads): Come ho tradotto un gioco in Cinese in 48 ore
Fist Of Fury (Roads): Come ho tradotto un gioco in Cinese in 48 ore
 
Rust & Gamedev
Rust & GamedevRust & Gamedev
Rust & Gamedev
 
Facciamo un gioco retrò in HTML5 con PICO-8
Facciamo un gioco retrò in HTML5 con PICO-8Facciamo un gioco retrò in HTML5 con PICO-8
Facciamo un gioco retrò in HTML5 con PICO-8
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Let's make a game for the Playdate