Flappy Bird Clones :)


24

ทุกคนต่างก็ประหลาดใจกับเกม "Flappy Bird" ที่ถูกลบออกไป ดังนั้นงานของคุณคือสร้างเกม Flappy Bird Clone มันง่ายจริงๆ นี่คือเส้นบอกแนว:

  • มันสามารถใช้ทั้ง ascii art หรือภาพจริง
  • คุณสามารถทำการพนัง "นก" ของคุณด้วยการคลิกหรือกดปุ่ม
  • ควรพยายามให้สั้นที่สุดเท่าที่จะเป็นไปได้ดังนั้นแท็ก

นี่คือตัวอย่าง: http://www.reddit.com/r/learnprogramming/comments/1xiimx/i_couldnt_sleep_so_i_cloned_your_flappy_bird/

เพื่อที่จะเป็น "Flappy Bird Clone" เกมของคุณจะต้องมีสิ่งต่อไปนี้:

  • นกหรือตัวละครอื่น ๆ
  • "นก" ควรขยับขึ้นเล็กน้อยเมื่อกดปุ่มหรือคุณคลิก / แตะ
  • หากไม่มีการคลิก / แตะ / ฯลฯ "นก" ควรเลื่อนลงอย่างรวดเร็ว
  • ท่อหรือสิ่งกีดขวางอื่น ๆ ควรเลื่อนไปทางซ้ายบนหน้าจอเพื่อสร้างภาพลวงตาที่นกกำลังเคลื่อนไหว
  • ท่อควรมีช่องว่างเล็ก ๆ สำหรับนกที่จะบินผ่าน
  • ทุกครั้งที่คุณผ่านช่องว่างระหว่างท่อคะแนนของคุณจะเพิ่มขึ้น 1
  • หากคุณกดท่อหรือพื้นดินเกมจะสิ้นสุดลงและคะแนนของคุณจะปรากฏขึ้น

ไม่จำเป็นต้องเป็น "เบิร์ด" หรือ "ไพพ์" ซึ่งทั้งหมดสามารถเป็นแอพพลิเคชั่นได้ นี่คือตัวอย่างน้อยที่สุดของหน้าจอนกที่ห้อยได้:

/ ----- [4] ----- \
| || || |
| || ¯¯ |
| || O> |
| ¯¯ __ |
| __ || |
| || || |
\ ------------- /

2
คำถามควรอยู่ในตัวเองและควรมีสเป็คแปรงกว้างอย่างน้อย
Peter Taylor

3
ตามที่ปรากฏมีปรากฏว่ามีความเป็นตัวตนมากเกินไปเล็กน้อยในสิ่งที่ถือว่าเป็นผลงานที่ถูกต้อง
Cruncher

2
ที่นั่น ฉันวางแนวทางบางอย่างเพื่อทำ "โคลนนก
ห้อย

ฉันทำสิ่งนี้เมื่อสองสามสัปดาห์ก่อน บางทีฉันจะเล่นกอล์ฟเมื่อฉันมีเวลา: cwhart.co/nyanpybird
Shmiddty

1
ฉันจริงๆ จริงๆต้องการที่จะเห็นรุ่นศิลปะ ASCII!
Robbie Wxyz

คำตอบ:


14

Javascript + jQuery (ศิลปะ ASCII) - 571 524 491

เปิดเครื่องมือ Dev (F12) และเรียกใช้รหัสต่อไปนี้ในหน้านี้ (ตอนนี้ไปเลย!) เพื่อให้ฟังก์ชั่นการสาธิตด้านล่าง

l=$('#answer-23452 blockquote pre').click(function(){m=1}),o=[],d=0,e=4,m=1;setInterval(function(){t=Array(153);s=~~(d/10-0.99);d++;d%10?0:o[d+20]=~~(Math.random()*5)+1;for(i=-1;k=o[i+d],i<17;i++)if(k--)for(j=-1;c=j==k||j-k==4?'-':j-k>0&&j-k<4?0:'|',j<9;j++)i>-1?t[j*17+i]=c:0,i<16?t[j*17+i+1]=c:0;m-=.2;e-=m;if(e<0||e>10||t[~~e*17+8])e=4,m=1,d=0,o=[];t[~~e*17+8]='>';r='|-------['+s+']-------';for(i=0;z=t[i]||' ',i<153;i++)i%17?r+=z:r+='|\n|'+z;r+='|\n|-----------------|';l.html(r);},150)

การสาธิต (ทำให้ใช้งานได้):

|-------[5]-------|
|    ||        -- |
|    ||           |
|    ||           |
|    --           |
|              -- |
|              || |
|              || |
|    --  >     || |
|    ||        || |
|-----------------|

ข้อบกพร่องเล็กน้อยที่รู้จักกัน:

  • หากคุณได้รับคะแนนสองหลักมันจะทำให้รูปแบบยุ่งเหยิง

  • มันไม่ง่ายเลย!!! (แต่ต้นฉบับไม่ได้เป็นอย่างใดอย่างหนึ่ง)

  • มีข้อเสียระหว่างประสิทธิภาพและ golfedness

รู้สึกอิสระที่จะแสดงความคิดเห็นกับคะแนนสูงสุดของคุณ

นอกจากนี้นี่เป็นโพสต์ Code Golf แรกของฉันดังนั้นคำแนะนำเกี่ยวกับการบีบอัด ฯลฯ จะได้รับการต้อนรับ


1
คุณสามารถลบvarคำสำคัญและการประกาศตัวแปร คุณสามารถแทนที่Array(153)โดย[]และอาจแทนที่~~(Math.random()*5)+1ด้วย1+new Date%5
Michael M.

หากคุณเพิกเฉยเลย์เอาต์ข้าม jQuery และเพิ่ม HTML เป็น 416 ไบต์: jsbin.com/flap/1/edit?html,output
aemkei

คะแนน 17. ฉันไม่มีชีวิตฉันรู้
ibrahim mahrir

Known_minor_bugs += "irritating, unwanted and distracting text selections when double clicking";
ibrahim mahrir

22

Javascript + jQuery (997)

ทดสอบกับ Chrome 32, Firefox 27, IE9

เปิด Console (F12) จากหน้านี้และคัดลอก / วางรหัสต่อไปนี้

scroll(0,0);h=1/30;p=[];r=320;n=0;w=80;f=2.5;o=80;t=setInterval;$('#question').children().hide().end().append('<p id="m"></p>').append('<p id="s"></p>').click(function(){v=100});$('#s').css({position:'relative',margin:'auto',border:'2px solid',width:200,height:r}).append('<img id="b" src="//i.imgur.com/4w6Vgud.gif"/>');$('<style>.p{width:1px;border:1px solid;position:absolute}</style>').appendTo('head');function u(){$('#m').text('score '+m+' (max '+n+')')}function i(){x=r/2;v=0;m=0;p.length=0;u()}i();t("v-=h*100;x+=h*v;if(x<0||x>r)i();$('.p').remove();for(j=0;j<p.length;j++){p[j].r+=h*w;if(p[j].r>200){p.shift();j--;m++;if(m>n)n=m;u();}else if((p[j].r>165&&p[j].r<185)&&(x<p[j].h||x>p[j].h+o))i();else{$('<div class=p></div>').appendTo('#s').css({bottom:0,right:p[j].r,height:p[j].h});$('<div class=p></div>').appendTo('#s').css({bottom:p[j].h+o,right:p[j].r,height:320-p[j].h-o})}}$('#b').css({position:'absolute',left:0,bottom:x-25})",h*1e3);t("p.push({h:Math.random()*(r-o),r:0})",f*1e3)

ป้อนคำอธิบายรูปภาพที่นี่
เกมนี้แทนที่บล็อกคำถามของหน้านี้
คุณต้องคลิกที่กรอบเกมเพื่อให้นกบิน

เวอร์ชันที่ไม่อัปโหลดและแสดงความคิดเห็น:

$('#question').children().hide();
$('#question').append('<div id="score"></div>');
$('#question').append('<div id="scene"></div>');
$('#scene').css({position:'relative',margin:'auto',border:'2px solid black',width:'200',height:'320'});
$('#scene').append('<img id="bird" src="http://fc01.deviantart.net/fs71/f/2014/037/d/0/pixel_art___flappy_bird_by_hipsterli-d75dkyr.gif"></img>');
$('#bird').css({display:'block',position:'absolute',left:0,'pointer-events':'none',margin:'0 auto'});
$(window).scrollTop(0);

//CONFIGURATION
var dt=1/30,      //delta timestep (typically 30Hz)
    pipevel=80,   //pipe velocity (in pixels per second)
    pipefreq=2.5, //pipe spawn frequency (in second)
    holesize=80,  //hole size (in pixels)
    gravity=-100, //gravity (in pixels per square second)
    punchvel=100; //velocity punch when clicked (in pixels per second)

var x, y, pipes=[], roof=$('#scene').height(), score, maxscore=0;

function updateScore() {
  $('#score').text('Score : '+score+' (max : '+maxscore+')');
}

function init() {
  x=roof/2; //position
  v=0; //velocity
  score=0;
  pipes.length=0;

  updateScore();
}

function step() {
  //euler integration
  v+=dt*gravity;
  x+=dt*v;

  if (x<0 || x>roof)  init();

  //pipes
  $('.pipe').remove();
  for (i=0; i<pipes.length; i++) {
    pipes[i].rightpos += dt*pipevel;
    if (pipes[i].rightpos > 200) {
      pipes.shift();
      i--;
      score++;
      if (score>maxscore) maxscore=score;
      updateScore();
    } else if ((pipes[i].rightpos > 165 && pipes[i].rightpos < 185) && (x < pipes[i].holepos || x > pipes[i].holepos+holesize)) {
      //collision
      init();
    } else {
      $('#scene').append('<div class="pipe" style="background-color:#000; width:1px;border:1px solid #000; position:absolute; bottom:0; right:'+Math.floor(pipes[i].rightpos)+'px; height:'+pipes[i].holepos+'px"></div>');
      $('#scene').append('<div class="pipe" style="background-color:#000; width:1px;border:1px solid #000; position:absolute; bottom:'+(pipes[i].holepos+holesize)+'; right:'+Math.floor(pipes[i].rightpos)+'px; height:'+(320-(pipes[i].holepos+holesize))+'px"></div>');
    }
  }

  $('#bird').css({bottom:Math.floor(x)-25});

  setTimeout(step, dt*1000);
}

$('#question').click(function() {
  v=punchvel;
});

function addPipe() {
  pipes.push({holepos:Math.random()*(roof-holesize),rightpos:0});
  setTimeout(addPipe, pipefreq*1000);
}

init();
setTimeout(step, dt*1000);
setTimeout(addPipe, pipefreq*1000);

คุณสามารถปรับเปลี่ยนการตั้งค่า (แรงโน้มถ่วง, ความเร็วของท่อ ... ), ดูที่คอมเม้นท์


1
ทำงานได้ดีใน Firefox 27 เช่นกัน ทำได้ดีมาก +1
Karl-Johan Sjögren

ขอบคุณทำงานบน IE9 เกินไปดังนั้นผมคิดว่ามันทำงานบนเบราว์เซอร์ที่ดีใด ๆ :)
ไมเคิลเอ็ม

nice work :) และชอบปกติบนจาวาสคริปต์ที่นี่การใช้คำถามเป็นเป้าหมาย: P
masterX244

1
ด้วยรูปแบบการควบคุมปัจจุบันมันง่ายเกินไปที่จะเข้าใจผิดโดยไม่ตั้งใจแล้วไม่สามารถตกลงไปไกลเกินกว่าที่จะไปถึงหลุมถัดไปได้ (และไม่สามารถทำอะไรเกี่ยวกับเรื่องนี้ได้)
Joe Z.

1
สิ่งที่ฉันกำลังพูดคือมันง่ายเกินไปที่จะคลิกผิดที่ตรงกลางและยากเกินไปที่จะคลิกอย่างถูกต้องเพราะการชกของคุณจะทำให้คุณเริ่มต้นความเร็วเดิมโดยไม่คำนึงว่าคุณลงไปเร็วแค่ไหน
Joe Z.

5

ฟลอปปี้ดราก้อน, JavaScript, 1024b

ฉันกำลังสร้างเกมนี้สำหรับ comps js1k ปัจจุบัน ( http://js1k.com )

เล่น: http://js1k.com/2014-dragons/demo/1704

_='c.scale(,    ;ontouchH=onmousedown=onkeydowif(e){    }else h=45,d=1};(Eq";Rect(0,0,^,^9Q"-k,0Q+N),0()-k,2E3980-(+3)N(+3)),Y(p="fEFf&{{~_=,;=vviJ.jfVi/.OoyizyhkhEwf74)\\n$fwwuvtU`"+(10<h?"iZ[*)yj:*im**y|Ktdww54#5Dy\\iz[Kzi[Jiijk[e@1!":"zl]LfU{\\lKtBUh{zzU66iigig5\\n&iiyz{vfwwiyDfwiiE"0"v=i-e,w=(j-=h)-eG in p)y=8>>4),z=16&15),Iv+=e?y:z,w+=e?-z:y(dW(h-=6dW!eW(k+=Q,^<kW(k-=^)!dXeX(k+280)%8X(f++,Q<lWl--if(q>jX9q<jX!((k+3)%8)W(j<qXj>2q))e=40;fff";c.font="6em Arial";dWf1,5dX"#FloppyDragon"11,5eW"score"4,4e?"reH":d?"":"H"5,6setTimeout(n,l)})()I40*o-k,a.width/()/2-30*    d=e=f=h=0;g=[];G=0;Y>o;o++)=g[o+Y]=8*Math.random()|0;i=j=3;k=Q;l=qc.fill;c.beginPath(c.moveTo(Style="#G=2E3;o--;)o%Q?,a.height/Y1*g[Q*~~(k/8)+Q]+);g[o]-2*(p.charCodeAt(o)Text(00n=function(){4*):(,1*Gfor(oHstartIc.lineTo(N),-4,1*Q20W&&X||Y1E3^4E4q50';for(Y in $='q^YXWQNIHG    ')with(_.split($[Y]))_=join(pop());eval(_)

ยินดีรับข้อเสนอแนะและแนวคิดใหม่ทั้งหมด!


นี่ยิ่งยากกว่า Flappy Bird มันจะง่ายกว่าถ้าคุณกดปุ่มเปิดการกระทำของพนัง แต่ฉันรู้ว่านี่คือรหัสกอล์ฟและคุณสมบัติอื่น ๆ ที่หมายถึงรหัสเพิ่มเติม
danmcardle

ไม่เป็นไรฉันสามารถลองเพิ่มการสนับสนุนปุ่มกดถ้าคุณคิดว่ามันมีประโยชน์ ...
xem

@crazedgremlin การควบคุมการกดปุ่มถูกเพิ่มเข้าไปในเวอร์ชั่นล่าสุด;)
xem

เย็น! ฉันไม่สามารถผ่าน 10 แต่ก็ยังเจ๋ง
danmcardle

2

วัตถุประสงค์ C - ไม่ดี

อาจเป็นรหัสที่แย่ที่สุดที่ฉันเคยเขียน

Hacky Bird Running

คุณสามารถดาวน์โหลดไบนารี่ได้ที่นี่: AsciiBird Download Binary

แตะปุ่มควบคุมเมามันเพื่อให้นกอยู่ในอากาศ!

สิ่งนี้รวบรวมโดย Xcode และทำงานในเทอร์มินัล มันมีสี! Protip: ปรับขนาดหน้าต่างเทอร์มินัลของคุณเพื่อให้คุณไม่เห็น backlog ของการรีเฟรชหน้าจอ

main.m:

#import <Foundation/Foundation.h>
#import "ABManager.h"

void drawScreen(int counter)
{
    __block struct ABPoint thisPoint;
    thisPoint.x = 0;
    thisPoint.y = 0;

    __block ABManager *man = [ABManager sharedManager];
    [man.screen enumerateObjectsUsingBlock:^(NSString *c, NSUInteger idx, BOOL *stop)
     {
         NSString *c2 = c;
         NSMutableArray *newObstacles = [[NSMutableArray alloc] init];
         for (NSValue *s in man.obstacles)
         {
             struct ABPoint o;
             [s getValue:&o];

             if (thisPoint.x == o.x)
             {
                 if (thisPoint.y != o.y && thisPoint.y != (o.y + 1) && thisPoint.y != (o.y - 1))
                 {
                     c2 = @"\033[1;33m|\033[0m";
                 }
                 else
                 {
                     if (counter == 0 && thisPoint.y < o.y)
                     {
                         o.x = o.x - 1;

                         if (o.x < 0)
                         {
                             o.x = 49;
                             o.y = (arc4random() % 11) + 1;
                         }

                         if (man.charPos.x == o.x)
                         {
                             man.score = man.score + 1;
                         }
                     }
                 }
             }
             [newObstacles addObject:[NSValue valueWithBytes:&o objCType:@encode(struct ABPoint)]];
         }

         man.obstacles = [[NSMutableArray alloc] initWithArray: newObstacles];


         if (thisPoint.x == man.charPos.x && thisPoint.y == man.charPos.y)
         {
             printf("\033[1;35m>\033[0m");

             if ([c2 isEqualToString:@"\033[1;33m|\033[0m"])
             {
                 man.shouldExit = TRUE;
             }
         }
         else
         {
             printf("%s", [c2 UTF8String]);
         }

         if (idx % 50 == 49)
         {
             printf("\n");
             thisPoint.y = thisPoint.y + 1;
             thisPoint.x = 0;
         }
         else
         {
             thisPoint.x = thisPoint.x + 1;
         }
     }];
}

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        ABManager *man = [ABManager sharedManager];
        int count = 0;
        BOOL ignoreKeypress = FALSE;
        while (TRUE)
        {
            if (CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState,59) && !ignoreKeypress)
            {
                ignoreKeypress = TRUE;
                struct ABPoint p = man.charPos;
                p.y = p.y - 2;
                man.charPos = p;
            }
            else
            {
                ignoreKeypress = CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState,59);

                if (count > 3)
                {
                    count = 0;
                    struct ABPoint p = man.charPos;
                    p.y = p.y + 1;
                    man.charPos = p;
                }
                else
                {
                    count = count + 1;
                }
            }

            if (man.charPos.y < -1 || man.charPos.y > 11 || man.shouldExit)
            {
                exit(1);
            }

            printf("\n\n\n\n\n");
            printf("\033[1;36m[\033[0m\033[1;30mHacky Bird\033[0m\033[1;36m]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m\n");
            drawScreen(count);
            printf("\033[1;32m[\033[0m\033[1;31mScore: %li\033[0m\033[1;32m]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m\n", (long)man.score);

            [NSThread sleepForTimeInterval:0.0157];
        }

    }
}

ABManager.h

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>

struct ABPoint {
    NSInteger x;
    NSInteger y;
};

@interface ABManager : NSObject
{

}

@property (nonatomic, readwrite) NSMutableArray *screen;
@property (nonatomic, readwrite) NSMutableArray *obstacles;
@property (nonatomic, readwrite) struct ABPoint charPos;
@property (nonatomic, readwrite) NSInteger score;
@property (nonatomic, readwrite) BOOL shouldExit;;

+ (id)sharedManager;

@end

ABManager.m

#import "ABManager.h"

@implementation ABManager
+ (id)sharedManager {
    static ABManager *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[self alloc] init];
    });
    return sharedMyManager;
}

- (id)init
{
    if (self = [super init]) {

        self.screen = [[NSMutableArray alloc] init];
        for (NSUInteger i=0; i < 600; i++)
        {
            [self.screen addObject:@" "];
        }

        self.score = 0;

        self.shouldExit = FALSE;

        struct ABPoint p;
        p.x = 5;
        p.y = 0;

        self.charPos = p;

        struct ABPoint o;
        o.x = 10;
        o.y = 5;

        struct ABPoint o2;
        o2.x = 30;
        o2.y = 5;

        self.obstacles = [[NSMutableArray alloc] initWithArray:@[[NSValue valueWithBytes:&o objCType:@encode(struct ABPoint)],[NSValue valueWithBytes:&o2 objCType:@encode(struct ABPoint)]]];
    }

    return self;
}

@end

2

สีแอนิเมชันและฟิสิกส์; จาวาสคริปต์บริสุทธิ์, 457 (335) ไบต์

นี่เป็นโพสต์แรกของฉันในฟอรัมนี้ ฉันสร้างโค้ดนี้และพบว่ามีการโพสต์เธรดนี้ย้อนหลัง
นี่คือโค้ดที่ห่อหุ้มใน HTML พร้อมที่จะคัดลอก / วางในไฟล์ html:

<body><script>A=120;B=280;d=document;y=180;x=v=n=s=0;f=140;c=d.createElement('canvas');p=c.getContext('2d');c.width=B;c.height=400;c.onclick=()=>{v-=6};p.font='50px Arial';d.body.appendChild(c);r=(h,t,k=0,i='#0f0',w=40)=>{p.fillStyle=i;p.fillRect(h,k,w,t)};b=setInterval(()=>{if(x==0){n=f;f=Math.floor(B*Math.random());x=160}x--;v+=.1;y+=v;r(0,400,0,'#08f',B);r(20,40,y,'#fc0');r(x-40,n);r(x+A,f);r(x-40,B-n,n+A);r(x+A,B-f,f+A);if(x==60)s++;p.strokeText(s,A,80);if(x>20&&x<100&&(y<n||y>n+80)){clearInterval(b);location.reload()}},15)</script><br>Made by Thomas Kaldahl</body>

มันมีการชนกันของพิกเซลที่สมบูรณ์แบบฟิสิกส์กำลังสองที่ถูกต้องและภาพเคลื่อนไหวที่ราบรื่นสีทั้งหมดในโค้ด Javascript ออฟไลน์แบบออฟไลน์ทั้งหมด 457 ไบต์มีความเป็นอิสระอย่างหมดจด

<!--entire HTML shell is omitted in golf-->
<body>
    <script>
        //common numbers and the document are assigned shortcut letters
        A = 120;
        B = 280;
        d = document;

        y = 180; //y position of the top of the bird
        x = //x position of scrolling for pipes
        v = //vertical velocity of bird
        n = //y position of the top of the nearest pipe opening
        s = 0; //score
        f = 140; //y position of the top of the farther pipe opening
        c = d.createElement('canvas'); //canvas
        p = c.getContext('2d'); //canvas context
        //set canvas dimensions
        c.width = B;
        c.height = 400;

        c.onclick = () => { v -= 6 }; //apply jump velocity to bird when clicked
        p.font = '50px Arial'; //font for scoring (omitted in golf)
        d.body.appendChild(c); //add canvas to html page
        //draw a rectangle on the canvas
        r = (h, t, k = 0, i = '#0f0', w = 40) => {
            p.fillStyle = i;
            p.fillRect(h, k, w, t)
        };
        //main loop (not assigned to b in golf)
        b = setInterval( () => {
            if (x == 0) { //the x position is a countdown. when it hits 0:
                n = f; //the far pipe is now the near pipe, overwriting the old near pipe
                f = B * Math.random() //assign the far pipe a new vertical location
                x = 160; //restart the countdown back at 160
                //(score increments here in golf)
            }
            x--; //count down
            v += .1; // apply gravity to velocity
            y += v; // apply velocity to bird
            r(0, 400, 0, '#08f', B); //draw background
            r(20, 40, y, '#fc0'); //draw bird (non-default color is omitted in golf)
            r(x - 40, n); //draw first pipe upper half
            r(x + A, f); //draw second pipe upper half
            r(x - 40, B - n, n + A); //draw first pipe lower half
            r(x + A, B - f, f + A); //draw second pipe lower half
            if (x == 60)
                s++; //(this is done earlier on golf)
            p.strokeText(s, A, 80); //draw score
            // if the bird is in range of the pipes horizontally,
            // and is not in between the pipes,
            if (x > 20 && x < 100 && (y < n || y > n + 80)) {
                clearInterval(b); location.reload() //omit interval clear in golf
            }
        }, 15) //(reduced the frame delay to 9, a 1 digit number, in golf)
    </script><br>
    Made by Thomas Kaldahl <!-- GG -->
</body>

เพื่อความสนุกนี่คือเวอร์ชั่น 1066 ไบต์ที่มีกราฟฟิคนักเล่น:

<body style='margin:0'><script>var y=180,x=v=n=s=0,f=140,c=document.createElement('canvas'),p=c.getContext('2d');c.width=280;c.height=400;c.onclick=function(){v-=6};c.style='width:68vh;height:97vh';document.body.appendChild(c);p.font="50px Arial";p.shadowColor='#444';p.shadowBlur=9;p.shadowOffsetX=p.shadowOffsetY=5;function r(h,t,k=0,i='#0f0',j='#0a0',u=0,l=0,w=40){var g=p.createLinearGradient(h,l,h+40,u);g.addColorStop(0,i);g.addColorStop(1,j);p.fillStyle=g;p.fillRect(h,k,w,t);}b=setInterval(function(){if(x==0){n=f;f=Math.floor(280*Math.random());}x=x==0?159:x-1;v+=.1;y+=v;r(0,400,0,'#08c','#0cf',280,0,280);r(20,40,y,'#ff0','#fa0',y+40,y);r(x-40,n);r(x-50,20,n-20,'#0f0','#0a0',n+20,n,60);r(x+120,f);r(x+110,20,f-20,'#0f0','#0a0',f+20,f,60);r(x-40,280-n,n+120);r(x-50,20,n+120,'#0f0','#0a0',n+140,n+100,60);r(x+120,280-f,f+120);r(x+110,20,f+120,'#0f0','#0a0',f+140,f+100,60);if(x==60){s++;}p.fillStyle='#fff';p.fillText(s,120,80);if(x>20&&x<100&&(y<n||y>n+80)||y<0||y>360){clearInterval(b);location.reload();}},15);</script><br>Made by Thomas Kaldahl</body>

นอกจากนี้การโกงใช้ระบบการบีบอัดเช่น DEFLATE หรือไม่
ด้านล่างนี้คือรหัส ASCII85 สำหรับรุ่น DEFLATEd ของรหัส:
โดยวิธีการบีบอัดจะมีผลรวม 335 ไบต์

Gapon95_Wi'Kf'c (i ## 6'h + cM \ JZeFO <เอช; $ W '# A1', RqNigBH02C '# R $ M] <i <X # 6GR`2pE <Ri5mu-n% cVPrsJe: * R ^ @ pnr9bI [DAZnPP02A ^ $ MN / @ `U7l5gm !! VR4> เอ;!.? P U [Pk8] jCnOP% อู` fWql> "tuO4 / KbIWgK. 7 / iJN'f2, hnFg8e ^ SO * เสื้อ \ * `3JBn6j (f`O #], M0? 5Sa35Zc @ * XaBs @ N%] k \ M76qa [.ie7n (^ * Z5G-lfhUZ3F # '% X17Pj1u] L) LjpO6XbIl% N3tJhTsab8oV1T (MC $ 9 mT; 90VMmnfBNKEY (^ 'UV4c SW?': X (4 * wcy + F; 19eQ `FK0I" (Ude: F & XV & ^ Rc + 'SWRIbd8Lj9bG.l (MRUc1G8HoUsn # H \ V (8" ! Y $ / TT (? ^ katb (OreGfWH7uIf


นี้ดูดี แต่โชคไม่ดีสำหรับcodr กอล์ฟคำถามที่เราต้องแข็งแรงเล่นกอล์ฟรหัส
NoOne อยู่ที่นี่

3
@NoOneIsHere โปรดอ่านโพสต์และดูรหัส
golfed

ฉันขอโทษฉันเห็นแล้ว นี่คือคำตอบที่ดี
NoOne อยู่ที่นี่

2

C, 386 351 347 341 ไบต์ (Windows, MinGW), 332 พร้อมเทอร์มินัลอีมูเลเตอร์

ป้อนคำอธิบายรูปภาพที่นี่

แน่นอนว่าไม่ใช่รายการที่สวยที่สุด แต่จับกลศาสตร์หลักของนกที่ห้อย: นกเร่งความเร็วลงการกดแป้นทำให้เขากระโดดขึ้นไปแตะท่อหรือขอบของหน้าจอสิ้นสุดเกมคะแนนคือจำนวนท่อที่เคลียร์

#import<windows.h>
#define T(x)P[v*10+x]=
char P[71];X,Y,W,s;main(v){srand(time(0));for(float y=1,t=0;!(v<0|v>6|(v<Y|v>=Y+W)&X>0&X<3);Sleep(99)){y+=t=kbhit()?getch(),-.9:t+.3;--X<0?X=8,Y=rand()%3+1,W=rand()%2+2:X-1||++s;memset(P,32,70);for(v=0;v<7;T(9)10,T(X)v<Y|v++>=Y+W?35:32);v=y;T(1)79;T(2)62;system("cls");printf("%s\nSCORE: %d",P,s);}}

สามารถย่อให้เหลือ 333 ไบต์หากใช้เครื่องจำลองเทอร์มินัล POSIX (เช่น Cmder):

#import<windows.h>
#define T(x)P[v*10+x]=
char P[71];X,Y,W,s;main(v){srand(time(0));for(float y=1,t=0;!(v<0|v>6|(v<Y|v>=Y+W)&X>0&X<3);Sleep(99)){y+=t=kbhit()?getch(),-.9:t+.3;--X<0?X=8,Y=rand()%3+1,W=rand()%2+2:X-1||++s;memset(P,32,70);for(v=0;v<7;T(9)10,T(X)v<Y|v++>=Y+W?35:32);v=y;T(1)79;T(2)62;printf("\033c%s\nSCORE: %d",P,s);}}
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.