Skip to content

Instantly share code, notes, and snippets.

@pema99
Created September 10, 2019 13:27
Show Gist options
  • Save pema99/267f851ce58543568c0e85104a718c77 to your computer and use it in GitHub Desktop.
Save pema99/267f851ce58543568c0e85104a718c77 to your computer and use it in GitHub Desktop.
Cursed processing breakout clone
float a,b,c,d,f;int[] e;int q=20;int w=50;
void r(){e=new int[32];c=2;d=2;b=300;f=0;a=0;}
void setup(){size(400,400);r();}
void draw(){
background(0);
rect(f,380,w,18);
for(int x=0;x<8;x++)
for(int y=0;y<4;y++)
if(e[y*8+x]==0){
int s=x*w;int t=y*q;
rect(s,t,w,q);
if(s<a+q&&s+w>a&&t<b+q&&t+q>b){
if(a>=s&&a+1<=s+w)d=-d;
else c=-c; e[y*8+x]=1;}}
a+=c; b+=d;
if (a<=0||a>=380)c=-c;
if (b<=0)d=-d;
rect(a,b,q,q);
if(keyPressed)f+=keyCode==LEFT?-4:4;
f=max(min(f,350),0);
if(b>=362){if(a+q>=f&&a<=f+w)d=-d;else r();}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment