小编Sam*_*Lec的帖子

中点位移算法 - 奇怪的结果

我正在编写自己的中点位移算法用于学习目的,我决定以自己的方式实现它,看看我是否能够理解算法,2)看看我是否可以根据自己的喜好修改它.

这是生成分形的代码:

 public void Generate(Double rg, int size)
    {
        Random rand = new Random();
        int min = -127;
        int max = 128;

        // Starting points of the rectangle
        MDP_Point s1 = new MDP_Point(0, 0, rand.Next(min, max));
        MDP_Point s2 = new MDP_Point(size, 0, rand.Next(min, max));
        MDP_Point s3 = new MDP_Point(size, size, rand.Next(min, max));
        MDP_Point s4 = new MDP_Point(0, size, rand.Next(min, max));

        // Lists containing the rectangles
        List<MDP_Rect> newRect = new List<MDP_Rect>();  // Newly created rectangles
        List<MDP_Rect> oldRect = new List<MDP_Rect>();  // …
Run Code Online (Sandbox Code Playgroud)

c# algorithm fractals

5
推荐指数
1
解决办法
1528
查看次数

在RTS游戏中处理'单位' - c ++

我目前正在用c ++制作简单的RTS风格游戏.

我想知道的是如何处理游戏中新单位的创建(即从军营中制造海军陆战队员).我如何存储这些单位?

我想有一个类'单位',然后由特定的单位类型(即海军陆战队,火焰等)继承,但如果我为这些创建一个数组(即.海军陆战队myMarines [20])将创建一个硬这些单位的上限.

我如何创建可以随意扩展的数组?谢谢!

c++

4
推荐指数
1
解决办法
2153
查看次数

SDL和OpenGL程序编译失败

我正在尝试构建一个拒绝工作的简单openGL和SDL程序。

我正在使用最新的nvidia驱动程序(我记得还记得285.something),我使用mingw进行编译。我使用的计算机运行Windows7。我对mingw的了解有限,因此这可能是一个非常简单的链接错误。

我正在使用的SDL版本是1.2(我应该升级到1.3吗?)

最初,一切正常,但是我只是通过SDL打开opengl窗口。这是原始makefile的代码

all:
g++ -o sdlGL.exe esg.cpp tiletest.cpp -lmingw32 -lSDLmain -lSDL -lopengl32 -lglu32
Run Code Online (Sandbox Code Playgroud)

这些是被称为2个功能

    void init_sdl(int width, int height) {
        //Start SDL
        if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
            fDebug << "Failed to init SDL" << std::endl;
            quit(1);
        }

        //Set SDL attrib.
        SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
        SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

        //Set SDL video mode
        if( SDL_SetVideoMode(width, height, 0, SDL_OPENGL) == 0 ) {
            fDebug << …
Run Code Online (Sandbox Code Playgroud)

c++ opengl sdl

1
推荐指数
1
解决办法
5034
查看次数

标签 统计

c++ ×2

algorithm ×1

c# ×1

fractals ×1

opengl ×1

sdl ×1