GithubHelp home page GithubHelp logo

raylib-beef's Introduction

Raylib-Beef

raylib-beef is a Beef wrapper library for Raylib 3.7, a simple and easy-to-use library. In combination with the benefits of the Beef programming language, making games is pure satisfaction!

Attention! These bindings are still in development. Bugs may occur. You can download this library with binaries from the Release page!

OS Support is limited to Windows right now. I am only able test this library on Windows at the moment.




What is done

  • Bindings for:
    • raylib.h
    • raymath.h
    • rlgl.h (partly)
    • Easings.h

Important notes

  • there are no bindings for text manipulating methods
    • Beef already has custom methods for text manupulation
  • rlgl bindings are partly done

TODO:

  • Rewrite examples in Beef
  • finish rlgl.h bindings

Quick Start (using Beef IDE)

  1. Download raylib-beef.zip FROM RELEASE PAGE and extract raylib-beef folder from that zip file to: C:\Program Files\BeefLang\BeefLibs
  2. Right-click on your workspace and select Add from Installed and choose raylib-beef

  1. Add raylib-beef as a dependency of your project

  1. Write some code:
using System;
using static raylib_beef.Raylib;

namespace YOUR_NAMESPACE_HERE
{
	class Program
	{
		public static int Main(String[] args)
		{
			let text = "Hello from Beef! Hope you have a good day!";

			SetConfigFlags(.FLAG_WINDOW_RESIZABLE);
			InitWindow(800, 600, "Hello world");
			SetTargetFPS(60);

			while (!WindowShouldClose())
			{
				BeginDrawing();

				ClearBackground(.(52, 52, 52, 255));

				var x = (GetScreenWidth() / 2) - (MeasureText(text, 35) / 2);
				var y = GetScreenHeight() / 2;

				DrawText(text, x, y, 35, .LIGHTGRAY);

				EndDrawing();
			}

			CloseWindow();
			return 0;
		}
	}
}
  1. Profit!

Static linking

By default linking is set to dynamically link to Raylib. You can change that by selecting different raylib-beef project configuration in Workspace settings. You can select from DebugStatic and ReleaseStatic.

Then set your app project build properties to this:

More Examples

https://github.com/DerTee/raylib-beef-examples

More Info

Contribution

I'll be glad for any reported issues & pull requests

Notes

  • any contributions apart from bugfixes need to be placed in src/Extensions
    • this will separate additional helper functions from bindings
    • for example if you want to add some cool method for Vector3, you will create Vector3.bf in src/Extensions/Types and add that cool method to existing Vector3 type by using extensions statement

raylib-beef's People

Contributors

m0n7y5 avatar sockacc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

raylib-beef's Issues

Linux - Not Finding Raylib Beef

I am not sure if this is an issue with this library or Beef. No matter what I do I get:

ERROR: Type could not be found (are you missing a using directive or library reference?) at line 2:14 in /home/joseph/Documents/beef-game/src/Program.bf
using static raylib_beef.Raylib;
             ^^^^^^^^^^^

It seems like Beef cannot parse the library correctly. Here is a zip of raylib-beef inside of the example you provided with flags on my end: https://drive.google.com/file/d/1l1yKDCufm7vB8m8zG_ykqykLvpR4Qdza/view?usp=sharing

Here is the repo:
https://github.com/joseph-montanez/beef-game

git clone --recurse-submodules https://github.com/joseph-montanez/beef-game.git

Error in Type RenderTexture2D

Worked out there is an error in the definition of id in the RenderTexture2D type (at least on the Windows platform)

unit id; needs to be unit32 id;

The values of the member types are set incorrectly as it currently is.

Thank you.

Update to 4.5

Any chance to see an update to raylib version 4.5 soon?

add a License

Please add a License for these bindings.
Personally I would like MIT or Zlib.
(btw. Raylib uses the Zlib-License)

Statically linking, Dublicate Symbol error

There is a dublicate error regarding CloseWindow() in user32 and the fix for it does not work in the static build version of the project.
For debug there is a fix by simply specifiying x64DLL in the additional link flags instead of x64.
This does not seem to work for releasee though

Some notes for Linux

OK, so I decided to use this library with linux. But, as with many other things it didn't work right away. So, I've decided to write this as a note for others who might want to do the same.

  1. Install raylib (duh!)
    The binaries for raylib in the release don't work on linux. Luckily, raylib is quite easy to get-just follow the instructions here.

2)Get rid of Windows dependencies in the binding
There are 4 Windows.IntBool s in Types/PhysicsBodyData.bf. I replaced them with int32 to maintain the size of the struct, but this might have broken something in the physics system-NOT TESTED.

3)Add linker flags to the BeefProj.toml file of YOUR project - not the library.

[Configs.Debug.Linux64]
OtherLinkFlags = "$(LinkFlags) -lraylib -lglfw -lGL -lopenal -lm -pthread -ldl"

Adding this should solve any linker errors, and the project should now compile and run.

LoadImage / LoadTexture not working properly

Hi. Thanks for this project. I was playing around with it a bit, and noticed that methods related to texture and image loading aren't returning proper "Image" and "Texture2D" structs. I mean the methods LoadImage, LoadTexture, LoadImageRaw etc.

Texture loading works fine when loading models with LoadModel, but when trying to load image files directly the returned structs are populated with invalid data. I have checked to see if the structs defined on Beef side match with the Raylib, and they seem fine. Parameters passed to the function looks right too. So I couldn't understand what the problem might be. I hope you might have an idea.

Here is the returned Texture2D data :

tex_error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.