Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with this code for game physics

Newbie
 
Join Date: Oct 2009
Posts: 2
#1: 4 Weeks Ago
Hi I am working though this book in my free time "Introduction to Game Development" by Steve Rabin and I hit a snag. Well on pg 402 there is aome psudo code that I cant understand what some of if means.
So I have this coded and I dont know where to go from here. This is prety much all I can get from this. What it supposed to do is a collection of N particals that move with out colideing, and then add some collition detection into this code later.
Expand|Select|Wrap|Line Numbers
  1. import java.lang.Math;
  2.  
  3. public class Euler {
  4.  
  5.     public static void main(String[] args) {
  6.         //data needed
  7.         float mass[];
  8.         float t;
  9.         float delta_t;
  10.         Vector3D cur_S[];
  11.         Vector3D prior_S[];
  12.         Vector3D S_derives[];
  13.         boolean gameOn = true; //keep game sim going
  14.  
  15.         //set current state to initial conditions
  16.         for(int i = 0, i < N; i++){
  17.             mass[i] = mass of particle i;
  18.             cur_S[2*i] = particle i initial linear momentum; 
  19.             sur_S[2*i+1] = particle i initial position; 
  20.         }
  21.  
  22.         while(gameOn == true){
  23.             delta_t.physicSim;
  24.             for (i = 0; i < N; i ++){ 
  25.                 Render particle i at postion cur_S[2*i +1]; 
  26.         }
  27.         }
  28.  
  29.         //do physic method
  30.         public void physicSim(delta_t){
  31.             prior_s = cur_S;
  32.             //calculate the staet derivative vector 
  33.             for(i = 0; i < N; i++){ 
  34.             S_derivs = CalcForce(i); 
  35.             S_derivs = prior_S[2*i] / mass[i];
  36.         }
  37.         }
  38.  
  39.         ExplicitEuler(2*N, cur_S, prior_S, S_derivs, delta_t); 
  40.  
  41.         t = t+ delta_t; 
  42. }
  43. }

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: 4 Weeks Ago

re: Help with this code for game physics


So what exactly is your problem here?
Newbie
 
Join Date: Oct 2009
Posts: 2
#3: 4 Weeks Ago

re: Help with this code for game physics


Well for one what is N supposed to be and also I dont know what this is particle too.
Thanks
Reply