Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411126 Posts in 69302 Topics- by 58376 Members - Latest Member: TitanicEnterprises

March 13, 2024, 02:27:33 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
  Show Posts
Pages: 1 2 [3] 4 5 ... 14
41  Community / Tutorials / Re: Quick art for programmers: Make a sprite in 15 minutes on: November 19, 2014, 03:48:02 PM
I just love it. So funny.
42  Developer / Technical / Re: Item Systems on: November 19, 2014, 01:00:26 PM
depends on what you want to do. Eg in diable items are totally different than in Zelda. Diable has a huge amount of items that are all basically the same. Equipment that changes your stats. While in Zelda you have much less items, but they are much more different.
43  Community / DevLogs / Re: Dungeon crawler game with 3D graphics. on: November 18, 2014, 02:31:28 PM
Say it to any fps developer, that Doom already exists Wink

You like Legend? Did you know that it's modeled on Dungeon Master, Eye of the Beholder and other 'legendary' games? LoG some of it's riddles have almost identical to those of DM, but of course you did not know about that Wink
Actually I did know that. I even have a big cardboard box that has "Dungeon Master II" written on it. I did not play Dungeon Master one that much, but I saw videos, and hell yes it is extremly similar.

What I meant in my original post was the description was like it was just like Legend of Grimrock (or Dungeon Master) without actually quoting it as a reference. If this game would be described as a Legend of Grimrock demake I would be perfectly happy.

So back to the game. I would like to have a comparison to what you are actually building on. And what you are planning to improve on. Or if it is just for you to master your programming skills without actually improving on anything gameplay wise, it is totally fine.
44  Community / DevLogs / Re: Forgettable Dungeon ( Online Multiplayer Roguelike ) on: November 18, 2014, 08:15:39 AM
I like the concept of an online zelda with silly voxels
45  Community / DevLogs / Re: In the shadows | Platform and puzzles on: November 18, 2014, 08:12:34 AM
The art style reminds me of Fez. But I really like the fireflies and the foreground layer. But to make it correct you also need to make the stars blurry. But I am not shure if I would like that
46  Community / DevLogs / Re: Dungeon crawler game with 3D graphics. on: November 18, 2014, 08:07:37 AM
Sorry to say this, but Legend of Grimrock already exists.
47  Developer / Playtesting / Re: Bean Farmer Pinball (beta 2) on: November 04, 2014, 08:36:54 AM
pleas take out the linux logo if you have no release for it.
48  Developer / Playtesting / Re: INJECTION - Untrusted, but in Python and not as good on: November 04, 2014, 08:35:45 AM
please either come with a binary (for all platforms) or give a build that works out of the box for non python programmers.
49  Community / Creative / Re: Development Without Programming on: October 28, 2014, 01:19:39 PM
find a team that does the programming and get hired for being very talented in art. Not everybody needs to be involved in everything in game development. But not being able to program even disqualifies you as a level designer, because many games require level scripting. So learn at least something.
50  Community / Creative / Re: What makes a game a game? on: October 28, 2014, 01:14:52 PM
I've read a definition about game, that requires two competing teams against each other. But that definition is from before the age of computer games.
51  Community / Tutorials / Re: Minimal GUI (in lines of code) on: October 26, 2014, 12:00:06 PM
thank you for your feedback. So in case you want to adapt this to your game, don't hesitate to ask questions.
52  Community / Tutorials / Re: Html UI with OpenGL and C++ on: October 23, 2014, 01:26:48 PM
the link is broken.
53  Community / Tutorials / Minimal GUI (in lines of code) on: October 23, 2014, 01:10:59 PM
Do you know this?: Your current game project needs a GUI, and then you check out for what is available out there and nothing really suits your needs. They are either way to complicated and lack of documentation (TWL), or they are super easy to integrate, but are only meant for debugging purpose and therefore to ugly for the final Product (AntTweakBar). Then you decide to make your own GUI and you want to do it right, so that you can use it for all your later projects (which you probably won't). And then writing the GUI system takes way to much resources from you and in the end you don't have a game, just a GUI. At least I do know projects that ended up like this and I even worked in one of them (it died).

So here is a tutorial on how to write your own GUI in a minimal way, so that your GUI ends up to be only a few lines as it should be. First of all it is important to understand, that less is more. People don't want to spend their time in a GUI, and you don't want to spend time developing the GUI. Good games don't even have a GUI.

This tutorial will cover code snippets that are written in C++ with SDL2. But it should be possible to adapt this to anything that you are using.


So first let's start with an example of what we would like to achieve:

sorry for jpeg quality, couldn't find anything better for now.

This game doesn't have much more in menus than a list of selectable items, and sub menus. Really that's it. Ok there are sliders in the options, but let's concentrate on the real important stuff here.


So let's first talk about our desired behavior of the menu. Menu items can be selected, and in case the items call a another menu it is possible to go back to the previous menu by selecting back.

For this behavior it is easiest to have a stack of menus, and always render the top menu. Like this it is super easy to always be able to go back. So from now on let's call the entire stack the menu, each element in the stack sub menu and each item in the sub menu we call menu item. So even the main menu is a sub menu in this definition.

So our menu is a stack of a list of menu items. In c++ std::vector is suitable for both, the stack and the list.
To make things pretty, we wrap our std::vector in nicely named classes Menu SubMenu and MenuItem.

Code:
class SubMenu {
  protected:
    std::vector<MenuItem> entries;
    [...]

  public:
    SubMenu() : entries(), sizes(), selected(0) {}
    SubMenu(std::vector<MenuItem> entries) : entries(move(entries)), sizes(this->entries.size()), selected(0) {}

    [...]
};

class Menu {
  protected:
    std::vector<SubMenu> menuStack;

  public:
    Menu() {}
    Menu(SubMenu menu) { menuStack.push_back(menu); }

    SubMenu& Current() { return menuStack.back(); }

    bool PopMenu() {
        menuStack.pop_back();
        return menuStack.empty();
    }

    void PushMenu(SubMenu menu) { menuStack.push_back(std::move(menu)); }

    [...]
};

So far we have not talked about the menu items. We could implement every MenuItem with an Effect Method, that does it's effect. But I have an alternative here with quite some advantages. Let's assume you have some base main class with a main loop that knows all your game world and state. We implement each effect of the menu items as methods in this class. Now we can simply implement all our desired effects, because we can simply access the game world or the menus or whatever we want to access. For example Quit sets the variable running on false, so that the main loop ends.

Code:

class GameObject {
  protected:
    Menu menu;
    World world;
    bool running;
    [...]
  public:
    GameObject(...);
    [...]
   
    //menu item actions
    void CallStartMenu();
    void CallIngameMenu();
    void StartGame();
    void SaveGame();
    void LoadGame();
    void ReturnToGame();
    void Quit();
    void ResetGame();
    void Screenshot();

    void MainLoop();
};


This also allows us to access all menu item effects from wherever we want as long as we have a reference to the GameObject. For example if we want to bind a hotkey to SaveGame, we can simply do it, without knowing any object of MenuItem.

now this is all that is left in a menu item:
Code:
typedef void (GameObject::*EffectMethod)();

struct MenuItem {
    const char *Text;  // you can also use std::string here if you prefer that
    EffectMethod EffectMethodPtr;
    MenuItem(const char *Text, EffectMethod EffectMethodPtr)
        : Text(Text), EffectMethodPtr(EffectMethodPtr) {}
};
in case you haven't seen it before, EffectMethod is a typedef for a pointer on a method of the class GameObject with zero arguments returning void. It is like a function pointer, but for methods instead of functions. To call them you always need an instance of GameObject.

Here an example of how menus can be populated:
Code:
void GameObject::CallStartMenu() {
    cout << "StartMenu" << endl;  // some logging
    menu.PushMenu({ { { "Start Game", &GameObject::StartGame },
                      { "Load Game", &GameObject::LoadGame },
                      { "Quit", &GameObject::Quit } } });
    state = GameState::Menu;      // tell the main loop that a menu has to be rendered
}

void GameObject::CallIngameMenu() {
    cout << "IngameMenu" << endl; // some logging
    menu.PushMenu({ { { "Return To Game", &GameObject::ReturnToGame },
                      { "Save Game", &GameObject::SaveGame },
                      { "Load Game", &GameObject::LoadGame },
                      { "Reset Game", &GameObject::ResetGame },
                      { "Quit", &GameObject::Quit } } });
    state = GameState::Menu; // tell the main loop that a menu has to be rendered
}

In order to make the menu controlable by keyboard, we also need to store one integer per sub menu to inticate which item is selected. We can't do that in the Menu (MenuStack) because when we want to pop the top sub menu we want to have a valid index afterwards that selects the item that called the popped sub menu. But this task is left you you to implement.

for rendering it is best to render each string in a texture, and then calculate a centralized position for all of them. Here it becomes hard to not disturb the Model View Controller. I gave the MenuItem an SDL_Texture* that go initialized whe first rendered, and a SDL_Rect for the position and size. If you insist on not having any rendering code in your MenuItem you can make a map<const char*, SDL_Texture*> in your renderer, which will work great if you don't plan to render tons of text in your game.

for the mouse suppert you can use the SDL_Rects that got initialized by the renderer to check weather the mouse hits the menu item.


So far, that's all. Happy coding and integrating in your project. This is how it looks in my game:

pretty bare bone, but it is meant to be minimal.

















54  Player / Games / Re: Favorite freeware games from the past two years? on: October 19, 2014, 12:19:05 PM
just go to digi pen. They have some awesome collection. Nitronic Rush for example.
55  Player / Games / Re: Games that you remember but no one else does. on: October 15, 2014, 08:24:13 PM
Vegi

it's like snake, but in this game you are allowed to touch walls. swamps and other pits kill you. Green makes you longer, red makes you shorter. Plus faster, minus slower.
56  Player / Games / Re: Games that you remember but no one else does. on: October 15, 2014, 01:23:12 PM
Little Big Adventure.
57  Player / Games / Re: Voxel Quest on: October 15, 2014, 09:03:05 AM
maybe it is again one of those big ambitios kickstarter projects that don't go anywhere, because technical motivational or other types of problems arise. But we will see.
58  Player / Games / Voxel Quest on: October 15, 2014, 07:32:28 AM


I found yet another voxel game on youtube, but this doesn't try to be that game that was recently bought by microsoft. It's style is somehow unique in todays world where everything is Unitiy. It reminds me of the great PC RPGs of the nineties.

Homepage
Kickstarter
youtube

So I hope the gameplay doesn't suck.
59  Developer / Technical / Re: What's your favorite programming language? on: October 09, 2014, 09:34:45 AM
I found an interesting talk from Jonathan Blow (Braid developer)


60  Community / DevLogs / Re: Dexterity Ball 3D on: October 08, 2014, 03:52:38 PM
yay, yet another marble madness, but as I think of it, there could be many more.most of them are just not really good.
Pages: 1 2 [3] 4 5 ... 14
Theme orange-lt created by panic