Simple Scoring system for game

Posted 30 March 2012 - 03:46 PM

Im creating a game which has a simple score system which i dont understand why it isnt working the way i want it to
When loading the game the User starts with 10 credits and for every time they run the game it costs 2 credits
This is my code for this below

it has no errors but it doesn't take away the credits each time the game is played besides the first time
so when i run the game it will go to 8 credits, and it will stay on 8 credits even if i run the game again
can anyone see a problem with my code above?
Thanks

Replies To: Simple Scoring system for game

Re: Simple Scoring system for game

Posted 30 March 2012 - 03:50 PM

There is nothing wrong with the code, just wrong with the logic. If this code is run only in form load then it will only ever subtract 2 credits from the 10 credits. May I suggest using a CommandButton or something along those lines and use a code structure similar to this:

Re: Simple Scoring system for game

Posted 30 March 2012 - 03:58 PM

DimitriV, on 30 March 2012 - 03:50 PM, said:

There is nothing wrong with the code, just wrong with the logic. If this code is run only in form load then it will only ever subtract 2 credits from the 10 credits. May I suggest using a CommandButton or something along those lines and use a code structure similar to this:

So that code would go in the declarations code section. Then for a click event of your button use this code:

intGamesPlayed += 1
intCredits -= 2

Cheers

Im not totally sure what you mean, Should have stated but this code isn't placed the form load I have it under a button, So that when the button is clicked this code should execute but it only does it once
Am i making sense or am i wrong? lol

Re: Simple Scoring system for game

Posted 30 March 2012 - 04:22 PM

DimitriV, on 30 March 2012 - 04:05 PM, said:

In that case, every time you click the button it redeclares a credits variable holding 10 credits!

I read your first post again I see what you meant now, its working now you win again
ive another question related to my point system if you can help, ill try explaining this first
ive got 3 picture boxes with the images being random, if 2 of these images end up the same my game will add 5 credits, if 3 of the images end up the same my game will add 10 credits.

ive done If Statements for this, but ive ended up with alot of code for this as there is alot of combinations that can be right