Click here to Skip to main content
15,878,852 members
Articles / Mobile Apps / Windows Mobile

MarbleMaze

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
31 Jul 2013CPOL3 min read 15.3K   4   4
Traditional game which becomes more interetsing.

This article is an entry in our AppInnovation Contest. Articles in this sub-section are not required to be full articles so care should be taken when voting.

Introduction

This application idea is under All-in-One: Games Category.

MarbleMaze is a game where the goal is to reach the destination by keeping safe from the obstacles. It is based on Motion Sensor (accelerometers) of the device where you have to manage your motion sensor to save your ball from hole. As the level increases the complexity increases by decreasing the time to reach the ball to destination. It will make game more interesting. Anyone can challenge other player to reach destination in any fixed time and if fails then he /she lose the game.

 Image 1

Image 2 

There will be an option to compete with your regional players or international players. By the help of GPS it will search all the players within a specific range of kilometers who wants to play and by this way the user have a freedom to play with regional or international players. This is just the sample picture for explaining the game idea. A better design of game is under construction and will be uploaded soon. 

Key features  

  • More than 50 levels to play.
  • Regional and International High scores list so that user will able to know his/her rankings in a better way
  • Some useful tips to improve the rankings.
  • Better UI design
  • Handling input from accelerometer, touch, and mouse, and game controller with the Windows Runtime. 
  • Three modes: Training, Beginner, Expert

Additional features 

  • Background Music
  • Playing and mixing sound effects
  • Different color marbles.

Using the code 

I am going to use C# to develop this game.

Handling accelerometer inputs

It shows how the Update method polls the accelerometer and updates the combined input values.  

C++
// for sensors. const float acceleromterScalingFactor = 3.5f;
if (m_accelerometer != nullptr)
{
    Windows::Devices::Sensors::AccelerometerReading^ reading =
        m_accelerometer->GetCurrentReading();

    if (reading != nullptr)
    {
        combinedTiltX += static_cast<float>(reading->AccelerationX) * acceleromterScalingFactor;
        combinedTiltY += static_cast<float>(reading->AccelerationY) * acceleromterScalingFactor;
    }
}

Detecting touch and mouse inputs

When the user touches or clicks then a menu item is chosen .The m_pointQueue tracks the locations where the user touched or clicked on the screen. If  any button was pressed then it updates the game state.

C++
// Check whether the user choose a button from the UI.
bool anyPoints = !m_pointQueue.empty();
while (!m_pointQueue.empty())
{
       UserInterface::GetInstance().HitTest(m_pointQueue.front());
       m_pointQueue.pop();
}
C++
// Update the game state if any button was pressed
if (m_startGameButton.IsPressed())
{
    SetGameState(GameState::PreGameCountdown);
    m_startGameButton.SetPressed(false);
}
if (m_highScoreButton.IsPressed())
{
    SetGameState(GameState::HighScoreDisplay);
    m_highScoreButton.SetPressed(false);
}    

Pause, resume, and restart functions

The game is suspended when user switches away from it and the game saves the current game state and pauses audio playback. When the app is resumed, the game resumes audio playback. When the app is closed and later restarted, the game resumes from its previous state. To support suspend and resume, Marble Maze defines the PersistentState class.

C++
ref class PersistentState
{
public:
    void Initialize(
        _In_ Windows::Foundation::Collections::IPropertySet^ m_settingsValues,
        _In_ Platform::String^ key
        );

    void SaveBool(Platform::String^ key, bool value);
    void SaveInt32(Platform::String^ key, int value);
    void SaveSingle(Platform::String^ key, float value);
    void SaveXMFLOAT3(Platform::String^ key, DirectX::XMFLOAT3 value);
    void SaveString(Platform::String^ key, Platform::String^ string);

    bool LoadBool(Platform::String^ key, bool defaultValue);
    int  LoadInt32(Platform::String^ key, int defaultValue);
    float LoadSingle(Platform::String^ key, float defaultValue);
    DirectX::XMFLOAT3 LoadXMFLOAT3(Platform::String^ key, DirectX::XMFLOAT3 defaultValue);
    Platform::String^ LoadString(Platform::String^ key, Platform::String^ defaultValue);

private:
    Platform::String^ m_keyName;
    Windows::Foundation::Collections::IPropertySet^ m_settingsValues;
};

The MarbleMaze class holds a PersistentState object. The MarbleMaze constructor initializes this object and provides the local application data store as the backing data store.

C++
m_persistentState = ref new PersistentState();
m_persistentState->Initialize(ApplicationData::Current-> 

Playing background music

C++
if (!m_audio.m_isAudioStarted)
{
    m_audio.Start();
} 

The OnSuspending method saves game state and suspends audio.

C++
void MarbleMaze::OnSuspending()
{
    SaveState();
    m_audio.SuspendAudio();
} 

Since, this application will be built from scratch and it is in the developing stage, all aspects from the concept, design (UI) and codes will be uploaded as soon as possible.  

Background  

I got this idea to develop MarbleMaze is from my last developed game for some other mobiles. I already developed this game for Qt mobiles and applying the same logic for developing games for for Windows 8 desktop with the advanced and some new features. 

As I am Microsoft Student Partner from last two years. So, i learned a lot from some MSP's and MVP's. They are helping me to design and code this. I am also taking help from MSDN site to learn and code this app.

Request

Your comments are very valuable and helps me to rectify problems and improve my app, so please comment about this article and help me to give a valuable game to this society. Thank you so much.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am Nokia Developer Champion and Microsoft MSP from last two year and have an experience of developing Windows phone apps and Windows 8 apps.
Won 1st prize in the worldwide competition of Windows phone 8 app by Nokia.
Some windows phone apps : http://www.windowsphone.com/en-us/search?q=ayush_kedia

Comments and Discussions

 
QuestionHow's app development going? Will you be submitting on time? Pin
Kevin Priddle24-Oct-13 5:32
professionalKevin Priddle24-Oct-13 5:32 
QuestionThanks for your submission! Pin
Kevin Priddle31-Jul-13 8:44
professionalKevin Priddle31-Jul-13 8:44 
AnswerRe: Thanks for your submission! Pin
Ayush00131-Jul-13 10:20
professionalAyush00131-Jul-13 10:20 
GeneralRe: Thanks for your submission! Pin
Kevin Priddle15-Aug-13 10:17
professionalKevin Priddle15-Aug-13 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.