Skip to content

Commit 18bcb19

Browse files
committed
ported 2 examples from c to fb
1 parent 694cd04 commit 18bcb19

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include "../../raylib.bi"
2+
3+
#define MAX_COLUMNS 20
4+
5+
dim as integer screen_width = 800
6+
dim as integer screen_height = 450
7+
8+
InitWindow(screen_width, screen_height, "raylib-freebasic [core] example - 3d camera first person")
9+
10+
dim as camera cam
11+
cam.position = vector3(4.0, 2.0, 4.0)
12+
cam.target = vector3(0, 1.8, 0)
13+
cam.up = vector3(0, 1, 0)
14+
cam.fovy = 60
15+
cam.projection = CAMERA_PERSPECTIVE
16+
17+
dim as short heights(MAX_COLUMNS)
18+
dim as vector3 positions(MAX_COLUMNS)
19+
dim as rlcolor col(MAX_COLUMNS)
20+
21+
for i as integer = 0 to MAX_COLUMNS
22+
heights(i) = GetRandomValue(1, 12)
23+
positions(i) = vector3(GetRandomValue(-15, 15), heights(i)/2.0, GetRandomValue(-15, 15))
24+
col(i) = rlcolor(GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255)
25+
next i
26+
27+
SetCameraMode(cam, CAMERA_FIRST_PERSON)
28+
29+
SetTargetFPS(60)
30+
31+
while not WindowShouldClose()
32+
33+
UpdateCamera(@cam)
34+
35+
BeginDrawing()
36+
37+
ClearBackground(RAYWHITE)
38+
39+
BeginMode3D(cam)
40+
41+
DrawPlane(vector3(0.0, 0.0, 0.0), vector2(32.0, 32.0), LIGHTGRAY)
42+
DrawCube(vector3(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, BLUE)
43+
DrawCube(vector3(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, LIME)
44+
DrawCube(vector3(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, GOLD)
45+
46+
for j as integer = 0 to MAX_COLUMNS
47+
DrawCube(positions(j), 2.0, heights(j), 2.0, col(j))
48+
DrawCubeWires(positions(j), 2.0, heights(j), 2.0, MAROON)
49+
next j
50+
51+
EndMode3D()
52+
53+
DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5))
54+
DrawRectangleLines( 10, 10, 220, 70, BLUE)
55+
56+
DrawText("First person camera default controls:", 20, 20, 10, BLACK)
57+
DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY)
58+
DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY)
59+
60+
61+
EndDrawing()
62+
wend
63+
64+
CloseWindow()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "../../raylib.bi"
2+
3+
dim as integer screen_width = 800
4+
dim as integer screen_height = 450
5+
6+
InitWindow(screen_width, screen_height, "raylib-freebasic [core] example - basic window")
7+
8+
SetTargetFPS(60)
9+
10+
while not WindowShouldClose()
11+
BeginDrawing()
12+
13+
ClearBackground(RAYWHITE)
14+
15+
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
16+
17+
EndDrawing()
18+
wend
19+
20+
CloseWindow()

0 commit comments

Comments
 (0)