Main Menu
  • Welcome to The RPG Maker Resource Kit.

Scoring In GameMaker

Started by Minihobbs, May 27, 2007, 12:58:23 PM

0 Members and 1 Guest are viewing this topic.

Minihobbs

I found the D&D score thing in GameMaker very hard to understand, and I told that GML was easier. I would like to know how to show the score, and know how to add 1 to it each time.

I have tried the following code below...
CODE STARTS
show_score
score += 1;

...but that has failed and comes up with the error message:

"COMPILATION ERROR in code action
Error in code at line 71:
score += 1;

at position 2: Assignment operator expected."
CODE ENDS

If someone could show me how to solve it, thanks in advance.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Hmmmmm...

Well, whoever told you that GML was easier is probably wrong. GML is not only a little harder (for me at least) to keep organized, and a little more glitch prone, but D&D is also read much faster by the compiler.

Could you please copy the entire code into a new post?

Minihobbs

I have sorted the problem.

I did that by finding out that I had to do the following:-

show_score = true;

I now want to know how I can show the score on the screen itself...rather than in the windows window thingy.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

There is a way, uh...lemme think.

You would just tell it to draw text, and in the place where it asks what text to show jusy say...player.score, I think.

I'm sorry, but I don't use either of those functions in any of my projects. If you continue to have trouble figuring it out, just say so, and I'll try to hook you up with an example.

Minihobbs

I have tried:

draw_text(0,32,score);

But it doesn't seem to work.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Hm. Well, I'll try to hook you up, just give me about a day. :D

ChaosSpartan28

Here is an example. All I did was change a system unction(see picture below) so that it wont show the border(therefore not showing the score as well).

Hope this helps. :D
Sig by MacGravel

Minihobbs

Not trying to be rude Stephen, but I'm having a bit fo a hard time learning/understanding .rar example you let me have a look at.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Minihobbs

Sorry for the double post. I have sorted the on screen score out. Now i might as well link this problem in this topic instead of starting a new one.

Rigth, so I have my score system set up using the gm score. But the thing is, I would like to know how to show the score on a scorecard at the end of each hole. I have set up another room, but I want to know how to show the score that the player got on that hole and pevious holes.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Okay, that I can tell you off the top of my head. ;D

Make a global variable called global.score. Set that variable to the player's score at the end of each level. Then, make the board check that variable, and display a corresponding number. :D

Minihobbs

Quote from: Arrow-1 on May 28, 2007, 02:21:19 PM
Okay, that I can tell you off the top of my head. ;D

Make a global variable called global.score. Set that variable to the player's score at the end of each level. Then, make the board check that variable, and display a corresponding number. :D
Sorry, about this, but where do I put this. Also, if you could use a little step by step, it will help me understand and learn better. That is the only way I can learn the code. Sorry if I'm being rude.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

No no, its perfectly fine! Do it like this:

1. Go to the object you use to handle score in the room where the game is played (where the score is set for the scoreboard).

2. Go to the control tab, and take a set variable button. Put it in the "create" event.

3. Make that set variable say "global.score", and make it equal to "0"

4. Grab another one, and in the "room end" event, make it set "global.score" equal to "score".

5. In the room with the scoreboard, open the object that controls the scoreboard's display.

6. When it is time for that object to decide what to display, tell it to check the variable you set up, "global.score".

7. Then, tell it to act on that variable. If you are using a sprite for the display, tell it to use a corresponding image_index. If you are drawing text, tell it to draw the number stored in your variable.

Good, or did I miss something?

Minihobbs

I don't use the 'room end' event, simply because it wont work for me. Are you telling me to create a room end event, or use the one I've got.(I haven't got one, as I use the different room event)


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Well, you could easily use somtehing else, just make sure that the variable is set to equal whatever your scroe is after that player finishes and before the scoreboard needs it really.

Minihobbs

Quote from: Arrow-1 on May 28, 2007, 03:48:51 PM
Well, you could easily use somtehing else, just make sure that the variable is set to equal whatever your scroe is after that player finishes and before the scoreboard needs it really.
Sorry, but this is getting a little confusing now. I'll post a link to the gm file, which should be below.

Link


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

#15
Holy crap, what happened to my spelling?

I'll take a look. :D

EDIT: Nice code! I made a REALLY simple score check, it just makes a crappy little number in the next room that is representative of your score. I'm interested in seeing where this goes, so keep us posted!

http://www.savefile.com/files/760071

Minihobbs

Quote from: Arrow-1 on May 28, 2007, 04:19:52 PM
Holy crap, what happened to my spelling?

I'll take a look. :D
Don't be so harsh on yourself...it's just a typo.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Edited my last post. Enjooooooooooooy :D

Minihobbs

So would that apply for the hole after the first one. What I mean is, when I move onto the second hole, and complete it, will the score from hole 1 still show?

I appreciate the help as well.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Well, you'd have to make a seperate score object for each hole. You'd make it have no sprite until it was needed. After each hole is completed, and the subimage is set, you'll want to make sure you store the subimage you got to a variable.

For instance, the first hole's score.

image_index=score

global.myimage1=score

-------------------------------
Then when you need it again, in a later score room
-------------------------------

self.image_index=global.myimage1

Minihobbs

#20
Quote from: Arrow-1 on May 28, 2007, 05:04:25 PM
Well, you'd have to make a seperate score object for each hole. You'd make it have no sprite until it was needed. After each hole is completed, and the subimage is set, you'll want to make sure you store the subimage you got to a variable.

For instance, the first hole's score.

image_index=score

global.myimage1=score

-------------------------------
Then when you need it again, in a later score room
-------------------------------

self.image_index=global.myimage1
Sorry, but would I put that in code, in a create event in the room I want as the scorecard?

EDIT: I will be going out soon, so I may have to look into this tomorrow.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf

Arrow

Tomorrow sounds just fine, I have things I need to do today as well. I'll just edit the gm6 again and repost it.

Minihobbs

Quote from: Arrow-1 on May 28, 2007, 05:36:20 PM
Tomorrow sounds just fine, I have things I need to do today as well. I'll just edit the gm6 again and repost it.
Yesturday I played a couple of games of snooker and some pool, it was great. No rush anyways, I have got plenty of graphics to do in the meantime.


Wisdom is knowing that a tomato is a fruit, knowledge is knowing not to put it in a fruit salad.

Currently working on:
Mini-Mini Golf