# Best way to make a Jeopardy type wheel.

I need to make a jeopardy type wheel for one of my project and am debating wether or not I should use physics. I have rarely used physics in any of my project so my experience with the library is rather small.

The wheel needs to spin by delta speed of touch. The wheel would have a clicker uptop that would provide a little bit of rotation dampening. Would the physics library be a good fit here or would handling the rotations myself be preferable.

The physics library is one area of codea that I do not have a good grasp of.

I would just code it yourself. The physics shouldn’t be too onerous.

@Briarfox I think physics would be the easiest way. There are a lot of options to control it’s rotation speed.

@Briarfox Here’s a spinning wheel. I haven’t added anything to slow it down.

EDIT: changes made to make it spin when the screen is touched and it will also slow down.

``````
displayMode(FULLSCREEN)

function setup()
xx=0
c=physics.body(CIRCLE,200)
c.x=WIDTH/2
c.y=HEIGHT/2
c.gravityScale=0
c.angularVelocity=0
c.angularDamping=.2
end

function draw()
background(40, 40, 50)
text("tap screen to spin",WIDTH/2,HEIGHT-100)
pushMatrix()
translate(WIDTH/2,HEIGHT/2)
xx=xx+1
rotate(c.angle)
stroke(0)
fill(255)
ellipse(0,0,400)
stroke(0)
strokeWidth(5)
line(0,0,200,0)
popMatrix()
end

function touched(t)
if t.state==BEGAN then
c.angularVelocity=200
end
end

``````

@Briarfox I modified the above code to spin the wheel when you tap the screen.

Here’s a very rough non-physics one with a “clacker” and “peg” type slowing mechanism.

``````-- jeopardy

-- Use this function to perform your initial setup
function setup()
ang=0
angvel=0
damping=0.01 --slowdown of the wheel based on friction
clackerdamping=0.1 --slowdown of wheel based on "clacker"
prevang=0
numsegments=4 --number of "pegs" on wheel which the clacker can hit
end

-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
pushMatrix()
translate(WIDTH/2,HEIGHT/2)
rotate(ang)
popMatrix()
ang = ang + angvel
if angvel>0 then
angvel = angvel - damping
end

--add the clacker damping
for i=0,numsegments do
if math.fmod(ang+(i*360)/numsegments,360)<math.fmod(prevang+(i*360)/numsegments,360) then
sound(SOUND_HIT, 45932)
if angvel>0 then
angvel = angvel - clackerdamping
end
end
end
prevang=ang
end

function touched(t)
if t.state==BEGAN then
angvel=20
end
end

``````

@West @dave1707 you guys are the best. Thanks for the examples!