add floor
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
#include "raylib.h"
|
||||||
|
#include "screen.h"
|
||||||
|
|
||||||
|
void DrawLevel00()
|
||||||
|
{
|
||||||
|
const int floorExtent = 25;
|
||||||
|
const float tileSize = 5.0f;
|
||||||
|
|
||||||
|
for (int y = -floorExtent; y < floorExtent; y++) {
|
||||||
|
for (int x = -floorExtent; x < floorExtent; x++) {
|
||||||
|
if ((y & 1) ^ (x & 1)) {
|
||||||
|
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vector3 towerSize = (Vector3){ 16.0f, 32.0f, 16.0f };
|
||||||
|
|
||||||
|
Vector3 towerPos = (Vector3){ 16.0f, 16.0f, 16.0f };
|
||||||
|
DrawCubeV(towerPos, towerSize, RED);
|
||||||
|
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
||||||
|
|
||||||
|
towerPos.x *= -1;
|
||||||
|
DrawCubeV(towerPos, towerSize, RED);
|
||||||
|
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
||||||
|
|
||||||
|
towerPos.z *= -1;
|
||||||
|
DrawCubeV(towerPos, towerSize, RED);
|
||||||
|
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
||||||
|
|
||||||
|
towerPos.x *= -1;
|
||||||
|
DrawCubeV(towerPos, towerSize, RED);
|
||||||
|
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
||||||
|
}
|
||||||
+3
-24
@@ -1,30 +1,10 @@
|
|||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
#include "screen.h"
|
||||||
static void DrawLevel()
|
|
||||||
{
|
|
||||||
const Vector3 towerSize = (Vector3){ 16.0f, 32.0f, 16.0f };
|
|
||||||
|
|
||||||
Vector3 towerPos = (Vector3){ 16.0f, 16.0f, 16.0f };
|
|
||||||
DrawCubeV(towerPos, towerSize, RED);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
|
||||||
|
|
||||||
towerPos.x *= -1;
|
|
||||||
DrawCubeV(towerPos, towerSize, RED);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
|
||||||
|
|
||||||
towerPos.z *= -1;
|
|
||||||
DrawCubeV(towerPos, towerSize, RED);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
|
||||||
|
|
||||||
towerPos.x *= -1;
|
|
||||||
DrawCubeV(towerPos, towerSize, RED);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
InitWindow(800, 600, "Super cool game");
|
InitWindow(800, 600, "Super cool game");
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(GAME_FPS);
|
||||||
|
|
||||||
Camera3D camera = { 0 };
|
Camera3D camera = { 0 };
|
||||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f };
|
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f };
|
||||||
@@ -41,8 +21,7 @@ int main()
|
|||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
DrawGrid(20, 10.0f);
|
DrawLevel00();
|
||||||
DrawLevel();
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef SCREEN_H
|
||||||
|
#define SCREEN_H
|
||||||
|
|
||||||
|
#define GAME_FPS 60
|
||||||
|
|
||||||
|
void DrawLevel00();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user