-
This commit is contained in:
16
main.c
16
main.c
@@ -5,6 +5,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "objects.h"
|
#include "objects.h"
|
||||||
|
|
||||||
|
#define VEC3FORMAT "%lf, %lf, %lf\n"
|
||||||
|
#define PRINTVEC3(vec) printf("%f, %lf, %lf\n", vec.x, vec.y, vec.z)
|
||||||
|
|
||||||
struct global {
|
struct global {
|
||||||
const int scwidth, scheight;
|
const int scwidth, scheight;
|
||||||
int fps;
|
int fps;
|
||||||
@@ -14,7 +17,7 @@ struct global {
|
|||||||
double friction;
|
double friction;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct global gl = {1600, 900, 144, {}, 0, 15, 0.001};
|
struct global gl = {1600, 900, 144, {}, 0, 30, 0.001};
|
||||||
|
|
||||||
void addobj(object *obj)
|
void addobj(object *obj)
|
||||||
{
|
{
|
||||||
@@ -28,7 +31,6 @@ void drawobjs()
|
|||||||
object *obj = gl.objs[i];
|
object *obj = gl.objs[i];
|
||||||
DrawSphere(obj->pos, obj->r, obj->color);
|
DrawSphere(obj->pos, obj->r, obj->color);
|
||||||
DrawSphereWires(obj->pos, obj->r, 16, 16, ColorBrightness(obj->color, -0.5f));
|
DrawSphereWires(obj->pos, obj->r, 16, 16, ColorBrightness(obj->color, -0.5f));
|
||||||
DrawLine3D(obj->pos, Vector3Add(obj->pos, obj->vel), PURPLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ void updateobjs()
|
|||||||
{
|
{
|
||||||
object *obj = gl.objs[i];
|
object *obj = gl.objs[i];
|
||||||
obj->vel.y -= 0 * GetFrameTime();
|
obj->vel.y -= 0 * GetFrameTime();
|
||||||
|
obj->vel = Vector3Scale(obj->vel, (1.0f-gl.friction));
|
||||||
//if (obj->vel.y < gl.terminal_yv)
|
//if (obj->vel.y < gl.terminal_yv)
|
||||||
if (obj->pos.y < obj->r) {
|
if (obj->pos.y < obj->r) {
|
||||||
obj->pos.y = obj->r;
|
obj->pos.y = obj->r;
|
||||||
@@ -63,7 +66,8 @@ void updateobjs()
|
|||||||
{
|
{
|
||||||
obj->vel = Vector3Scale(obj->vel, 1.0f/ratio_speed_to_terminal);
|
obj->vel = Vector3Scale(obj->vel, 1.0f/ratio_speed_to_terminal);
|
||||||
}
|
}
|
||||||
obj->vel = Vector3Scale(obj->vel, (1.0f-gl.friction));
|
//PRINTVEC3(obj->vel);
|
||||||
|
DrawLine3D(obj->pos, Vector3Add(obj->pos, obj->vel), PURPLE);
|
||||||
obj->pos = Vector3Add(obj->pos, Vector3Scale(obj->vel, GetFrameTime()));
|
obj->pos = Vector3Add(obj->pos, Vector3Scale(obj->vel, GetFrameTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,9 +86,9 @@ int main(void) {
|
|||||||
InitWindow(gl.scwidth, gl.scheight, "raylib engine");
|
InitWindow(gl.scwidth, gl.scheight, "raylib engine");
|
||||||
|
|
||||||
SetTargetFPS(gl.fps);
|
SetTargetFPS(gl.fps);
|
||||||
addobj(newobj((Vector3){10, 40, 0}, 2, BLUE, 1, 200000));
|
addobj(newobj((Vector3){-100, 60, 0}, 2, BLUE, 0.8, 2000));
|
||||||
addobj(newobj((Vector3){50, 20, 0}, 5, RAYWHITE, 0., 5000000));
|
addobj(newobj((Vector3){100, 50, 0}, 50, RAYWHITE, 0, 50000000));
|
||||||
Camera3D camera = {{0, 20, 10}, {0, 20, 0}, {0, 1, 0}, 50, CAMERA_PERSPECTIVE};
|
Camera3D camera = {{0, 50, 20}, {0, 50, 0}, {0, 1, 0}, 50, CAMERA_PERSPECTIVE};
|
||||||
DisableCursor();
|
DisableCursor();
|
||||||
SetWindowMonitor(0);
|
SetWindowMonitor(0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user