You were close. The rotate goes before the draw. Add 1 to ang, not a.
translate(WIDTH/2,HEIGHT/2)
rotate(ang)
t1:draw()
ang=ang+1
You were close. The rotate goes before the draw. Add 1 to ang, not a.
translate(WIDTH/2,HEIGHT/2)
rotate(ang)
t1:draw()
ang=ang+1
Somehow I did it ! I had a ‘a’ instead of ang… but I have 1 more question : how can I make this spin in reverse ??
I have another question, I put 4 ellipses in a table, I don’t know if this should be in a table or class, and I’m trying to make the table rotate from the center…
-- Ellipses
--=========================
function setup()
ellipseMode(CORNER)
a=0
c { ellipse(350,200,50,100), ellipse(350,100,50,100),
ellipse(385,175,100,50), ellipse(265,175,100,50) }
end
--========================
function draw()
background(0)
translate (WIDTH/2,HEIGHT/2)
fill(132, 217, 215)
a=a+1
rotate(a)
c:draw()
end
--========================
Does this look right ?? Or was I supposed to approach this from another angle ??? Maneuver these ellipse should be in a class…
@kendog400 You can’t take a working program and make wild changes to it and expect it to work. Your above code is so wrong I don’t think anything can be done to it to get it to work, other than deleting it and writing something else. Sorry for being so blunt, but …
It’s ok, I’m not good as you when it comes to programming…I would like to get that gud …
This wasn’t a working pgm, I made this up myself…I had an idea I just didn’t know how to implement it…I was thinking I could put objects in a table and rotate the whole table, or mabey it would be better off in a class…Cud u give me an idea on how to approach this ??? If I cud get by this one hurdle I cud get my roll going on…
Here’s your code, fixed somewhat. Don’t know what you were trying to do. I didn’t know anything about Codea/Lua when I started, but I just kept writing small programs until I understood what I was doing. Then I started writing larger ones, trying different things until I understood what they were doing. There’s still a lot that I don’t know, and I’m still learning. So just hang in there and write small code that you understand and try modifying it a little so you see what that’s doing. If you know a lot of small things, you can combine them into larger things.
displayMode(FULLSCREEN)
function setup()
a=0
c ={vec4(350,200,50,100),vec4(450,200,50,100),
vec4(400,150,100,50),vec4(400,250,100,50) }
end
function draw()
background(0)
for z=1,#c do
pushMatrix()
translate (c[z].x,c[z].y)
rotate(a)
fill(132, 217, 215)
ellipse(0,0,c[z].z,c[z].w)
translate()
popMatrix()
end
a=a+1
end
Thanks ! …
I have a quick question : does codea have other shapes like stars using vec2 commands ? Can a programmer make other shapes by adding vec2 points ? I checked the graphics help and only seen rect, ellipse, and that’s all…
@kendog400 - you can build your own classes for different shapes, you may find code in the previous threads.
Can you Sen me a link to one so I cud take a peek and see how it’s done ??
I have here 4 ellipses…I want to know if I should put them in a table or a class to spin them from the center…
-- still ellipses
displayMode(FULLSCREEN)
function setup()
end
function draw()
background(0)
-- Draw a blue rect with light opacity to highlite the controls at the bottom
fill(0, 0, 255, 50) -- this fills the rect with blue
strokeWidth(1.5)
rect(6,3,265,35) -- this is the wht highliteer
for i=1,4 do -- just show the 4 ellipses in a still position
fill(255)
e1 = ellipse (175,200, 50)
e2 = ellipse (480,200, 50)
e3 = ellipse (325,300, 50)
e4 = ellipse (325,100, 50)
end
end
Here they are spinning but not from center mode, as you can see they move off the screen, I’m trying to keep them on the screen :
displayMode(FULLSCREEN)
function setup()
-- ellipesMode(CORNER)
ang=0
end
function draw()
background(0)
-- Draw a blue rect with light opacity to highlite the controls at the bottom
fill(0, 0, 255, 50) -- this fills the rect with blue
strokeWidth(1.5)
rect(6,3,265,35)
-- this is the wht highliteer
for i=1,4 do
ang=ang+0.1
fill(255)
translate(50,0)
e1 = ellipse (175,200, 50)
e2 = ellipse (480,200, 50)
e3 = ellipse (325,300, 50)
e4 = ellipse (325,100, 50)
rotate(ang)
end
end
Can anyone tell me how to go about this, I cud use different shapes with the same approach, in Cinema 4D it’s easy, I haven’t figured how to do this Codea…Thanks to anyone & everyone…
I can get 1 ellipses to stay on the screen but not 4…
-- orbiting ellipse
displayMode(FULLSCREEN)
--======================
function setup()
ang=0
--........................................................
-- ( left, right, tip )
e1 = ellipse (100,100, 50)
--........................................................
end
--========================
function draw()
background(0)
--....................................................
-- Draw a blue rect with light opacity to highlite the controls at the bottom
fill(0, 0, 255, 50) -- this fills the rect with blue
strokeWidth(1.5)
rect(6,3,265,35) -- this is the wht highliteer
--......................................................
translate(WIDTH/2,HEIGHT/2)
rotate(ang)
e1 = ellipse (100,100, 50)
ang=ang+1
end
--====================
-- orbiting ellipse
displayMode(FULLSCREEN)
--======================
function setup()
ang=0
end
--========================
function draw()
background(0)
translate(WIDTH/2,HEIGHT/2)
rotate(ang)
ellipse (100,100, 50)
ellipse (-100,100, 50)
ellipse (100,-100, 50)
ellipse (-100,-100, 50)
ang=ang+1
end
Cud anyone tell me why I’m not getting these triangles to spin in opposite directions ???
-- Rotating Triangles
displayMode(FULLSCREEN)
blendMode(OVERLAY)
-- blendMode(ADDITIVE)
--========================================
function setup()
ang=0
-- the vec points
a1=-120 -- right side x position
b1=-60 -- right side y position
c1= 100 -- left side x position
d1=-60 -- left side y position
e1=-10 -- tips x position
f1= 60 -- tips y position
a2=-120 -- right side x position
b2= 60 -- right side y position
c2= 100 -- left side x position
d2= 60 -- left side y position
e2= -10 -- tips x position
f2= -60 -- tips y position
--..............................................................
-- ( left, right, tip )
t1 = MakeTriangle (vec2(a1,b1), vec2(c1,d1), vec2(e1,f1), color(0, 0, 255))
t2 = MakeTriangle (vec2(a2,b2), vec2(c2,d2), vec2(e2,f2), color(0, 255, 0))
--...............................................................
end
--==========================================
function draw()
background(0)
--...............................................................
-- Draw a blue rect with light opacity to highlite the controls at the bottom
fill(0, 0, 255, 50) -- this fills the rect with blue
strokeWidth(1.5)
rect(6,3,265,35) -- this is the wht highliteer
--...............................................................
translate(WIDTH/2,HEIGHT/2)
pushMatrix()
rotate(ang)
t1:draw()
ang=ang+0.5
popMatrix()
pushMatrix()
rotate(ang)
t2:draw()
ang=ang-1
popMatrix()
end
--========================================
function MakeTriangle (v1, v2, v3, c)
m=mesh()
m.vertices={v1, v2, v3}
m:setColors(c)
return m
end
Thanks in advanced…
Give them different rotation angles.
-- Rotating Triangles
displayMode(FULLSCREEN)
blendMode(OVERLAY)
-- blendMode(ADDITIVE)
--========================================
function setup()
ang1=0
ang2=0
-- the vec points
a1=-120 -- right side x position
b1=-60 -- right side y position
c1= 100 -- left side x position
d1=-60 -- left side y position
e1=-10 -- tips x position
f1= 60 -- tips y position
a2=-120 -- right side x position
b2= 60 -- right side y position
c2= 100 -- left side x position
d2= 60 -- left side y position
e2= -10 -- tips x position
f2= -60 -- tips y position
--..............................................................
-- ( left, right, tip )
t1 = MakeTriangle (vec2(a1,b1), vec2(c1,d1), vec2(e1,f1), color(0, 0, 255))
t2 = MakeTriangle (vec2(a2,b2), vec2(c2,d2), vec2(e2,f2), color(0, 255, 0))
--...............................................................
end
--==========================================
function draw()
background(0)
--...............................................................
-- Draw a blue rect with light opacity to highlite the controls at the bottom
fill(0, 0, 255, 50) -- this fills the rect with blue
strokeWidth(1.5)
rect(6,3,265,35) -- this is the wht highliteer
--...............................................................
translate(WIDTH/2,HEIGHT/2)
pushMatrix()
ang1=ang1+0.5
rotate(ang1)
t1:draw()
popMatrix()
pushMatrix()
ang2=ang2-1
rotate(ang2)
t2:draw()
popMatrix()
end
--========================================
function MakeTriangle (v1, v2, v3, c)
m=mesh()
m.vertices={v1, v2, v3}
m:setColors(c)
return m
end