VOID Game_Paint(HWND hwnd) { ball.x = 200 * cosf(ball.angle) + 320 ; ball.y = 200 * sinf(ball.angle) ; if (t <= 60) { ball.angle = easeIn(t, 60, PI / 2, 0); } else if (t <= 120) { ball.angle = easeOut(t - 60, 60, PI / 2 , PI / 2); }else if(t <= 180){ ball.angle = easeIn(t - 120, 60, -PI / 2, PI); } else if (t <= 240) { ball.angle = easeOut(t - 180, 60, -PI / 2, PI / 2); }else{ t = 0; } t++; //3.选用位图对象 SelectObject(g_bdc, g_hBackground); //4.贴图 BitBlt(g_mdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_bdc, 0, 0, SRCCOPY); //SelectObject(g_bdc, g_hBall); //4.贴图 //BitBlt(g_mdc, 400, ball.y, 64, 64, g_bdc, 0, 0, SRCCOPY); SelectObject(g_bdc, g_hBall); TransparentBlt(g_mdc, ball.x, ball.y, 64, 64, g_bdc, 0, 0, 64, 64, RGB(0, 0, 0)); BitBlt(g_hdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_mdc, 0, 0, SRCCOPY); }
void calculatePoints(bool reset) { setaValorDaVariavel("x",0); double testNum = calcula(input.text); if (TemErro() && PegaCodigoErro() != ok) { functionPlot = false; errorMsg = PegaCodigoErro(); errorMsgShow = errorMsg != expressao_vazia; } else { if (!reset && weightTempo > 0) { plotTempo = easeIn(plotTempo); for (int a = 0; a < cacheCount; a++) { functionCachePrev[a] = dlerp(functionCache[a],functionCachePrev[a],plotTempo); } plotTempo = 1; } else { plotTempo = 0; } functionPlot = true; errorMsgShow = false; zeroHeightPrev = lerp(zeroHeight,zeroHeightPrev,zeroHeightTempo*zeroHeightTempo); zeroHeight = testNum; zeroHeightTempo = 1; cacheCount = 0; for (double p = functionStart; cacheCount < CACHE_MAX && p <= functionEnd; cacheCount++,p += functionGap) { setaValorDaVariavel("x",p); functionCache[cacheCount] = calcula(input.text); } } }
InbetweenDialog::InbetweenDialog(QWidget *parent) : Dialog(TApp::instance()->getMainWindow(), true, "InBeetween") { setWindowTitle(tr("Inbetween")); QString linear(tr("Linear")); QString easeIn(tr("Ease In")); QString easeOut(tr("Ease Out")); QString easeInOut(tr("Ease In / Ease Out")); QStringList items; items << linear << easeIn << easeOut << easeInOut; beginHLayout(); m_comboBox = new QComboBox(this); m_comboBox->addItems(items); addWidget(tr("Interpolation:"), m_comboBox); endHLayout(); QPushButton *okBtn = new QPushButton(tr("Inbetween"), this); QPushButton *cancelBtn = new QPushButton(tr("Cancel"), this); connect(okBtn, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject())); addButtonBarWidget(okBtn, cancelBtn); }
void level_draw() { al_clear_to_color(al_map_rgb(255,255,255)); float weight; if (game.height <= 180) { weight = 1; } else { weight = round(game.height/180.0); } //inversa do tamanho do mapa, pra usar como porcentagem double scaleX = 1.0/mapWidth; double scaleY = 1.0/mapHeight; int t; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { t = tilemap[y*mapWidth+x]; if (t == 0) { al_draw_filled_rectangle(px(x*scaleX),py(y*scaleY),px((x+1)*scaleX),py((y+1)*scaleY),al_map_rgb(51,51,51)); } else if (t == 1) { al_draw_filled_rectangle(px(x*scaleX),py(y*scaleY),px((x+1)*scaleX),py((y+1)*scaleY),al_map_rgb(204,51,51)); } else if (t == 2) { al_draw_filled_rectangle(px(x*scaleX),py(y*scaleY),px((x+1)*scaleX),py((y+1)*scaleY),al_map_rgb(51,204,51)); } } } //posição do ponto 0 do gráfico double offsetX = scaleX*(baseX+1); double offsetY = scaleY*(baseY+1+lerp(zeroHeight,zeroHeightPrev,easeIn(zeroHeightTempo))); //desenha os eixos BLENDALPHA(); ALLEGRO_COLOR axisColor = al_map_rgba(255,255,255,51); al_draw_line(px(offsetX),py(0),px(offsetX),py(1),axisColor,weight); double gridPos; int gridOffset; if (functionDir > 0) { al_draw_line(px(offsetX),py(offsetY),px(1),py(offsetY),axisColor,weight); gridOffset = 1; while (1) { gridPos = gridOffset*scaleX+offsetX; if (gridPos > 1) break; gridPos = px(gridPos); al_draw_line(gridPos,py(offsetY-scaleY*.125),gridPos,py(offsetY+scaleY*.125),axisColor,weight); gridOffset++; } } else { al_draw_line(px(0),py(offsetY),px(offsetX),py(offsetY),axisColor,weight); gridOffset = floor(-offsetX/scaleX); while (1) { gridPos = gridOffset*scaleX+offsetX; if (gridOffset >= 0 || gridPos > 1) break; gridPos = px(gridPos); al_draw_line(gridPos,py(offsetY-scaleY*.125),gridPos,py(offsetY+scaleY*.125),axisColor,weight); gridOffset++; } } gridOffset = floor(-offsetY/scaleY); while (1) { if (gridOffset == 0) { gridOffset++; continue; } gridPos = gridOffset*scaleY+offsetY; if (gridPos > 1) break; gridPos = py(gridPos); al_draw_line(px(offsetX-scaleX*.125),gridPos,px(offsetX+scaleX*.125),gridPos,axisColor,weight); gridOffset++; } BLENDDEFAULT(); //plota a função if (weightTempo > 0 && cacheCount > 0) { float t = easeIn(plotTempo); float w = easeOut(weightTempo); ALLEGRO_COLOR plotColor = al_map_rgba(255,255,255,w*255); w = ceil(w*weight); double x,xa; BLENDALPHA(); if (functionDir > 0) { for (x = dottedTempo*.25-.125; x < functionEnd; x += .25) { xa = (x < 0)?0:x; al_draw_line( dx(offsetX+xa*scaleX),dy(offsetY-getValueOnCacheLerp(xa,t)*scaleY), dx(offsetX+(x+.125)*scaleX),dy(offsetY-getValueOnCacheLerp(x+.125,t)*scaleY), plotColor,w ); } } else { for (x = -dottedTempo*.25+.125; x > functionStart; x -= .25) { xa = (x > 0)?0:x; al_draw_line( dx(offsetX+xa*scaleX),dy(offsetY-getValueOnCacheLerp(xa,t)*scaleY), dx(offsetX+(x-.125)*scaleX),dy(offsetY-getValueOnCacheLerp(x-.125,t)*scaleY), plotColor,w ); } } BLENDDEFAULT(); } //textbox float textboxHeight = textboxPos?.8:0; BLENDALPHA(); if (input.captureText) { al_draw_filled_rectangle(px(0),py(textboxHeight),px(1),py(.2+textboxHeight),al_map_rgba(255,255,255,204)); } else { al_draw_filled_rectangle(px(0),py(textboxHeight),px(1),py(.2+textboxHeight),al_map_rgba(255,255,255,153)); } BLENDDEFAULT(); int textboxOffsetX = px(.04); int textboxOffsetY = py(.03+textboxHeight); int selOffset; for (int a = 0; 1; a++) { if (input.captureText) { if (input.captureText && a == input.caretPos && input.caretBlink < .5f) { al_draw_line( textboxOffsetX, textboxOffsetY, textboxOffsetX, textboxOffsetY+al_get_font_line_height(data.font_UbuntuB), al_map_rgb(255,255,255),1 ); } if (input.selectionStart != -1 && input.selectionEnd == a) { BLENDALPHA(); al_draw_filled_rectangle( selOffset, textboxOffsetY, textboxOffsetX, textboxOffsetY+al_get_font_line_height(data.font_UbuntuB), al_map_rgba(51,51,51,51) ); BLENDDEFAULT(); } } if (input.text[a] == '\0') break; if (input.selectionStart == a) { selOffset = textboxOffsetX; } textboxChar[0] = input.text[a]; al_draw_text(data.font_UbuntuB,al_map_rgb(51,51,51),textboxOffsetX,textboxOffsetY,ALLEGRO_ALIGN_LEFT,textboxChar); textboxOffsetX += al_get_text_width(data.font_UbuntuB,textboxChar); } if (errorMsgShow) { al_draw_filled_triangle( px(.0135),py(.1797+textboxHeight), px(.0415),py(.1797+textboxHeight), px(.0275),py(.125+textboxHeight), al_map_rgb(255,204,15) ); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.0275),py(.127+textboxHeight),ALLEGRO_ALIGN_CENTRE,"!"); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.05),py(.125+textboxHeight),ALLEGRO_ALIGN_LEFT,MensagemDoErro[errorMsg]); } if (input.captureText) { al_draw_text(data.font_UbuntuB,al_map_rgb(51,51,51),px(.01),textboxOffsetY,ALLEGRO_ALIGN_LEFT,">"); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.99),py(.125+textboxHeight),ALLEGRO_ALIGN_RIGHT,"tab: inverter - enter: fechar"); } else { al_draw_text(data.font_UbuntuB,al_map_rgb(102,102,102),px(.01),textboxOffsetY,ALLEGRO_ALIGN_LEFT,">"); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.99),py(.125+textboxHeight),ALLEGRO_ALIGN_RIGHT,"backspace: voltar - tab: inverter - enter: abrir"); } }
double BounceEase::easeInOut(double time_) const { if(time_ < _duration / 2) return easeIn(time_ * 2) * 0.5; else return easeOut(time_ * 2 - _duration) * 0.5 + _change * 0.5; }
float Bounce::easeInOut(float t,float b , float c, float d) { if (t < d/2) return easeIn (t*2, 0, c, d) * .5f + b; else return easeOut (t*2-d, 0, c, d) * .5f + c*.5f + b; }
float BounceEase::easeInOut(float time) const { if(time < _duration / 2) return easeIn(time * 2) * 0.5; else return easeOut(time * 2 - _duration) * 0.5 + _change * 0.5; }