-
This commit is contained in:
16
main.c
16
main.c
@@ -5,6 +5,9 @@
|
||||
#include <stdlib.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 {
|
||||
const int scwidth, scheight;
|
||||
int fps;
|
||||
@@ -14,7 +17,7 @@ struct global {
|
||||
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)
|
||||
{
|
||||
@@ -28,7 +31,6 @@ void drawobjs()
|
||||
object *obj = gl.objs[i];
|
||||
DrawSphere(obj->pos, obj->r, obj->color);
|
||||
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];
|
||||
obj->vel.y -= 0 * GetFrameTime();
|
||||
obj->vel = Vector3Scale(obj->vel, (1.0f-gl.friction));
|
||||
//if (obj->vel.y < gl.terminal_yv)
|
||||
if (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-gl.friction));
|
||||
//PRINTVEC3(obj->vel);
|
||||
DrawLine3D(obj->pos, Vector3Add(obj->pos, obj->vel), PURPLE);
|
||||
obj->pos = Vector3Add(obj->pos, Vector3Scale(obj->vel, GetFrameTime()));
|
||||
}
|
||||
}
|
||||
@@ -82,9 +86,9 @@ int main(void) {
|
||||
InitWindow(gl.scwidth, gl.scheight, "raylib engine");
|
||||
|
||||
SetTargetFPS(gl.fps);
|
||||
addobj(newobj((Vector3){10, 40, 0}, 2, BLUE, 1, 200000));
|
||||
addobj(newobj((Vector3){50, 20, 0}, 5, RAYWHITE, 0., 5000000));
|
||||
Camera3D camera = {{0, 20, 10}, {0, 20, 0}, {0, 1, 0}, 50, CAMERA_PERSPECTIVE};
|
||||
addobj(newobj((Vector3){-100, 60, 0}, 2, BLUE, 0.8, 2000));
|
||||
addobj(newobj((Vector3){100, 50, 0}, 50, RAYWHITE, 0, 50000000));
|
||||
Camera3D camera = {{0, 50, 20}, {0, 50, 0}, {0, 1, 0}, 50, CAMERA_PERSPECTIVE};
|
||||
DisableCursor();
|
||||
SetWindowMonitor(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user