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)
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.
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.
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.
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.
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.
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.
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.
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%
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.
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.