non mi ricordo nemmeno io che cosa ho aggiunto
This commit is contained in:
18
main.c
18
main.c
@@ -2,6 +2,7 @@
|
||||
#include <raylib.h>
|
||||
#include <raymath.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "objects.h"
|
||||
|
||||
struct global {
|
||||
@@ -10,9 +11,10 @@ struct global {
|
||||
object *objs[128];
|
||||
size_t obj_count;
|
||||
double terminal_v;
|
||||
double friction;
|
||||
};
|
||||
|
||||
struct global gl = {1600, 900, 144, {}, 0, 15};
|
||||
struct global gl = {1600, 900, 144, {}, 0, 15, 0.001};
|
||||
|
||||
void addobj(object *obj)
|
||||
{
|
||||
@@ -25,6 +27,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +63,7 @@ void updateobjs()
|
||||
{
|
||||
obj->vel = Vector3Scale(obj->vel, 1.0f/ratio_speed_to_terminal);
|
||||
}
|
||||
DrawLine3D(obj->pos, Vector3Add(obj->pos, obj->vel), GREEN);
|
||||
obj->vel = Vector3Scale(obj->vel, (1.0f-gl.friction));
|
||||
obj->pos = Vector3Add(obj->pos, Vector3Scale(obj->vel, GetFrameTime()));
|
||||
}
|
||||
}
|
||||
@@ -78,18 +82,18 @@ int main(void) {
|
||||
InitWindow(gl.scwidth, gl.scheight, "raylib engine");
|
||||
|
||||
SetTargetFPS(gl.fps);
|
||||
addobj(newobj((Vector3){0, 20, 0}, 1, RED, 1, 1000));
|
||||
addobj(newobj((Vector3){8, 20, 0}, 2, BLUE, 1, 2000));
|
||||
gl.objs[1]->vel = (Vector3){0, 0, 0};
|
||||
Camera3D camera = {{0, 20, -30}, {0, 0, 0}, {0, 1, 0}, 45, CAMERA_PERSPECTIVE};
|
||||
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};
|
||||
DisableCursor();
|
||||
SetWindowMonitor(0);
|
||||
|
||||
while(!WindowShouldClose())
|
||||
{
|
||||
|
||||
UpdateCamera(&camera, CAMERA_FREE);
|
||||
BeginDrawing();
|
||||
{
|
||||
UpdateCamera(&camera, CAMERA_FREE);
|
||||
ClearBackground(BLACK);
|
||||
BeginMode3D(camera);
|
||||
DrawPlane((Vector3){0, 0, 0}, (Vector2){500, 500}, RAYWHITE);
|
||||
|
||||
Reference in New Issue
Block a user