Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Eduard Engine 0.0.1  (Read 10589 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Eduard Engine 0.0.1
« on: September 05, 2012, 01:22:25 am »
Just a little something I've been messing around with during last month to brush my c++, SFML, Box2D and interfacing-all-of-them-together-into-easy-to-manage-structure skills.

Download (Wins32 Relase compilation):
https://docs.google.com/open?id=0B8dEkQw1a4WvZERTbmdDMDZoT2c

Choose to download entire .rar(File-download or press Ctrl+S), then unpack and run the exe.
I don't know what will happen if you remove some of resources, I tried to make checks for fstreams but I might have missed a spot.  :)

Corners that have been cut:
-Options and Load Game are placeholders  :(
-Click on these two buttons and background creates a floating text 'Test'  :)
-The menu buttons are plain images  :(
-Only thing that is implemented so far are tiles and terrain
-Tiles are ugly placeholders
-Game and Editor automagically load the testing map
-Algorithm to change editor data into box2d data is not too good but well abstarcted away so if I come up with better one I can convert map with new one using 3 command lines

Controlls:
-Editor is controlled by tilde to toggle console, command lines(full list in Resources/Main/EditorDictionary.txt), mouse for editing and escape and wasdqd for camera, it's better and safer to avoid it for the time being, I might write instruction
-Game is controlled by W S A D keys, press E to toggle Box2D debug draw

SFML part:
-Windowing
-Time control with clocks
-Input, rendering
-Extremely easy Box2d debug draw rendering with vertices
-Not using the default font altho I didn't upgrade to the latest version and still have it  8)

Box2D part:
-Everything physics related ie movement, collision, callbacks(currently only very few, for example the jumping sensor that allows jumping only from top of something solid)

P.S. No, my name's not Eduard.  ;)
P.P.S. I wonder if someone reached this point.  :-\
« Last Edit: September 12, 2012, 10:14:32 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: Eduard Engine 0.0.1
« Reply #1 on: September 05, 2012, 01:43:23 am »
P.P.S. I wonder if someone reached this point.  :-\

No, I stopped the line above, I was stunned when I learnt your name isn't Eduard :(

I haven't tried a lot the editor but I surprised myself enjoying the jumping little red square....

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #2 on: September 05, 2012, 01:47:07 am »
You better don't go into editor, it lacks any gui, I can only manage with what it has so far because I know the code behind.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Eduard Engine 0.0.1
« Reply #3 on: September 05, 2012, 01:54:18 am »
Hi Eduard eerhm FRex... ;D
Nice project! :)
I guess non programmers wouldn't understand what seems to be great about this, since it's very simplistic but the code behind it, is what counts atm. ;)

We're still missing a nice tutorial on how to glue SFML and Box2D together, so if you got some time... ;)

How do you render the tiles? Because from time to time I get white lines between them when moving around.

Keep up the work on the engine! :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #4 on: September 05, 2012, 02:07:15 am »
I use tiledmap class with chunks of 512x512(size is controlled by a constant in one of headers and 512 seemed like a good compromise between amount of draw calls and uneccesarry tiles getting rendered off view), engine renders only one that fall within current view, but I guess that has nothing to do with the problem. The lines actually come from sfml but I don't really mind. There is a position on my todo list 'wrap render window so that view get trunced to pixel perfect rendering' but I'm too lazy, it's like 20 lines of code, I might do it soon-ish.  :P

Quote
We're still missing a nice tutorial on how to glue SFML and Box2D together, so if you got some time...
I have like 6 months of c++, 1 year of extremely weak c(no free store, no string.h, no nothing) and 1,5 years of total programming background (delphi, borlands vcl) and almost no education except net and a bad, bad course (not even a book).
I used box2d for 2 monnths, sfml 2.0 for 2 months and sfml in total for 5 months maybe.
Do you still want me to write a tutorial. ;) (but I might)
However the old debug drawing class could work outside the box if I didn't delete it.(I checked, it's still there  :P)

Quote
I guess non programmers wouldn't understand what seems to be great about this, since it's very simplistic but the code behind it, is what counts atm.
I might post the code, I don't think I cussed in comments and they are kind of informative (but few) and explain purpose of class/header and variables and methods are not nammed like 'do_voodoo()' but rather 'GenerateTerrain()' and 'DumpIntoStream(std::ofstream& gstream)'
Also quite good class is the silent hero of the jumping - b2contactlistener derived class, it tells both objects: you collided with this guy and give each others pointer to them, currently all collision going on is between a static wall(that does nothing, ever) player(same) and jump sensor(count touching walls, if greater than 0 then it permits a push upwards('jump')) but all it takes is adding some new type of object to enum ,derieveing a class from interface from eeuserdata and declare virtual methods to react to type in whatever ways.
Oh.. but I'm reluctant because it's probably nooby design and execution.  :-[
« Last Edit: September 05, 2012, 02:28:39 am by FRex »
Back to C++ gamedev with SFML in May 2023

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: Eduard Engine 0.0.1
« Reply #5 on: September 05, 2012, 02:50:52 am »
We're still missing a nice tutorial on how to glue SFML and Box2D together, so if you got some time... ;)

Yeah, if someone around here have time to do a tutorial, it would be very apreciate=) Mixing the two isn't so hard, but mixing them well is not so easy...

I haven't notice those white lines, it sounds like a missing sf::Texture::setSmooth(true), no ?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #6 on: September 05, 2012, 11:02:03 am »
Quote
it sounds like a missing sf::Texture::setSmooth(true), no ?

That makes lines appear non-stop.
Quote
Mixing the two isn't so hard, but mixing them well is not so easy...
I have no idea really. I could post my old debug draw class, it's self explanatory, but so is (imo) everything.
Back to C++ gamedev with SFML in May 2023

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #7 on: September 05, 2012, 08:12:17 pm »
Here's ee's debug draw, slightly modified and commented, it's kind of quick and dirty, it's a debug tool after all, I hope I didn't make a mistake somewhere, it assumes you flipped the Y axis to match SFML's convention:
class EEDebugDraw3 : public b2Draw
{
private:
        sf::RenderTarget * m_target;
        //inliners for colour and point conversions
        inline sf::Color EEColor(const b2Color& gCol)
        {
                return sf::Color(static_cast<sf::Uint8>(255*gCol.r),
                                                static_cast<sf::Uint8>(255*gCol.g),
                                                static_cast<sf::Uint8>(255*gCol.b));
        }
        inline sf::Vector2f EEVector(const b2Vec2& gVec){return sf::Vector2f(gVec.x*pixmeters,gVec.y*pixmeters);}
        const float pixmeters,radegrees;//constants for point and degree conversions
public:
        EEDebugDraw3(void);
        virtual ~EEDebugDraw3(void){};
        void LinkTarget(sf::RenderTarget& gtarget);
        virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
        virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
        virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color);
        virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color);
        virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color);
        virtual void DrawTransform(const b2Transform &xf){};
};
#include "EEDebugDraw3.h"
EEDebugDraw3::EEDebugDraw3(void):
pixmeters(32.f),//arbitrary value dependant on the program needs
radegrees(57.2957795f),//degrees per radian,a physical constant
m_target(0x0)
{
        AppendFlags(static_cast<uint32>(~0));//set all drawing bits to 1(not all 32 are relevant but it's ok)
}
void EEDebugDraw3::LinkTarget(sf::RenderTarget& gtarget)
{
        m_target=&gtarget;
}
void EEDebugDraw3::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
        sf::ConvexShape shape;
        shape.setOutlineColor(EEColor(color));
        shape.setOutlineThickness(1);
        shape.setFillColor(sf::Color::Transparent);
        shape.setPointCount(vertexCount);
        for(int i=0;i<vertexCount;++i)
        {shape.setPoint(i,EEVector(vertices[i]));}
        m_target->draw(shape);
}
void EEDebugDraw3::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
        sf::ConvexShape shape;
        shape.setFillColor(EEColor(color));
        shape.setPointCount(vertexCount);
        for(int i=0;i<vertexCount;++i)
        {shape.setPoint(i,EEVector(vertices[i]));}
        m_target->draw(shape);
}
void EEDebugDraw3::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
{
        sf::CircleShape shape;
        shape.setOutlineColor(EEColor(color));
        shape.setOutlineThickness(1);
        shape.setFillColor(sf::Color::Transparent);
        shape.setRadius(radius*pixmeters);
        shape.setOrigin(sf::Vector2f(radius*pixmeters,radius*pixmeters));//set origin to middle or position setter below would not work correctly
        shape.setPosition(EEVector(center));
        m_target->draw(shape);
}
void EEDebugDraw3::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
{
        sf::CircleShape shape;
        shape.setFillColor(EEColor(color));
        shape.setRadius(radius*pixmeters);
        shape.setOrigin(sf::Vector2f(radius*pixmeters,radius*pixmeters));
        shape.setPosition(EEVector(center));
        m_target->draw(shape);
}
void EEDebugDraw3::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
{
        sf::Vertex line[2];//const sized c styled array, safe enough in here
        line[0].color=EEColor(color);
        line[0].position=EEVector(p1);
        line[1].color=EEColor(color);
        line[1].position=EEVector(p2);
        m_target->draw(line,2,sf::Lines);
}
Example:
{
        sf::RenderWindow App(sf::VideoMode(500,500),"Bug Draw");//window setup
        App.setFramerateLimit(60);//important because steps are linked to fps for this example,
        //construction and linkage to window
        EEDebugDraw3 debugdraw;
        debugdraw.LinkTarget(App);
        //construction and linkage to debug draw
        b2World world(b2Vec2(0.f,9.8f));
        world.SetDebugDraw(&debugdraw);
        //sample body
        b2BodyDef bdef;
        bdef.type=b2_dynamicBody;
        b2FixtureDef fdef;
        b2PolygonShape sha;
        sha.SetAsBox(1.f,1.f);
        fdef.shape=&sha;
        bdef.position=b2Vec2(4.f,0.f);
        world.CreateBody(&bdef)->CreateFixture(&fdef);

        while(1)
        {
                App.clear();
                world.Step(1.f/60.f,8,3);
                world.DrawDebugData();
                App.display();
        }
}
Back to C++ gamedev with SFML in May 2023

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #8 on: September 09, 2012, 02:48:50 am »
Small update to download in the first post(caused by me sharing last ee with eduard this evening and deleting the old one in the process ::) ):
:D There should be no graphical weirdness at all at this point ie. no white lines between tiles, sprite shouldn't shake like a jelly ect.
:D Red box got replaced by brick I used long ago for irrlevant things(hence 'Old_Resources' folder).. it's to test sprites movement(that werejerky before, red box was actually a retangleshape), it'll also appear to slightly face left or right when moving left and right
:D Options screen 'implemented' : ESC to quit, save and apply changes, click on 'Fullscreen' to switch between fullscreen and window, click on arrows to select one of resolutions(they should be valid, they are requested from sfml, not hardcoded), resolutions only apply to fullscreen, window is freely resizeable
:D Resources/Main/ResolutionSettings.txt, it's saved on pressing ESC in options screen and stores the resolution you picked, if the file is missing it'll be created and default to windowed mode
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Eduard Engine 0.0.1
« Reply #9 on: September 09, 2012, 07:50:22 am »
Nice! :-)

You are aware that forum has listing tags (list and li), so that a weired looking smilie listing isn't needed? ;D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #10 on: September 09, 2012, 07:18:17 pm »
Ya, ya, whatever.  ;) I hoped that you abuse the vertex display code again to see that the graphical artefacts are gone.  :D There was mini update a few hours ago, I forgot to add 'Renderer.setVerticalSyncEnabled(true)' before.
I may or may not add doors between maps and some other minor bulls**t in the next few days(most methods are ready, I just need to grab a bunch and make them cooperate).
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Eduard Engine 0.0.1
« Reply #11 on: September 09, 2012, 08:53:42 pm »
I just tested it again and the lines are gone and we've got a jumping wall, yey! ;D

Anyways I'm not sure if you already know that there's a bug which lets the wall get constantly draw one pixel too high. See attached image. ;)

[attachment deleted by admin]
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #12 on: September 09, 2012, 09:29:19 pm »
Thanks  ;)
https://docs.google.com/open?id=0B8dEkQw1a4WvVlhacXFlZER2MXc
Replace exe with this one and tell me if it's still there, if you could.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Eduard Engine 0.0.1
« Reply #13 on: September 09, 2012, 09:32:34 pm »
Yep it's gone. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Eduard Engine 0.0.1
« Reply #14 on: September 10, 2012, 01:00:43 am »
Two major bugs:
-Terrain generation script can bug out if there is a big chunk of terrain, it can be seen in debug draw in the game
-Removing terrain outside map bounds may cause acessing vector out of bounds, (I missed one -1 in code) :-[
Back to C++ gamedev with SFML in May 2023

 

anything