float angle;
int dist_ball = 100;
void setup() {
size(800, 600);
background(0);
}
void draw() {
fill(20,20);
noStroke();
rect(0,0,width, height);
fill(255);
translate(width/2, height/2);
rotate(angle);
pushMatrix();
rotate(angle);
translate(dist_ball,0);
ellipse(0, 0, 10, 10);
popMatrix();
angle += 0.1;
}
The result is this effect:
2D, 3D, game, games, online game, game development, game engine, programming, OpenGL, Open AI, math, graphics, design, graphic, graphics, game development, game engine, programming, web development, web art, web graphic, arts, tutorial, tutorials,
vineri, 15 septembrie 2017
Using processing.js to make a rotating ball effect .
This tutorial show us how to make a rotating ball effect.
You can see the background is not black and the reason is the background is set just into setup function.
Another part of this effect is the rect function from draw.
This rect will clean the ball.
The ball is a ecllipse function with a size a 10.
The pushMatrix function pushes the current transformation matrix onto the matrix stack.