English 中文(简体)
利用SDL组织游戏守则
原标题:Organization of code for a game using SDL
  • 时间:2012-01-13 21:19:30
  •  标签:
  • c++
  • sdl

几天前,我一直在使用SDL,在经过一些辅导之后,我决定开始发展自己在加加加的衣帽。 然而,我很难找到我守则的适当布局。

例如,我有一个空间类别,定义如下:

class Spaceship : public Sprite
{
public:
    Spaceship(SDL_Surface *surface);
    Spaceship(const char *filename);

    void handleEvent(SDL_Event *event);
};

where Sprite is a base class that holds the position on the screen and so on. My constructor would be something like:

Spaceship::Spaceship(SDL_Surface *surface) :
    Sprite(surface)
{
    m_y = Game::screenHeight() - m_surface->h; //positions the ship at the bottom
}

从我所看到的情况来看,不可能使用猎物:屏幕Width()[法定类别],因为我需要包括基本上属于主要游戏类别的“加”,包括“空间:h”,基本上形成一种无限的循环(我利用胎头等进行尝试,但没有成功)。

Is it possible to achieve this kind of result?

http://www.un.org。 我找到了解决这一问题的办法(我刚才补充说,“加梅......h”包括在申请档案中,而不是放在头号档案中)。

问题回答

如果你只想存储点或提及这些物体,那么你可以提前申报一个或两个类别,即<代码>级游戏;或级航天学;。 如果这些物体作为参数或将其返还(除一些例外情况外,还算法克),则该物品也属于罚款。

如果你真的要有一位成员,那么,这便是而不是<>em>,因为每个物体在其中都有自己的副本。

你需要打破你的依赖图表的循环。

例如,我们可以在您的航天学班中增加一个可以节省屏幕高度的领域。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?