{"id":20257140,"url":"https://github.com/oechsler/baresharp","last_synced_at":"2025-11-29T23:02:14.816Z","repository":{"id":116522555,"uuid":"87801364","full_name":"oechsler/BareSharp","owner":"oechsler","description":"🖼2D sprite framework, living ontop of MonoGame.","archived":false,"fork":false,"pushed_at":"2018-11-11T11:10:41.000Z","size":2534,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T18:58:40.583Z","etag":null,"topics":["gameengine","lua","monogame","sprites"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oechsler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-10T11:06:23.000Z","updated_at":"2022-02-13T05:15:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"c5ff1ad6-771d-437d-b8c4-0d92f25187f8","html_url":"https://github.com/oechsler/BareSharp","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/oechsler/BareSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oechsler%2FBareSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oechsler%2FBareSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oechsler%2FBareSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oechsler%2FBareSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oechsler","download_url":"https://codeload.github.com/oechsler/BareSharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oechsler%2FBareSharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27368892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-29T02:00:06.589Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gameengine","lua","monogame","sprites"],"created_at":"2024-11-14T10:49:33.133Z","updated_at":"2025-11-29T23:02:14.768Z","avatar_url":"https://github.com/oechsler.png","language":"C#","readme":"*Since this has been a project for school, it won't get updates in the future! \n\u003cbr /\u003eNevertheless feel free to use the code in you're own projects.*\n\n# Getting Started\n\nFor further information on the MonoGame framework, please do checkout their [documentation](http://www.monogame.net/documentation/?page=main).\n\u003cbr /\u003eThis guide assumes that you already know how to work with MonoGame's content pipeline.\n\n### General setup\n\n1. Import Bare's shared project into your Visual Studio solution.\n2. Link the shared project with your executing MonoGame project.\n3. Link a version of [MoonSharp](http://www.moonsharp.org) with your executing project or define a `NOSCRIPT` preprocessor flag.\n\n### Entrypoint\n\nIn order for Bare to run, you need to replace the default `Game1` class with Bare's Entrypoint. The Entrypoint can also be customized to fit your needs by overriding it. *It is highly recommended that you create your own Entrypoint, when using C# to code.*\n\n~~~cs\nusing BareKit;\n\npublic class Program\n{\n\tpublic static void Main(string[] args)\n\t{\t\n\t\tusing (var entrypoint = new Entrypoint())\n\t\t\tentrypoint.Run();\n\t}\t\n}\n~~~\n\n### Scripting\n\n*Bare uitilizes [MoonSharp](http://www.moonsharp.org) to implement the Lua scripting language. It is intended that you use Lua for scripting your games. But because Bare's API is written completly in C# and translated to Lua during runtime, you may use C# aswell for more advanced scripting or due to personal preference.*\n\n* *Known caveat: the integrated [Glide](https://bitbucket.org/jacobalbano/glide) tweening engine is not accessible through Lua. [Tween.lua](https://github.com/kikito/tween.lua) is used instead and can be accessed via `tween`.*\n* *Object oriented scripting is possible with the embedded version of [30log](https://github.com/Yonaba/30log), accessible through the `class` field.*\n\nUserdefined Lua scripts by deafult are located in the `Scripts` subdirectory of your project and need to be marked as `Embedded resource` in Visual Studio. *For changing the default directory please have a look into Bare's Entrypoint class.*\n\nTo enable Lua scripting create a file in the `Scripting` directory, name it `main.lua` and mark it as `Embedded resource`.  Just add the following lines of code to it and you are done.\n\n~~~lua\nfunction bare.start()\n\tprint(\"Ready.\")\nend\n~~~\n\n*When executing, this should print out* `Ready.` *in Visual Studio's output window.*\n\n### Callback functions\n\n###### bare.start\n\n~~~lua\nfunction bare.start()\n\t-- Creates a scene and navigates to it\n\tlocal scene = init(bare.scene)\n\tbare.stage.navigateTo(scene)\nend\n~~~\n\n*This function gets called once, when Bare is started. This is usually where you load your scenes and setup things specific to your game. You may want to do these things somewhere else, but doing them here ensures that they're only done once and therefore saving a lot of system resources.*\n\n###### bare.update\n\n~~~lua\nfunction bare.update()\n\t-- Increments `number` by `1` per second.\n\tnumber = number + 1 * bare.delta\nend\n~~~\n\n*This function is continoussly called before rendering a frame. Probably this is where all your logic is done.* `bare.delta` *is the so called delta time. It is the amount of time in seconds since the last time this function was called (usually a small value). Due to the event driven nature of the Bare framework (each scene has its own update event), the delta time can be accessed via a variable.*\n\n###### bare.config\n\n~~~lua\nfunction bare.config(e)\n\t-- Sets the window size\n\te.scaling = init(bare.scalingManager, e.graphics, e.window, init(bare.vector3, 950, 16, 9), 1)\n\t-- Disables rendering the cursor\n\te.isMouseVisible = false\nend\n~~~\n\n*This function is called before the window is created and therefore allows you to make a change to the default size of 720x506 in the way indicated above. Other things like for example mouse visibility are configurable aswell.*\n\n### Standard library\n\nBare's Lua interpereter contains most of the standard functions. Beyond that there are a few important functions for registering and allocating objects from the underlaying C# context.\n\n###### alloc\n\n~~~lua \n-- definition\ntypedef = alloc(className, assemblyName)\n-- example\nvector2 = alloc('Microsoft.Xna.Framework.Vector2', 'MonoGame.Framework')\nmyClass = alloc('MyNamespace.MyClass', _DEFAULT)\n~~~\n\n*This function allocates C# classes to the Lua scripting context. When allocating from your executing assembly, you can simply use `_DEFAULT` instead of specifing the assembly name.*\n\n###### dealloc\n\n~~~lua\ndealloc(typedef)\n~~~\n*This function is the counterpart to alloc (use this function carefully).*\n\n###### init\n\n~~~lua\n-- definition\ninstance = init(typedef, arg1, arg2, ...)\n-- example\nscale = init(vector2, 2)\nscale.x = 2.5\nprint('Current scale: ' .. scale.toString())\n~~~\n\n*This function instanciates C# objects inside the Lua scripting context. Methodes and fields of the respective objects can be accessed the same way as in C#, but always need to start lowercase. To initiate garbage collection of an instance simply set its userdata reference to a `nil` value.*\n\n###### static\n\n~~~lua\n-- definition\nreference = static(typedef)\n-- example\nstream = static(storage).read(\"example.txt\")\n~~~\n\n*This function references static C# class methods inside the Lua scripting context.*\n\n###### enum\n\n~~~lua\n-- definition\nreference = enum(typedef)\n-- example\nbackground = enum(color).cornflowerBlue\n~~~\n\n*This function references C# enums inside the Lua scripting context.*\n\n###### Drawables\n\n~~~lua\nbare.container        -- Container drawable.\nbare.label            -- Text-label drawable.\nbare.rect             -- Rectangular drawable.\nbare.scene            -- Scene for rendering drawables.\nbare.sprite           -- Sprite drawable.\n~~~                           \n\n###### Interfaces\n\n~~~lua\nbare.streamReader     -- System.IO.StreamReader.\nbare.streamWriter     -- System.IO.StreamWriter.\nbare.storage          -- Interface for acessing the filesystem. \nbare.database         -- Interface for storing persistent values.\nbare.shader           -- Interface for using shaders.\nbare.sound            -- Interface for playing sounds.\n~~~\n\n###### Inputs\n\n~~~lua\nbare.gamepadInput     -- Interface for handling gamepad input.\nbare.keyInput         -- Interface for handling keyboard input.\nbare.touchInput       -- Interface for handling touch/mouse input.\n~~~\n\n###### Datatypes\n\n~~~lua\nbare.color            -- Three/Four dimensional color vector.\nbare.rotatedRectangle -- Rotatable, rectangular shape.\nbare.timeSpan         -- System.TimeSpan.\nbare.vector2          -- Two dimensional vector.\nbare.vector3          -- Three dimensional vector.\n~~~\n\n###### Enums\n\n~~~lua\nbare.blendMode        -- Enums for different color blend modes.\nbare.finger           -- Enums for different fingers.\nbare.inputState       -- Enums for different input device states.\nbare.keys             -- Enums for different keys.\n~~~\n\n*For furter information on how each of the modules work, please have a look at it's respective class definition. Each method and field of the module has a short documentation attached to it.*\n\n### Examples\n\n###### Displaying a sprite\n\n*The sprite already has to be imported into MonoGame's content pipline. Also make sure that your sprites and fonts have a scale definition assigned. This is done by adding a `_nx` suffix to the filename. So if you have got a sprite called `banana.png`, the name for the standard size would be `banana_1x.png`. The Scaling sizes have to be of the integer type and a standard size must always be provided.*\n\n##### main.lua\n~~~lua \nlocal scene = require \"scene\"\n\nfunction bare.start()\n\tbare.stage.navigateTo(scene)\nend\n~~~\n\n##### scene.lua\n~~~lua \nlocal scene = init(bare.scene)\nlocal sprite = nil\n\nscene.entered.add(function(self)\n\tsprite = init(bare.sprite, self.content, \"banana\")\n\tself.addChild(sprite)\nend)\n\nreturn scene\n~~~\n\n###### Handling input\n\n##### scene.lua\n~~~lua\nlocal scene = init(bare.scene)\nlocal keyEvent = nil\n\nscene.entered.add(function(self)\n\tkeyEvent = init(bare.keyInput, enum(bare.inputState).pressed, enum(bare.keys).k)\n\tkeyEvent.triggered.add(function(sender)\n\t\tprint(sender .. \" triggered the event.\")\n\tend)\n\tself.input.addChild(keyEvent)\nend)\n\nreturn scene\n~~~\n\n###### Playing a sound\n\n*The sound already has to be imported into MonoGame's content pipline. Also make sure that you have `SoundEffect` selected as importer, otherwise the sound will not be playable (and an exeption will be thrown).*\n\n##### scene.lua\n~~~lua\nlocal scene = init(bare.scene)\nlocal sound = nil\n\nscene.entered.add(function(self)\n\tsound = init(bare.sound, self.content, \"banana_squash\")\n\tself.sound.addChild(sound.play())\nend)\n\nreturn scene\n~~~\n\n### License\n\n*Copyright © 2017 – Samuel Oechsler*\n\n**Modified version of Zlib.** \n*This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a comercial product, an acknowledgment in the product documentation is required. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. This notice may not be removed or altered from any source distribution.*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foechsler%2Fbaresharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foechsler%2Fbaresharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foechsler%2Fbaresharp/lists"}