Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vanz

Member Since 15 Mar 2002
Offline Last Active Dec 04 2013 07:35 PM

Topics I've Started

Unity Engine

19 November 2013 - 08:02 PM

Anyone use the Unity Engine much, any cons or issues?

 

Been playing around with and it seems pretty cool... I'm into making a 2d physics type game to run in Windows Store and work on Surface Pro and RT. Want my game to be like the game "Cut the Rope" in terms of nice clean and smooth moving graphics and object movements defined by real world physics, but my concept is totally different.

 

At this point I'm thinking of using Unity to export the c++ code after I get the sprites moving smoothly, mouse, sound and the touch portion working. Then continue on in c++. So basically use Unity to create a Windows Store compatible template with smooth graphics and all the input/outputs then jump back to c++ for all the rest...

 

At any rate would be interested in your experience and comments...

 

Thanks,,

 

Vanz


Visual Studio 2013 C++ and Windows 8.1 Issues

18 November 2013 - 05:00 PM

Trying to get some Windows 8.0 Visual Studio 2012 C++ solution files to work on Visual Studio 2013 C++ and Windows 8.1, when I go to open the solution file it says I need to "Retarget your Windows Store app to Windows 8.1"  

 

http://msdn.microsoft.com/en-us/library/windows/apps/dn263114.aspx

 

okay what the frick, I'll play along... Now I need to open the folder that contains the solution file, okay I finally found the "Source Control Explorer" but it won't let me open anything, it's all greyed out except for the refresh button?? Do I need to sign up for something to use this feature just so I can open my older project? I really hate signing up for stuff, plus it's not even clear what exactly I need to sign up for...

 

Finding working in Visual Studio 2013 C++ and Windows 8.1 to be pretty frustrating so far...

 

Vanz

 

 

 

 


Direct3D Sprites

18 November 2013 - 12:41 PM

Learning C++, can someone please explain how the following works or point me to on-line tutorial or book covering topic:

 

 

SimpleSprites::SimpleSprites() : m_numParticlesToDraw(SampleSettings::Performance::InitialParticleCount)

 

How does f::f: work and f::f::f ?

 

Basically I'm trying to really understand the following code, it's from an sdk:

//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved

#include "pch.h"
#include "SimpleSprites.h"
#include "BasicLoader.h"

using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Core;

using namespace BasicSprites;

SimpleSprites::SimpleSprites() :
    m_numParticlesToDraw(SampleSettings::Performance::InitialParticleCount)
{
}

void SimpleSprites::CreateDeviceIndependentResources()
{
    DirectXBase::CreateDeviceIndependentResources();

    // Create the performance throttler.

    m_autoThrottle = ref new AutoThrottle(SampleSettings::Performance::TargetFrameTime);
}

void SimpleSprites::CreateDeviceResources()
{
    DirectXBase::CreateDeviceResources();

    // Create the sprite batch.

    m_spriteBatch = ref new SpriteBatch();
    unsigned int capacity = SampleSettings::Performance::ParticleCountMax + SampleSettings::NumAsteroids + 1;
    if (m_featureLevel < D3D_FEATURE_LEVEL_9_3)
    {
        capacity = min(Parameters::MaximumCapacityCompatible, capacity);
    }
    m_spriteBatch->Initialize(
        m_d3dDevice.Get(),
        capacity
        );

    // Load the sprite textures.

    BasicLoader^ loader = ref new BasicLoader(m_d3dDevice.Get(), m_wicFactory.Get());

    loader->LoadTexture(
        "m31.png",
        &m_background,
        nullptr
        );
    m_spriteBatch->AddTexture(m_background.Get());

    loader->LoadTexture(
        "ida.dds",
        &m_asteroid,
        nullptr
        );
    m_spriteBatch->AddTexture(m_asteroid.Get());

    loader->LoadTexture(
        "particle.dds",
        &m_particle,
        nullptr
        );
    m_spriteBatch->AddTexture(m_particle.Get());

    // Create the Sample Overlay.

    m_sampleOverlay = ref new SampleOverlay();

    m_sampleOverlay->Initialize(
        m_d2dDevice.Get(),
        m_d2dContext.Get(),
        m_wicFactory.Get(),
        m_dwriteFactory.Get(),
        "Direct3D SpriteBatch sample"
        );
}

void SimpleSprites::CreateWindowSizeDependentResources()
{
    DirectXBase::CreateWindowSizeDependentResources();

    // Randomly generate some non-interactive asteroids to fit the screen.

    m_asteroidData.clear();
    for (int i = 0; i < SampleSettings::NumAsteroids; i++)
    {
        AsteroidData data;
        data.pos.x = RandFloat(0.0f, m_windowBounds.Width);
        data.pos.y = RandFloat(0.0f, m_windowBounds.Height);
        float tempRot = RandFloat(-PI_F, PI_F);
        float tempMag = RandFloat(0.0f, 17.0f);
        data.vel.x = tempMag * cosf(tempRot);
        data.vel.y = tempMag * sinf(tempRot);
        data.rot = RandFloat(-PI_F, PI_F);
        data.scale = RandFloat(0.1f, 1.0f);
        data.rotVel = RandFloat(-PI_F, PI_F) / (7.0f + 3.0f * data.scale);
        m_asteroidData.push_back(data);
    }


    if (m_particleData.size() == 0)
    {
        // Initialize the interactive particle buffer to fill the window if it is empty.

        for (int i = 0; i < SampleSettings::Performance::ParticleCountMax; i++)
        {
            ParticleData data;
            data.pos.x = RandFloat(0.0f, m_windowBounds.Width);
            data.pos.y = RandFloat(0.0f, m_windowBounds.Height);
            data.vel = float2(0.0f, 0.0f);
            m_particleData.push_back(data);
        }
    }
    else
    {
        // Otherwise, move the interactive particles to fit within the screen.

        for (auto particle = m_particleData.begin(); particle != m_particleData.end(); particle++)
        {
            if (particle->pos.x > m_windowBounds.Width)
            {
                particle->pos.x = m_windowBounds.Width;
            }
            if (particle->pos.y > m_windowBounds.Height)
            {
                particle->pos.y = m_windowBounds.Height;
            }
        }
    }

    m_sampleOverlay->UpdateForWindowSizeChange();
}

void SimpleSprites::Update(float timeTotal, float timeDelta)
{
    // Update the performance throttler.

    auto control = m_autoThrottle->Update(timeDelta);

    if (control == FrameWorkload::Increase)
    {
        m_numParticlesToDraw += SampleSettings::Performance::ParticleCountDelta;
    }
    if (control == FrameWorkload::Decrease)
    {
        m_numParticlesToDraw -= SampleSettings::Performance::ParticleCountDelta;
    }
    if (control != FrameWorkload::Maintain)
    {
        m_numParticlesToDraw = max(SampleSettings::Performance::ParticleCountMin, min(SampleSettings::Performance::ParticleCountMax, m_numParticlesToDraw));
        if (m_featureLevel < D3D_FEATURE_LEVEL_9_3)
        {
            m_numParticlesToDraw = min(static_cast<int>(Parameters::MaximumCapacityCompatible - SampleSettings::NumAsteroids - 1), m_numParticlesToDraw);
        }
    }

    // Update the non-interactive asteroids.
    // Their behavior is to drift across the window with a fixed translational and rotational
    // velocity.  Upon crossing a boundary outside the window, their position wraps.

    for (auto asteroid = m_asteroidData.begin(); asteroid != m_asteroidData.end(); asteroid++)
    {
        static const float border = 100.0f;
        asteroid->pos = asteroid->pos + asteroid->vel * timeDelta;
        if (asteroid->vel.x < 0)
        {
            if (asteroid->pos.x < -border)
            {
                asteroid->pos.x = m_windowBounds.Width + border;
            }
        }
        else
        {
            if (asteroid->pos.x > m_windowBounds.Width + border)
            {
                asteroid->pos.x = -border;
            }
        }
        if (asteroid->vel.y < 0)
        {
            if (asteroid->pos.y < -border)
            {
                asteroid->pos.y = m_windowBounds.Height + border;
            }
        }
        else
        {
            if (asteroid->pos.y > m_windowBounds.Height + border)
            {
                asteroid->pos.y = -border;
            }
        }

        asteroid->rot += asteroid->rotVel * timeDelta;
        if (asteroid->rot > PI_F)
        {
            asteroid->rot -= 2.0f * PI_F;
        }
        if (asteroid->rot < -PI_F)
        {
            asteroid->rot += 2.0f * PI_F;
        }
    }

    // Update the interactive particles.
    // Their behavior is to be gravitationally attracted to two oscillating gravity
    // wells and repelled by any pressed pointer points.  Upon reaching the edge of
    // the window, the particles bounce.

    // Add two gravity wells that move throughout the window.
    float2 wellPositions[] =
    {
        float2(
            (1.0f + 0.8f * cosf(timeTotal / (2.0f * PI_F) + 3.0f)) * m_windowBounds.Width / 2.0f,
            (1.0f + 0.8f * sinf(timeTotal / 5.0f)) * m_windowBounds.Height / 2.0f
            ),
        float2(
            (1.0f + 0.8f * cosf(timeTotal / (PI_F * PI_F) + 1.0f)) * m_windowBounds.Width / 2.0f,
            (1.0f + 0.8f * sinf(timeTotal / PI_F)) * m_windowBounds.Height / 2.0f
            )
    };

    for (auto particle = m_particleData.begin(); particle != m_particleData.begin() + m_numParticlesToDraw; particle++)
    {
        if (particle->pos.x < 0)
        {
            particle->vel.x = abs(particle->vel.x);
        }
        if (particle->pos.x > m_windowBounds.Width)
        {
            particle->vel.x = -abs(particle->vel.x);
        }
        if (particle->pos.y < 0)
        {
            particle->vel.y = abs(particle->vel.y);
        }
        if (particle->pos.y > m_windowBounds.Height)
        {
            particle->vel.y = -abs(particle->vel.y);
        }

        for (auto repulsor = m_repulsors.begin(); repulsor != m_repulsors.end(); repulsor++)
        {
            float2 delta = particle->pos - repulsor->second;
            float deltaLength = length(delta) + 24.0f; // Offset length to avoid division by zero.
            float deltaLengthCubed = deltaLength * deltaLength * deltaLength;
            particle->vel = particle->vel + SampleSettings::Physics::Gravity * timeDelta * delta / deltaLengthCubed;
        }

        for (int i = 0; i < ARRAYSIZE(wellPositions); i++)
        {
            float gravitySign = 1.0f;
            if ((static_cast<int>(timeTotal / 2.0f) + 1) % 10 == 0)
            {
                // Every 20 seconds, "explode" the gravity wells for 2 seconds.
                gravitySign = -1.0f;
            }
            float2 delta = wellPositions[i] - particle->pos;
            float deltaLength = length(delta) + 24.0f;
            float deltaLengthCubed = deltaLength * deltaLength * deltaLength;
            particle->vel = particle->vel + gravitySign * 0.2f * SampleSettings::Physics::Gravity * timeDelta * delta / deltaLengthCubed;
        }

        particle->vel = particle->vel * (1.0f - SampleSettings::Physics::Damping);

        // Add random noise to the velocity to prevent particles from locking together.

        particle->vel.x += RandFloat(-0.5f, 0.5f);
        particle->vel.y += RandFloat(-0.5f, 0.5f);

        particle->pos = particle->pos + particle->vel * timeDelta;
    }
}

void SimpleSprites::Render()
{
    m_d3dContext->OMSetRenderTargets(
        1,
        m_d3dRenderTargetView.GetAddressOf(),
        nullptr
        );

    m_d3dContext->ClearRenderTargetView(
        m_d3dRenderTargetView.Get(),
        reinterpret_cast<float*>(&D2D1::ColorF(D2D1::ColorF::MidnightBlue))
        );

    m_spriteBatch->Begin();

    // Draw the background.

    m_spriteBatch->Draw(
        m_background.Get(),
        float2(0.5f, 0.5f),
        PositionUnits::Normalized,
        float2(1.0f, 1.0f),
        SizeUnits::Normalized
        );

    // Draw the non-interactive asteroids.

    for (auto asteroid = m_asteroidData.begin(); asteroid != m_asteroidData.end(); asteroid++)
    {
        m_spriteBatch->Draw(
            m_asteroid.Get(),
            asteroid->pos,
            PositionUnits::DIPs,
            float2(1.0f, 1.0f) * asteroid->scale,
            SizeUnits::Normalized,
            float4(0.8f, 0.8f, 1.0f, 1.0f),
            asteroid->rot
            );
    }

    // Draw the interactive particles.

    for (auto particle = m_particleData.begin(); particle != m_particleData.begin() + m_numParticlesToDraw; particle++)
    {
        float alpha = length(particle->vel) / 200.0f;
        m_spriteBatch->Draw(
            m_particle.Get(),
            particle->pos,
            PositionUnits::DIPs,
            float2(32.0f, 32.0f),
            SizeUnits::DIPs,
            float4(0.1f, 0.02f, 0.0f, alpha),
            0.0f,
            BlendMode::Additive
            );
    }

    m_spriteBatch->End();

    // Render the Sample Overlay.

    m_sampleOverlay->Render();
}

float SimpleSprites::RandFloat(float min, float max)
{
    return (static_cast<float>(rand() % RAND_MAX) / static_cast<float>(RAND_MAX)) * (max - min) + min;
}

void SimpleSprites::AddRepulsor(_In_ uint32 id, _In_ float2 position)
{
    m_repulsors[id] = position;
}

void SimpleSprites::MoveRepulsor(_In_ uint32 id, _In_ float2 position)
{
    m_repulsors[id] = position;
}

void SimpleSprites::RemoveRepulsor(_In_ uint32 id)
{
    m_repulsors.erase(id);
}


2D Windows 8.1 game development C++

15 November 2013 - 01:21 PM

Please select from the poll, program needs to work on the Surface Pro and Surface RT.

 

I have discounted SFML as it is not compatible with Windows RT.

 

 

Thanks,

 

Vanz


SFML

14 November 2013 - 03:35 PM

Looking into designing a 2D based physics based game for the Windows Surface tablets. Would want my game to look and feel like Angry Birds or Cut the Rope, in terms of nice crisp moving graphics, but my concept is totally different is SFML the best way to go or would you recommend something else? 

 

Some Questions about SFML:

  1. Have you used SFML, would you please provide your honest feedback on using it?
  2. What if I spend a ton of time using it, then they don't support it anymore am I basically screwed? I guess I'm basically concerned about the future of it.
  3. I don't see how they make revenue from SFML as it appears free? What's keeping it from collapsing or not being maintained
  4. Will games programmed in SFML work with on Windows RT?
  5. SFML vs. GDI+? Seems like GDI+ is harder, but I already know GDI well, and seems like GDI+ has a solid future, would it make more sense for me to stick with GDI+?
  6. Not SFML question but I’ll ask here anyways, I know Poser already, what other program(s) are generally used to make nice smooth looking graphics like  in Angry Birds or Cut the Rope or is this really just the artist being great and using any program?
  7. Does SFML support touch screen? Can it be encorporated?

 

Thanks,

 

Vanz


PARTNERS