Jabox has asked for the wisdom of the Perl Monks concerning the following question:

To avoid myself yapping away I will get straight to the point!

Okay so File 1 and File 2.

File 1, Can I make a code that saves information just like a login but with two files in the same directory? So maybe something like User and password*optional* and while typing save while in a stage it will save the stage on the same section your user is so in file 2 will be user:pass:stagenumber. Basically file 1 talks with file 2 and next time logging in, it will start from that stage.

What my original idea is was. Stage 1, generates total of 5 random numbers and letters, not case sensitive.

Stage 2, x2 the amount

Stage 3, x3 case sensitive

etc etc

Once the stage is complete, it will give you the seconds it took for you to complete it. Adding rankings too. To complete it, you have to match the randomly generated code which it will recognise.

Also I heard Perl isn't much for games so if this isn't possible, I apologise in advance.

Yapping time! *you can ignore this part* Right now it's just the login situation I am wondering about, the rest I will try to figure out. I'm new to Perl and I find it easier to learn by doing random things and fixing my own errors than to read off the book *I just started and is still reading the Llama book*. I already made a super simple file that provides the list in the array and when selected it will provide a description of your choice :) So I want to make my studies more difficult and effective by fun which is creating a simple game or activity that motivates me even more to understand.

Replies are listed 'Best First'.
Re: Creating A mini typing game!
by karlgoethebier (Abbot) on Feb 25, 2014 at 18:36 UTC
    "Also I heard Perl isn't much for games..."

    You have been fooled:

    karls-mac-mini:~ karl$ perl -MChatbot::Eliza -e '$mybot=new Chatbot::E +liza;$mybot->command_interface;' Eliza: Please tell me what's been bothering you. you: perl isn't for games Eliza: Tell me more about that. you: IT ISN'T Eliza: Does talking about this bother you? you: perl is a scripting language Eliza: I'm not sure I understand you fully. you: i like ruby Eliza: Please go on

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re: Creating A mini typing game!
by marto (Cardinal) on Feb 25, 2014 at 18:15 UTC

    "Can I make a code that saves information just like a login but with two files in the same directory?"

    Yes, but this makes no sense since you suggest "file 1" should contain the user and password details, "file 2" contains this with the addition of the stage. Why have two files when "file 2" contains all of this data? This is the only question I can find in your post. I suggest you think about your design some more and read How do I post a question effectively?. If you have any questions quesitons please feel free to ask.

    "Also I heard Perl isn't much for games so if this isn't possible"

    Your question has nothing specific to computer games, you're asking about basic file input and output.

      I apologise for not writing it more clear, was all bunched up in my head. What I meant was file 1 is where everything happens and file 2 is just a file where it holds the user, password, and stage level. So when I login while running file 1, it gets the information from file 2. And when I save in file 1, it saves any changes in file 2.

        Sure, keeping your perl code and application data in separate files is common practice. You could even store this data in a database, for example DBD::SQLite.

Re: Creating A mini typing game!
by atcroft (Abbot) on Feb 26, 2014 at 07:44 UTC

    For a typing game, it shouldn't take much. Here's an example I kicked out in 30-45 minutes or so:

    It doesn't involve a username/password and doesn't keep track of high or previous scores, but it does handle most of the basic parts of a game.

    Enjoy the puzzle, and hope that helps (at least stimulate some ideas).