Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 29 May 2013
Offline Last Active Today, 08:01 AM

Topics I've Started

2D physics, random line geometry, many balls, and jitter problem

21 April 2014 - 10:55 PM

Hi guys,


I have managed to cobble together a simple phyiscs simulation with random line geometry, and as many balls as I wish to create, all of which posses mass, resitituion and friction properties,


Collision and all of the physical properties seem to work fine, but I can't get the balls to settle, once they are close to rest, they keep jittering and bouncing slightly, and it's really unappealing. I tried implementing a threshold, but it did not solve my problem. Here's a section of the main loop.

		for(int i=0;i<balls.size();i++)

		for(int i=0;i<balls.size();i++){//balls vs balls
			for(int j=i+1;j<balls.size();j++){
				V2 coll_normal;
		for(int i=0;i<lines.size();i++){//lines vs balls
			for(int j=0;j<balls.size();j++){
				V2 point(0,0);

I was wondering if anyone has a good perspective on settling the balls to a resting state.





.fla viewing source code

17 April 2014 - 10:26 AM

Hi guys,


I found some physics tutorials online and I am interested in viewing the source but the files provided are .fla format. I tried opening it up in notepad++ but got a lot of garbage.


Without having to download some propriatery IDE, registering and all the other nonsense, is there an easy way to get at the source? I don't want to program or edit, just view.





2D, Ball and Line distance problem

11 April 2014 - 12:46 PM

Hi guys,


Here's my problem...


I have a ball constructor Ball(x,y) and a line constructor Plane(x0,y0,x1,y1)



The norm of the line is defined as dx=x1-x0, and dy=y1-y0, where the normal vector is either norm(-dx,dy) or norm(dx,-dy)


In order the gauge the distance from the ball at some arbitrary position to the line/plane at some arbitrar position, I use the followin funcition:

float Plane::distToPlane(Ball &ball){
	float dot_prod=(ball.getCricle().position.dot(normal));
	return (dot_prod);

Everything works fine except the float that's returned I can't use. What I really need, is a as the ball is approaching the line, the distance get's closer and closer to zero, and right now it's not doing that.


I need to be able to do this check for any arbitrary line/ball position:


if(distance<0)//do this


I guess what I am really trying to say is that I need this....

float Plane::distToPlane(Ball &ball){
	float dot_prod=(ball.getCricle().position.dot(normal)+SOME_OFFSET);
	return (dot_prod);

Where the offset will always close the dot product to zero no matter where the ball and the line start.


I have been trying many different things but can't grasp the mathematical relationship.


If anyone has any idea on how to approach the problem, please let me know.






measuring efficiency in a game

05 February 2014 - 05:11 PM

Hello everyone,


I have a general question I have been thinking about for some time. My gaming experience so far has involved 2D side scrollers. Every now and then I read up on statements such as "trig ratio functions are resource expensive" and "SDL rotozoom should not be used as it's too costly."


I am sure that these statements are true, but how does a newbie game developer measure or keep track of how resource intensive a game is? Obviously when the application slows down I know too many resource are being used, but are there are programs, strategies or advice that someone can tell me about which will point me in the right direction in measuring program efficiency?





Using SDL Rotozoom

24 December 2013 - 09:12 AM

Hi guys,


I am having a problem using SDL_Rotozoom.


(1) I downloaded the SDL2_gfx library.

(2) I put the SDL2_rotozoom.h and SDL2_rotozoom.c into my project folder

(3) Then, I typed in <SDL_rotoroom.h> (I am not sure why the file is called SDL2_rotozoom.h, beacuse when I type in <SDL2_rotozoom.h> visual studio complains.

(4) I went into project->c/c++->general->additional include directories and put in my path for my project


However, when I try to compile, visual studio tells me:


"1>main.obj : error LNK2019: unresolved external symbol _rotozoomSurface referenced in function _SDL_main
1>C:\Users\Mike\Documents\Visual Studio 2010\Projects\sdl_tutorial\Debug\sdl_tutorial.exe : fatal error LNK1120: 1 unresolved externals"


I have never tried to use an "outside" .h and .c in any of my projects before so I am not quite sure what I am doing wrong. Any help would be greatly appreciated.