Is not jumping on small screen sizes...
in
Programming Questions
•
3 months ago
Hello, i trying a little jump and run. The problem is when i set screensize to displayWidth and displayHeight you can see the box jumping. But when i set width and height to 800x480, you can not see the box jump.
This is my code:
float x,y,w,h,i;
nt ltime, ctime;
float etime;
void setup(){
float width=800;
float height=480
float boxwidth,boxheight;
boxwidth=width*0.02;
boxheight=width*0.02;
oben=height*0.35-boxheight;
unten=height*0.7-boxheight;
}
void draw(){
size(800,480);
rgb1=247;
rgb2=234;
rgb3=112;
x=0.7*width;
y=0.5*height;
w=0.05*width;
h=height;
rect(x,y,w,h);
//speed=0.019*width;
//i=i+speed;
velocity=width*0.007;
speed=width*0.01;
ctime = millis();
etime = (ctime - ltime)/10;
ltime = ctime;
i=i+velocity*etime;
float inc = TWO_PI/(width*0.0005);
//a = a + inc;
if(mousePressed==true &&jump==0)jump=1;
if(jump==1)
{
jumc=jumc+1;
if(jumc==15){jump=0;a=0;jumc=0;}
yy2=unten- abs(sin(a)) *width*0.2;
//yy2=unten+sin(a)*210.0;1
rect(i,yy2,boxwidth,boxheight);
a=a+inc;
}
if(mousePressed==false && jump==0){ yy2=unten;a=0;
rect(i,yy2,boxwidth,boxheight);
}
if(i>width)i=0;
}
1