spritesetvel.cpp (1261B)
1 // sprite setvel tests 2 3 #include "../lash_game_sprite.h" 4 #include <stdio.h> 5 #include <math.h> 6 7 int main(int argc, char *argv[]) { 8 Lash_Sprite_2D_Simple *sprite = new Lash_Sprite_2D_Simple(); 9 /*float ox = -32.8112793; 10 float ny = 94.9453812; 11 float nx = -31.390686; 12 float oy = 94.4638519; 13 */ 14 15 float testx = 2.f; 16 float testy = 3.f; 17 float testd = sqrt(pow(testx, 2) + pow(testy, 2)); 18 float testa = atan2(-testy, testx); 19 20 float r; 21 float v; 22 23 sprite->init(200, 200, 0.f, 0.f); 24 25 sprite->setVelX(testx, 0); 26 sprite->getVel(&v, &r); 27 printf("getvel after init setvelx %f = v %f, r %f\n", testx, v, r); 28 sprite->setVelY(testy, 1); 29 sprite->getVel(&v, &r); 30 printf("getvel after setvely (keep x) %f = v %f, r %f\n", testy, v, r); 31 sprite->setVel(testd, testa); 32 sprite->getVel(&v, &r); 33 printf("getvel after setvel %f, r %f = v %f, r %f\n", testd, testa, v, r); 34 35 sprite->setVelY(testy, 0); 36 sprite->getVel(&v, &r); 37 printf("getvel after init setvely %f = v %f, r %f\n", testy, v, r); 38 sprite->setVelX(testx, 1); 39 sprite->getVel(&v, &r); 40 printf("getvel after setvelx (keep y) %f = v %f, r %f\n", testx, v, r); 41 sprite->setVel(testd, testa); 42 sprite->getVel(&v, &r); 43 printf("getvel after setvel %f, r %f = v %f, r %f\n", testd, testa, v, r); 44 45 return 0; 46 }