Display score on key press...?

Started by Matt Brown, Sat 14/06/2003 21:04:21

Previous topic - Next topic

Matt Brown

Okay, I know this sort of thing is mentioned in teh manual, but I think I need it explained in a different way...


I want to have my game set so when one presses the "s" key, a message displays their current score out of possible points. I think the built-in GUI varibles doohicky for score would work here, (like, display "@score out of @totalscore, or whatever those are) but if I have to create a global int, and use other varibles, lemme know.

I dont however, know where or what to put for the script for teh whole pressing S part. please enlighten me


thanks guys!
word up

Jimi

#1
er... i think it might be something like....

on_key_press(84) {
   GuiOn(3);
   Wait(180);
   GuiOff(3);
   }


and have a gui with @score out of @totalscore or whatever in it. it will come on, wait for about 5 seconds, then go offf...hopefully.

Matt Brown

hmmmm, not really what I'm looking for.

I'm shooting for when the player presses S, a window pops up, like if the player looked at a hotspot, that said, Blah Points out of Blah Possible.

Jimi, all I think that does is flash the GUI.
word up

Jimi

oh. then...

on_key_press(84) {
   Display("@score out of @totalscore");
   }


I'm pretty sure you can use the @thingy's in stuff other than GUIs.  :-\

Matt Brown

okay, few more questions then..

1. where does this go?
and 2. do I copy that just like it is?

almost got it

thanks
word up

Jimi

wow. Right. I think it would go in the global script. Otherwise you'd have to put it in every room. You could try it like that, but if it has a script error, change it to something like....

if (on_key_press(84)) {
   Display("Blah Blah Blah");
   }


i'm not 100% sure though, since I've never used this before. Good luck!

Matt Brown

okay, I think I might have it...I bet there is a certain place in teh global script where it goes though...hmmmm..

thanks jimi. if anybody can offer more complete answers, I'm all for them
word up

Matt Brown

hey, I set it up so when I press S, word appear...but it looks like @SCORETEXT@ only works in GUIs....waaaa
word up

Scorpiorus

A little correction:

in global's repeatedly:

if (IsKeyPressed(83)) {
Display("Score: %d out of %d", game.score, game.total_score);
}




another way just to modify on_key_press() itself:

function on_key_press(int keycode) {
// called when a key is pressed. keycode holds the key's ASCII code
if (IsGamePaused() == 1) keycode=0;  // game paused
if (keycode==83) Display("Score: %d out of %d", game.score, game.total_score);
//...
//...
//...
}

-Cheers

Jimi

hmm. I was just a little off  :-[. I wasn't sure whether to use IsKeyPressed, because the manuakl said something about it only working with the functions "below"....so... :-[

Matt Brown

word up

SMF spam blocked by CleanTalk