Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- MiniBreakout
- Autor:
- wersja: 0.1
- */
- int px,py; //pozycja srodka pilki
- int dx, dy; // kierunek ruchu pilki
- int pl; //pozycja x naszej paletki (lewy gorny rog)
- int plx; // ruch naszej paletki
- void setup()
- {
- size(800,600);
- px = width/2;
- py=450;
- dx = 1;
- dy = 1;
- pl = width/2 - 75;
- plx = 0;
- frameRate(500);
- }
- void draw()
- {
- background(0,0,0);
- paletka();
- pilka();
- }
- void paletka()
- {
- fill(0,0,255);
- pl += plx;
- rect(pl, 540, 150, 20); // paletka
- if (pl<0) pl = 0;
- if (pl>width-150) pl = width-150;
- }
- void pilka()
- {
- fill(255,0,0);
- px -= dx;
- py += dy;
- ellipse(px, py, 30, 30); // pilka
- if(px<15 || px>width-15) dx=-dx;
- if(py<15 || py > 585) dy=-dy;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement