# C++ incline friction simulation game time problem

Page 1 of 1

## 10 Replies - 2289 Views - Last Post: 02 May 2011 - 04:30 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=228266&amp;s=89cf1d61098ca09c906646956dd9a968&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 elephaNtastic

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 28-November 10

# C++ incline friction simulation game time problem

Posted 18 April 2011 - 03:06 PM

These are .cpp and .h classes for a square particle that is supposed to go down the incline. moveConst() function works fine, moves the square from one side of the screen to another. I cant figure out why addAcc or updateAcc functions wont work. any help would be very appreciated
#include "particleModel4.h"
#include<math.h>

float ParticleModel4::forceFx(){

forceF.x = u * m* g *cos(angle);
return(forceF.x);
}
float ParticleModel4::forceNx(){
forceN.x = m*g*cos(angle);
return (forceN.x);
}
float ParticleModel4::forceTx(){
forceT.x = m*g*sin(angle);
return (forceT.x);
}
float Nx();
float forceFy();
float forceNy();
float forceTy();
float Ny();
float ParticleModel4::updateNetForce(){
netForce.x = forceFx()+forceNx()+forceTx();
return (netForce.x);
}

void ParticleModel4::updateAcc(){
if (forceTx() < forceFx())
{
//acc.x = (forceTx() - forceFx())/m;
acc.x = g * (sin(angle) - u * cos(angle)) * cos(angle);
acc.y = g * (sin(angle) - u * cos(angle)) * sin(angle);

DWORD curTime = GetTickCount();
if((curTime - prevTime) >= 100){prevTime = curTime;}

if (pos.y <= 450)
{
acc.y += acc.y;
}
else
{
pos.y += acc.y*prevTime;
pos.x += acc.x*prevTime;
}
}
}

static unsigned long LastTime = GetTickCount();
unsigned long CurrentTime = GetTickCount();
unsigned long interval = CurrentTime - LastTime; // time in ms
unsigned long intervalSec = interval; // convert to sec /100

DWORD curTime = GetTickCount();
if((curTime - prevTime) >= 10000){prevTime = curTime;}

if (pos.y <= 450)
{
acc.y += acc.y;
}
else
{
pos.y += acc.y*interval;
pos.x += acc.x*prevTime;
}
LastTime = CurrentTime;
}

void ParticleModel4::moveConst()
{
static unsigned long LastTime = GetTickCount();
unsigned long CurrentTime = GetTickCount();
unsigned long interval = CurrentTime - LastTime; // time in ms
unsigned long intervalSec = interval; // convert to sec /100
//float timer = TimerValSec;

pos.x += vel.x * intervalSec;
//Sleep(100);
LastTime = CurrentTime;
//timer++;

}

.h

#ifndef _PARTICLEMODEL4_H
#define _PARTICLEMODEL4_H

#include	<windows.h>
#include	"dataTypes.h"		/* include file for custom data types */
#include	"graphics.h"		/* include file for graphics module */
#include	"input.h"			/* include file for user input module */

class ParticleModel4 {
private:

public:
Point2D 	pos;// position of particle used as physics model of game object
Point2D		dis;
Point2D		vel;
float			m;
float			g;
float			u;
float			angle;
Point2D			acc;
Point2D			forceF; // = u*m*g*cos0 = u*forceN
Point2D			forceN; // = m*g*cos0
Point2D			forceT; // = m*g*sin0
Point2D			N; // -N = forceN = m*g*cos0
Point2D			netForce;
DWORD			prevTime;
// if forceT > forceF the box slides down hill
// a = (forceT - forceF)/m;
ParticleModel4(){
m = 10;
g = -9.81;
u = 0.3;
angle = 45;
vel.x = 0.1;
acc.x = 0;
acc.y = 0;
prevTime = 0;
}
long int curTime;
int moveRight();			// Move particle towards right
int moveLeft();
void moveConstDisp();
float forceFx();
float forceNx();
float forceTx();
float Nx();
float forceFy();
float forceNy();
float forceTy();
float Ny();
float updateNetForce();
void updateAcc();
void moveConst();

};
#endif

Is This A Good Question/Topic? 0

## Replies To: C++ incline friction simulation game time problem

### #2 #define

• Duke of Err

Reputation: 1853
• Posts: 6,671
• Joined: 19-February 09

## Re: C++ incline friction simulation game time problem

Posted 18 April 2011 - 06:42 PM

One thing - the angle in cos(angle) and sin() need to be in radians.

sin

### #3 elephaNtastic

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 28-November 10

## Re: C++ incline friction simulation game time problem

Posted 19 April 2011 - 03:41 AM

Thank you, I converted angles to radians, but it still doesn't move

### #4 janotte

• code > sword

Reputation: 991
• Posts: 5,141
• Joined: 28-September 06

## Re: C++ incline friction simulation game time problem

Posted 19 April 2011 - 03:56 AM

Can you extract enough of your program so that it compiles and demonstrates the error you are having?
If you can't then post the whole program.

We can help you a lot more if we have a compiling program to work with.

### #5 elephaNtastic

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 28-November 10

## Re: C++ incline friction simulation game time problem

Posted 19 April 2011 - 04:47 AM

The program runs but it doesn't do what I want it to. I watched variables: prevTime, acc.x, acc.y, pos.x, pos.y. prevTime: is 4340433 and keeps increasing by random amount in thousands every time I click play. acc.x and acc.y hold correct calculation results. pos.x += acc.x*prevTime; line doesn't work. As I skip pos.x and pos.y values do not increase.

### #6 janotte

• code > sword

Reputation: 991
• Posts: 5,141
• Joined: 28-September 06

## Re: C++ incline friction simulation game time problem

Posted 19 April 2011 - 04:54 AM

If you can't understand the program when you are running it your debugger imagine how hard it is for us to understand the portion of the program you have shared with us based on your vague description of what you are seeing in the debugger.

Again, if you share a compiling program with us we can help you a lot more.

### #7 elephaNtastic

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 28-November 10

## Re: C++ incline friction simulation game time problem

Posted 19 April 2011 - 05:10 AM

OK Here is the code from relevant classes:
#ifndef _gameObject4_H
#define _gameObject4_H
#include	<windows.h>
#include	"dataTypes.h"		/* include file for custom data types */
#include	"graphics.h"		/* include file for graphics module */
#include	"input.h"			/* include file for user input module */
#include	"particleModel4.h"

class GameObject4{
public:

/*
* Attributes of objects that make up the game world
*/
// Appearance attributes (for object display)
Point2D		shape4[4];			// array to store a polygonal shape consisting of four vertices (e.g. a square)
void setShape2Square4();		// Set shape of object to square

};
#endif

#ifndef _PARTICLEMODEL4_H
#define _PARTICLEMODEL4_H

#include	<windows.h>
#include	"dataTypes.h"		/* include file for custom data types */
#include	"graphics.h"		/* include file for graphics module */
#include	"input.h"			/* include file for user input module */

class ParticleModel4 {
private:

public:
Point2D 	pos;// position of particle used as physics model of game object
Point2D		dis;
Point2D		vel;
float			m;
float			g;
float			u;
float			angle;
Point2D			acc;
Point2D			forceF; // = u*m*g*cos0 = u*forceN
Point2D			forceN; // = m*g*cos0
Point2D			forceT; // = m*g*sin0
Point2D			N; // -N = forceN = m*g*cos0
Point2D			netForce;
DWORD			prevTime;
// if forceT > forceF the box slides down hill
// a = (forceT - forceF)/m;
ParticleModel4(){
m = 10;
g = -9.81;
u = 0.3;
angle = 45;
vel.x = 0.1;
acc.x = 0;
acc.y = 0;
prevTime = 0;
}
long int curTime;
int moveRight();			// Move particle towards right
int moveLeft();
void moveConstDisp();
float forceFx();
float forceNx();
float forceTx();
float Nx();
float forceFy();
float forceNy();
float forceTy();
float Ny();
float updateNetForce();
void updateAcc();
void moveConst();

};
#endif

/*

#ifndef _WORLDDATA_H
#define _WORLDDATA_H

#include	<windows.h>
#include	"dataTypes.h"		/* include file for custom data types */
#include	"graphics.h"		/* include file for graphics module */
#include	"input.h"			/* include file for user input module */
#include	"particleModel.h"
#include	"gameObject.h"
#include	"particleModel2.h"
#include	"gameObject2.h"
#include	"particleModel3.h"
#include	"gameObject3.h"
#include	"particleModel5.h"
#include	"gameObject5.h"
#include	"particleModel4.h"
#include	"gameObject4.h"
class WorldData
{
private:

/*
* Attributes of objects that make up the game world
*/
// Appearance attributes (for object display)
Point2D		dispBuffObj[4];		// array to store display coordinates of a polygonal object
Point2D		dispBuffObj2[4];
Point2D		dispBuffObj3[4];
Point2D		dispBuffObj4[4];
Point2D		dispBuffObj5[2];
// Dynamics parameters (for physics simulation)

long int relTime, initTime;
public:

// Constructors and destructor
WorldData();
~WorldData();

int worldDataModuleInit();						// Initialise the world
void worldCleanUp();							// Release objects, if applicable

int update(keyEvent kEvent);					// Update the world's dynamics state

int draw(GraphicsM * pGraphicsModule);			// Draw the world

/* Set / get attributes of game object */
void setPosition(float xCoord, float yCoord);   // Set world position of game object
void setPosition2(float x, float y);
void setPosition3(float x, float y);
void setPosition4(float x, float y);
void setPosition5(float x, float y);

Point2D getPosition();							// Get position of game object
Point2D getPosition2();
Point2D getPosition3();
Point2D getPosition4();
Point2D getPosition5();

private:
ParticleModel pModel;
GameObject cube;
ParticleModel2 pModel2;
GameObject2 cube2;
ParticleModel3 pModel3;
ParticleModel5 pModel5;
ParticleModel4 pModel4;
GameObject3 cube3;
GameObject4 cube4;
GameObject5 cube5;
/* Apply physics formulae to particle */

/* Graphics data update (before actual display) */
int dispBufUpdate();		// Update display buffer
int dispBufUpdate2();
int dispBufUpdate3();
int dispBufUpdate5();
int dispBufUpdate4();
};

#endif /* _WORLDDATA_H */

Source Files .cpp

#include "gameObject4.h"
void GameObject4::setShape2Square4(){
shape4[0].x = 0.0F;		shape4[0].y = 0.0F;
shape4[1].x = 10.0F;	shape4[1].y = 0.0F;
shape4[2].x = 10.0F;	shape4[2].y = 10.0F;
shape4[3].x = 0.0F;		shape4[3].y = 10.0F;
}

#include "particleModel4.h"
#include<math.h>
#define PI 3.14159265

float ParticleModel4::forceFx(){

forceF.x = u * m* g *cos(PI * angle/180);
return(forceF.x);
}
float ParticleModel4::forceNx(){
forceN.x = m*g*cos(PI * angle/180);
return (forceN.x);
}
float ParticleModel4::forceTx(){
forceT.x = m*g*sin(PI * angle/180);
return (forceT.x);
}
float Nx();
float forceFy();
float forceNy();
float forceTy();
float Ny();
float ParticleModel4::updateNetForce(){
netForce.x = forceFx()+forceNx()+forceTx();
return (netForce.x);
}

void ParticleModel4::updateAcc(){

//acc.x = (forceTx() - forceFx())/m;
acc.x = g * (sin(PI * angle/180) - u * cos(PI * angle/180)) * cos(PI * angle/180);
acc.y = g * (sin(PI * angle/180) - u * cos(PI * angle/180)) * sin(PI * angle/180);

DWORD curTime = GetTickCount();
if((curTime - prevTime) >= 1000){prevTime = curTime;}

if (pos.y <= 450)
{
acc.y += acc.y;
}
else
{
pos.y += acc.y*prevTime;
pos.x += acc.x*prevTime;
}
}

static unsigned long LastTime = GetTickCount();
unsigned long CurrentTime = GetTickCount();
unsigned long interval = CurrentTime - LastTime; // time in ms
unsigned long intervalSec = interval; // convert to sec /100

DWORD curTime = GetTickCount();
if((curTime - prevTime) >= 10000){prevTime = curTime;}

if (pos.y <= 450)
{
acc.y += acc.y;
}
else
{
pos.y += acc.y*interval;
pos.x += acc.x*prevTime;
}
LastTime = CurrentTime;
}

void ParticleModel4::moveConst()
{
static unsigned long LastTime = GetTickCount();
unsigned long CurrentTime = GetTickCount();
unsigned long interval = CurrentTime - LastTime; // time in ms
unsigned long intervalSec = interval; // convert to sec /100
//float timer = TimerValSec;

pos.x += vel.x * intervalSec;
//Sleep(100);
LastTime = CurrentTime;
//timer++;

}

/*

#include "worldData.h"

/*----------------------------------------------------------------------------\
*                                                                            |
*                       INITIALISATION AND CLEAN UP                   		  |
*                                                                            |
*----------------------------------------------------------------------------*/

/*
Constructs and initialises a world data management module

Parameter list
none
*/

WorldData::WorldData()
{
/* TO DO: add relevant code */

}

/**
Initialises the world

Parameter list
none.
*/
int WorldData::worldDataModuleInit()
{
/* TO DO: add relevant code */

// Initialise dynamics parameters (for physics simulation) of world objects
setPosition(500.0F, 20.0F);
setPosition2(500.0f,  40.0f);
setPosition3(50.0F, 300.0F);
setPosition4(640.0F, 345.0F);
setPosition5(100.0F, 300.0F);
/* TO DO: Call functions to set other particle model parameters, e.g. velocity, acceleration, ... */

// Initialise appearance parameters of game object
cube.setShape2Square();         /* Set shape of object to square */
cube2.setShape2Square2();
cube3.setShape2Square3();
cube5.setShape2Square5();
cube4.setShape2Square4();
return 1;
}

/*
Destructs world data management module

Parameter list
none
*/
WorldData::~WorldData()
{
/* TO DO: add relevant code */

worldCleanUp();

return;
}

/*
Releases objects

Parameter list
none
*/

void WorldData::worldCleanUp()
{
/* TO DO: add relevant code */

return;
}

/*
* Sets shape of object as square.
*
* Parameter list
*        none.
*/

/*----------------------------------------------------------------------------\
*                                                                            |
*                  STATE ACCESS (get / set) FUNCTIONS                        |
*                                                                            |
*----------------------------------------------------------------------------*/

/*
* Sets position of particle.
*
* Parameter list
*        xPos		x-coordinate of position.
*        yPos		y-coordinate of position.
*/
void WorldData::setPosition(float xPos, float yPos)
{
// position of particle
pModel.pos.x = xPos; pModel.pos.y = yPos;
}
void WorldData::setPosition2(float xPoss, float yPoss)
{
pModel2.pos2.x = xPoss; pModel2.pos2.y = yPoss;
}
void WorldData::setPosition3(float xPoss, float yPoss)
{
pModel3.pos3.x = xPoss; pModel3.pos3.y = yPoss;
}
void WorldData::setPosition5(float xPoss, float yPoss)
{
pModel5.pos5.x = xPoss; pModel5.pos5.y = yPoss;
}
void WorldData::setPosition4(float xPoss, float yPoss)
{
pModel4.pos.x = xPoss; pModel4.pos.y = yPoss;
}
/* TODO: Add functions to set other particle model parameters, e.g. velocity, acceleration, ... */

/*
* Gets position of particle.
*
* Parameter list
*        none.
*/
Point2D WorldData::getPosition()
{
return pModel.pos;
}
Point2D WorldData::getPosition2()
{
return pModel2.pos2;
}
Point2D WorldData::getPosition3()
{
return pModel3.pos3;
}
Point2D WorldData::getPosition4()
{
return pModel4.pos;
}
/* TODO: Add functions to get other particle model parameters, e.g. velocity, acceleration, ... */

/*----------------------------------------------------------------------------\
*                                                                            |
*                                  STATE UPDATE                              |
*                                                                            |
*----------------------------------------------------------------------------*/

/*
* Updates world state.

Parameter list
kEvent       input event ID.
*/
int WorldData::update(keyEvent kEvent)
{
/* TO DO: add relevant code */
// For example:
// update world position of square as determined by user input.
switch(kEvent)
{
// Update parameters of virtual world

case UP:
// TO DO: service up-key as approriate
pModel2.moveUp();
break;
case DOWN:
// TO DO: service down-key as approriate
pModel2.moveDown();
break;
case RIGHT:
// TO DO: service right-key as approriate
// For example:
// update world position of object to move it to the right.
pModel.moveRight();
break;
case LEFT:
// TO DO: service left-key as approriate
pModel.moveLeft();
break;
case SPACE:
pModel3.shoot();
default:
// TO DO: service "all-other-keys" as approriate

break;
}
if (pModel.pos.x > 600)
{pModel.vel.x *= -1;}
else if (pModel.pos.x < 10)
{pModel.vel.x *= -1;}
if (pModel4.pos.x > 640)
{pModel4.vel.x *= -1;}
else if (pModel4.pos.x < 50)
{pModel4.vel.x *= -1;}

//pModel.moveConstDisp();
pModel.moveConstVel();
//pModel4.moveConst();
pModel4.updateAcc();
return 1;

}

/*
Updates particle position: move particle towards right.

Parameter list
none
*/

/* TO DO: Add other functions to update position using appropriate formulae */

/* TO DO: Add functions to update other particle model parameters, e.g. velocity, acceleration, ... */

/*----------------------------------------------------------------------------\
*                                                                            |
*                                   DISPLAY                                  |
*                                                                            |
*----------------------------------------------------------------------------*/

/*
Draws the world.

Parameter list
pGraphicsModule       pointer to graphics module.
*/
int WorldData::draw(GraphicsM * pGraphicsModule)
{
/* TO DO: add relevant code */

/* Display world */

//   Draw the square.
dispBufUpdate();	// update content of display buffer (with outline of square at its current position)
pGraphicsModule->drawPolygon(dispBuffObj, 4, true); // display content of buffer
dispBufUpdate2();
pGraphicsModule->drawPolygon(dispBuffObj2, 4, true); // display content of buffer
dispBufUpdate3();
pGraphicsModule->drawPolygon(dispBuffObj3, 4, true); // display content of buffer
dispBufUpdate5();
pGraphicsModule->drawPolygon(dispBuffObj5, 2, true); // display content of buffer
dispBufUpdate4();
pGraphicsModule->drawPolygon(dispBuffObj4, 4, true); // display content of buffer
return 1;
}

/*
* Updates content of display buffer.
*
* Parameter list
*        none.
*/
int WorldData::dispBufUpdate()
{
/* TO DO: add relevant code */

// update display object (content of display buffer (with calculated vertex coordinates of square at its current position))
for (int vert = 0; vert < 4; ++vert)
{
dispBuffObj[vert].x = cube.shape[vert].x + pModel.pos.x;
dispBuffObj[vert].y = cube.shape[vert].y + pModel.pos.y;
}

return 1;
}

int WorldData::dispBufUpdate2()
{
/* TO DO: add relevant code */

// update display object (content of display buffer (with calculated vertex coordinates of square at its current position))
for (int vert = 0; vert < 4; ++vert)
{
dispBuffObj2[vert].x = cube2.shape2[vert].x + pModel2.pos2.x;
dispBuffObj2[vert].y = cube2.shape2[vert].y + pModel2.pos2.y;
}

return 1;
}
int WorldData::dispBufUpdate3()
{
/* TO DO: add relevant code */

// update display object (content of display buffer (with calculated vertex coordinates of square at its current position))
for (int vert = 0; vert < 4; ++vert)
{
dispBuffObj3[vert].x = cube3.shape3[vert].x + pModel3.pos3.x;
dispBuffObj3[vert].y = cube3.shape3[vert].y + pModel3.pos3.y;
}

return 1;
}
int WorldData::dispBufUpdate5()
{
/* TO DO: add relevant code */

// update display object (content of display buffer (with calculated vertex coordinates of square at its current position))
for (int vert = 0; vert < 2; ++vert)
{
dispBuffObj5[vert].x = cube5.shape5[vert].x;
dispBuffObj5[vert].y = cube5.shape5[vert].y;
}

return 1;
}
int WorldData::dispBufUpdate4()
{
/* TO DO: add relevant code */

// update display object (content of display buffer (with calculated vertex coordinates of square at its current position))
for (int vert = 0; vert < 4; ++vert)
{
dispBuffObj4[vert].x = cube4.shape4[vert].x + pModel4.pos.x;
dispBuffObj4[vert].y = cube4.shape4[vert].y + pModel4.pos.y;
}

return 1;
}

Here are all of the relevant header and source files, if necessary I can attach the actual files. Thank you

This post has been edited by elephaNtastic: 19 April 2011 - 05:14 AM

### #8 #define

• Duke of Err

Reputation: 1853
• Posts: 6,671
• Joined: 19-February 09

## Re: C++ incline friction simulation game time problem

Posted 19 April 2011 - 04:48 PM

Acceleration only needs to be calculated once since it is a constant.
The velocity and position will change.

Equations of motion

### #9 elephaNtastic

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 28-November 10

## Re: C++ incline friction simulation game time problem

Posted 01 May 2011 - 10:30 PM

I fixed all of the equations, I don't know how to apply them in real time This is what i got so far for moving the object down the incline.... main function
float countTicks;
void ParticleModel4::downHill()
{
static unsigned long LastTime = GetTickCount();
unsigned long CurrentTime = GetTickCount();
float a = forceFx(); // force friction
float velxx = velX(); // vel.x = 2* a.x * s
float accxx = updateAccX(); //acc.x = (forceTx() - forceFx())/m;
float velyy = velY(); // vel.y = 2* a.y * s
float accyy = updateAccY(); //acc.y = (forceTy() - forceFy())/m;
unsigned long interval = GetTickCount() - LastTime; // time in ms
long intervalSec = interval/100; // 1sec
//bool hit = false;

if (pos.x > 350 && pos.y > 250){ // while on the incline
countTicks += intervalSec;
pos.x -= velxx * countTicks + accxx * countTicks * countTicks / 2;
velxx += accxx * countTicks;
pos.y += velyy * countTicks + accyy * countTicks * countTicks / 2;
velxx += accyy * countTicks;
}
else
{
pos.x += -((velxx) * (velxx)) / (2 * -a); //displacement with friction in straight line
}
countTicks += intervalSec;
//}
//

LastTime = CurrentTime;

}

the function above is supposed make an object go down the incline when button is clicked. So far it only jumps down by a random amount to the right direction after clicking the button several times. please please please help me.

This post has been edited by elephaNtastic: 01 May 2011 - 10:32 PM

### #10 elephaNtastic

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 28-November 10

## Re: C++ incline friction simulation game time problem

Posted 01 May 2011 - 10:39 PM

I'm trying to simulate 2D projectile motion. So far I have done all of the calculations, checked them, wrote them in C++. I got stuck with applying them and getting the time right. Code so far:
#include<math.h>
#define PI 3.14159265

float intervalSec = 0;
void ParticleModel3::shoot()
{
float time2 = 0;
// vO = 50, angle = 60, g = -9.81
DWORD LastTime1 = GetTickCount();
float radianX = (PI / 180) * angle;
velO.x += (vO)*(cosf(radianX));  // 25
velO.y += (vO)*(sinf(radianX)); // velocity from orginial vel  43.301
float t = (0 - velO.y) / g; // time to reach high point y-axis 4.413
//disY = disY / t; // displacement per second in y-axis till high point
float t2 = (-2 * velO.y) / g ; // total motion time 8.827
float disY = velO.y * t + 0.5*g*((t)*(t)); // high point y-axis 95.566
float disX = vO *t2*(cos(angle)); // x-axis displacement 220.675
float disYD = 0.5 * g * ((t2 - t) * (t2 - t)); //down the Y- axis -95.566

DWORD LastTime2 = GetTickCount();

static unsigned long LastTime = GetTickCount();
unsigned long CurrentTime = GetTickCount();
unsigned long interval = CurrentTime - LastTime; // time in ms
intervalSec = interval;

while ( time2 < t2*1000)
{
if (time2 < t*1000){
pos3.y += velO.y * time2 + 0.5*g*((time2)*(time2));
pos3.x += vO *time2*(cos(radianX));
}
else{
float disYD = 0.5 * g * ((t2 - t) * (t2 - t)); //down the Y- axis -95.566
pos3.x += vO *time2*(cos(radianX));
pos3.x += 0.1 + time2;
}
time2 += intervalSec;

}

LastTime = CurrentTime;

The shoot function should move the projectile when space button is clicked.
Any help would be really appreciated.

• Saucy!

Reputation: 6246
• Posts: 24,014
• Joined: 23-August 08

## Re: C++ incline friction simulation game time problem

Posted 02 May 2011 - 04:30 AM

Merged duplicate topics. Please do NOT create a new topic when you already have on on the same project.