PDA

View Full Version : puzzle game (if/else + score scripts) pls help



adieha
October 12th, 2004, 07:53 AM
i'm doing a puzzle game where the user have to solve the puzzle by entering the answer in the inputText and then click submit. I am going to use the If/else action script provided here http://www.kirupa.com/developer/flash5/ifelse.htm

some of the answer for the puzzle are quite long, so is that script suitable to be use or do u have other scripts which may help me.the example for that script is actually for password.

and how do i make the answer not case sensitive, meaning it doesnt matter if the user types in using capital letter, small letters or both. but spelling errors dont count.

another thing is, that if the user answer correctly, they will get points. if they answer incorrectly, not point will be added. These are the scripts that i will use for my score.http://www.kirupa.com/developer/mx/score.htm

now my problem is, how do i combine this two scripts. so that, when the user keys in the an answer which will pop up a window saying that whether he/she has answered correctly.. and at the same time the score will gain about +20 or zero for wrong.

ok.. pls help me. i'm very new with this flash thingy.

p.s: this is a CD game.

Dr Warm
October 12th, 2004, 08:41 AM
i'm very new with this flash thingy yeah i noticed (no offense). if ur puzzle game needs long responses, it going to be hard to code this, because there's almost an infinite amount of ways to answer a question, i'm not quite sure what questions u'll be asking, maybe u should post some examples.

as for making it so cases don't matter, any string variable you can convert to upper or lower case.

so what u would do for code is (this should work, but it's hard to remember all the commands):

score = 0;
checkMyText = inputText;
password = checkMyText.toLowerCase; //<-- i think it's called toLowerCase
if(password == "some words (in lowercase)"){
score += 5;
displayText.text = "You got it right!" ;
} else {
displayText.text = "You got it wrong";
}
also have a dynamic text somewhere with instance name displayText

this should get u started, if not post back

adieha
October 12th, 2004, 10:01 AM
tried the scripts u gave me.. but it didnt display the score and the msg "you got it right".


Rebus puzzle examples (http://www.geocities.com/narusegawa1907/rebuspuzz_eg.gif)- this is some of my puzzle examples. its a word picture puzzle which represents a word or a phrase.


the game will look something like this...


http://www.geocities.com/narusegawa1907/rough.gif

Dr Warm
October 13th, 2004, 03:34 AM
ok u sort of need to know how to use code, if u send me exactly what u put down (ur code) i'll modify it for u

adieha
October 13th, 2004, 04:20 AM
for the input text

if (inputName == "puzzle answer") {
inputStatus = "Correct! Good job!" ;
} else {
inputStatus = "Wrong! Go to next puzzle" ;
}<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

Dr Warm
October 13th, 2004, 04:47 AM
have this:
score = 0;
textChecker = inputName.toLowerCase();
if (textChecker == "puzzle answer") {
score += 5;
score_txt.text = score;
inputStatus = "Correct! Good job!" ;
} else {
inputStatus = "Wrong! Go to next puzzle" ;
}

that should work next post ur code for scoring and i'll try and incorporate it, in ur pic in the score text box next to it (displaying 200) give it an instance name of score_txt and maybe this will work.

Dr Warm
October 13th, 2004, 05:26 AM
here's a crappy quiz i started making when i first got flash, about 6 months ago, when i still really didn't know how to do anything. but it works for the first two questions, the main script is in the buttons, when u get to the end it says how well u went, which i got from somewhere else (hence the comments about italians, but i thought i was funny so i left it in!)
hope u can get something out of it, i love little logic quiz's (even though i hardly ever get them right!)

adieha
October 22nd, 2004, 07:53 PM
i'm still having problem with the score. the score only works for the first puzzle question. to download the flash file, click the link below

http://www.geocities.com/narusegawa1907/testscore.fla

here is the script i'm using
score = 0;
textChecker = inputName.toLowerCase();
if (textChecker == "puzzle") {
score += 20;
score_txt.text = score;
inputStatus = "You are correct!" ;
} else {
inputStatus = "Wrong answer!" ;
}

referring to my file, for this level. there are 5 puzzles. the score only works for the first puzzle and does not add up after i answered puzzle 2 until 5. user will gain +20 points for each correct answer. for wrong answer, no points will be deducted.

the user have to type in the answer in the input text field, and then click the button next to it to submit the answer. in this case, i have placed all the answer for these puzzles as "puzzle" so that you can test the score.

so, if the user managed to answer all these 5 question correctly, his/her total score will be 100 points (20 pts x 5).this is what i want to achieve in my game. i'm not quite sure, whether there is problem with the script. for izzit the arrangement in my timeline is incorrect.

i have 4 levels in my game. and each level have 5 questions each. i have placed this levels in difference scenes. i hope the score is able to work in all this 4 scenes. adding up from level 1 to level 4. after level 4, a score board will appear displaying the total points the user have accumulated.

Level 1 - 5 question x 20 pts each = 100
Level 2 - 5 question x 20 pts each = 100
Level 3 - 5 question x 20 pts each = 100
Level 4 - 5 question x 20 pts each = 100

so by the end of the game, the total score for
all 4 levels (if the user answer all the
puzzle correctly) is 400.

hope anyone can help me out. pls help. TQ.

Dr Warm
October 22nd, 2004, 08:19 PM
ur not using scenes are u????? noooooooooooooooooooo, ok i'll have a look at it for u

adieha
October 22nd, 2004, 08:23 PM
i am using scenes. but according to levels. that is actually a sample of the file. i have delete all the other stuff, so that the file wont be too big. if u want the original file, i'll post the link.

Dr Warm
October 22nd, 2004, 08:41 PM
if i can't figure it out in the next 20 mins, i'll have to put it back sometime later today (it's 9:11 am here)

adieha
October 22nd, 2004, 08:47 PM
http://www.geocities.com/narusegawa1907/testE.fla

the scenes are
- intro
- main
- L1
- L2
- L3
- L4
- L5 <- only this scene contains the score + input script

L1-L4 - contains only the input script.

just want to test out the score on L5 first.

it's 7.47 here. let me guess.. u r from australia. :)

Dr Warm
October 23rd, 2004, 03:17 AM
wwwfirst can i ask if u could zip the file nexttime that would help, it only takes a few secs extra to do.

ok what's supposed to happen is in the fla i've attached, but it doesn't seem to work with urs, i have 2 theory's:

theory 1: is that u started coding it in flash 5 format, and then u converted it to MX. sometimes flash doesn't like when u do this, and something's don't work, it's happened to me lots of times

theory 2: it's because ur using scenes, but i think that's a little far fetched.

solution 1: copy all ur stuff into my fla, test that it works or not then post back on here, but this will probably take a few hours for u to copy everything.

solution 2: post ur fla and mine to actionscript.org (in mx forum) then say when ur comparing the two fla's why doesn't it work, or flashkit.com (game forum).

firstly try to do what i did in ur fla, make the text box have instance name score_txt (make sure u delete variable name 'score'), then in the frame where u have stop(); (i think it's the one where it asks u about crosses) have _root.score = 0; and then _root.score_txt.text = 0; and then under the checker if(password == "something"){
_root.score += 20;
_root.score_txt.text = _root.score;
}

and if that works for u that will be weird.

Also ur quiz is looking great! Did u come up with all the questions by urself?

don't use scenes again! trust me on this, do a search and u'll see some debates about why not to