Last active
March 16, 2016 01:18
-
-
Save powerc9000/8aafab40600e123a519c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*purpose:simple game about falling | |
| Author:Kaydon Stubbs | |
| Date: | |
| */ | |
| #include<iostream> | |
| #include<time> | |
| #include<stdlib> | |
| using namespace std; | |
| int main() | |
| { | |
| struct vector3D { | |
| float x; | |
| float y; | |
| float z; | |
| } | |
| //position of character,asteroid(s),landing zone, powerup(s),bullet(s) | |
| vector3D Char, land, bullet, acceleration, velocity; | |
| int positionAx, positionAy, positionAz; //should be array 0 ==x,1==y, 2==z | |
| int positionPx, positionPy, positionPz; //should be array 0 ==x,1==y, 2==z | |
| clock_t time;// right now it is just a count of how many seconds go by | |
| int speed; | |
| int shield; | |
| int power; | |
| int numast=0; | |
| //maybe bool data type | |
| int creata=0; | |
| int creatp=1; | |
| //inut for movement | |
| char input; | |
| //seed random number generator | |
| srand(time (NULL)); | |
| //set power-up to nothing possible an enumerated data type | |
| power=0; | |
| //set health to 100% | |
| shiled=100; | |
| //spawn character at begining | |
| //random x,y and z will be set at predetermined number> 10 | |
| positionCx=rand()%50+1; | |
| positionCy=rand()%50+1; | |
| positionCz=rand()%1000+10; | |
| //spawn landing zone at begining | |
| // random x y cordinant z is always zero | |
| positionCx=rand()%50+1; | |
| positionCy=rand()%50+1; | |
| positionCz=0; | |
| //show animation of player on platform runnign and jumping off. move into 1st person view. | |
| //start time counter | |
| time=clock(); | |
| int tI=time; | |
| bool running=true;//gamestate | |
| while (running)//game loop | |
| { | |
| //randomize spawning of asteroids | |
| //we dont want to many to spawn so generate a random number | |
| //use modular division by k(k is an intiger) to find remainder | |
| //when remaider is 0 create an asteraid at random startposition x, y | |
| //dynamicaly allocated asteroids? so we can haave more thatn one at a time | |
| creata=rand()%10; | |
| if (creata=0) | |
| { | |
| positionAx=rand()%50+1; | |
| positionAy=rand()%50+1; | |
| positionAz=-25; | |
| numast++; | |
| } | |
| //randomize spawnig of powerups | |
| //we dont want to many to spawn so generate a random number | |
| //use modular division by k(k is an intiger) to find remainder | |
| // when remaider is 0 create an asteraid at random startposition x, y | |
| //dynamicaly allocated? so we can haave more thatn one at a time | |
| creatp=rand()%50; | |
| if (creatp=0) | |
| { | |
| positionAx=rand()%50+1; | |
| positionAy=rand()%50+1; | |
| positionAz=-25; | |
| } | |
| cin<<move; | |
| //find input(swipe right left up down, tap screen, end icon, pause icon) | |
| //if a=left d=right w=up s=down | |
| //move character x and y according | |
| //change x or y and z | |
| switch(input) | |
| { | |
| case a: | |
| acceleration.x += -1.3; | |
| break; | |
| case s: | |
| acceleration.y += -1.3; | |
| break; | |
| case d: | |
| acceleration.x += 1.3; | |
| break; | |
| case w: | |
| acceleration.y += 1.3; | |
| break; | |
| } | |
| position = add(position, mul(acceleration, delta_time)); | |
| Char = add(Char, mul(position, delta_time)); | |
| //if tap screen | |
| //fire bullet to that tap location | |
| //change z | |
| //if pause icon or tab | |
| //change pause icon to unpause | |
| // system hold | |
| if(input=='09') | |
| { | |
| } | |
| //check for input unpause icon | |
| //return program to find input | |
| //if end icon or escape | |
| //end program | |
| //if no input character z position change | |
| //change charater postition | |
| //get x, y, z | |
| Char.z--; | |
| //change asteroid position | |
| //get x, y, z | |
| positionAz++; | |
| //change landing zone position | |
| //get x, y, z | |
| land.z++; | |
| //change powerups location | |
| //get x, y, z | |
| positionPz++; | |
| //change bullet position | |
| //get x, y, z | |
| bullet.z=positionBz-3; | |
| //change if bullets hit asteroid | |
| //if bullet z== asteroid z | |
| //if bullet x== asteroid x | |
| //if bullet y== asteroid y | |
| //asteroid blows up and is gone | |
| if(bullet.z=positionAz) | |
| then if(bullet.x=positionAx) | |
| then if(bullet.y=positionAy) | |
| { | |
| destroy the array | |
| numast--; | |
| } | |
| //find if character hits ateroid | |
| //if character z== asteroid z | |
| //if character x== asteroid x | |
| //if character y== asteroid y | |
| //compare force of asteroid to force of character(force =mass*aceleration) | |
| //if asteroid > character, character position changes>asteroid position | |
| //if character>asteroid, asteroid position change>character position | |
| //decrease shield by percentage of force | |
| //check shield | |
| //if sheild <=0 failure | |
| //show failed across the screen | |
| //ask to replay or return to menue | |
| //check input (replay or main menue) | |
| //if replay/ retry | |
| //set power up to nothing | |
| //set health to 100% | |
| //spawn character at begining | |
| //random x,y and z will be set at predetermined number> 10 | |
| //spawn landing zone at begining | |
| // random x y cordinant z is always zero | |
| //show animation of player on platform runnign and jumping off. move into 1st person view. | |
| //start time counter | |
| time=clock(); | |
| //if return to menue | |
| //return to main menue | |
| //find if asteroids hit asteroids | |
| //if astroidz==asteroidz | |
| //if astroidx==asteroidx | |
| //if astroidy==asteroidy | |
| //compare force of asteroid to force of astroid (force =mass*aceleration) | |
| //if asteroid>asteroid, asteroid position change>asteroid change | |
| //if asteroid>asteroid, asteroid position change>asteroid change | |
| //find if character hits powerups | |
| //if character z== powerup z | |
| //if character x== powerup x | |
| //if character y== powerup z | |
| //what is the power up | |
| //automaticaly start powerup | |
| //find if character hits landing zone | |
| //if character z== landing z | |
| //if character x== landing x+-4 | |
| //if character y== landing y+-4 | |
| //stop timer | |
| //display congragulations | |
| //show final time/ score | |
| time=clock-time; | |
| cout<<time*100<<" seconds; | |
| //save score, date, and difficulty level | |
| //ask to replay or return to main | |
| //check input (replay or main menue) | |
| //if replay/ retry | |
| //set power up to nothing | |
| //set health to 100% | |
| //spawn character at begining | |
| //random x,y and z will be set at predetermined number> 10 | |
| //spawn landing zone at begining | |
| // random x y cordinant z is always zero | |
| //show animation of player on platform runnign and jumping off. move into 1st person view. | |
| //start time counter | |
| //if return to menue | |
| //return to main menue | |
| //post score to world if internet connection and authorized. | |
| //find if character passes landing zone | |
| //if character z< landing z | |
| //get sucked into black hole | |
| //show failed across the screen | |
| //ask to replay or return to menue | |
| //check input (replay or main menue) | |
| //if replay/ retry | |
| //set power up to nothing | |
| //set health to 100% | |
| //spawn character at begining | |
| //random x,y and z will be set at predetermined number> 10 | |
| //spawn landing zone at begining | |
| // random x y cordinant z is always zero | |
| //show animation of player on platform runnign and jumping off. move into 1st person view. | |
| //start time counter | |
| //if return to menue | |
| //return to main menue | |
| //show time | |
| time=clock-tI; | |
| cout<<time*100<<" seconds; | |
| //we need to sleep until the next frame | |
| } | |
| return 0; | |
| } | |
| //power ups:speed boost, phase through, replenish shield,missiles, reflective force, black hole, | |
| /* | |
| start by jumping of a platform and free falling.In the distance you can see a landing platform | |
| Your goal is to land as close to the center of the landing pad as possible. | |
| on your way there will be debriese(asteroids) that if hit change your path and speed. | |
| It also drops your shield by a percentage.If your shiled drops to zero and you hit something game over. | |
| The character can be moved in the x and y axis's. The character may also shoot at the debries to move the debries. | |
| The goal is to have the fastest time and the most shield when landing on the landing platform. | |
| If the landing platform is missed game ends with a failed attempt. | |
| */ | |
| //functions | |
| //now we can make some vector functions | |
| vector3D add(vector3D left, vector3D right){ | |
| vector3D result = {}; | |
| result.x = left.x + right.x; | |
| result.y = left.y + right.y; | |
| result.z = left.z + right.z; | |
| return result; | |
| } | |
| vector3D mul(vector3D vector, float scalar){ | |
| vector3D result = {}; | |
| result.x = vector.x * scalar; | |
| result.y = vector.y * scalar; | |
| result.z = vector.z * scalar; | |
| return result; | |
| } | |
| float dot(vector3D left, vector3D right){ | |
| float result = (left.x * right.x) + (left.y * right.y) + (left.z * right.z); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment