Показать сообщение отдельно
  #6  
18.11.2011, 16:32
Цитата Сообщение от GhoST69 Посмотреть сообщение
Меня интересует возможность разделения тачек по Т. Типа в банере т1-лучшая тачка, дальше т2-лучшая тачка и т3-лучшая тачка.
я себе так сделал. приведен только кусок кода с выборкой автомобилей. синим выделено то, что надо будет дописать:
Код:
        // get best car 1
bestcar=0;
bestcar_rating=0;
foreach(p.cars as d) {
  if(d.rating>bestcar_rating && d.tier==3) {
    bestcar=d;
    bestcar_rating=d.rating;
  }
}

tx=ctx; ty=cty;
defaults.size=carSize;

image(file:cc('/cardetails/tier',bestcar.tier,'.png'), x:tx, y:ty, w:26, h:20);

// car name
tx=tx+30; ty=ty+15; te=cc(bestcar.make,' ',bestcar.carName);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// Perf block
pty=ty+2;
defaults.size=perfSize;

// speed label
tx=ptx; ty=pty+10; te=cc('Top speed: ',bestcar.topSpeed);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// Acceleration label
tx=tx+100; te=cc('Acceleration: ',bestcar.acceleration);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// handling label
tx=tx+100; te=cc('Handling: ',bestcar.handling);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// top speed
tx=ptx; ty=pty+15;
prg=progress(start:0, curr:bestcar.topSpeed, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// Acceleration
tx=tx+100;
prg=progress(start:0, curr:bestcar.acceleration, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// Handling
tx=tx+100;
prg=progress(start:0, curr:bestcar.handling, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// get best car 2
bestcar2=0;
bestcar2_rating=0;
foreach(p.cars as d) {
  if(d.rating<bestcar_rating && d.rating>bestcar2_rating && d.tier==2) {
    bestcar2=d;
    bestcar2_rating=d.rating;
  }
}

tx=ctx; ty=ty+8;
defaults.size=carSize;

image(file:cc('/cardetails/tier',bestcar2.tier,'.png'), x:tx, y:ty, w:26, h:20);

// car name
tx=tx+30; ty=ty+15; te=cc(bestcar2.make,' ',bestcar2.carName);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// Perf block
pty=ty+2;
defaults.size=perfSize;

// speed label
tx=ptx; ty=pty+10; te=cc('Top speed: ',bestcar2.topSpeed);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// Acceleration label
tx=tx+100; te=cc('Acceleration: ',bestcar2.acceleration);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// handling label
tx=tx+100; te=cc('Handling: ',bestcar2.handling);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// top speed
tx=ptx; ty=pty+15;
prg=progress(start:0, curr:bestcar2.topSpeed, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// Acceleration
tx=tx+100;
prg=progress(start:0, curr:bestcar2.acceleration, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// Handling
tx=tx+100;
prg=progress(start:0, curr:bestcar2.handling, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// get best car 3
bestcar3=0;
bestcar3_rating=0;
foreach(p.cars as d) {
  if(d.rating<bestcar2_rating && d.rating>bestcar3_rating && d.tier==1) {
    bestcar3=d;
    bestcar3_rating=d.rating;
  }
}

tx=ctx; ty=ty+8;
defaults.size=carSize;

image(file:cc('/cardetails/tier',bestcar3.tier,'.png'), x:tx, y:ty, w:26, h:20);

// car name
tx=tx+30; ty=ty+15; te=cc(bestcar3.make,' ',bestcar3.carName);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// Perf block
pty=ty+2;
defaults.size=perfSize;

// speed label
tx=ptx; ty=pty+10; te=cc('Top speed: ',bestcar3.topSpeed);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// Acceleration label
tx=tx+100; te=cc('Acceleration: ',bestcar3.acceleration);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// handling label
tx=tx+100; te=cc('Handling: ',bestcar3.handling);
text(x:tx-1, y:ty+1, text: te, color: shcol);
text(x:tx+1, y:ty-1, text: te, color: shcol);
text(x:tx-1, y:ty-1, text: te, color: shcol);
text(x:tx+1, y:ty+1, text: te, color: shcol);
text(x:tx+2, y:ty+2, text: te, color: shcol);
text(x:tx, y:ty, text: te);

// top speed
tx=ptx; ty=pty+15;
prg=progress(start:0, curr:bestcar3.topSpeed, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// Acceleration
tx=tx+100;
prg=progress(start:0, curr:bestcar3.acceleration, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

// Handling
tx=tx+100;
prg=progress(start:0, curr:bestcar3.handling, next:1000, w:90);
rectangle(x:tx, y:ty, w:90, h:prh, fill:'999999');
rectangle(x:tx, y:ty, w:prg.currw, h:prh, fill:'27FD0A');

__________________

Последний раз редактировалось deadmoroz14; 18.11.2011 в 16:37.