Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Going insane trying to add a simple state manager

Author
Message
gh0sted
7
Years of Service
User Offline
Joined: 19th Jun 2016
Location:
Posted: 19th Jun 2016 02:30
I'm working in C++, and I've gotten the template to work for me and run showing the FPS.

Now I've followed a simple tutorial on creating a game state manager (http://staniks.github.io/tut_01.html). But I can't for the life of me figure out how I can use that with the template. I think it's more of a Visual Studio issue than an AppGameKit issue?

I believe all I need to do is make the template project load this main.cpp file instead of the template.cpp but I have no idea how to change that. Any ideas would be much appreciated!

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Jun 2016 00:37
I use a series of state machines in my WIP in C++.

It would help to see your code.

Part of the trick in Tier 2 is understanding a key difference in how the Sync() command works in Tier 2 vs Tier 1. In Tier 1 you can use the command anywhere and it will process all input (user/keyboard/device) and output. In Tier 2, inputs are grabbed only once at either the beginning or end of the app::Loop() method (I don't know which). Outside of the app::Loop() the Sync() command only updates display stuff and physics.

This is what my template.cpp file looks like:


As you might notice, this is set up to compile in multiple environments.

In the _AS_MAIN_PLAY_ state, the function mainProcessingLoop() is called to get the state for the game playing. mainProcessingLoop() is defined in my game_functions.cpp file (which is 2495 lines long, so I am not posting that here).

I am attaching a simple state machine demo I did a while back. It doesn't include the AppGameKit core files, just the ones that I wrote for the demo. It shows a simplified version of what I do in my WIP.
Cheers,
Ancient Lady

Attachments

Login to view attachments
gh0sted
7
Years of Service
User Offline
Joined: 19th Jun 2016
Location:
Posted: 21st Jun 2016 03:12 Edited at: 21st Jun 2016 18:25
I'll look through that code and your attached zip and see if I can figure out what I need to do! Thank you for those leads!

My problem is that the template comes with the being/loop/end functions built in and I'm having a hard time understanding how I can get rid of that. If I delete those functions I get errors when I compile, but I was trying to avoid having all the logic in one loop (even if it's calling functions from another file). It just seems neater to me to have a different loop for each state. But I'll go with this way so I can get up and running.

If I was able to just include the AppGameKit library to a completely blank project without these included functions I think I'd be set, but I'm not familiar enough with C++ and Visual Studio to figure out how the hell to do that haha. I'm very well versed in Java and PHP, but Visual Studio is confusing the hell out of me.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Aug 2016 22:40
I am sorry this has taken so long to reply. My real-world job has had me quite busy.

You cannot get rid of the begin/loop/end methods. They are how the AppGameKit engine works. And you have to code within them.

The app::Loop() method is how AppGameKit handles basic functionallity. My example actually has only a fraction of the logic in that method. And all of it could be put in a different file in some function and that function called in app::Loop(). In my poor WIP (no time for it, either), the code in the main template.cpp file looks much like what I pasted as an example. And it is a tiny fraction of the code in the project.

The libraries build for Visual C require that those methods exist. If they aren't there, as you discovered, at a minimum it won't compile.

If you aren't familiar with C++, that does make it a bit more difficult.

And, starting from a blank VS project would handicap you greatly trying to get it all working with AGK. The templates usually start with all the right files, library includes and settings and such.

Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-03-29 04:47:16
Your offset time is: 2024-03-29 04:47:16