The RPG Maker Resource Kit

Other Game Creation => Other Game Making Programs => Topic started by: Minihobbs on May 27, 2007, 12:58:23 PM

Title: Scoring In GameMaker
Post by: Minihobbs on May 27, 2007, 12:58:23 PM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow on May 27, 2007, 03:29:44 PM
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?
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 27, 2007, 05:57:24 PM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow on May 27, 2007, 05:58:58 PM
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.
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 27, 2007, 06:36:03 PM
I have tried:

draw_text(0,32,score);

But it doesn't seem to work.
Title: Re: Scoring In GameMaker
Post by: Arrow on May 27, 2007, 07:48:03 PM
Hm. Well, I'll try to hook you up, just give me about a day. :D
Title: Re: Scoring In GameMaker
Post by: ChaosSpartan28 on May 27, 2007, 08:47:34 PM
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
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 06:16:07 AM
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.
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 11:17:16 AM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow 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
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 02:34:54 PM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow on May 28, 2007, 02:45:45 PM
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?
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 03:19:40 PM
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)
Title: Re: Scoring In GameMaker
Post by: Arrow 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.
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 04:18:00 PM
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 (http://www.savefile.com/files/760027)
Title: Re: Scoring In GameMaker
Post by: Arrow on May 28, 2007, 04:19:52 PM
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
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 04:24:19 PM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow on May 28, 2007, 04:40:13 PM
Edited my last post. Enjooooooooooooy :D
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 04:56:49 PM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow 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
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 28, 2007, 05:08:54 PM
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.
Title: Re: Scoring In GameMaker
Post by: Arrow 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.
Title: Re: Scoring In GameMaker
Post by: Minihobbs on May 29, 2007, 05:10:23 AM
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.