I’ve been trying to create something in a similar vein to Game & Watch: Ball and am trying really hard to get a ball sprite to animate over an arc, but bounce back on the same path when it hits a collision. The behavior has been really unpredictable and crazy (to me), I can tell I'm not using some system properly, but I just can't seem to figure out how to get this to work ![]()
The sprites seem to be tied to a specific motion on the arc and can't move around it freely most of the time, and when the sprite returns it follows a very slightly different path than before. When I use shapes other than arcs or re-position things, the sprite sometimes teleports to the starting point and won't bounce back at all. Does anyone have any idea how I could be doing this better?
I combined my different objects into one file to make it easier to send but can't seem to send the two sprite images, I hope it works. Thanks so much! ![]()
(I'm on Windows! forgot to add that)

import "CoreLibs/object"
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/timer"
local pd <const> = playdate
local gfx <const> = playdate.graphics
-- Create a ball
class('Ball').extends(gfx.sprite)
local ballImage = gfx.image.new("images/ballSprite")
function Ball:init(x, y)
Ball.super.init(self)
self:setImage(ballImage)
self:setCollideRect(0, 0, self:getSize())
self:setGroups(1)
self:setCollidesWithGroups(2)
self:moveWithCollisions(x, y)
self:add()
end
function Ball.collisionResponse(other)
return gfx.sprite.kCollisionTypeBounce
end
-- Create the floor
class('Floor').extends(gfx.sprite)
local floorImage = gfx.image.new("images/floorSprite")
function Floor:init(x, y)
Floor.super.init(self)
self:setImage(floorImage)
self:setCollideRect(0, 0, self:getSize())
self:setGroups(2)
self:setCollidesWithGroups(1)
self:moveTo(x, y)
self:add()
end
-- Game logic
function BallGame()
local arcX = 200
local arcY = 120
local arcR = 90
local arcStart = 0
local arcEnd = 360
local ballSpeed = 2000
local arcGeo = pd.geometry.arc.new(arcX, arcY, arcR, arcStart, arcEnd)
local arcGeo2 = pd.geometry.arc.new(arcX, arcY, arcR + 30, arcStart, arcEnd)
local arcGeo3 = pd.geometry.arc.new(arcX, arcY, arcR - 30, arcStart, arcEnd)
ArcAnim = gfx.animator.new(ballSpeed, arcGeo)
ArcAnim2 = gfx.animator.new(ballSpeed, arcGeo2)
ArcAnim3 = gfx.animator.new(ballSpeed, arcGeo3)
ArcAnim.repeatCount = -1
ArcAnim2.repeatCount = -1
ArcAnim3.repeatCount = -1
FloorSprite = Floor(200, 160)
BallSprite = Ball(0, 0)
BallSprite2 = Ball(0, 0)
BallSprite3 = Ball(0, 0)
end
BallGame()
function pd.update()
BallSprite:moveWithCollisions(ArcAnim:currentValue())
BallSprite2:moveWithCollisions(ArcAnim2:currentValue())
BallSprite3:moveWithCollisions(ArcAnim3:currentValue())
gfx.sprite.update()
end