In my code i have got when player touches point,it registers collision and prints out score in the console, the problem is that for some reason instead of just printing one
score-point per point (There is 10 points in the array) it continues to add score for as long as the player is colliding with said point, how do I limit it...

I'm sorry, you have the wrong forum. I believe you were looking for the psychic friends forum.

Please provide example

Where is the code? How are we supposed to know whats the problem when there is no code. Also printf() sounds like C++ and you are making a GAME! This is a completely different forum SOFTWARE DEVELOPMENT --> C or SOFTWARE DEVELOPMENT --> GAME DEELOPMENT

Please provide example

@Narue No need to be rude..

Sorry about that I forgot here is the printf code

playerA.score++;
printf(" point[%d] score=%d", k, playerA.score);

Is that all or do you need the actual collision code as well.

Sorry if this is in the wrong place, still new at these forums.

What are the types for k and playerA.score, int?

What are the types for k and playerA.score, int?

Pretty sure yes,

In that case its not clear what the problem is. Try to narrow it down and give us some sample code where the problem manifests itself.

That was the code narrowed down, do you want me to add more?, here's an example hopefully this will explain it better
When player touches the point,it is supposed to give something like this and then stop like this
point[1] score=1

instead it does this

point[1] score=1 point[1] score=2 point[1] score=3 point[1] score=4 point[1] score=5 etc and keeps going up rapidly for as long as the player is within 10 pixels of the point.

Maybe this will help.

for (int k=0;k<POINTSNUMBER;k++)
					{
						
						{
							if ((abs(points[k][0]-playerA.x)<10)&&(abs(points[k][1]-playerA.y)<10))
							
							{
								playerA.score++;
								printf(" point[%d] score=%d", k, playerA.score);
							}

						}
					}

put a print statement before the for loop

printf("entering for loop...");

and see what happens...

It repeats the entering the loop...Is this because the code is within the game loop and keeps refreshing...

Most probably. Perhaps you only want to fire this code on the first mouse click (down or up) only.

Hmm, Well I don't have a mouse up or down, got a motion, I put it in that and that sort of works, problem is it still goes has more than one score-point per point but only one at a time this time. Is there a way to disable the collision when the point is hit once?

Perhaps you can maintain state when a point is hit and only update when it changes.

So change collision to false when point is hit? or would that affect the other points in the array...

Depending on the input device used, most probably there is a start and end events generated. If so that would may be the cleanest solution to the problem.

Thanks a lot I put in bool, and now it works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.