Giter Club home page Giter Club logo

angel2d's Introduction

Angel 2DBuild Status

Homepage: http://angel2d.com Documentation: http://docs.angel2d.com

Angel is a cross-platform 2D game prototyping framework based on OpenGL and C++.

It provides a broad set of basic game functionality in a lightweight fashion, and is designed to make it easy to get your game ideas up and running as quickly as possible.

Angel's main priorities

  • Provide all functionality in a quickly understandable way.
    • We try to avoid overly complicated programming techniques, even if that means sacrificing efficiency or, in some cases, functionality.
    • As far down the stack as we can manage, the code is plainly written and thoroughly commented. We expect people to modify the core engine in the course of their work, so we've tried to make that a manageable thing.
  • Provide as much functionality as possible.
    • Angel was originally created (and is still used) as an engine for game jams, and the last thing you want to be doing in a jam context is debugging the pathfinding code you had to cobble together.
    • If there's something big you feel is missing from Angel, please send an email to the discussion group. We can't add every feature, obviously, but we want to at least make sure there's nothing we're forgetting.
  • Allow an experienced developer to dive deeper.
    • Given the first two points, we create a lot of wrappers around third-party libraries, but we always make it simple to access the raw capabilities of those libraries. So if you know what you're doing, you can be making direct OpenGL calls or poking the Box2D physics simulation.
    • In short, we strive to keep our code relatively shallow -- it's always easy to find the code doing the actual work, so you're not slogging through multiple levels of OO redirection.

Getting Started

In addition to the Angel library itself, we've included two sample projects that serve as useful starting points.

  • IntroGame - a set of modular demos that show off specific bits of Angel functionality. Each demo also displays the relevant code or configuration files, so if you see something you like, you know where to find it.
  • ClientGame - a good point for you start your own game. It already has all its paths and includes set up properly, and a main function that initiates Angel with nothing in the world but a simple grid to help you place objects.

We've taken pains to make Angel work as well as possible out of the box, but there are some prerequisites for each platform, still.

Windows

  • You'll need some version of Visual Studio 2012 or later. Angel works great with Visual Studio Express, so you don't even have to spend money here.
  • You'll also need to install the DirectX SDK, or resign yourself to not being able to use a 360 controller. You can get the SDK from Microsoft's web site.
  • When you build your game in Release mode, a "Published" directory is created alongside the .vcproj file. This contains all the libraries, resources, documentation, etc., and is appropriate for zipping up for distribution.

Mac

  • You'll need the OS X Development Tools, available either from the Extra Installs disc that came with your computer (prior to Lion) or free from the Mac App Store. After you install Xcode, go to the Downloads section of the Xcode preferences and install the command line tools.
  • You need to either have MacPorts or Homebrew installed. Hopefully if you're a developer you've already got one of these systems that you like. Either one is easy to install.
  • Once you've done both of the above, you have a choice. Do ONE of:
    • Run the included script that will prep your system. Open the terminal, navigate to the Code/Angel directory, and run sudo ./nix-prereqs.sh
    • Do what that script is doing, manually:
      • Install SWIG.
        • MacPorts: sudo port install swig-lua
        • Homebrew: brew install swig
      • Install the kernel extension that exposes the 360 controller as a HID Input device. This extension is in Tools directory.
  • When you build your game for Archiving (or with any scheme with a Release configuration) it will create a "Published" directory alongside the project file. This contains the app itself, along with the documentation, ready for zipping and distribution.

iOS

  • Follow the same setup instructions for the Mac build. There's a separate Xcode project file for the iOS build.
  • There are some differences in building a project for iOS:
    • We only support loading PNG files as textures on iOS, so make sure to convert all your resources beforehand.
    • Because of the way iOS apps are structured, the main() function is taken over by the base engine. So take any setup that you used to do in main() and move it to the iPhoneMain.cpp file.
    • You can't set the resolution of the game -- it will always be the native resolution of the device. Note this may cause some differences between high resolution screens and traditional ones, so take this into account when doing any calculations about pixel distances.

Linux

  • Angel's tested on the latest releases of Debian, Ubuntu, and Fedora. It should work on other recent distributions as well so long as all the dependencies are installed.
  • If you're on one of those supported distributions, navigate to Code/Angel and run sudo ./nix-prereqs.sh to install all the prerequisites.
  • To compile, cd into either the ClientGame or IntroGame directory and simply run make. This will also build Angel and all its associated libraries if necessary.
  • FMOD (the default sound library used by Angel) sometimes has difficulties with autodetecting your audio subsystem. Because of this, by default we configure FMOD to use ALSA. If you do not wish to use ALSA, you can override the audio subsystem selection using an environment variable: FMOD_OUTPUTTYPE. The possible override choices are: AUTODETECT, ALSA, OSS, ESD, and NOSOUND. For example, to set the environment variable (if using the bash shell), use the following command: export FMOD_OUTPUTTYPE="OSS"
  • On certain processors, Angel applications may crash with "Illegal instruction" errors. This is likely due to the fact that the DevIL library in most distributions is compiled to use SSE1, SSE2, and SSE3 instructions. Some processors do not support these instructions and the program will crash. If you see this error, the recommended work-around is to download and compile your own version of DevIL. To disable all SSE instructions, add "--disable-asm" when using the configure script.
  • On Fedora systems, Angel and SELinux do not get along. Be prepared to create exceptions for your Angel programs or disable SELinux altogether.

FAQ

  • Why is it called "Angel"?

    • Because the original team was working at Electronic Arts in Los Angeles. It's a whole city of angels.
  • Why did you set up {X} that way? Don't you know it's faster if you...

    • Take a look at the top of this document and the goals we laid out there. Angel is designed to be easy to use and modify, not hyper-efficient.
  • You said the code was supposed to be easy to read, but some parts are really ugly. What gives?

    • Some of it gets a little sloppy. Cleanup is always ongoing. Also, some of the ease of use comes from deep magic.
  • Why make your own engine instead of using {MyFavoriteEngine3D}?

    • We initially explored lots of options, but couldn't find anything lightweight enough, focused on 2D, and in C++. As a bonus, it's kind of fun to make an engine.
  • Was Angel made from scratch?

    • Yes, but it was based on experiences using the Experimental Gameplay Project engine (which evolved into the 2D Boy engine), Unreal, Panda 3D, and some other engines. If you're familiar with any of these, you'll recognize some concepts and techniques.
  • Why C++? {C#/Erlang/D/Haskell} is the wave of the future!

    • We wanted a language that would match up well with the experience of most of the people at our studio at the time. When you only have a weekend to make a game, you don't want to have the language reference open in another window. Since then, that decision has proven to give us a lot of flexibility in porting to new platforms, and has kept the engine alive as other platforms have fallen away. ( :( RIP XNA)
  • What libraries are used in Angel?

    • OpenGL for rendering
    • FMOD or OpenAL/Vorbis for audio
    • Box2D for physics
    • FreeType2 and FTGL for text rendering
    • DevIL or libpng for image loading
    • GLFW for windowing and input
    • Lua for scripting
    • SWIG to bind the engine to Lua
    • Doxygen for HTML and PDF documentation

angel2d's People

Contributors

dejaime avatar elbeno avatar evanwalsh avatar sjml avatar swt2c avatar toumorokoshi 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  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  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

angel2d's Issues

Problems with hi-res / retina displays

I am using Angel2d on a retina macbook pro. Although Angel2d has some support for high resolution screens (an excellent feature in a cross-platform game engine!), there are some issues.

  • GWEN UI elements are drawn with incorrect sizesand, sometimes, at incorrect locations.
  • The mouse coordinates for picking the GWEN UI elements are significantly shifted from where they should be.
  • If a window is moved from a retina screen to a conventional screen, or vice versa, GWEN UI elements disappear entirely.
  • World::SetSideBlockers works incorrectly -- blockers exist but are far outside the window boundaries.

I will follow up with some thoughts on fixing these issues.

Screenshots from IntroGame:

gwenerr1

gwenerr2

Error in World::DrawDebugLines

In the function World::DrawDebugLines:

void World::DrawDebugLine(const Vector2& a, const Vector2& b, float time, const Color& color)
{
    DebugLine* line = new DebugLine();
    line->_points[0] = a.X;
    line->_points[1] = a.Y;
    line->_points[2] = b.X;
    line->_points[3] = a.Y; // <-- Should be b.Y
    line->_color = color;
    line->_timeRemaining = time;
    line->_bPermanent = (time < 0);
    _debugDrawItems.push_back(line);
}

You can see that the line line->_points[3] = a.Y; should be line->_points[3] = b.Y;.

I will submit a pull request with the fix momentarily.

float considered harmful

Angel2D uses float for it's floating point data type, for intermediate values, long term storage, and as a conversion medium. Unfortunately, float has significant disadvantages for all of these applications.

--- Support ---
All platforms that Angel2D supports have hardware support for float and double at roughly the same speed.
On x86/x64, SSE only supports 4 float's; however, SSE2 supports two double's, and has been available and standard since the Pentium 4.
On ARM (iOS, Android, Windows RT), double is supported on all available platforms, and is as fast as float. Only on new iPhone's with a NEON chip is float substantially faster, and usually only with use of intrinsics.
On PowerPC, the pipeline is designed for double; rounding to single is slower than using double exclusively.

--- Performance ---
On all platforms, long double is at least as big as double (and on linux/mac, is a true extended precision type), and only on PowerPC it is it slower than float or double.
PowerPC uses double double math; this is slightly slower (measurements indicate around 5%).

--- Hardware ---
On x86/x64, all operations actually occur in long double, internally.
On ARM, all operations occur in their specified type.
On PowerPC, all operations occur on double.

--- Intermediate Values ---
Not all numbers are directly representable in floating points.
If a number cannot be represented, an approximation is used.

Most operations on floating points result in an increase in digits.
ex. 10.5 * 10.5 = 100.25
If we only had 3 digits to store in, we would store 100.2, with an error of 0.05
Multiplication can lead to twice as many digits as we put in.
Transcendental operations (sin,cos,etc) can be much worse.

By using a larger type than we intend to store in, we keep as many significant figures as possible. Even if we round down at the end, using larger values for intermediates means no loss of significant figures.

Using float for everything means our result can have half as much precision as we started with!

--- Long Term Storage ---
OpenGL does not use doubles, but it often does not use float either; 24 bit floats are still common, and 16 bit "half"s were (and are) often used internally. Using float means inaccurate intermediate values to (possibly) avoid a double to single (or less) conversion to the "sink".

Furthermore, Lua uses double exclusively, and GLFW returns them regularly; many of the libraries do. Using float discards valuable precision from these "sources", resulting in substantially few significant figures to work with.

--- Conversions ---
Angel uses float as if it can safely store and restore an int. It cannot.

Single precision floating points have 24 bits to their significand.
int is 32 bits, 8 less than float can store.

Converting an int to a float is risky, and causes significant problems.

Double precision floating points have 54 bits in their significand.
They can easily store an int, signed or unsigned.
This is why lua uses double exclusively.

--- Recommended Changes ---
Use double instead of float where ever applicable
Use long double for intermediate values
Change Vector2/3 to use double
Directly use/copy lua values (instead of using userdata) for Vector2/3

--- Possible Alternative ---
Make a two float vector into a standard lua type. This would be possible with either default lua or luaJIT, and make Vector2 a first class Lua object.
Annotate Vector2 with intrinsics for speed.

--- Conclusions ---
The only reason float could possibly be preferred for use is because it is faster or smaller (and thus faster), but on any platform used by Angel it is not faster, much less safe, and requires large amounts of boilerplate to accommodate (adding f to constants is cumbersome and easy to miss).

As Angel is based on being understandable instead of performant, uses Lua as it's primary scripting language (which uses double exclusively), and uses C++ as it's main language (which makes all constants double), double should be the preferred type for floating points in Angel.

Bug in keyboard events using -Message in .ini file

The messaging system keeps sending key-release messages while a key is kept in pressed state.
How to reproduce:

  1. In a project, add a binding for any key in Config/input_bindings_ini, like this:
    SPACE: +MyKeyIsPressed
    SPACE: -MyKeyIsReleased
  2. In code, register a MessageListener for the messages
  3. Now when the game is run, press the key, eg SPACE but don't release it: you will receive the "MyKeyIsPressed" message once and infinite "MyKeyIsReleased" messages until the key is actually released, although the release message should only occur once when the key is actually released.

DrawGameText not working or text trans.

Hello,
When I want draw a text into game, its not working. Probably text transparent. How can I add color to text?

#include "stdafx.h"


int main(int argc, char* argv[])
{
    int windowWidth = 800;
    int windowHeight = 600;
    std::string windowName = "Pencere Ismi";
    bool antiAliasing = false;
    bool fullScreen = false;
    bool resizable = false;

    theWorld.Initialize(800,600,"Pencere Ismi");
    sysLog.Log("Game initialized");

    //adds the default grid so you can more easily place Actors
    theWorld.Add(new GridActor(), -1);
    sysLog.Log("Default grid added");

    //YOUR GAME SETUP CODE HERE
    RegisterFont("Resources/Fonts/Inconsolata.otf", 12, "Black12");
    sysLog.Log("Black font registered");
    DrawGameText("Tugay Torunok", "Black12", 50, 50, 45.0f);
    sysLog.Log("Text drawed");

    // do all your setup first, because this function won't return until you're exiting
    sysLog.Log("Game starting...");
    theWorld.StartGame();

    // any cleanup can go here
    sysLog.Log("Cleanup started...");
    theWorld.Destroy();
    sysLog.Log("Cleanup finished");

    return 0;
}

Out of the box build fails in VS Community 2015

Downloaded Angel 2D 3.2, opened up GameJam.sln in a fully updated Visual Studio Community 2015 on Windows 10 x64 bit and attempted to build the IntroGame. Received the following errors:

image

I had to do the following things to get IntroGame to build and execute properly:

  1. When opening the project for the first time I let Visual Studio update the compiler for the projects.
  2. In the Angel project, Infrastructure/Common.h at line 41 is the #include for hash_map, I add this line above it:
    #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
  3. Right click project _GLFW > Properties, in the new window I go to Configuration Properties > C/C++ > Code Generation and change Enable Function-Level Linking to Yes

At this point the build runs and the intro executes fine but there's still an error about not finding "stdafx.h" in Actor.cpp. At one point I was able to get rid of that but while reproducing my steps for this bug I can't seem to figure out what I did before. You can definitely get rid of it by adding an empty stdafx.h to the Angel project though.

I'm not a very experienced C++ dev so I don't know what side effects some of these changes might have. I'm just bringing this to somebody's attention so they can make the informed decision about what to do with these out-of-the-box errors.

SideBlockers assume non-rotated camera

World::SetSideBlockers() assumes the camera has zero rotation. If the camera is rotated (e.g. if it is locked to a rotating Actor and theCamera._lockRotation == true), the side blockers move with respect to the field of view, often entering the visible area and affecting the physics simulation.

This occurs because the blockers take Camera::GetWorldMinVertex and ::GetWorldMaxVertex to be the bottom left and lower right corners of the view, respectively. This property is only true when the camera is axis-aligned.

Not a big issue, but probably worth documenting.

Linux

In Intro Game the error WARNING: Can't add a null element to the World. Segmentation fault (core dumped) happens frequently especially once the file after "DemoScreenDefFile.cpp, demo_actors.lua" screen. Also in Client Game the message `OpenGL Error: invalid value' gets spamed out to console one time per second. Please take a look at this :)

Actor class added to world but not showing

I created an Actor Class and added to theWorld. But in scene, actor not showing.

// Game Manager's Init function
Character* character = new Character();
theWorld.Add(character);
#include "stdafx.h"
#include "Character.h"

Character::Character()
{
    SetPosition(-3.0f, 4.0f);
    SetDrawShape(ADS_Square);
    SetSprite("Resources/Images/character.png");
    SetSize(3.0f);
    SetName("Character");
    Tag("player, controllable");
}
class Character : public Actor {
public:
    Character();

        void Update(float dt);

        void Render();

private:
};

No Compile Error

How can I create Game Manager?

Hello,
I want use

theWorld.SetGameManager(???);

How can I create a Game Manager. I think I must create gameManagerGame.h and gameManagerGame.cpp. Whats I write into to gameManagerGame.h and gameManagerGame.cpp. Any example? I can't understand at IntroGame folder.

In Update Function "OpenGL Error: invalid value"

Hello,
I created game manager and i testing Update Function. But in console log this message logging.

OpenGL Error: invalid value
OpenGL Error: invalid value
OpenGL Error: invalid value
[...]

What is problem?

Main.cpp

#include "stdafx.h"
#include "theGameName.h"


int main(int argc, char* argv[])
{
    int windowWidth = 800;
    int windowHeight = 600;
    std::string windowName = "Pencere Ismi";
    bool antiAliasing = false;
    bool fullScreen = false;
    bool resizable = false;

    theWorld.Initialize(800,600,"Pencere Ismi");
    sysLog.Log("Game initialized");

    //adds the default grid so you can more easily place Actors
    theWorld.Add(new GridActor(), -1);
    sysLog.Log("Default grid added");

    //YOUR GAME SETUP CODE HERE
    theWorld.SetGameManager(&theGameName);

    // do all your setup first, because this function won't return until you're exiting
    sysLog.Log("Game starting...");
    theWorld.StartGame();

    // any cleanup can go here
    sysLog.Log("Cleanup started...");
    theWorld.Destroy();
    sysLog.Log("Cleanup finished");

    return 0;
}

theGameName.h

#pragma once

class theGameName
{
public:
    virtual void Start();
    virtual void Update(float dt);
};

theGameName.cpp

#include "stdafx.h"
#include "theGameName.h"

void theGameName::Start()
{
    RegisterFont("Resources/Fonts/Inconsolata.otf", 12, "Black12");
    sysLog.Log("Black font registered");

    Actor *player = new Actor();
    player->SetPosition(0.0f, 0.0f);
    player->SetDrawShape(ADS_Square);
    player->LoadSpriteFrames("Resources/Images/skeletonfront_001.png");
    player->PlaySpriteAnimation(0.2f, SAT_Loop, 0, 4, "SkeletonFront");
    player->SetSize(2.0f);
    sysLog.Log("Player actor created");

    theWorld.Add(player);
    sysLog.Log("Player added to world");
}

void theGameName::Update(float dt)
{

}

GridActor SetInterval does not actually do anything

I haven't looked at game engines in a while, so forgive me if this is not an actual issue. In the GridActor code, SetInterval just updates the _interval variable, but without recalculating points (a private function, so can't call outside) this doesn't really seem to do what it should be doing. Changing min and max coords calls RecalculatePoints, and so the does the constructor, which I understand I can just use that to start with but this seems like a break in functionality.

Doesn't support HiDPI displays

Hello! I was testing out Angel and I noticed the demos all look a bit pixelated on my retina MBP. Here's a screenshot (make sure you look at the full size):

Screen Shot 2013-04-09 at 22 09 20

Message::GetMessageType

In Message.h
///A templated class for delivering additional information with Messages
/**

  • This class lets you define your own message types that carry data with
  • them. For instance, if you wanted to create a Message that carried
  • a world location with it:
  • \code
  • TypedMessage *m = new TypedMessage("SomethingHappenedHere", Vector2(-3, -2));
  • \endcode
  • This gets sent through the Switchboard as just a pointer to the base class,
  • though, so your MessageReceivers will have to parse what it is from the
  • Message::GetMessageType function and cast it appropriately from there.
    */

The Message::GetMessageType function isn't implemented or declared anywhere it seems. Maybe I'm missing something.

Angel2D won't find GLFW

I'm doing my first steps with C++ and game development to build a simple prototype.

This would be more as a question because i'm not sure is an issue.

I've chosen Angel2D as framework to get some help from the beginning but I have problems to get it working with a simple Hello world! console message.

I've followed the installation instructions for Mac but it won't work properly.

My project structure is

/GamePrototype/test.cpp // the file I try to build
/GamePrototype/Angel    // Angel2D is inside this folder
/GamePrototype/Etc

If I try a file like this:

#include <iostream>
using namespace std;

int main() {
    cout << "Hello world!" << endl;
    return 0;
 }

Sublime Text opens it's console and shows Hello world! correctly.

If I just include Angel main file Angel.h to the file like this

#include "Angel/Angel.h"
#include <iostream>
using namespace std;

int main() {
    cout << "Hello world!" << endl;
    return 0;
}

It throws this error:

/Angel/Actors/../Infrastructure/../Util/../Infrastructure/Common.h:94:11:
fatal error: 'GLFW/glfw3.h' file not found
    #include <GLFW/glfw3.h>
                  ^

The file is probably located in /GamePrototype/Angel/Libraries/glfw-3.0.3/include/GLFW/glfw3.h

Probably it's just a base knowledge of C++ and how to build projects, what's wrong with the OpenGL library?

It seems like it's just trying to load the library in the wrong place, but I can't believe the release is broken.

Networking Support

Has anyone started developping networking stuff yet? If not, I'd start it with Raknet. http://www.jenkinssoftware.com/
It's free for non-commercial games on Windows, Mac, Linux, Android, Windows Phone 8, and IOS. See here: http://www.jenkinssoftware.com/pricing.html I think that fits the needs for game jams.
It also has a GitHub Repo: https://github.com/OculusVR/RakNet

My ideas are: basically get a functionality like in Unity3d. We will need something like a connection manager. We need an easy way to synchronize (physics-) actors. We need a way to call special functions on "the other side".

Any hints for how to do this? I've never done such a thing so help is appreciated.

Is the project active?

Hi angel2d developer team.

I very like your framework and I want to write own game engine. I was looking classes of the engine and your codes looks like very clean. I can understand how the engine works. I know It's not easy and the project is amazing.

I hope you still update the engine? And do you think to add android option in the future?

Thank you.

can't open in-game console

Hi,

I have a different keyboard layout (german). Probably that is also the main reason, why I can't open the in-game console. It would be very helpful if the key to open the console was configurable.

(ubuntu build)

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.