Click here to Skip to main content
Click here to Skip to main content

Roller Coaster

By , 21 May 2013
 

Please note

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  

Roller Coaster. Build and ride roller coasters with ease. Designed to be able to learn to play in seconds with touch. Use of gyroscope while riding to get coins for high scores. 

Its designed to be able to play it in varying time spans. Its a game you could pull out at lunch and build a coaster in 2-3 min and show a friend. Also one that you could spend much more time building the perfect coaster. 

The game is written in C#, and is using XNA as a front end (a Windows 8 "Desktop App").

Background  

My name is Mark Dickinson I am a student at ASU, and am a CS major.  I have been working with roller coaster design since I made my first mod on Warcraft 3 with triggers. I learned a huge amount from watching players struggle to learn the game quickly. I stopped adding features and spent over a year on and off making the features that existed very easy to use and straight forward. I have since spent most of my time in c#, sliverlight, and xna. 

Key Features   

  • Fully playable with keyboard, mouse, and touch. 
  • Building coasters, with a large amount of flex-ability yet designed to take only seconds to learn. 
  • Ride coasters, from in the cart or from a third person perspective.
  • Ability to lean in your cart left or right in your cart to get coins while riding.

Screenshots  

Riding (Cart View)

Riding (Third Person View)

The code 

Backend

The back end of the game is built in c# in a library called "RCLIB" .  

Here is a function I have in "RCLIB".

Build Track  

  • Is coaster finished  
  • Where would the track be built
  • Check for flipped on bools, (e.g., iqnoreOutOfBounds)
  • If its on, make sure it can fix the issue, or return zero tracks built.  

Note: When it attempts to fix the issue, it allows the game to build additional tracks, or back up a small amount. 

static public int BuildTrack(Direction direction, 
	      List<Object3D> myTracks, ref List<Direction> directions)
{
    //No Building Tracks IF Coaster is finshed, this is a fail safe.
    if (CoasterFinshed)
    {
        return 0;
    }


    Object3D track = new Object3D();
    Vector3 newOrientation = new Vector3();
    Vector3 newLocation = new Vector3();
    Vector3 LastOrientation = new Vector3();

    //Find Where Next Track would be
    if (myTracks.Count > 0)
    {
        LastOrientation = new Vector3(myTracks.Last<Object3D>().Orientation.X, 
          myTracks.Last<Object3D>().Orientation.Y, myTracks.Last<Object3D>().Orientation.Z);
        newOrientation = new Vector3(myTracks.Last<Object3D>().Orientation.X, 
          myTracks.Last<Object3D>().Orientation.Y, myTracks.Last<Object3D>().Orientation.Z);
        newLocation = new Vector3(myTracks.Last<Object3D>().Location.X, 
          myTracks.Last<Object3D>().Location.Y, myTracks.Last<Object3D>().Location.Z);
    }
    else
    {
        LastOrientation = new Vector3();
        newOrientation = new Vector3(0, 270, 0);
        newLocation = new Vector3(0, 0, -40);
    }
    newOrientation = GetNewOrientation(newOrientation, direction);
    newLocation = GetNewLocation(newOrientation, newLocation, LastOrientation);

    track.Location = newLocation;
    track.Orientation = newOrientation;
    track.Scale = new Vector3(Constants.TRACK_SCALE, Constants.TRACK_SCALE, Constants.TRACK_SCALE);

    //
    if (iqnoreAllButStandard)
    {
        //Build The Track Standard
        directions.Add(direction);
        myTracks.Add(track);
        return 1;
    }

    else if (iqnoreFinshArea == false && InFinshArea(newLocation))
    {
        directions.Add(direction);
        myTracks.Add(track);
        FinshCoaster(myTracks, ref directions, 1);
        return 0;
    }

    else if (iqnoreAutoLoop == false && AutoLoop(myTracks, ref directions))
    {
        return 0;
    }

    else if (iqnoreCollision == false && CollisionDetected(newLocation, myTracks))
    {
        return 0;
    }

    else if (iqnoreFlaten == false && Flaten(myTracks, direction, track, 
             newOrientation, newLocation, LastOrientation, ref directions))
    {
        return 0;
    }

    if (iqnoreTracksToLow == false && TrackToLow(newLocation, newOrientation))
    {
        return 0;
    }

    else if (iqnoreBounceOffWall == false && BounceOffWall(newLocation, direction, myTracks, ref directions))
    {
        return 0;
    }

    else if (iqnoreOutOfBounds == false && OutOfBounds(newLocation))
    {
        return 0;
    }

    else
    {
        //Build The Track Standard
        directions.Add(direction);
        myTracks.Add(track);
        return 1;
    }

The point of showing this is that the game attempts to fix rules broken by the user, so to lower the learning curve in such a way that they can keep building, with out having to deal with rules most of the time.  

Frontend

The front end is using standard XNA, to for user Inputs, loading content, and showing visuals. 

Due to not wanting my back end to have any ties to my front end I had to rebuild parts that existed in xna.

Here is my draw method, showing a downside of my choice of making them completely separate instead of sharing some of the xna code base. But overall it makes for a much more flexible code base. 

Draw loop

protected override void Draw(GameTime gameTime)
{

    GraphicsDevice.DepthStencilState = DepthStencilState.Default;
    GraphicsDevice.BlendState = BlendState.Opaque;
    GraphicsDevice.Clear(Color.CornflowerBlue);

    //Layout
    drawManager.DrawModel(layoutModel, new Microsoft.Xna.Framework.Vector3(0, 0, 0), 
      new Microsoft.Xna.Framework.Vector3(0, 0, 0), new Microsoft.Xna.Framework.Vector3(.25f, .25f, .25f));

    //Tracks
    for (int i = 0; i < core.Tracks.Count; i++)
    {
        drawManager.DrawModel(trackModel, 
          new Microsoft.Xna.Framework.Vector3(core.Tracks[i].Location.X, 
              core.Tracks[i].Location.Y, core.Tracks[i].Location.Z),
          new Microsoft.Xna.Framework.Vector3(core.Tracks[i].Orientation.X, 
              core.Tracks[i].Orientation.Y, core.Tracks[i].Orientation.Z),
          new Microsoft.Xna.Framework.Vector3(RollerCoaster.Constants.TRACK_SCALE, 
              RollerCoaster.Constants.TRACK_SCALE, RollerCoaster.Constants.TRACK_SCALE));
    }

    //Cart
    drawManager.DrawModel(cartModel, 
       new Microsoft.Xna.Framework.Vector3(core.Cart.Location.X, 
           core.Cart.Location.Y, core.Cart.Location.Z),
       new Microsoft.Xna.Framework.Vector3(core.Cart.Orientation.X, 
           core.Cart.Orientation.Y, core.Cart.Orientation.Z),
       new Microsoft.Xna.Framework.Vector3(RollerCoaster.Constants.CART_SCALE, 
           RollerCoaster.Constants.CART_SCALE, RollerCoaster.Constants.CART_SCALE));


    spriteBatch.Begin();
    //Menu
    DrawMenu();

    //Draw Mouse
    MouseState currentMouseState = Mouse.GetState();
    float mouseX = (1980.0f / GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width) * currentMouseState.X;
    float mouseY = (1080.0f / GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height) * currentMouseState.Y;

    Microsoft.Xna.Framework.Vector2 posMouse = new Microsoft.Xna.Framework.Vector2(mouseX, mouseY);
    spriteBatch.Draw(pointer, posMouse, Color.White);

    spriteBatch.End();

    //Clean Up
    GraphicsDevice.DepthStencilState = DepthStencilState.Default;

    base.Draw(gameTime);
}

Final Note   

Building a game project that makes sense for the Ultrabook has been sort of like building a project built for computer and a tablet at the same time. Finding the fine line from additional features/ Options and keep simplicity has been a interesting struggle.   

In the end roller coaster is a perfect fit for causal play on an Ultrabook in nearly any setting.  

Download   

http://www.appup.com/app-details/roller-coaster-maker

Change Log 

10/8/1012 - Uploaded Roller Beta Version (1.0) 

10/27/1012 - Uploaded Roller Coaster Version (1.14), Fixed Menus (ride menu still needs finished), added coin mode, fixed several issues and bugs. Next version will be on the app-up Store.

11/21/1012 - Finished Game, Cleaned out bugs, streamlined UI. Submitted App to AppUp Store, Awaiting approval. 

11/21/1012 - Approved in the Appup Store. Removed old Versions from this post.

 

 

License

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

About the Author

Rover2341 - Mark Dickinson
Student
United States United States
Member
Student at ASU, CS Major.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberMember 94311087 Jan '13 - 10:55 
Very good use of Windows 8 features - great article.
GeneralMy vote of 5membermanoj kumar choubey15 Nov '12 - 19:48 
Nice
GeneralMy vote of 5memberSavalia Manoj M6 Nov '12 - 17:19 
good one...
GeneralMy vote of 5mvpMika Wendelius27 Oct '12 - 9:24 
Looking really good
GeneralMy vote of 5memberHari Tantry24 Oct '12 - 11:57 
Excellent.
GeneralMy vote of 3memberHari Tantry23 Oct '12 - 7:32 
Good.
GeneralRe: My vote of 3 [modified]memberRover2341 - Mark Dickinson23 Oct '12 - 8:10 
Thanks for checking it out Smile | :)
 
How can improve this to make it a 5?
 
If you are rating the current version on the post. then i understand your rating Smile | :)
Else i would love to improve it if you have any suggestions.

modified 23 Oct '12 - 14:38.

GeneralMy vote 5memberNitin Sawant22 Oct '12 - 20:23 
Awesome! Thumbs Up | :thumbsup:
 
============================================
My Entry for AppInnovation Contest:
http://bit.ly/RKNa5Q
GeneralMy vote of 5memberAndrewAylett20 Oct '12 - 12:06 
Looks really fun -- can't wait to try it when I get suitable hardware Smile | :) .
GeneralMy vote of 5memberYvan Rodrigues19 Oct '12 - 13:26 
Looks neat and makes we want too learn more about XNA.

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 22 May 2013
Article Copyright 2013 by Rover2341 - Mark Dickinson
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid