Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post Posted: August 1st, 2017, 8:24 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Ha, the only reason it's going quickly is I'm only doing enough to make a single test run work, but thanks for the encouragement, cheers.

I really need to add some error checking and logging. This will help in instances where either I fucked up or the person using the extensions does. Hopefully, it will help me find more bugs.

I'm trying to think of things you'd find in a 2D game engine.
Right now I'm thinking of giving a shot at some simple physics collision detection and correction, rects and circles. If that bombs, I'll just slap on some Box2D. That one will be a harder beast to fit in and make simple to use cause first I need to learn it myself.
2D path finding is another idea I had. I've wanted to add an A* path finding algorithm, but haven't gotten around to it yet.
2D skeletal animations for smoother animations with the ability to blend animations.
I want to add a system for setting way points and have objects follow that path. This would animate objects around the game map.
2D visual effects would be nice to add as well.

With all that I'm thinking of, once it's all said and done, I'll want to rewrite what I can to use SSE/AVX and/or C++Amp ( GPU processing ) to keep things moving along. That's still a long way off I suppose.

The first thing will be to fix the bugs and add error handling and logging. I don't want to add any more features right now. I'll never get back to refining anything if I keep adding stuff.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 2nd, 2017, 9:29 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Exceptions added to some of the setup code. Now if you pass in a file name for a bitmap and it can't be found, you'll get a popup window telling you that it couldn't be found and the name of the file. I put in some exceptions for insufficient memory allocations as well, haven't tested it to see if it works. I have tested the file not found exception though and it works.

Probably not as useful, but I also created a logger. It is setup to log the functions it enters and if an exception is throw not only do you get a PopUp window letting you know, you can check the TraceLog.txt file in the folder and see what the last function was that was entered. If everything goes well, the file is empty. If there is an exception thrown while loading images the file will list the functions it entered before the exception. The format of the function name is the signature of the function, except it doesn't show you the alias name for things. For instance, instead of std::string, you'll get std::basic_string<char, std::allocator> or something along those lines.

I made a base Logger class, so if you wanted to create your own Logging class, you could inherit from it. I haven't uploaded this stuff to GitHub yet, I still need to test and polish some things. I'm also experimenting with the font rendering stuff, like figuring out a good way to do word wrapping and vertical centering. It's going well so far.

I haven't gotten around to the sprite bugs yet. That will be next before finishing with the exception and logging stuff and before playing around with the text rendering.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 3rd, 2017, 6:42 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Oh...My...God!

Ok, so I couldn't figure out a good way of handling clipping sprites when drawing in reverse, so I just removed the drawing functions and made functions to clone a mirrored version, including one for the Frames class. Now you just have twice as many sprites or frames objects to keep track of, sorry lol. I've updated some of the demo code as well, including the Scene_Camera class. This was mostly for testing, but it's there also so you can see how one might handle stuff.

Everything I've done has been uploaded to GitHub under the master branch since this was mostly a bug-fix session. Fortunately or unfortunately, my exception and logging code is in there too, I forgot to make a new branch for that stuff.

I'm not too worried about extending the logging and exception stuff, so I'll move on for now.

I think the next thing I want to work on is a simple Text class that will do some text formatting.

I want to make screen size load from a file, this way if I make changes to Graphics and you have something besides the default 800x600 set it won't keep changing as stuff gets added or changed.

I thought about making this a library, but it relies too much on the structure of the Chili framework. It could still be done, and the only thing you'd bring to the table is your game ideas. This means in your solution, you would only have your game logic ( ex. Game, Player, Enemy files ) and the rest would have to be imported. If I go this route, I'll have to make a video on how to install/use it, so it will be a ways off.

Lately, I've realized that this has been a lot more fun for me than actually trying to make a game. Putting all my knowledge to use, just not in the way expected when I first started learning to code. Hopefully, someone takes advantage of this shit. Even if no one does, I'll have done something I've been wanting to do for a year or so. I don't know if a game will come from me, but who knows, I'm having fun anyway.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 3rd, 2017, 1:42 pm 
User avatar

Joined: February 14th, 2017, 7:32 pm
Posts: 170
I'm definitely taking advantage of all this :P


Top 
 Profile  
Reply with quote  
 Post Posted: August 3rd, 2017, 8:42 pm 
User avatar

Joined: February 14th, 2017, 7:32 pm
Posts: 170
Quote:
AnimationController m_animController( 1.f, m_stand );
m_animController = AnimationController( 30.f / 900.f, m_walk );

Pretty sure there's an error here, atleast I can't get it to work on my end.
I had to do the following:
Code:
AnimationController m_animController = AnimationController( 1.f, m_stand);

Maybe I screwed something up myself, but wanted to let you know just in case

Also, I'm getting build errors when doing the frames stuff. I don't get an error if I keep the following uncommented:
User.h (with #include "AnimatedSprite.h")
Code:
Frames SouthSprintingAnim = Frames(Frames::SpriteType::Alpha, 2, "Images/SouthRunning", ".png");
   AnimationController SouthSprintingAnimationHandler = AnimationController(0.5f, SouthSprintingAnim);

I have two images inside of Images/, called SouthRunning00 and SouthRunning01, both have an Alpha Channel. (But these are build errors, so this info doesn't matter)
User.cpp (with #include "User.h")
Code:
SouthSprintingAnimationHandler.Advance(dt);
         SouthSprintingAnimationHandler.Draw(DestRect, gfx);

(DestRect is constructed from User.h variables, isn't the error though, because DestRect is used in other instances too, without errors)

Game.h (with #include "User.h")
Code:
FrameTimer DrawFt;


Game.cpp
Code:
const float dt = DrawFt.Mark();
usr.Draw(gfx, dt);


Error
Spoiler:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\xmemory0(840): error C2280: 'std::unique_ptr<Sprite,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': attempting to reference a deleted function
1> with
1> [
1> _Ty=Sprite
1> ] (compiling source file Game.cpp)

A lot of notes after this too.

I probably made a stupid mistake somewhere, but it might also be because I still have an older version of the framework?


Top 
 Profile  
Reply with quote  
 Post Posted: August 3rd, 2017, 11:53 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Most of these resource classes, if not all, can't be copied. They can only be moved. I think that somewhere you have a
spriteA = spriteB when it should be
spriteA = Sprite( ... ) or
spriteA = std::move( spriteB );


If you can upload to GitHub, I'll take a look at what you have and let you know.

Thanks for letting me know about the AnimationController thing, I'll check it out.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 4th, 2017, 6:15 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Ok, I'm getting lazy so here is the commit message so I don't have to recall what I changed/added.

Quote:
Renamed TraceLog.h/.cpp to Logger.h/.cpp
Added Vec2f overloads for the Font::DrawString and Font::DrawChar functions for simplicity
Added FontSheet::GetCharHeight function, don't know why it didn't make it in ther to begin with.
Changed the Graphics::Rectify function to return a Recti and made it public.
Added a Graphics::Rectify function that takes a Recti for simplicity.
Added some demo code for the new Text class in Scene_FontRendering including a marquee/scrolling banner, a fps counter and a demo of vertical alignment with word wrapping.
Made some non-breaking changes to the Logging system. It actually helped me figure out a crash I was having, left that code in the Font::DrawString function. Only enabled when in debug mode.


Here's a scaled down version to fit chili forum
Image

original
http://i.imgur.com/ZJOfgwy.png This one isn't on my account so don't know if they expire.

PS, this one is in the TextFormatting branch on GitHub.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 4th, 2017, 6:44 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Some notes about the Text class.

It's not a string class

It's more a formatting class. When you create it, it uses a Text::TextLayout object you pass in to setup the string to be aligned vertically ( top, middle, bottom ) and/or horizontally (left, center, right ... sorry no justified ). Also, it handles tab spacing and '\n' new lines. For all EndOfLine behavior ( wrap, trucate or none ) new lines are discarded and a " new line " is added. For tabs '\t' it inserts spaces depending on what you set the tab spacing to in the Text::TextLayout.

Something I forgot to add to the commit message was, I added code for clipping the fonts when off screen partially and fully. I calculate where to start and end in the string based on the screen resolution set in Graphics.

I still need to check out the possible bug Zedtho pointed out, but I'm waiting for an upload to GitHub so I can see what's going on.

So right now I'm thinking about going back to the Particle stuff.

I also might work on path finding, but for that I'll need a grid. The grid will need to have passable and impassable cells to make the path finding relevant. I wonder how general I can be with this, I'll have to test top down and side scroll I suppose.

I'm also wondering about making a asset loader? I've seen someone on here use text files basically to load read in what assets to load and thought it was a good idea. I'd have to come up with a standard layout. This ties in the recent chili tutorial homework, which I didn't do. I haven't watched it yet either, and don't plan on until I give it a go.

This also goes back to wanting to keep screen res in a settings file as well. The constexpr would go away from Graphics stuff, but keeping it static would still allow access to that info. Just need to create a function to update that info if the screen res changes mid game like maximizing the window or resizing it.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 4th, 2017, 9:33 am 
User avatar

Joined: February 14th, 2017, 7:32 pm
Posts: 170
https://github.com/Zedtho/Attack-on-the-Forest
Should've updated the github in the first place, but here you go anyways!


Top 
 Profile  
Reply with quote  
 Post Posted: August 4th, 2017, 3:08 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Ok, the problem was a copy issue, but not what I was expecting.

In Game you try passing a User object by value ( a copy ). Looks like it's just an oversight cause I see you used a reference (&) on the PossiblyDamage function, but changing the User usr to User &usr let's it compile and run.
Code:
void PossiblyDamage(User& usr, std::vector<Entity>& Entities)
void HandleDeaths(User usr, std::vector<Entity>& Entities);


The odd thing is, the errors in the version you have. It just says trying to access a deleted function. However, when I copied the updated Sprite files to your project, intellisense told me right away where the error was, underlining the mistake in Game.cpp.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: