160 lines
4.1 KiB
HolyC
160 lines
4.1 KiB
HolyC
// Random Spline.HC related code snippets removed from the project
|
|
|
|
//CD2 curveTmp[8] = {
|
|
#define curveTmpLen 12
|
|
CD2 curveTmp[curveTmpLen] = {
|
|
{164,173},
|
|
{175,340},
|
|
{234,142},
|
|
{225,345},
|
|
{165,473},
|
|
{123,324},
|
|
{193,153},
|
|
{275,340},
|
|
{234,329},
|
|
{54,345},
|
|
{100,432},
|
|
{300,230},
|
|
};
|
|
|
|
MoveSpline testPattern;
|
|
|
|
// TMP
|
|
InitMoveSpline(&testPattern, 18);
|
|
I64 i;
|
|
testPattern.path[0].x = SCX;
|
|
testPattern.path[0].y = -128;
|
|
testPattern.path[1].x = SCX;
|
|
testPattern.path[1].y = 0;
|
|
testPattern.path[2].x = SCX;
|
|
testPattern.path[2].y = SCY;
|
|
|
|
I64 loopCnt = testPattern.cnt-2;
|
|
I64 sinCnt = loopCnt-4;
|
|
for (i=3; i<loopCnt; i++) {
|
|
testPattern.path[i].x = SCX+Sin(ToF64(i)/sinCnt*pi*2)*64;
|
|
testPattern.path[i].y = SCY+Cos(ToF64(i)/sinCnt*pi*2)*64;
|
|
}
|
|
testPattern.path[testPattern.cnt-2].x = 640;
|
|
testPattern.path[testPattern.cnt-2].y = SCY;
|
|
testPattern.path[testPattern.cnt-1].x = 1000;
|
|
testPattern.path[testPattern.cnt-1].y = SCY;
|
|
testPattern.len = SplineUpdateLen2(testPattern.path, testPattern.cnt-3, testPattern.pathLens);
|
|
|
|
|
|
// TMP draw spline
|
|
/*
|
|
F64 fi;
|
|
dc->color = WHITE;
|
|
//curveTmp[0].x = 128 + Sin(t_now)*32;
|
|
//curveTmp[curveTmpLen-1].y = 128 + Sin(t_now)*128;
|
|
F64 curveLens[curveTmpLen];
|
|
F64 totalLen = SplineUpdateLen2(curveTmp, curveTmpLen-3, curveLens);
|
|
|
|
CD2 res;
|
|
for (fi=0; fi<curveTmpLen-3; fi += 0.005) {
|
|
SplineGetPos2(curveTmp, fi, &res);
|
|
if (fi >= 1.0 && fi <= 2.0)
|
|
dc->color = RED;
|
|
else
|
|
dc->color = WHITE;
|
|
GrPlot1(dc, res.x, res.y);
|
|
}
|
|
|
|
for (i=0; i<curveTmpLen; i++) {
|
|
SplineGetPos2(curveTmp, i, &res);
|
|
if (i == 1)
|
|
dc->color = RED;
|
|
else
|
|
dc->color = YELLOW;
|
|
#ifdef DEBUG
|
|
//CommPrint("p: %d %fx%f\n", i, res.x, res.y);
|
|
#endif
|
|
//GrCircle(dc, res.x, res.y,8);
|
|
}
|
|
|
|
F64 cursor = titleData.time*32.0%totalLen;
|
|
F64 cursorOff = SplineGetNormalized(curveLens, cursor);
|
|
CD2 p1, g1;
|
|
SplineGetPos2(curveTmp, cursorOff, &p1);
|
|
SplineGetGradient2(curveTmp, cursorOff, &g1);
|
|
GrLine(dc, p1.x, p1.y, p1.x+g1.x*64, p1.y+g1.y*64);
|
|
F64 sR = Arg(g1.x, -g1.y);
|
|
dc->color = BLUE;
|
|
GrLine(dc, 5.0*Sin(sR)+p1.x, 5.0*Cos(sR)+p1.y, -5.0*Sin(sR)+p1.x, -5.0*Cos(sR)+p1.y);
|
|
dc->color = YELLOW;
|
|
GrCircle(dc, p1.x, p1.y, 16);
|
|
|
|
testPattern.len = SplineUpdateLen2(testPattern.path, testPattern.cnt-3, testPattern.pathLens);
|
|
DrawSplineAgent(dc, &testPattern, titleData.time*32);
|
|
|
|
DrawMoveSpline(dc, &testPattern);
|
|
DrawMoveSpline2(dc, &testPattern);
|
|
|
|
//TMP
|
|
I64 tm[4][4];
|
|
Mat4x4IdentEqu(tm);
|
|
Mat4x4RotZ(tm, tS);
|
|
Mat4x4Scale(tm, Sin(tS)*4);
|
|
dc->x = 320;
|
|
dc->y = 320;
|
|
dc->r = tm;
|
|
PxBlotM2(dc, gAssets.pxScum, -gAssets.pxScum->width/2, -gAssets.pxScum->height/2, 0);
|
|
|
|
F64 c2 = titleData.time*4%(curveTmpLen-3);
|
|
CD2 p2;
|
|
SplineGetPos(curveTmp, c2, &p2);
|
|
GrCircle(dc, p2.x, p2.y, 16);
|
|
*/
|
|
|
|
MoveSpline mobCurve;
|
|
|
|
U0 InitPatterns() {
|
|
InitMoveSpline(&mobCurve, 18);
|
|
I64 i;
|
|
mobCurve.path[0].x = SCX;
|
|
mobCurve.path[0].y = -128;
|
|
mobCurve.path[1].x = SCX;
|
|
mobCurve.path[1].y = 0;
|
|
mobCurve.path[2].x = SCX;
|
|
mobCurve.path[2].y = SCY;
|
|
|
|
I64 loopCnt = mobCurve.cnt-2;
|
|
I64 sinCnt = loopCnt-4;
|
|
for (i=3; i<loopCnt; i++) {
|
|
mobCurve.path[i].x = SCX+Sin(ToF64(i)/sinCnt*pi*2)*64;
|
|
mobCurve.path[i].y = SCY+Cos(ToF64(i)/sinCnt*pi*2)*64;
|
|
}
|
|
mobCurve.path[mobCurve.cnt-2].x = 640;
|
|
mobCurve.path[mobCurve.cnt-2].y = SCY;
|
|
mobCurve.path[mobCurve.cnt-1].x = 1000;
|
|
mobCurve.path[mobCurve.cnt-1].y = SCY;
|
|
mobCurve.len = SplineUpdateLen2(mobCurve.path, mobCurve.cnt-3, mobCurve.pathLens);
|
|
}
|
|
|
|
InitPatterns;
|
|
|
|
U0 MoveCurve(World*, Mob *mob, F64 delta) {
|
|
mob->time += delta;
|
|
CD2 p0, p1, p2, res;
|
|
/*
|
|
p0.x = 0;
|
|
p0.y = 0;
|
|
p1.x = SCR_W;
|
|
p1.y = FB_H;
|
|
p2.x = SCX;
|
|
p2.y = FB_H;
|
|
//GetPosOnCurve2(CD2 *p0, CD2 *p1, CD2 *p2, CD2 *p3, mob->time, &res);
|
|
//BezierQuadratic(&p0, &p1, &p2, mob->time/3, &res);
|
|
// F64 addY = 64.0 * delta;
|
|
mob->pos.x = res.x;
|
|
mob->pos.y = res.y;
|
|
*/
|
|
F64 t = mob->time*128 % mobCurve.len;
|
|
F64 tn = SplineGetNormalized(mobCurve.pathLens, t);
|
|
SplineGetPos2(mobCurve.path, tn, &mob->pos);
|
|
CD2 g;
|
|
SplineGetGradient2(mobCurve.path, tn, &g);
|
|
mob->rot = Arg(g.x, g.y);
|
|
}
|