|
-
Nov 26th, 2001, 05:02 AM
#1
Thread Starter
Junior Member
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
-
Nov 26th, 2001, 12:34 PM
#2
Addicted Member
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...
-
Nov 27th, 2001, 04:05 AM
#3
Thread Starter
Junior Member
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
-
Nov 27th, 2001, 07:30 AM
#4
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.
-
Nov 28th, 2001, 08:29 AM
#5
Thread Starter
Junior Member
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
-
Nov 28th, 2001, 05:00 PM
#6
Addicted Member
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
-
Nov 29th, 2001, 05:11 AM
#7
Thread Starter
Junior Member
hey thanks heaps drewski
thats been a HUGE help
-
Nov 29th, 2001, 07:38 AM
#8
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.
-
Nov 30th, 2001, 08:10 AM
#9
Thread Starter
Junior Member
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
-
Nov 30th, 2001, 09:52 AM
#10
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.
-
Nov 30th, 2001, 03:45 PM
#11
Good Ol' Platypus
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|