Coder Social home page Coder Social logo

bee2d's Introduction

Bee2D

Bee2D is a semi-barebones 2D game engine integrated into Roblox. Simply download the repo and run the default.project.json with Rojo to clone it into your game. Additionally, you can add it straight into your game with the model below: https://www.roblox.com/library/12159480029/Bee2D

Discord Server: https://discord.gg/ptNSRYcvr9

Getting Started

Bee2D has a bit of a learning curve, but once you get into it, it's extremely simple. To start out, simply require the Main and Engine modules from Bee2D like so:

local Engine = require(Services.ReplicatedStorage.Bee2D.Engine)
local Bee2D = require(Services.ReplicatedStorage.Bee2D.Main)

From there, there's a couple of built-in functions you can set up.

Engine.BindToUpdate("Name", function(deltaTime)
	-- This will allow you to bind functions to the update calls of the engine. 
	--Engine.Update(deltaTime) runs every frame.
	-- The first argument, "Name", is what you will use to unbind the function.
end)

Engine.BindToDraw("Name", function()
	-- This will allow you to bind functions to the draw calls of the engine. 	
	-- Engine.Draw() runs every frame after Engine.Update() is called.
	-- The first argument, "Name", is what you will use to unbind the function.
end)

In order to unbind these functions, it's as simple as running the following:

Engine.UnbindFromUpdate("Name")
Engine.UnbindFromDraw("Name")

This engine runs with modules called Scenes. Scenes have their own Start, Update, and Draw functions which are called with the Engine. To set up your scenes, simply make a folder for them and load them with the following:

Engine.LoadScenes(ScenesFolder)

A scene is set up like such:

-- First you want to include the Scene module, as it sets up the class for you to use.
local Scene = require(ReplicatedStorage.Bee2D.Components.Scene)

-- Then you can set up your Scene like such:

local YourSceneName = Scene.new()
YourSceneName.Prioritize = true -- This will make this scene the current active scene when it is loaded. This means that it will be displayed immediately.

function YourSceneName:Start()
-- This will run once when the scene is loaded.
end

function YourSceneName:Update(deltaTime)
-- This will run every frame.
end

function YourSceneName:Draw()
-- This will run every frame after Update, and is used to render images and geometry.
end

Bee2D's Main module also has some neat functions for you to use.

function Bee2D.DrawFPS()
-- Displays the FPS on screen in the top right corner.

function Bee2D:SetFullScreen(boolean)
-- Will make the window take up the entire screen.

function Bee2D.DrawImage(texture: string, position: Vector2, rotation: number, scale: Vector2, tint: Color3)
-- Will draw an image on screen given the texture (roblox image link).

function Bee2D.DrawRectangle(posX: number, posY: number, width: number, height: number, color: Color3)
-- Will draw a rectangle on screen given a position, width, and height.

function Bee2D.DrawRectangleEx(posX: number, posY: number, width: number, height: number, rotation: number, color: Color3)
-- Will draw a rectangle on screen same as above, but includes rotation.

function Bee2D.DrawText(text: string, posX: number, posY: number, color: Color3, font: Enum.Font, size: number)
-- Displays text on screen

function Bee2D.DrawLine(lineStart: Vector2, lineEnd: Vector2, width: number, color: Color3)
-- Draws a line on screen given a start and end. May be buggy.

function Bee2D.DrawCircleLine(posX: number, posY: number, radius: number, color: Color3)
-- Draws a circle out of lines.

Actors

Actors are more advanced objects that are displayed in a scene. Actors also have a Start, Update, and Draw function that can be overriden. These functions are run when you add the actor to a scene like such:

local Actor = require(ReplicatedStorage.Bee2D.Components.Actor)
local Sprite = require(ReplicatedStorage.Bee2D.Components.Interface.Sprite)
-- Sprite class is used to display the actor

local Player = YourSceneName:AddActor(Actor.new("Player",  Sprite.new(Color3.new(1,1,1), "imagelinkhere")))

Additionally, actors can be moved, scaled, and rotated by their Transform properties, and also can be given collision.

Player.Transform:SetLocalPosition(Vector2.new(1,1))

More information regarding Transforms can be seen below.

Transform

WIP

bee2d's People

Contributors

solodeveloper avatar thegalaxydev avatar

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.