It took two days until I had some time to look through your program. I'd like to give you some advice. The code is not bad as a first attempt, you obviously studied C++ but there are a few misunderstandings.
First a forum advice: next time, use the code button above the text area to enclose the program text in code tags, before and after. It will show a nice button to open and hide the code and it will also preserve the indentation, so it's easier to read. Now onto the programming advice.
You do not handle the return values of functions properly (for example choice1, choice2). The returned value of a function will not get into a global variable by itself. Your main game loop looks like this:
while(LoopGDK() && stillPlaying)
{
DisplayRPS();
PlayerChoice();
ComputerChoice();
DetermineWinner(choice1, choice2);
dbSync();
}
Although the PlayerChoice and ComputerChoice functions are executed, you don't do anything with their return value. You should do this instead:
while(LoopGDK() && stillPlaying)
{
DisplayRPS();
choice1 = PlayerChoice();
choice2 = ComputerChoice();
DetermineWinner(choice1, choice2);
dbSync();
}
See how the returned values are assigned to the global variables? Without these, the global choice1 and choice2 will always be zero (or in the worse case, heaven knows what value, because they are not even initialized).
DetermineWinner function: you made a mistake everywhere in the syntax of incrementing a variable. It is NOT:
but correctly:
so the equal sign is missing. Without that, it works like your function calls: executed but doesn't store the result back into the variable, so it doesn't increment anything.
In the same function, you made a syntax error in the equality check:
if(playerpoints = cpupoints)
This must be double equal sign:
if(playerpoints == cpupoints)
otherwise the playerpoints variable will be MADE equal to cpupoints, not only tested and the test will always be true...
The large nested "if" statement is not bad in itself, but a switch statement would be more elegant and readable.
PlayerChoice function: in all three tests, you give the same sprite number, so you are always testing the first sprite...
onSprite function: not bad, although I don't understand why you included the dbSpriteOffset if you haven't offset either of the sprites... But it would be simpler to use sprite collision. In games, it is customary to load a mouse cursor sprite which is moved together with the mouse and then you can use dbSpriteCollision to test whether this mouse sprite collided with any of the others. It returns the index of the clicked sprite and it is simpler than using coordinate calculations. But the coordinate method should work as well, as soon as you get the rest of the program working.
General game design: Do not reload images in every loop. You use dbLoadImage in functions which are called repeatedly from the main game loop, with the result that the program loads these images every time again from disk. It can even create a memory leak, I don't know the behaviour of Dark GDK if you reload an image over an existing one... You should load images once in the game setup and then use only the dbSprite commands to position the sprites where you need them. In fact, if the position of the sprites does not change, even the dbSprite command is enough once at the beginning because the screen update dbSync() does not erase sprites from the screen, as it erases text and drawing.
Likewise, the dbRandomize command should be called only once. Although with the timer as the seed, it will not repeat the random numbers, but it is really unnecessary to call it several times. Do this in the game setup.
If the dbRandomize command is replaced into the game setup part, actually one line can replace your whole ComputerChoice function:
int ComputerChoice()
{
return dbRND(2);
}
displayIntro function: when the title screen is not necessary any more, the image could be deleted from memory. Also, it is good practice to delete the used images and sprites when the program is finished, although Windows should clean up after your program but it's good to get used to deleting the resources when they are no longer needed.
mouseFullClick function: I see you already know that the program should detect when the mouse button is released, because dbMouseClick returns true as long as the button is held down. This is a possible way to do it. I'd just like to mention that this way, the user can freeze the program by holding down the mouse button, because as long as the while loop is running, the screen is not updated. Usually a game wants to remain moving whatever the player is doing, so it would be better to use a static variable to keep track of the status of the mouse button and get rid of the while loop. I'll write an example next time if you are interested, but I guess this won't cause a problem for now.
These are the comments I can give you about the program. With just a little tweaking and correcting, you should be able to get it working nicely. Good luck and don't give up!