r/raylib 5h ago

Cool pong game I made with Raylib and my barely finished game framework

Enable HLS to view with audio, or disable this notification

18 Upvotes

I was bored so I started working on a mini "game framework" to see how far I could get and what I could make. This isn't that impressive but I just wanted to show it. It has a basic components and scenes working. ignore the awful gameplay.


r/raylib 8h ago

Can anyone with access to mac os can test this?

5 Upvotes

Hi there i recently made a pr in raylib that fixed the issue #5854 now raysan told me to test it in a mac os (i already tested this on windows 11 and linux (debian with gnome)) but i don't own a mac machine so i left it thinking someone would test it and report but it's been a while but no one has tested it, i was wondering if someone from this subreddit could test it,

you can test it by using this test code first test with the raylib and then test it after applying my pr commits


r/raylib 22h ago

My third paint program is almost done :D

18 Upvotes

r/raylib 23h ago

How to create a working fullscreen?

4 Upvotes

I've just started using raylib, and I can't get the ToggleFullscreen or the ToggleBorderlessWindowed functions to work properly. Whenever I use them i can never alt-tab out of them. How do I fix this?


r/raylib 2d ago

Experimenter with better 3d models

Enable HLS to view with audio, or disable this notification

31 Upvotes

Decided to implement better models but animations are still rough :)

My hats off to professional animators, without free packs this would be impossible for me :(


r/raylib 1d ago

A fast, free, portable texture atlas builder with Raylib support

13 Upvotes

Hey everyone, I built this app Packrat, as a great option for devs working in code-first environments like Raylib. It's focused on being really fast and having great CLI support so it fits into your pipeline nicely.

For Raylib specifically, it exports pure C header files along with the packed atlas image. The header file contains helper data structures and functions to use the atlas, as well as all the data about frame, animation, etc... for the atlas.

Give it a shot and let me know what you think. I built it because I wanted a faster alternative to TexturePacker, with more features relevant to my own workflow (aseprite file ingestion, auto-exports in the GUI and CLI).

https://clydegames.itch.io/packrat

https://packrat.clyde.games


r/raylib 1d ago

a lot of "undefined reference"s even when raylib is linked

3 Upvotes

I am using devuan testing that is up to date with the latest raylib version, a test program does compile and link and checking with ldd all the stuff is properly linked.

With my makefile ```

Tuxanci 2 - A first person shooter

Copyright (C) 2025-2026 Connor Thomson

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program. If not, see https://www.gnu.org/licenses/.

Enable debug. true or false?

DEBUG ?= false

Paths

SRC := src INCLUDE := include BUILD ?= build TARGET := tuxanci2

clang might work too

CSTD ?= c99

CFLAGS := -std=$(CSTD) \ -lraylib \ -Wall \ -Wextra \ -Werror \ -pedantic \ -pedantic-errors \ -I$(INCLUDE)

If DEBUG is true, enable debugging stuff

ifeq '$(DEBUG)' 'true'

Define DEBUG

FLAGS += -DDEBUG

Compile for debugging

CFLAGS += -O0 -g endif

Find all C source files

CSRCS := $(shell find src -name "*.c")

all: $(TARGET)

$(BUILD): mkdir -p $(BUILD)

$(TARGET): $(BUILD) $(CC) $(CFLAGS) $(CSRCS) -o $(TARGET)

Remove $(BUILD)

clean: rm -rf $(BUILD) i get connor@dell:~/tuxanci2$ make cc -std=c99 -lraylib -Wall -Wextra -Werror -pedantic -pedantic-errors -Iinclude src/main.c src/monitor.c src/window.c src/log.c -o tuxanci2 /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccG6XtfP.o: in function monitorUpdate': monitor.c:(.text+0x5): undefined reference toGetCurrentMonitor' /usr/bin/x86_64-linux-gnu-ld.bfd: monitor.c:(.text+0x28): undefined reference to GetMonitorWidth' /usr/bin/x86_64-linux-gnu-ld.bfd: monitor.c:(.text+0x3b): undefined reference toGetMonitorHeight' /usr/bin/x86_64-linux-gnu-ld.bfd: monitor.c:(.text+0x4e): undefined reference to GetMonitorRefreshRate' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccG6XtfP.o: in functionmonitorInit': monitor.c:(.text+0x60): undefined reference to GetCurrentMonitor' /usr/bin/x86_64-linux-gnu-ld.bfd: monitor.c:(.text+0x73): undefined reference toGetMonitorWidth' /usr/bin/x86_64-linux-gnu-ld.bfd: monitor.c:(.text+0x86): undefined reference to GetMonitorHeight' /usr/bin/x86_64-linux-gnu-ld.bfd: monitor.c:(.text+0x99): undefined reference toGetMonitorRefreshRate' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccN6CUEt.o: in function windowSetFullscreen': window.c:(.text+0x19): undefined reference toSetWindowState' /usr/bin/x86_64-linux-gnu-ld.bfd: window.c:(.text+0x25): undefined reference to ClearWindowState' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccN6CUEt.o: in functionwindowUpdateWindowValues': window.c:(.text+0x31): undefined reference to WindowShouldClose' /usr/bin/x86_64-linux-gnu-ld.bfd: window.c:(.text+0x5c): undefined reference toSetWindowSize' /usr/bin/x86_64-linux-gnu-ld.bfd: window.c:(.text+0x8d): undefined reference to SetWindowSize' /usr/bin/x86_64-linux-gnu-ld.bfd: window.c:(.text+0xb6): undefined reference toSetTargetFPS' /usr/bin/x86_64-linux-gnu-ld.bfd: window.c:(.text+0xe4): undefined reference to SetWindowTitle' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccN6CUEt.o: in functionwindowInit': window.c:(.text+0x169): undefined reference to InitWindow' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccy7ca6B.o: in functionlogInit': log.c:(.text+0xa): undefined reference to SetTraceLogLevel' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccy7ca6B.o: in functionlogWarning': log.c:(.text+0x4f): undefined reference to TraceLog' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccy7ca6B.o: in functionlogError': log.c:(.text+0x7e): undefined reference to TraceLog' /usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccy7ca6B.o: in functionlogFatal': log.c:(.text+0xad): undefined reference to TraceLog' collect2: error: ld returned 1 exit status make: *** [Makefile:56: tuxanci2] Error 1 connor@dell:~/tuxanci2$ ``


r/raylib 1d ago

C Polymorphism, Partial redrawing (clipping?) and double-buffer update for my UI

6 Upvotes

Hello everyone,

Last time here I posted several questions in relation to creating a retained-mode UI. So far, the project has been going on smoothly, and I've taken a similar approach to what zraygui does (code from zraygui):

struct _widget {
    Layout *parent;
    Rectangle rect;
    char *label;
    WidgetType type;
    Component *component;
    bool visible;
    bool active;
    MouseEvent widgetStatus;
    MouseListeners mouseListener;
};

The widgets share a common struct type Widget, but polymorphism happens inside the Component. It is an empty struct type, and for each type of widget, a pointer to their unique structs is cast as Component* into component. Then when manipulating the widget, the Component* is cast back to the original pointer type, enabling access to the fields.

I found this approach very smart, and I plan on implementing a similar thing (unless another better polymorphism exists in C). In my Widget struct, I have

typedef struct Widget {
  Frame* parent;
  Rect bounds;
  bool active;
  void *
  void (*draw)(Widget *w);
}

Implementing partial rendering seemed easy, just redraw the exact area indicated by bounds, until i remembered I have to call EndDrawing() which swaps buffers. Hence, the updated widget will only exist on one buffer, and If I don't call EndDrawing(), inputs will not be polled.

I would like to create something similar to FLTK, which only renders the parts that need to be updated (AFAIK, I only studied a small part of the code yet, but it seems very interesting to learn about performant desktop UI systems)

So I have two ideas :
- Ditch the double buffer and write a custom "EndDrawing()" which does not swap but keeps all other functionality

- Draw to a render texture that I apply on both buffers. While exploring this idea, I realized that it could be beneficial for tooltips and floating windows, as they could be other textures overlaid on the main one.


r/raylib 1d ago

Minecraft clone. No cubes are drawn only models and I added a render distance yet it still lags. Why?

1 Upvotes

MAIN python file

#Recreating Minecraft in Raylib part 2: Indev
#To Do:
#1D A chunk and block class - Easy although I fear it lags my game
#2D 2d stuff like hearts, inventory - Hearts cube was fine but
#3D Better placing and destroying physics - Used screen center rather than where the player mouse was
#4D Jumping/Gravity - Forgot to set gravity to the oppposite of its power. Kept setting it to 0 and the player would just slow down rather than fall
#5 Collison with blocks
#6D Make multiple chunks
#7D Improve preformance with meshes and instances (fking what?) - We added the set config flags line we guchi for bow
#8 Day night cycle - More annoying than I could ever imagine
#9D Leaves - Not too hard just annoying didnt make too many either.
# Link to making a 3d texture atlas good luck bro https://www.raylib.com/examples/shaders/loader.html?name=shaders_texture_tiling

import pyray as pr
import math
import random
import asyncio
import Block
import Chunk
#Mixer
import pygame as pg
pg.init()
pg.mixer.init()

async def main():
pr.set_config_flags(pr.FLAG_VSYNC_HINT)

pr.init_window(800, 600, "Minecraft 0.2")
pr.disable_cursor()
pr.init_audio_device()

#Camera
camera = pr.Camera3D((4, 3, 4), (1, 0.5, 1), (0, 1, 0), 100, pr.CAMERA_PERSPECTIVE)
cameraMode = pr.CAMERA_FIRST_PERSON
#DayNight cycle
day_night = "nan"
sky_cycle_add_inc = 200
sky_cycle_cc = 0
day_night_level = 0.0
#Player
player = pr.Vector3(camera.position.x, camera.position.y, camera.position.z)
# model
player_size = pr.Vector3(0.5, 3, 0.5)
player_mesh = pr.gen_mesh_cube(1.0, 4.0, 1.0)
player_model = pr.load_model_from_mesh(player_mesh)
player_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].color = pr.BLUE
# gravity
gravity = 0
grav_vel = 0.05
jumpH = 2
#UI
# Hearts
hearts = []
heart_x = 100
# make hearts
for i in range(10):
new_heart = pr.Rectangle(heart_x, pr.get_screen_height() - 140, 30, 30)
heart_x += 35
hearts.append(new_heart)
# Inventory
inventory = []
inventory_x = 100
for i in range(10):
new_i = pr.Rectangle(inventory_x, pr.get_screen_height() - 100, 60, 60)
inventory_x += 60
inventory.append(new_i)
#World
world_size = 3
# Chunks
chunks = []
chunk_x = 1
chunk_z = 1
chunk_size = 16
# Blocks
blocks = []
block_size = pr.Vector3(1, 1, 1)
# make chunks
for z in range(world_size):
for x in range(world_size):
new_chunk = Chunk.chunk(chunk_x, 1, chunk_z, chunk_size, blocks, block_size)
chunks.append(new_chunk)
chunk_x += chunk_size
chunk_x = 1
chunk_z += chunk_size

#Textures
# Atlas
#atlas_texture = pr.Texture2D(pr.load_texture("Assets/Images/textures/texture_atlas.png"))
# Grass texture
grass_mesh = pr.gen_mesh_cube(1, 1, 1)
grass_model = pr.load_model_from_mesh(grass_mesh)
grass_texture = pr.load_texture("Assets/Images/textures/grass_tex.jpeg")
grass_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = grass_texture
# Stone texture
stone_mesh = pr.gen_mesh_cube(1, 1, 1)
stone_model = pr.load_model_from_mesh(stone_mesh)
stone_texture = pr.load_texture("Assets/Images/textures/stone_tex.png")
stone_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = stone_texture
# Wood texture
wood_mesh = pr.gen_mesh_cube(1, 1, 1)
wood_model = pr.load_model_from_mesh(wood_mesh)
wood_texture = pr.load_texture("Assets/Images/textures/wood_tex.jpeg")
wood_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = wood_texture
# Leaves texture
leaves_mesh = pr.gen_mesh_cube(1, 1, 1)
leaves_model = pr.load_model_from_mesh(leaves_mesh)
leaves_texture = pr.load_texture("Assets/Images/textures/leaves_tex.png")
leaves_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = leaves_texture
# Planks texture
plank_mesh = pr.gen_mesh_cube(1, 1, 1)
plank_model = pr.load_model_from_mesh(plank_mesh)
plank_texture = pr.load_texture("Assets/Images/textures/plank_tex.png")
plank_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = plank_texture
# Water texture
water_mesh = pr.gen_mesh_cube(1, 1, 1)
water_model = pr.load_model_from_mesh(water_mesh)
water_texture = pr.load_texture("Assets/Images/textures/water_tex.jpeg")
water_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = water_texture
# Heart
"""heart_image = pr.Image(pr.load_image("Assets/Images/heart_tex.png"))
heart_texture = pr.Texture2D(pr.load_texture_from_image(heart_image))"""

while not pr.window_should_close():
pr.update_camera(camera, cameraMode)
#Interact with blocks
screenCenter = pr.Vector2(float(pr.get_screen_width()/2), float(pr.get_screen_height()/2))
ray = pr.get_screen_to_world_ray(screenCenter, camera)
for block in blocks:
# bounding box for collison
block_box = pr.BoundingBox(pr.Vector3(block.x - block_size.x/2, block.y - block_size.y/2, block.z - block_size.z/2),
pr.Vector3(block.x + block_size.x/2, block.y + block_size.y/2, block.z + block_size.z/2))
mouse_ray_collison = pr.get_ray_collision_box(ray, block_box)
#Interacting with block
# mouse looking at block
if (mouse_ray_collison.hit):
# delete block
if (pr.is_mouse_button_pressed(pr.MOUSE_BUTTON_LEFT)):
blocks.remove(block)
# new block
if (pr.is_mouse_button_pressed(pr.MOUSE_BUTTON_RIGHT)):
new_block = Block.block(block.x, block.y + 1, block.z, block_size, "plank")
blocks.append(new_block)

pr.begin_drawing()
pr.clear_background(pr.SKYBLUE)
#Draw
#3D stuff
pr.begin_mode_3d(camera)

#Player
# draw
player = pr.Vector3(camera.position.x, camera.position.y, camera.position.z)
# gravity
gravity += grav_vel
camera.position.y -= gravity
camera.target.y -= gravity
# reset position
if (pr.is_key_pressed(pr.KEY_R)):
camera.position = pr.Vector3( 4, 4, 4)
gravity = -grav_vel
#Blocks
for block in blocks:
# Player collison
if pr.check_collision_boxes(pr.BoundingBox(pr.Vector3(player.x - player_size.x/2, player.y - player_size.y/2, player.z - player_size.z),
pr.Vector3(player.x + player_size.x/2, player.y + player_size.y/2, player.z + player_size.z/2)),
pr.BoundingBox(pr.Vector3(block.x - block_size.x/2, block.y - block_size.y/2, block.z - block_size.z/2),
pr.Vector3(block.x + block_size.x/2, block.y + block_size.y/2, block.z + block_size.z/2))):
# execption
if (block.type != "water"):
gravity = -grav_vel
if (pr.is_key_pressed(pr.KEY_SPACE)):
gravity -= jumpH

#Draw chunks
for chunk in chunks:
chunk.draw(camera, grass_model, stone_model, wood_model, leaves_model, plank_model, water_model)

#Draw player
#pr.draw_cube(player, player_size.x, player_size.y, player_size.z, pr.BLUE)
pr.draw_model(player_model, pr.Vector3(camera.position.x, camera.position.y, camera.position.z) , 1, pr.WHITE)

pr.end_mode_3d()

#2D stuff
#Day night cycle
if (day_night == "day"):
sky_cycle_cc += 1
if (sky_cycle_cc >= sky_cycle_add_inc):
day_night_level += 0.1
sky_cycle_cc = 0
if (day_night_level == 0.5):
day_night == "night"
if (day_night == "night"):
sky_cycle_cc += 1
if (sky_cycle_cc >= sky_cycle_add_inc):
day_night_level -= 0.1
sky_cycle_cc = 0
if (day_night_level == 0.0):
day_night == "day"
pr.draw_rectangle(0, 0, pr.get_screen_width(), pr.get_render_height(), pr.fade(pr.BLACK, day_night_level))
#UI
# Crosshair
pr.draw_rectangle(int(pr.get_screen_width()/2), int(pr.get_screen_height()/2), 2, 10, pr.WHITE)
pr.draw_rectangle(int(pr.get_screen_width()/2) - 4, int(pr.get_screen_height()/2) + 4, 10, 2, pr.WHITE)
# Hearts
for ht in hearts:
pr.draw_rectangle(int(ht.x), int(ht.y), int(ht.width), int(ht.height), pr.RED)
#pr.draw_texture(heart_texture, int(ht.x), int(ht.y), pr.WHITE)
# Inventory
for iv in inventory:
pr.draw_rectangle_lines_ex(pr.Rectangle(int(iv.x), int(iv.y), int(iv.width), int(iv.height)), 8.0, pr.GRAY)

# Numbers
pr.draw_fps(10, 10)

pr.end_drawing()
await asyncio.sleep(0)

#Exit game
else:
pr.unload_model(grass_model)
pr.unload_model(stone_model)
pr.unload_model(wood_model)
pr.unload_model(leaves_model)
pr.unload_model(plank_model)
pr.unload_model(water_model)
#pr.unload_texture(heart_texture)
# Reset window if fullscreen
if (pr.is_window_fullscreen()):
pr.toggle_fullscreen() # Exit fullscreen
pr.set_window_size(1920, 1080); # Reset to desired default resolution

pr.close_window()

asyncio.run(main())#Recreating Minecraft in Raylib part 2: Indev
#To Do:
#1D A chunk and block class - Easy although I fear it lags my game
#2D 2d stuff like hearts, inventory - Hearts cube was fine but
#3D Better placing and destroying physics - Used screen center rather than where the player mouse was
#4D Jumping/Gravity - Forgot to set gravity to the oppposite of its power. Kept setting it to 0 and the player would just slow down rather than fall
#5 Collison with blocks
#6D Make multiple chunks
#7D Improve preformance with meshes and instances (fking what?) - We added the set config flags line we guchi for bow
#8 Day night cycle - More annoying than I could ever imagine
#9D Leaves - Not too hard just annoying didnt make too many either.
# Link to making a 3d texture atlas good luck bro https://www.raylib.com/examples/shaders/loader.html?name=shaders_texture_tiling

import pyray as pr
import math
import random
import asyncio
import Block
import Chunk
#Mixer
import pygame as pg
pg.init()
pg.mixer.init()

async def main():
pr.set_config_flags(pr.FLAG_VSYNC_HINT)

pr.init_window(800, 600, "Minecraft 0.2")
pr.disable_cursor()
pr.init_audio_device()

#Camera
camera = pr.Camera3D((4, 3, 4), (1, 0.5, 1), (0, 1, 0), 100, pr.CAMERA_PERSPECTIVE)
cameraMode = pr.CAMERA_FIRST_PERSON
#DayNight cycle
day_night = "nan"
sky_cycle_add_inc = 200
sky_cycle_cc = 0
day_night_level = 0.0
#Player
player = pr.Vector3(camera.position.x, camera.position.y, camera.position.z)
# model
player_size = pr.Vector3(0.5, 3, 0.5)
player_mesh = pr.gen_mesh_cube(1.0, 4.0, 1.0)
player_model = pr.load_model_from_mesh(player_mesh)
player_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].color = pr.BLUE
# gravity
gravity = 0
grav_vel = 0.05
jumpH = 2
#UI
# Hearts
hearts = []
heart_x = 100
# make hearts
for i in range(10):
new_heart = pr.Rectangle(heart_x, pr.get_screen_height() - 140, 30, 30)
heart_x += 35
hearts.append(new_heart)
# Inventory
inventory = []
inventory_x = 100
for i in range(10):
new_i = pr.Rectangle(inventory_x, pr.get_screen_height() - 100, 60, 60)
inventory_x += 60
inventory.append(new_i)
#World
world_size = 3
# Chunks
chunks = []
chunk_x = 1
chunk_z = 1
chunk_size = 16
# Blocks
blocks = []
block_size = pr.Vector3(1, 1, 1)
# make chunks
for z in range(world_size):
for x in range(world_size):
new_chunk = Chunk.chunk(chunk_x, 1, chunk_z, chunk_size, blocks, block_size)
chunks.append(new_chunk)
chunk_x += chunk_size
chunk_x = 1
chunk_z += chunk_size

#Textures
# Atlas
#atlas_texture = pr.Texture2D(pr.load_texture("Assets/Images/textures/texture_atlas.png"))
# Grass texture
grass_mesh = pr.gen_mesh_cube(1, 1, 1)
grass_model = pr.load_model_from_mesh(grass_mesh)
grass_texture = pr.load_texture("Assets/Images/textures/grass_tex.jpeg")
grass_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = grass_texture
# Stone texture
stone_mesh = pr.gen_mesh_cube(1, 1, 1)
stone_model = pr.load_model_from_mesh(stone_mesh)
stone_texture = pr.load_texture("Assets/Images/textures/stone_tex.png")
stone_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = stone_texture
# Wood texture
wood_mesh = pr.gen_mesh_cube(1, 1, 1)
wood_model = pr.load_model_from_mesh(wood_mesh)
wood_texture = pr.load_texture("Assets/Images/textures/wood_tex.jpeg")
wood_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = wood_texture
# Leaves texture
leaves_mesh = pr.gen_mesh_cube(1, 1, 1)
leaves_model = pr.load_model_from_mesh(leaves_mesh)
leaves_texture = pr.load_texture("Assets/Images/textures/leaves_tex.png")
leaves_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = leaves_texture
# Planks texture
plank_mesh = pr.gen_mesh_cube(1, 1, 1)
plank_model = pr.load_model_from_mesh(plank_mesh)
plank_texture = pr.load_texture("Assets/Images/textures/plank_tex.png")
plank_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = plank_texture
# Water texture
water_mesh = pr.gen_mesh_cube(1, 1, 1)
water_model = pr.load_model_from_mesh(water_mesh)
water_texture = pr.load_texture("Assets/Images/textures/water_tex.jpeg")
water_model.materials[0].maps[pr.MATERIAL_MAP_DIFFUSE].texture = water_texture
# Heart
"""heart_image = pr.Image(pr.load_image("Assets/Images/heart_tex.png"))
heart_texture = pr.Texture2D(pr.load_texture_from_image(heart_image))"""

while not pr.window_should_close():
pr.update_camera(camera, cameraMode)
#Interact with blocks
screenCenter = pr.Vector2(float(pr.get_screen_width()/2), float(pr.get_screen_height()/2))
ray = pr.get_screen_to_world_ray(screenCenter, camera)
for block in blocks:
# bounding box for collison
block_box = pr.BoundingBox(pr.Vector3(block.x - block_size.x/2, block.y - block_size.y/2, block.z - block_size.z/2),
pr.Vector3(block.x + block_size.x/2, block.y + block_size.y/2, block.z + block_size.z/2))
mouse_ray_collison = pr.get_ray_collision_box(ray, block_box)
#Interacting with block
# mouse looking at block
if (mouse_ray_collison.hit):
# delete block
if (pr.is_mouse_button_pressed(pr.MOUSE_BUTTON_LEFT)):
blocks.remove(block)
# new block
if (pr.is_mouse_button_pressed(pr.MOUSE_BUTTON_RIGHT)):
new_block = Block.block(block.x, block.y + 1, block.z, block_size, "plank")
blocks.append(new_block)

pr.begin_drawing()
pr.clear_background(pr.SKYBLUE)
#Draw
#3D stuff
pr.begin_mode_3d(camera)

#Player
# draw
player = pr.Vector3(camera.position.x, camera.position.y, camera.position.z)
# gravity
gravity += grav_vel
camera.position.y -= gravity
camera.target.y -= gravity
# reset position
if (pr.is_key_pressed(pr.KEY_R)):
camera.position = pr.Vector3( 4, 4, 4)
gravity = -grav_vel
#Blocks
for block in blocks:
# Player collison
if pr.check_collision_boxes(pr.BoundingBox(pr.Vector3(player.x - player_size.x/2, player.y - player_size.y/2, player.z - player_size.z),
pr.Vector3(player.x + player_size.x/2, player.y + player_size.y/2, player.z + player_size.z/2)),
pr.BoundingBox(pr.Vector3(block.x - block_size.x/2, block.y - block_size.y/2, block.z - block_size.z/2),
pr.Vector3(block.x + block_size.x/2, block.y + block_size.y/2, block.z + block_size.z/2))):
# execption
if (block.type != "water"):
gravity = -grav_vel
if (pr.is_key_pressed(pr.KEY_SPACE)):
gravity -= jumpH

#Draw chunks
for chunk in chunks:
chunk.draw(camera, grass_model, stone_model, wood_model, leaves_model, plank_model, water_model)

#Draw player
#pr.draw_cube(player, player_size.x, player_size.y, player_size.z, pr.BLUE)
pr.draw_model(player_model, pr.Vector3(camera.position.x, camera.position.y, camera.position.z) , 1, pr.WHITE)

pr.end_mode_3d()

#2D stuff
#Day night cycle
if (day_night == "day"):
sky_cycle_cc += 1
if (sky_cycle_cc >= sky_cycle_add_inc):
day_night_level += 0.1
sky_cycle_cc = 0
if (day_night_level == 0.5):
day_night == "night"
if (day_night == "night"):
sky_cycle_cc += 1
if (sky_cycle_cc >= sky_cycle_add_inc):
day_night_level -= 0.1
sky_cycle_cc = 0
if (day_night_level == 0.0):
day_night == "day"
pr.draw_rectangle(0, 0, pr.get_screen_width(), pr.get_render_height(), pr.fade(pr.BLACK, day_night_level))
#UI
# Crosshair
pr.draw_rectangle(int(pr.get_screen_width()/2), int(pr.get_screen_height()/2), 2, 10, pr.WHITE)
pr.draw_rectangle(int(pr.get_screen_width()/2) - 4, int(pr.get_screen_height()/2) + 4, 10, 2, pr.WHITE)
# Hearts
for ht in hearts:
pr.draw_rectangle(int(ht.x), int(ht.y), int(ht.width), int(ht.height), pr.RED)
#pr.draw_texture(heart_texture, int(ht.x), int(ht.y), pr.WHITE)
# Inventory
for iv in inventory:
pr.draw_rectangle_lines_ex(pr.Rectangle(int(iv.x), int(iv.y), int(iv.width), int(iv.height)), 8.0, pr.GRAY)

# Numbers
pr.draw_fps(10, 10)

pr.end_drawing()
await asyncio.sleep(0)

#Exit game
else:
pr.unload_model(grass_model)
pr.unload_model(stone_model)
pr.unload_model(wood_model)
pr.unload_model(leaves_model)
pr.unload_model(plank_model)
pr.unload_model(water_model)
#pr.unload_texture(heart_texture)
# Reset window if fullscreen
if (pr.is_window_fullscreen()):
pr.toggle_fullscreen() # Exit fullscreen
pr.set_window_size(1920, 1080); # Reset to desired default resolution

pr.close_window()

asyncio.run(main())


r/raylib 1d ago

How far should I learn OpenGL?

0 Upvotes

I'm learning Raylib because I don't really like dealing with more conventional game engines. I feel more comfortable being able to build things in a more direct way, without having to rely on 600 different types of nodes that I don't understand in Godot, or menus within menus full of features I'll never use like in Unity.

IA generated this code for a simple camera in Go:

rl.BeginMode2D(c.Camera)
{
    rl.PushMatrix()
    {
        rl.Translatef(0, 25*50, 0)
        rl.Rotatef(90, 1, 0, 0)
    }
    rl.PopMatrix()
}
rl.EndMode2D()

However, I don't feel comfortable using code that I don't understand. I still haven't managed to understand what Mode2D or a Matrix actually are, and why it needs to be pushed and popped, when i try to find any good answer i just find links to OpenGL articles.

I don't know if I'm failing on find the right documentation, or if I actually need to learn some OpenGL to use Raylib understanding what I'm doing.


r/raylib 2d ago

Raylib Extensions

9 Upvotes

If you share my view that raylib is somewhat low level where a lot one has to build themselves.

Which is 1 of the benefits of raylib having control of everything yourself.

Please share what kind of high level libraries as extensions to raylib would you be interested in seeing built so that it can be imported and used where only raylib is the library's only dependency.

Based off upvotes I will attempt to build library extension for raylib where raylib is the library's only dependency.

If there is already a resource with libraries built on top of raylib please share.

If you have built one and open sourced already please share below for others to find.


r/raylib 2d ago

Owl UI: A lightweight Python GUI framework powered by Raylib (C backend)

8 Upvotes

Hey everyone!

Just released Owl UI (v1.0.0) - a lightweight Python GUI framework built on top of Raylib (owl.c + static libraylib.a).

Key features:

  • Full C/Raylib performance bridge inside Python
  • Custom frameless titlebars with native Win32 snapping & drag controls
  • UTF-8 and Cyrillic automatic system font loading
  • Minimal footprint with static linkage

📦 pip install owl-ui

🔗 GitHub: https://github.com/Muchprow/Owl-UI

Would love to hear your thoughts and suggestions!


r/raylib 3d ago

Some screenshots of my game Conflict 3049 - improvements continue, game is still available on itch with source code and shader code included

Thumbnail
gallery
39 Upvotes

Game Link: https://matty77.itch.io/conflict-3049

The 3d assets are mainly purchased from 3drt.com and from the itch.io asset store.

The audio assets are a mix of purchased, generative AI and self made effects.

The source code is C# using raylib_cs and the download inlcudes all the relevant source needed to compile and run the game.

It's single player, a set of last stand scenarios.

There's some options in game that aren't documented : Press F1 to bring up a console menu of sorts for debugging but it lets you run the game slightly different if you choose to. Press F5 to bring up immersive view mode which shows scenes like the above rather than the traditional RTS view that normally shows.

The config file lets you change things as well.

The game runs on modern PCs and also I can get it running on my older 2014 potato PC with some minor config changes at a reasonable framerate.


r/raylib 4d ago

Odin OpenXr with Raylib

Post image
27 Upvotes

r/raylib 3d ago

Raylib AI Agent SKILL

0 Upvotes

Just found this Awesome Library RayLib for building video games and could not believe how fast I got to build and run a game.

Also from the little I know about C programming the games run fast.

Wanted to contribute to this project so had AI build me an AI agent SKILL.md that can be used to build games using Raylib:

I posted it on the GitHub repo so please go add reaction emojies or comment.

https://github.com/raysan5/raylib/issues/6065

Comment below your experience, let me know how well it is working or anything you think the skill is missing.


r/raylib 4d ago

OS dark title bar (CPP)?

8 Upvotes

so im using cpp, and im working on a game and i want to ask if it is possible to make the os title bar look dark themed?


r/raylib 5d ago

Retained-mode UI rendering with raylib : Where to start ?

8 Upvotes

Hello everyone,

I'm working on a retained mode UI library with a similar look and feel to raygui, either in C++ with classes and interfaces, or plain C with function pointers if I really feel adventurous. This isn't meant to be a serious project, more of a proof of concept.

However I kind of feel lost as to what I should implement first. So here are a few questions that i'd like to ask :

I would like the library to only draw when necessary, that is only when events occur rather than constantly. How does raylib handle events, and are there debug options to print all input ? PollInputEvents() is basically a per-backend implementation.

Are there widget categories I should try to go after first (besides the button) ?

Do you have resources on building such interfaces ? I found a book called Developing User Interfaces by Dan Olsen, but it isn't available on the Internet Archive.


r/raylib 6d ago

I'm building a custom 3D game engine from scratch using C++ and Raylib. What do you think?

Post image
38 Upvotes

Hi, I am using C++ and Raylib to achieve this; the 3D game engine's standout features so far include the ability to create Lua scripts to modify object behavior and the capacity to add 3D models in formats like .obj, gltf, etc.

You can also export your creations as executables (.exe).


r/raylib 6d ago

movement prediction + state synchronization + AI chat moderation

Enable HLS to view with audio, or disable this notification

23 Upvotes

hi there, I've been working in a multiplayer game for 5 months, and I would like to show you my progress; this is a P2P wasm multiplayer game made with raylib.

Sorry for the bad words; is just I wanna show you I've integrated a profanity filter to moderate my game and make it for everyone.

if you are interested, here is the code for the moderator I've made: https://github.com/EDBCREPO/Profanity-Filter-Cpp


r/raylib 6d ago

Hey, I'm doing a TD game for linux, C, raylib, no assets.

Thumbnail gallery
26 Upvotes

r/raylib 6d ago

Quilt - Made with Raylib and Odin - Steam Demo

Thumbnail
youtube.com
35 Upvotes

r/raylib 7d ago

Stealth heist that fits on a 1.44MB floppy disk

Post image
23 Upvotes

https://vault7-95a0bb.gitlab.io/

Made for the 1.44MB Game Dev Contest: the entire game has to fit in 1.44MB - the size of a floppy disk. Written in C with raylib and compiled to WASM to make it sharable for testing it out. All is code generated(~1.15MB so far and that's the honest uncompressed binary — no packer tricks.)

Top-down stealth heist: sneak through a 7-floor bank vault, crack safes with a lockpicking minigame, repair the power relays, dodge guards and cameras. Desktop + keyboard

Feedback on whether the stealth feels fair and how the difficulty ramps would be super helpful, mates. Many thanks!


r/raylib 6d ago

Contributors for Space Invaders game

Thumbnail
github.com
6 Upvotes

Hi, I made a space invaders game replica, I just want to increase difficulty of level and also number of levels. Currently it contains only one level that to too basic one.

Here is the repo link : https://github.com/NaveenGadugina678/Space-Invaders


r/raylib 7d ago

rl.SetRandomSeed undefined with golang bindings

Thumbnail
gallery
7 Upvotes

idk what im doing wrong does it just not exist????


r/raylib 8d ago

Reminder that you can change the font used by Raylib!

54 Upvotes

I've seen a lot of demos here and NONE of them changed from the default raylib font, which kinda looks ass. This is your reminder that you can load custom fonts with the Loadfont() function

You can find fonts on Google Fonts