This commit is contained in:
bdnugget committed 2024-04-17 20:30:23 +02:00
1 parent 838d97cd97
commit 3bf2ed3347
15 files changed
+5 -136

No files matched your search

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+5 -2
View File
@@ -2,6 +2,9 @@
#include <time.h> // For time function
#include <stdlib.h> // For NULL
// Comment/uncomment for WASM
//#define PLATFORM_WEB
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -136,8 +139,8 @@ void UpdateGame(void) {
allowMove = false;
}
if ((framesCounter % FPS_TARGET) == 0) {
car.position.x += SQUARE_SIZE;
if ((framesCounter % (FPS_TARGET/60)) == 0) {
car.position.x += SQUARE_SIZE/FPS_TARGET;
car.position.y += car.direction * SQUARE_SIZE;
allowMove = true;
car.direction = 0;
BIN
View File
Binary file not shown.
-44
View File
@@ -1,44 +0,0 @@
#include "raylib.h"
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
BIN
View File
Binary file not shown.
-90
View File
@@ -1,90 +0,0 @@
#include "raylib.h"
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 1200;
const int screenHeight = 768;
InitWindow(screenWidth, screenHeight, "Dikke stront dino");
// Define our custom camera to look into our 3d world
Camera camera = { 0 };
camera.position = (Vector3){ 18.0f, 21.0f, 18.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Image image = LoadImage("resources/dinosmall.png"); // Load heightmap image (RAM)
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 4, 16 }); // Generate heightmap mesh (RAM and VRAM)
Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
float cameraSpeed = 0.2f;
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Move the camera with arrow keys
if (IsKeyDown(KEY_RIGHT)) camera.position.x += cameraSpeed;
if (IsKeyDown(KEY_LEFT)) camera.position.x -= cameraSpeed;
if (IsKeyDown(KEY_UP)) camera.position.z -= cameraSpeed;
if (IsKeyDown(KEY_DOWN)) camera.position.z += cameraSpeed;
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawModel(model, mapPosition, 1.0f, BLUE);
//DrawGrid(20, 1.0f);
DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY);
EndMode3D();
DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE);
DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture
UnloadModel(model); // Unload model
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB