wires
This commit is contained in:
+45
-20
@@ -3,34 +3,58 @@
|
||||
#include "player.h"
|
||||
#include "raylib.h"
|
||||
#include "screen.h"
|
||||
#include "wire.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
Button button = {
|
||||
.position = (Vector3){0.0f, 0.0f, -5.0f},
|
||||
.length = 1.0f,
|
||||
.height = 0.1f,
|
||||
.color = PINK,
|
||||
.wiresColor = BLACK,
|
||||
.pressed = false,
|
||||
};
|
||||
|
||||
Cube cube = {
|
||||
.initialized = false,
|
||||
.position = (Vector3){0.0f, 0.5f, 0.0f},
|
||||
.minY = 0.4f + 0.01f,
|
||||
.edge = 0.8f,
|
||||
.color = RED,
|
||||
.wiresColor = BLACK,
|
||||
.grabbed = false,
|
||||
};
|
||||
static bool level_started = false;
|
||||
|
||||
void DrawLevel00(Player *player)
|
||||
{
|
||||
if (!cube.initialized)
|
||||
static Button button = {
|
||||
.position = (Vector3){0.0f, 0.0f, -5.0f},
|
||||
.length = 1.0f,
|
||||
.height = 0.1f,
|
||||
.colorEnabled = GREEN,
|
||||
.colorDisabled = RED,
|
||||
.wiresColor = BLACK,
|
||||
.pressed = false,
|
||||
};
|
||||
|
||||
static Wire wire = {
|
||||
.power = &button,
|
||||
.colorEnabled = GREEN,
|
||||
.colorDisabled = BLACK,
|
||||
};
|
||||
|
||||
static Cube cube = {
|
||||
.position = (Vector3){0.0f, 0.5f, 0.0f},
|
||||
.minY = 0.4f + 0.01f,
|
||||
.edge = 0.8f,
|
||||
.color = RED,
|
||||
.wiresColor = BLACK,
|
||||
.grabbed = false,
|
||||
};
|
||||
|
||||
if (!level_started)
|
||||
{
|
||||
level_started = true;
|
||||
|
||||
cube.model = LoadModelFromMesh(GenMeshCube(cube.edge, cube.edge, cube.edge));
|
||||
cube.initialized = true;
|
||||
|
||||
float wireW = 0.1f;
|
||||
float wireH = 0.1f;
|
||||
float wireL = 5.0f;
|
||||
float wireZ = button.position.z - wireL / 2.0f - button.length / 2.0f;
|
||||
Vector3 wirePos = {0.0f, wireH / 2.0f, wireZ};
|
||||
WireAppend(&wire, wirePos, wireW, wireH, wireL);
|
||||
|
||||
wireZ -= wireL / 2.0f;
|
||||
wireW = 5.0f;
|
||||
wireH = 0.1f;
|
||||
wireL = 0.1f;
|
||||
wirePos = (Vector3){wireW / 2.0f, wireH / 2.0f, wireZ};
|
||||
WireAppend(&wire, wirePos, wireW, wireH, wireL);
|
||||
}
|
||||
|
||||
const int floorExtent = 25;
|
||||
@@ -56,4 +80,5 @@ void DrawLevel00(Player *player)
|
||||
|
||||
MyDrawCube(&cube); // Draw a cube
|
||||
DrawButton(&button, &cube); // Draw a button
|
||||
DrawWire(&wire); // Draw a wire
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user