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

TerminalVelocity an action game for windows8

By , 10 Oct 2012
 

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

Game setting: A rigged space elevator in a gas giant (like jupiter).

You play: A robot /bot who is falling indefinitely in the elevator( which is rigged to kill/destroy any thing).

Obstacles/Enemy: Electric Wires,Moving Slicers/Blades,Moving Lasers, Trip wires, Corrosive fields , Emf generators.

Collectables:Energy Cells,Intel points .

Background

This is a 2d game from front view . Where player control the bot using accelerometer and touch input of his/her ultrabook, player main mission is to avoid colliding any obstacle as long as possible while falling.

As still I am working on art of game and only have sketches on graph paper .It will take one to two weeks for these concept art to become reality.  

Legends for viewing prototype video

The prototype use red square as danger zones which can be of different type .

The hero of our game is shown as blue rectangle .

Black Rectangle at bottom is emulating tilt of ultrabook is .It is faking it using mouse events to feed it. 

collectibles /powerup not shown in prototype as they can use similar concept as danger zones so will be developed in later prototyping stages.

Video of prototype 1

http://www.youtube.com/watch?v=SlCNfOK09dQ

 

the video is shot by my lumia ,so please compromise  quality  because camstudio  is not working with windows 8. 

Some code may be messy or uncommented but you can easily use the project in visual studio for windows 8.I will update this to some extent as more prototype or more feature would be added .But don't count on this too much as I will stop updating this after the prototyping phase of my app development will finish.   

Using the code

A quick prototype is done in java script .Where only minimal functionality as proof of concept is achieved .

First I will try to describe my prototype logic .

//Function to initialize game assets 
function init(){}
//Function to prepare data after initialization of game assets  
function preparegame(){}
//Function which insisted game loop   
function startgame(){}      
//Calls update and draw  
function gameloop(){}  
//responsible for updating hero and villain positions and calling collision check  
function update(){}  


//collision check is done in prototype by checking the distance between hero and villain.    
//Some Part of this prototype  are hard coded 
//dx^2+dy^2 is checked    against 900*sx*sy   . 
//sx is scalex sy is scale y 900 is used  because it is nearly the distance^2 between hero and villain when they are near each other .
//sx*sy is better approximation than sx*sx or sy*sy. 

if (Math.pow((hero.x - dangerzone.x), 2) + Math.pow((hero.y - dangerzone.y), 2) < 900 * sx * sy || Math.pow((hero.x - dangerzoneless.x), 2) + Math.pow((hero.y - dangerzoneless.y), 2) < 900 * sx * sy)
gameover();
 function gameover()
 {
     createjs.Ticker.setPaused(true);
     stage.addChild(levelstate);
     stage.update();
 }
 
//It is called from update .Checks if villains are above screen then reset them  .And make them moving every 10 calls
//usb is a cool counter isn't it I know it is not a good name for a counter  . 

function updatevillains ()
 {
     if (dangerzone.y < -50)
     {
         dangerzone.x = minx + (maxx - minx) * Math.random();
         dangerzone.y = window.innerHeight;
     }
     if (dangerzoneless.y < -50)
     {  dangerzoneless.x = minx + (maxx - minx) * Math.random();
      dangerzoneless.y=window.innerHeight;
     }
     usb++;
     if (dangerzone.y > -50&&usb>10)
     {
         dangerzone.y -= speed;
     }
     if (dangerzoneless.y > -540 && usb > 10)
     {
         dangerzoneless.y -= speed;
         usb = 0;
     }
 }

Attached project for this game's prototype try it for your entertainment.

Points of Interest 

Some part of code is fixed by bruteforce code like the distance based collision detection.   

if (Math.pow((hero.x - dangerzone.x), 2) + Math.pow((hero.y - dangerzone.y), 2) < 900 * sx * sy || Math.pow((hero.x - dangerzoneless.x), 2) + Math.pow((hero.y - dangerzoneless.y), 2) < 900 * sx * sy)gameover();    

The speed of villians is slowed using a flag counter 

if(count  >10){count=0;update_dangerjones();}count++; 
 //Not a proper way we must use timer for all animation for a proper game. 

The accelerometer behaviour emulation by mouse .

//mouse events update a rotation variable.
function MouseD(e)
 {
     if (e.x <window.innerWidth/2) 
         emulal.rotation-=5;
     else
     emulal.rotation+=5;
     if(emulal.rotation<115)
         emulal.rotation=115;
     if(emulal.rotation>245)
         emulal.rotation = 245;
     readingx =( emulal.rotation-180) ;
 
 } 
//rotation-180/5 will update the position of hero
function updatehero()
 {
     if (readingx>0 && hero.x < maxx)
         hero.x += readingx;
     else if (readingx<0 && hero.x > minx)
         hero.x += readingx; 
    readingx = 0; 
 } 

Further modification

  1. The game would be built on xna .Will use monogames with it to produce final app for windows 8 .
  2. The prototype only show how that could be implemented. Well more to come like collectables ,mini puzzle game ,different type of input modes available based on different bots(thruster robot/ fan bot /magnetic bot) so game will feel good.

Ultrabook Features use

  1. This game is a accelerometer and touch based game .This will use accelerometer feature in ultrabook.
  2. If enough time is left after polishing app then this app can support all orientation while autodetecting tilt and changing the gaming area as the white zone is main playable area and we are starting with landscape thus portrait would be easy

License

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

About the Author

PraveenOjha
India India
Member
No Biography provided

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWhich flavour?adminChris Maunder11 Oct '12 - 11:31 
AnswerRe: Which flavour?memberpraveenojha11 Oct '12 - 18:31 
GeneralRe: Which flavour?adminChris Maunder12 Oct '12 - 7:06 
You need to register for the contest in order to win.
cheers,
Chris Maunder
 
The Code Project | Co-founder
Microsoft C++ MVP

GeneralRe: Which flavour?memberpraveenojha12 Oct '12 - 7:19 
GeneralMy vote of 5memberDrABELL11 Oct '12 - 5:22 
QuestionPlease clarify accelerometer use casememberDrABELL11 Oct '12 - 3:41 
AnswerRe: Please clarify accelerometer use casememberpraveenojha11 Oct '12 - 4:29 
GeneralRe: Please clarify accelerometer use casememberDrABELL11 Oct '12 - 5:21 
GeneralRe: Please clarify accelerometer use casememberpraveenojha11 Oct '12 - 5:46 
GeneralRe: Please clarify accelerometer use casememberDrABELL11 Oct '12 - 7:31 

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 11 Oct 2012
Article Copyright 2012 by PraveenOjha
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid