This repository includes 9 lua files. Each can be renamed to main.lua
and put into your project's Source
folder. Play around with the number of sprites and what each sprite does to make new discoveries!
Summary
In each file, the refresh rate is set to 50 FPS and an effective frame rate of 48-50 FPS is achieved. In each file except overlapping-call-main.lua
and overlapping-collisions-main.lua
, the sprite update function is assigned directly to playdate.update
. In overlapping-call-main.lua
and overlapping-collisions-main.lua
, a function that calls the playdate sprite update
and allOverlappingSprites
functions is assigned to playdate.update
.
empty-sprite-main.lua
- 500 empty sprites.
image-sprite-main.lua
- 476 sprites with the same image (a 40px black square).
movement-main.lua
- 200 instances of a class that extends the Playdate sprite class. The update method uses
moveTo
with the sprite'sdx
anddy
values added to itsx
andy
values.
- 200 instances of a class that extends the Playdate sprite class. The update method uses
collision-movement-main.lua
- 40 instances of a class that extends the Playdate sprite class. The update method uses
moveWithCollisions
with the sprite'sdx
anddy
values added to itsx
andy
values. Each has a collide rect of 1x1, groups = {1}, and collidesWithGroups = {2}.
- 40 instances of a class that extends the Playdate sprite class. The update method uses
collision-movement-collisions-main.lua
- 40 instances of a class that extends the Playdate sprite class. The update method uses
moveWithCollisions
with the sprite'sdx
anddy
values added to itsx
andy
values. Each has a collide rect of 1x1, groups = {1}, and collidesWithGroups = {1}.
- 40 instances of a class that extends the Playdate sprite class. The update method uses
mixed-main.lua
- 20 instances of a class that extends the Playdate sprite class. The update method uses
moveWithCollisions
with the sprite'sdx
anddy
values added to itsx
andy
values. Each has a collide rect of 1x1, groups = {1}, and collidesWithGroups = {2}. - 100 instances of a class that extends the Playdate sprite class. The update method uses
moveTo
with the sprite'sdx
anddy
values added to itsx
andy
values. - 125 empty sprites.
- 20 instances of a class that extends the Playdate sprite class. The update method uses
overlapping-call-main.lua
- 95 instances of a class that extends the Playdate sprite class. The update method uses
moveTo
with the sprite'sdx
anddy
values added to itsx
andy
values. allOverlappingSprites
is called in theplaydate.update
function.
- 95 instances of a class that extends the Playdate sprite class. The update method uses
overlapping-collisions-main.lua
- 8 instances of a class that extends the Playdate sprite class. The update method uses
moveTo
with the sprite'sdx
anddy
values added to itsx
andy
values. Each has a collide rect of 1x1, groups = {1}, and collidesWithGroups = {1}. allOverlappingSprites
is called in theplaydate.update
function.
- 8 instances of a class that extends the Playdate sprite class. The update method uses
overlapping-sprites-main.lua
- 21 instances of a class that extends the Playdate sprite class. The update method uses
moveTo
with the sprite'sdx
anddy
values added to itsx
andy
values, then it callssprite:overlappingSprites
. Each has a collide rect of 1x1, groups = {1}, and collidesWithGroups = {1}.
- 21 instances of a class that extends the Playdate sprite class. The update method uses
Conclusions
Collision detection is an expensive operation. Although moveTo
is faster than moveWithCollisions
, using moveTo
with either of the overlapping sprite functions scales worse than using only moveWithCollisions
.