Switched it to allow for up to 100 test objects before you can't prove which object is which via instance count.
This commit is contained in:
		
							
								
								
									
										7
									
								
								Ball.h
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Ball.h
									
									
									
									
									
								
							@@ -10,11 +10,16 @@ public:
 | 
			
		||||
	Ball() : GraphicsObject(&Ball::SetX, this) // pointer to self (specific instance)
 | 
			
		||||
		{
 | 
			
		||||
			instance_num = ++instance_counter;
 | 
			
		||||
			// NOTE(dev): don't go above 100, please, for the sake of the example.
 | 
			
		||||
		}
 | 
			
		||||
	void GetXFromPhysicsSimulation()
 | 
			
		||||
		{
 | 
			
		||||
			x = instance_num + ((rand() % 10) * 100); // move around by ten, but keep single digit
 | 
			
		||||
		}
 | 
			
		||||
	static void SetX(int &x, void *instance)
 | 
			
		||||
		{
 | 
			
		||||
			Ball *ball = static_cast<Ball*>(instance);
 | 
			
		||||
			ball->x = ball->instance_num; // prove we're accessing the right one
 | 
			
		||||
			ball->GetXFromPhysicsSimulation();
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user