Results 1 to 11 of 11

Thread: 2 questions for my little test like rpg thing

  1. #1

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23

    Talking 2 questions for my little test like rpg thing

    hey im faiiirly new to vb and im making a little rpg thing.
    anyway i was wondering how would be best to save characters and how to do it?? i mean like .ini files? .dat files?? how do i do that?

    annd one more thing, keypresses dont seem to work, i mean ive tryed the 'Form_KeyPress' and the 'Form_KeyDown', doesnt seem to want to work. the form that im working with has a main frame with some pictures in it and two text boxes on the form as well (a lil console type thingy). it just doesnt want to work for me, anyway im just trying to get the arrow keys going for now if thats anything.

    anyway any help would be heaps apreciated, hope all that made sense.
    thanks
    tim

  2. #2
    Addicted Member Osiris's Avatar
    Join Date
    Oct 2000
    Location
    Dimension Hole
    Posts
    142
    the way i look at it, is that if your going to make a file for a saved
    game, dont save it in as an ini file, you can make up your own
    like "save.me" could be a file, that way the user wont be able to
    cheat by changing things in the ini file, well, they'll be able to
    change them in the "save.me" file, but it'll be harder

    well, keypress and keydown dont work for you because you said,
    you have textboxes, pictures, and frames on your form, and thats
    taking the focus away from the form, and the only way keypress
    and keydown work is when they have the focus...
    ؊Ϯϊ

  3. #3

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    hey thanks for the reply, i was kinda hoping for some code for using files, just i dont know how to create and save to files and stuff

  4. #4
    Zaei
    Guest
    There are tutorials on this site (take a look at the nav bar at the very bottom). You should find all you need there.

    Z.

  5. #5

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    hey thanks, i can use files now..

    another thing though
    is there a decent way to generate random numbers?

    i mean is (Rnd * 750) for instance a good way to do it?
    because i dunno, either its just me or im getting the same numbers EVERY single time being generated

    anyway thanks

  6. #6
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Timmy, to make it so that KeyPress and KeyDown will always work even if you have controls on the form all you need to do is set the Keypreview to true. This way you won't have to keep switching the focus between the form and the controls.

    Here's the formula to create random numbers:

    Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    Uppperbound is the highest number you want the random number to be and lowerbound is the lowest number the random can be.

    The reason why you always get the same number when making your random number is that Rnd keeps the value it has the first time its called. If you want to call Rnd again for a new random number use the Randomize statement.

    Randomize
    Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    These two lines of code will create a brand new random number each time they are run. Just make sure to fill in the variables


    Hope this helps.



    Drewski
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  7. #7

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    hey thanks heaps drewski
    thats been a HUGE help

  8. #8
    Zaei
    Guest
    Generally, you should call Randomize only ONCE per application.

    Rnd() will always produce the same random values. For instance, create a form, and add a list box. On Form_Load, use this code:
    Code:
    Randomize 0
    dim i as integer
    for i = 0 to 10
    list1.additem cstr(rnd()*100)
    next i
    Every time you run that program, you should get the same values.

    This fact was used in games like Elite, to create infinite universes. The only thing that then had to be saved for a saved game was the seed value used to create the universe, because using that seed, the same series of numbers could be re-generated.

    Z.

  9. #9

    Thread Starter
    Junior Member timmy's Avatar
    Join Date
    Nov 2001
    Location
    qld aus
    Posts
    23
    thanks zaei

    another question though (i figure i may as well keep posting in this thread )

    say i want to have a listbox with all my savegames being listed..
    how could i get the listbox to display all the '.tim' files in a directory so i can load the files and etc...

    thanks

  10. #10
    Zaei
    Guest
    It would be easier to use the Common Dialog Control (Something like Microsoft Common Dialog Control 6.0, or something in the components section). It will give your application a sense of familiarity to users. Most all windows programs use it, or the API call equivelent.

    Z.

  11. #11
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    There's a great arcticle here with a full module (!) that contains the code to make the Common Dialog with API calls, shaving hundreds of kilobytes off the finished product.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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