Computer Science Canada Input at ANY time |
Author: | TokenHerbz [ Sun Sep 04, 2005 8:34 pm ] | ||||
Post subject: | Input at ANY time | ||||
Hi, im making an extremly awsome RPG... I would like to add a freature to see your STATS at any givin time in the game... I decided a proc would be wise...
This works fine, But i tryed to make it so when you press the UP arrow key of works... This DOSN"T work, i need help... What code do i place to GET this proc?? i attempted this...
i guess i was thinking if i pressed UP it would call my proc, But NOPE@! Anyways, i would love help, and please tell me theres an easyer way then having to put it in EACH loop... As im going to have a FEW procs.... |
Author: | Cervantes [ Sun Sep 04, 2005 8:49 pm ] | ||||
Post subject: | |||||
Make sure the declaration of the keys variable is outside your loops; make sure the Input.KeyDown is inside your loop; make sure the if keys (KEY_UP_ARROW) is inside your loop. If you don't want to put it in each loop, the easiest thing to do would be to make a procedure to handle all the controls. You might want to think about passing the status of the keyboard into this procedure as a parameter. If you cannot solve the problem with this, attach your code. EDIT: Here's some example code as to how to map out your keyboard and give each key an action. I've commented out my first attempt at doing this, which is a little more understandable because it does not use
But it isn't very nice having to assign two variables just to get one key working. The following code is more elegant and maps the entire keyboard, at the cost of having to check the boolean status of every key each time through the loop, as opposed to just checking the boolean status of the keys that have an action associated with them, as the previous code did.
|
Author: | TokenHerbz [ Mon Sep 05, 2005 4:34 am ] | ||
Post subject: | |||
say i have somthing like
Now that has 2 loops... Say i have this... proc ha put "HAHAHA" end ha How can i make it so, it i press "UP" no matter WHERE i am in the code, It WILL work... and post HAHAHA Thanks... Also, if your post already told me, please do explain it better, cause you lost me... thanks |
Author: | Cervantes [ Mon Sep 05, 2005 7:47 am ] | ||
Post subject: | |||
tokenherbz wrote: How can i make it so, it i press "UP" no matter WHERE i am in the code, It WILL work... and post HAHAHA There is no way to write some code that will automatically stick itself inside every one of your loops. As I said before, write a procedure to handle all your controls, and call that procedure where ever you want it.
|
Author: | [Gandalf] [ Mon Sep 05, 2005 11:22 am ] | ||
Post subject: | |||
Yes, any you might want to use a function to do the 'number checking', since if you are going to be having more than one you could automate the process (although in your case you do so little that it would make a small difference). Also, why do you have those else statements? They are pretty pointless, you can write an 'if' statement without including 'else'. For example, this:
is a syntax error, since you have an end if without a matching 'if'. |
Author: | TokenHerbz [ Mon Sep 05, 2005 1:17 pm ] |
Post subject: | |
gandof i tryed to make an exaplme really fast... it was to be cls thanks for the help Canvas (sorry itf i spelled wrong) i will try it... |
Author: | [Gandalf] [ Mon Sep 05, 2005 1:24 pm ] |
Post subject: | |
![]() Either way, the 'else' is not needed. Since the if statement will be evaluated, and if it is true then the loop will exit at that point, if it is not then it will continue, and 'cls'. It's just a waste of code. |
Author: | TokenHerbz [ Mon Sep 05, 2005 2:15 pm ] | ||||
Post subject: | |||||
Gandalf, im still going to use it for now, as it keeps it cleaner...
~~~~~~~~~~~~~~ ANYWAYS, I dont know where to enter the proc? like you say make the keybored one, which i have done, i make it so it called another proc which i need... But where do i put it?? This is for an RPG, where i have lots of If, Fors, and loops... Start it after the main loop?? i tryed... Also when i have a situation of...
I dont think i'll be eble to enter the "UP" Arrow key... as its wanting a number... Tell me how to get around that?? Ill zip my up-2-date RPG to you if you want, Thanks, |
Author: | Delos [ Mon Sep 05, 2005 2:53 pm ] | ||
Post subject: | |||
Let's look at your concept a little...I'll rephrase that. Let's look at the concept. - create an RPG-styled game that could viably include various forms of graphics, sounds, and most importantly, interactions. - said interactions could be evnironmental (objects on screen react to each others' presence, eg. collision detection), textual (messages being displayed), graphical, audible, etc etc. - an important aspect of this would have to be User-input. This would likely define movement, choice selection, etc. - there would be several levels of gameplay involved, eg. interactive environment, intereactive menus, fight sequences/interactive fights, cinematics (ok, Turing's not going to do too well here ![]() We can continue to analyze this topic till the cows come home, or the fat lady sings, or the mocking birds get sued, or whatever...but that's actually already been done for us. This rather old Tut will give you a great breakdown and even some hints regarding everything RPG-ish you'll need. I will warn you again that it's old and as such some concepts and command structures used have been outdated (the whole playing music in a process thing comes to mind). Back to your problem. The entire point of this preramble was to point out an important detail. One that Cervantes (Oh good grief, Canvas!) has already put out there. The use of procedures, records, fucntions, and Object Oriented programming in general. You're really, *really* going to want to make sure you have this stuff down pat if you're serious about making an "extremely awsome" RPG. Having looked at some of your code you've included, I'd say you're on the right path. A good strategy I've found when making some sort of programme that involves User input is to have only one area of Input. This sounds familiar doesn't it? Everything in your programme has to react according to the input given, and if you can narrow down your code such that this only occurs in your 'main' procedure, then you're in good standing already. Since everything that happens then, is a result of the main proc, you'll be in a position that no matter what happens, you'll always end up back in the main proc's loop which will house the Input clause. Did that make sense? It should, it's been said before but not in so many words. As for the mass of loops, ifs, fors, etc that you'll undoubtedly have, simply ensure that none of them run the risk of falling into infinity and you should be able to return back to the main loop each time. And don't worry, a computer has the ability to get through quite a bit of code and processing and back out in time to catch even the most nimble of fingers' input. You'll want to stay very far away from any input that pauses for the User (such as get, getch). hasch is a possibility, but doesn't quite stack up against Input.KeyDown(). So, let's look at a little example now, shall we?:
Was that useful? Likely not. But go think upon it anyway, perhaps you'll figure out what I'm getting at... As said before, if you're still not getting anywhere, post some code. I highly doubt that posting your entire proggie is giong to help since that would mean us wading through mountains of code that may or may not be commented enough for us to understand its underlying complexities and meanings and as such be utterly and irrevocably adverse to the said reason of obtaining help from said analysers of said code in said timeframe and I'm listening to a remix of Powerless by Nelly Furtado and it rocks. BTW Canvas-man! Arrays of procedures?! Methinks you've been spending far too much time in Ruby these days. Good stuff. Learn something new every day... |
Author: | [Gandalf] [ Mon Sep 05, 2005 3:29 pm ] |
Post subject: | |
Been doing a bit o- C, Delos? ![]() An idea is (if your code is indeed getting cluttered), to have many files for your program. Not just for 'data' and then 'program', but having a seperate file for 'input' 'battles' 'collision detection?', etc. That way, you can then have a 'main' file, with your main loop - simply to have the basic structure of the program. It makes it easier to think everything through and see what your program is doing without going through hundreds of lines of code. You cannot 'get' the up arrow, that is what Input.KeyDown is used for. Making an RPG is no simple matter, so expect problems. Quote: BTW Canvas-man! Arrays of procedures?! Methinks you've been spending far too much time in Ruby these days. Good stuff.
Learn something new every day... Same ![]() |
Author: | Cervantes [ Mon Sep 05, 2005 5:34 pm ] | ||
Post subject: | |||
tokenherbz wrote: I dont know where to enter the proc? like you say make the keybored one, which i have done, i make it so it called another proc which i need... But where do i put it?? Somewhere in your main loop, preferrably in the 'Input' section. I like to break my main loop up, if possible, into 'Input', 'Processing', and 'Output' sections. [Gandalf] wrote: Been doing a bit o- C, Delos? Smile "IDE" "//" Sure, it's "pseudo", but... "IDE" and "//" are not specific to C. Java, for example, uses "//" as a one-line comment. Also, I'm sure that almost every language has at least one IDE. Delos wrote: BTW Canvas-man! Arrays of procedures?! Methinks you've been spending far too much time in Ruby these days. Good stuff.
Learn something new every day... One can never spend too much time with Ruby. ![]() I did not invent that, however; I reinvented it and then rediscovered that that is how Turing's GUI works.
That's what prevents you from linking procedures with parameters to your buttons. That's the greatest annoyance of Turing's GUI. tockemhaerbx wrote: thanks for the help Canvas (sorry itf i spelled wrong) ![]() +10 BITS for calling me something that ridiculous! EDIT: Arrgh! Dan still hasn't fixed the donating/modding bits. I owe you ten bits, tokenherbz. That reminds me: I owe someone else bits, though I forget who and how much. |
Author: | [Gandalf] [ Mon Sep 05, 2005 5:46 pm ] |
Post subject: | |
Yes, yes... Bits all around! Quote: "IDE" and "//" are not specific to C. Java, for example, uses "//" as a one-line comment. Also, I'm sure that almost every language has at least one IDE.
I am quite aware of that, I was just taking a guess since those two examples are things not used in Turing. Personally, I wouldn't call the Turing, eh... Environment an IDE (I know that is a slight contradiction, but you know what I mean). |
Author: | Delos [ Mon Sep 05, 2005 9:53 pm ] |
Post subject: | |
Nope, no O'C for me, or C for that matter. Just a lot of Turing when time permits. As I always say, I should really get into Ruby. As for the whole mod-bit-thing, [cue British accent]what's all this then?[/accent] |
Author: | wtd [ Mon Sep 05, 2005 10:35 pm ] |
Post subject: | |
Delos wrote: Nope, no O'C for me
Well, that's a shame. Objective-C is kinda cool. |
Author: | TokenHerbz [ Tue Sep 06, 2005 2:06 am ] |
Post subject: | |
Heh, My code i think is more then enough Commented... Or so to me anyways... Im going to post my RPG anyways, so you can take a look at my mess... You will then see how i think its utterly impossible to call my proc at ANY GIVIN POINT! Here it is, and yes, You can play what is made, not that i am far... |
Author: | Cervantes [ Tue Sep 06, 2005 4:48 pm ] |
Post subject: | |
That's a nice mess you've got there tokenherbz. I suggest you find a way to tidy it up. With this approach you've got now, the complexity of your code will go up exponentially as you add more features (and I'm talking about exponentially with a big base. ![]() Try to cut it down to one main loop. Compartmentalize things as much as you can. Make functions for getting input. Make procedures/functions for other things that you do a lot, or even if you think making a proc/fcn out of it would help to organize your code. If you want to go further and organize your procedures/functions, make modules. Delos wrote a tutorial on modules: check the walkthrough for the link. (I didn't run you're program, as there were a few errors that I did not feel like tracing.) |
Author: | TokenHerbz [ Tue Sep 06, 2005 6:02 pm ] |
Post subject: | |
eh errors? perhaps your on a different vesion... i think im up-2-date Anyways, you sure i can make that complex code into 1 loop? i mean, it opens and closed windows, has a tavern, invintory... so you want me to make each section into a procedure? then call that proceasure in the main loop? perhaps ill start over then, and this time use GUI... and graphics... ill start with the most basic RPG tho, not complex, just to firmiliarize myself with the new codes im about to learn... Wish me luck... |
Author: | Cervantes [ Tue Sep 06, 2005 7:28 pm ] |
Post subject: | |
I'm on 4.0.5. The errors are not version related. Things like "'wepon' is not a field of backpack" and the like. You won't make it into 1 loop, but you'll have one loop with procedure and function calls in it, which may or may not contain their own loops. It makes it managable. If you start over and want to work with GUI and graphics, I wouldn't recommend learning them while making your RPG, as it will probably mean your RPG is messier than it needs to be, as you will not have discovered the tricks. Make some smaller programs to learn GUI and graphics, then return to the RPG. Good luck! |
Author: | [Gandalf] [ Tue Sep 06, 2005 9:49 pm ] |
Post subject: | |
Yes, make something other than an rpg if you are going to do graphics. I tried starting off Turing 4.0.5 by making a graphical rpg, it didn't turn out too good and it discourages you. When you make an rpg, you compete with things like Diablo, etc (even subconsciously ![]() |
Author: | wtd [ Tue Sep 06, 2005 10:47 pm ] |
Post subject: | |
See every challenge as an opportunity to learn some new skill(s)... not simply an exercise in pushing your existing skills to ridiculous extremes. For instance, making an RPG without attempting to learn how to use records would be silly. |
Author: | TokenHerbz [ Wed Sep 07, 2005 1:12 am ] |
Post subject: | |
Alright... Any basic games i should attempt to strengthen my skills in the graphics area? And thnaks for the help! |
Author: | wtd [ Wed Sep 07, 2005 1:55 am ] |
Post subject: | |
tokenherbz wrote: Alright...
Any basic games i should attempt to strengthen my skills in the graphics area? Just guessing from the code I've seen, but you may wish to work on other basic concepts first. More on arrays, as already suggested. Records are good too. |