level 8
leader400
楼主
我要做个小游戏,和flappy bird十分相似:一个小球穿过地图。。。
我把地图和球做好了,但想往里放置一条规则,且碰到地图边缘就死,但放不进去。。。
哪位大神能帮帮忙。。。
没加规则的:
int mapList[]={70,90,80,100,80,70,100,150,100,70};
int bheight;
void setup(){
size(640,360);
stroke(50);
frameRate(24);
bheight = 180;
}
void draw(){
int mapList[]={70,90,80,100,80,70,100,150,100,70};
int bheight;
void setup(){
size(640,360);
stroke(50);
frameRate(24);
bheight = 180;
}
void draw(){
background(50);
drawMap();
int x = (millis()/10)%width;
ellipse(x,bheight,20,20);
bheight = bheight + 1 ;
}
void drawMap(){
beginShape();
vertex(0,0);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]);
vertex((i+1)*64,mapList[i]);
}
vertex(640,0);
endShape();
beginShape();
vertex(0,640);
int mapList[]={70,90,80,100,80,70,100,150,100,70};
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]+100);
vertex((i+1)*64,mapList[i]+100);
}
vertex(640,640);
endShape();
}
void keyPressed(){
bheight = bheight - 5 ;
}
background(50);
drawMap();
int x = (millis()/10)%width;
ellipse(x,bheight,20,20);
bheight = bheight + 1 ;
}
void drawMap(){
beginShape();
vertex(0,0);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]);
vertex((i+1)*64,mapList[i]);
}
vertex(640,0);
endShape();
beginShape();
vertex(0,640);
int mapList[]={70,90,80,100,80,70,100,150,100,70};
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]+100);
vertex((i+1)*64,mapList[i]+100);
}
vertex(640,640);
endShape();
}
void keyPressed(){
bheight = bheight - 5 ;
}
。。。。。。。。。
现在我加上了规则,但好像有几句位置不对,出现了问题。。
int mapList[]={70,90,80,100,80,70,100,150,100,70};
int bheight;
void setup(){
size(640,360);
stroke(50);
frameRate(24);
bheight = 180;
}
void draw(){
background(50);
drawMap();
bheight = bheight+2;
int x = (millis()/10)%width;
ellipse(x,bheight,20,20);
if ( isCollapsed(x))
{
background(50);
noLoop();
}
}
boolean isCollapsed(int x){
int index = (x-1) /64;
int min = mapList[index]+10;
int max = 100+mapList[index]-10;
}
if (bheight<min||bheight>max)
return true;
return false;
void drawMap(){
beginShape();
vertex(0,0);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]);
vertex((i+1)*64,mapList[i]);
}
vertex(640,0);
endShape();
beginShape();
vertex(0,640);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]+100);
vertex((i+1)*64,mapList[i]+100);
}
vertex(640,640);
endShape();
}
void keyPressed(){
bheight = bheight - 5 ;
}
哪位大神能帮我改改呀,感激不尽
。
2015年04月24日 09点04分
1
我把地图和球做好了,但想往里放置一条规则,且碰到地图边缘就死,但放不进去。。。
哪位大神能帮帮忙。。。
没加规则的:
int mapList[]={70,90,80,100,80,70,100,150,100,70};
int bheight;
void setup(){
size(640,360);
stroke(50);
frameRate(24);
bheight = 180;
}
void draw(){
int mapList[]={70,90,80,100,80,70,100,150,100,70};
int bheight;
void setup(){
size(640,360);
stroke(50);
frameRate(24);
bheight = 180;
}
void draw(){
background(50);
drawMap();
int x = (millis()/10)%width;
ellipse(x,bheight,20,20);
bheight = bheight + 1 ;
}
void drawMap(){
beginShape();
vertex(0,0);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]);
vertex((i+1)*64,mapList[i]);
}
vertex(640,0);
endShape();
beginShape();
vertex(0,640);
int mapList[]={70,90,80,100,80,70,100,150,100,70};
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]+100);
vertex((i+1)*64,mapList[i]+100);
}
vertex(640,640);
endShape();
}
void keyPressed(){
bheight = bheight - 5 ;
}
background(50);
drawMap();
int x = (millis()/10)%width;
ellipse(x,bheight,20,20);
bheight = bheight + 1 ;
}
void drawMap(){
beginShape();
vertex(0,0);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]);
vertex((i+1)*64,mapList[i]);
}
vertex(640,0);
endShape();
beginShape();
vertex(0,640);
int mapList[]={70,90,80,100,80,70,100,150,100,70};
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]+100);
vertex((i+1)*64,mapList[i]+100);
}
vertex(640,640);
endShape();
}
void keyPressed(){
bheight = bheight - 5 ;
}
。。。。。。。。。
现在我加上了规则,但好像有几句位置不对,出现了问题。。
int mapList[]={70,90,80,100,80,70,100,150,100,70};
int bheight;
void setup(){
size(640,360);
stroke(50);
frameRate(24);
bheight = 180;
}
void draw(){
background(50);
drawMap();
bheight = bheight+2;
int x = (millis()/10)%width;
ellipse(x,bheight,20,20);
if ( isCollapsed(x))
{
background(50);
noLoop();
}
}
boolean isCollapsed(int x){
int index = (x-1) /64;
int min = mapList[index]+10;
int max = 100+mapList[index]-10;
}
if (bheight<min||bheight>max)
return true;
return false;
void drawMap(){
beginShape();
vertex(0,0);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]);
vertex((i+1)*64,mapList[i]);
}
vertex(640,0);
endShape();
beginShape();
vertex(0,640);
for (int i=0;i<10;i++)
{
vertex(i*64,mapList[i]+100);
vertex((i+1)*64,mapList[i]+100);
}
vertex(640,640);
endShape();
}
void keyPressed(){
bheight = bheight - 5 ;
}
哪位大神能帮我改改呀,感激不尽