A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Typing game in flash?

  1. #1
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Typing game in flash?

    Im trying to pull a typing game in flash, Ive tried doing it before. But I had to stop when I realized there was too much buffering in the keys. Now Im back in the saddle And I thought on asking you guys for help.

    Oh. something new to add to the mix I used flashmx instead of mx2004 last time so maybe that could help on the typing speed. Also I can now use flash studio pro. so creating a dll to read dxinput is not completely out of the question (although Im not sure thats the best answer)

  2. #2
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    How were you doing the keypress input? Just using KeyDown or onEnterframe with KeyDown?

    I've never tired to do one myself, but I've seen it done in Japan, successfully, many times without any delay problems (as far as I can tell).

    I was going to post an example, but Mars Cat made it so you can't directly link to the page. >_<

    If you think you can navigate through a Japanese site with a little bit of English on it, let me know.

    -pXw

  3. #3
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    RE: typing game

    I would love to see that example if you could give me a link I would apreciate it.

    Hmm.. knowing that Its possible helps, but the question is How? are they using as 2.0?

    Actually the code I used was a keylistener with a onKeyDown() function that got the ascii code for each key pressed, thats supossed to be the fastest way to do it. But now that you mentioned it, Im going to run some tests using onEnterFrame instead.

  4. #4
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Mars Cat...

    http://www3.wind.ne.jp/umi/hp1.htm

    It's the top one in the games section.

    Click the Red X and then click the O to get in and play it.

    -pXw

  5. #5
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    ouch!

    nice game, but oh my! its just me or are those "words" really difficult to type?

    Im not sure they hit the speed bump here though, since the engine is basically not doing much else but checking on input. My game has a lot more "action" to worry about than this.
    Last edited by AzraelKans; 01-18-2005 at 05:35 PM.

  6. #6
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Like what? Are we talking Typing of the Dead level of complexity?

    The words are Japanese (and some English thrown in), and some of them are sentences. You just don't need spaces to seperate words in Japanese.

    -pXw

  7. #7
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Wow! that was a pretty good guess.

    How did you guessed what the game was about so quickly? (I didnt even knew todd was any popular) anyway, yes the game is somewhat like TODD minus the zombies and the 3d, an "enemy" appears on the screen and you need to type a letter or phrase its holding in order to beat it. (Im not being too specific but thats the general idea) hence the speed bump I guess.

    Curiously enough I already did something like that in C but now I need to do a flash version.

    So there are no spaces in japanese? that explains it all.

  8. #8
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    What can I say? I know my "obscure" video games.

    Anyhow, I think all you need is a system like this:

    1) User enters data into a text field
    2) Use the TextField.onChanged to check to see if the textbox content equals anything on screen. This check will occur EVERYTIME SOMETHING IS TYPED INTO THAT TEXT FIELD. (I'd recommend using arrays to do the comparison...)
    3) If the user presses return, clear out the textbox.

    That's how I would do it. In my opinion, you can have a pretty high degree of complexity using that method.

    -pXw

  9. #9
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Sounds good.

    Ok Ive done some tests and it looks like it could work, one detail thoughg is that I have to keep the text on the setFocus in order for this to work. Is something minor. since I can use
    selection.setFocus(typer) each time I want .

    Thanks! I will implement it into the framework and see how it works.

  10. #10
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Originally posted by WilloughbyJackson
    Mars Cat...

    http://www3.wind.ne.jp/umi/hp1.htm

    It's the top one in the games section.

    Click the Red X and then click the O to get in and play it.

    -pXw
    MAn, i love that mangá japanese art!!Do you know more games (or even series )like this?

  11. #11
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Mmm, cat ears and she'd be perfect. Mmmmmmmmmm.
    // Mazapán, my portfolio

  12. #12
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Originally posted by tonypa
    I dont understand why would you want to use so strange system. Using textField is in my opinion bad idea and its even worse if you force user to press Enter or something.
    As I said at the beginning of the post, I haven't done a typing game. That is how I do mainframe quiz simulations in Flash (yes, people are still on mainframe computer terminals, and yes, it is in the US). Admittedly, it's a completely different animal.

    However, the code I gave can easily be altered so the text field is just showing what gets typed and is not clickable, so no worries about focus or anything else and you don't have to press Enter.

    MAn, i love that mangá japanese art!!Do you know more games (or even series )like this?
    Unfortunately, MARS Cat seems to have retired from Flash game making and is into busy creating Japanese Scale Models and Dolls. However, there are several other games in his games section and one hidden game on the front page.

    -pXw
    Last edited by WilloughbyJackson; 01-19-2005 at 10:58 AM.

  13. #13
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    I have a typing game in mind too, but it will be a bit different. It will be kind of like a dance game where you have to hit the right character at the right time. They scroll from the bottom to the top and you get points for how close you are to the line.

  14. #14
    my x booty it is that BIG
    Join Date
    Jun 2004
    Location
    New York
    Posts
    696
    one thing though looking at the big picture and whole point behind making a game...do people actually play typing games? i say people cuse me personaly dont play them, simple reason is they get boring after the first 5 minutes.-from my point of view that is-
    Project||[GAME]-on hold for now
    ------------------
    [Hero]-80%
    [Enemies]-1%
    [Weapons]-90%
    [Items]-0%
    [Levels]-10%

  15. #15
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Typing of the Dead for PC did pretty good. (Not so much for Dreamcast.)

    But what's more important is you can market is as educational since it can teach typing skills.

    No really, I'm serious:

    http://siliconvalley.internet.com/ne...cle.php/568121

    -pXw

  16. #16
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Well after working with it a bit

    I had to return to the old keydown system, the textfield works pretty well but is difficult to check if a key has been pressed twice. since there is no data being sent when no key is pressed (in keydown I get keyup) besides its kind of weird if you type really fast you can get entire strings in a frame. "asd" per example.

    Well Im stuck again, the system works perfectly for 1 key per critter, per example a char with the letter A I can get up to 3 of those in the screen and the FPS hardly drop from 30-25. but all hell is lose if I start checking for strings.

    This is the code Im using for checking an string.

    Code:
    for (n in enemies){
    	m=enemies[n]
    	var Palabra=m.vPalabra
    	if (m.bandera) {
    		m.move();//moving function
    		if (_root.keypressed && m._y>80) {
    			if (_root.letra == m.vLetra) {
    				m.char++;
    				if (m.char>=m.len/*m.vPalabra.length*/) {
    					m.energy = 0;
    					if (m.bandera == true) {
    						m.bandera = false;
    						m.gotoAndPlay("dead");
    						return;
    					}
    					
    				}
    				m.vLetra = m.vPalabra.charAt(m.char);
    				
    			} 
    		}
    	}
    }
    letra = the last value I got from the keys.
    Is there a faster way to check an string?
    Last edited by AzraelKans; 01-19-2005 at 07:02 PM.

  17. #17
    Here is something I came up with.

    http://www.aaronspjut.com/test/typeit/typeit.html

    I remember playing something similar to this in elementary school on an old apple II.

  18. #18
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Thats nice.

    Thats nice, how are you capturing the keys?

  19. #19
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Ok I finally got it.

    Finnally I did it!

    All I did was to check the keydown for each movie itself. NOT creating a global checker for all keys. There already is a keyboard checking system so thats actually unneeded. (however I did added a listener to know if ANY key has been pressed)

    So each critter checks its own keycode

    Code:
    //notice all variables are local for speed Thanks for the tip strille!
    for (var n in enemies){
    var m=enemies[n] //get a local object
    if (Key.isDown(m.mycode) m.Imdead() 
    }
    so easy it hurts! but actually thats the fastest way to do it! (and no buffering goes to the keys!)

    Things arent so easy for a string, since you dont have a keycode per each letter in the string so some precalculation is needed.

    Code:
    arr=word.split("") ;//we create an array with the string
    for (c=0;c<arr.length;c++){
    arr[c]=GetKeyCode(arr[c].toUpperCase())
    }
    //That may seem slow but is only done once!
    
    //We need an array with the codes.
    code=[]
    code["A"] = 65;
    code["B"] = 66;
    code["C"] = 67;
    code["D"] = 68;
    /*etc*/
    
    
    function getKeyCode(ch){
    return (code[ch])
    }
    //Please notice ch is a character not a number.
    That way we get the code for each letter in the string!

    Code:
    //On monster creation
    //we get the monster code 
    m.palabra=getCodes(m.palabra) //the function we did before
    m.code=m.array[0];//get the first code
    m.c=0 ;//we initiaize the pointer.
    
    /*Now during the game
    for (var n in enemies){
    var m=enemies[n] //get a local object
    if (Key.isDown(m.mycode){ 
    m.c++
    if (m.char>m.len) {
    m.Imdead()
    }
    else{
    m.code=m.arr[m.c]
    }
    
    }
    //ta-da!
    btw: Apparently thats the fastest way to check an string (by turning it into an array first)

    p.s. this is a simplified version for illustration purposes. a complete version should check if a key has been constantly pressed or not.

    Thanks go to Marmotte and Baukereg for the idea of using keycodes in arrays and Key.isDown() to avoid buffering, also to everyone who helped in this problem.

    Thanks flashkit!
    Last edited by AzraelKans; 01-21-2005 at 12:19 PM.

  20. #20
    Here is the code
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center