We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Does anybody have examples of drawing programmation or programs that work in the way that any action is influenced by the former or latter action.
example.
keypressed 1 gives you a line, when keypressed 2 gives you an other line based on what the former key was that has been pressed.
I don't know what to search for to find what I want. So this question was necessary to continue in my project.
Hopefully someone can point me in the wright direction. Or even help me out!
Answers
Sounds like "Key Combinations" or "Combos" (from a gamer's perspective), google it or try the following sketch (not commented, but should be pretty self explanary):
I'm not a pro programmer! So bare with me.
But I can't change the values of up and down, etc.. to key's ex. 1,2,3 etc...
could be instead of
super( new int[] { UP, UP, DOWN, DOWN } );
now
in all 3 lines where you see it...
Well I've done that before I asked the question and it says can't give int to boolean.
Chrisir is right, simply replace UP/DOWN/LEFT/RIGHT with chars ('1', '2', 'a', 'b', '#'...) or key codes.
If you still get errors, please post the complete error message plus the code you've changed.
Just to make the example I just changed it.
Normally the combination of the chars 1,2 etc should give the same result as the left up down.
Whith following code nothing happens.
Forgot when I do the keycode it gives me :
processing.app.SketchException: Badly formed character constant (expecting quote, got 6) at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:478) at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:515) at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:270) at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:185) at processing.mode.java.JavaBuild.build(JavaBuild.java:144) at processing.mode.java.JavaBuild.build(JavaBuild.java:123) at processing.mode.java.JavaMode.handleRun(JavaMode.java:120) at processing.mode.java.JavaEditor$18.run(JavaEditor.java:468) at java.lang.Thread.run(Unknown Source)
Ok it's seems work with the number that are not in then numpad. keycode still doesn't work for me.
Did you try something like '37'?
If yes, single quotes are reserved for chars ('1', 'a', ':'), you are not allowed to put multiple chars in one single quotation block. Key codes are unsigned bytes (1, 120, 37) or in Processing's case int (1, 12000, 37000). Just remove the quotation marks and your code should work. Example:
super( new int[] { 37, 38, 39, 40 } );
When I add a comboD it give me that their is no such class?
Anybody an idea what's wrong?
I have to stop accepting answer to quick, i've noticed that once I do it I get no reaction any more :) I'll open a new topic, maybe it's more appropriated!
Because you have to actually a class ComboD in order to use it. Just take the following code and change ComboC to ComboD:
Maybe you should start smaller and read some tutorials about classes and object oriented programming in general.
Hi, I'm reading tutorials aswell.
And I've better put my code on too. But the example you gave I did ofcourse if I add something or declare something I should find it somewhere further down the line.
So what you wrote I've already done.
But it gave me the former error.
followed by
} } }
I can already see two errors in the code you've posted:
Please post your complete code. The following works perfectly for me:
It was all because a dubble keypressed declaration. Soo stupid of me to didn't notice it.
I've fixed it, and ofcourse now it works. But now I can't save.
NullpointerExecption that show my beginrecord(pdf); marked in yellow.
And thus it won't save anymore.
Thanks for all your help with the combos!
And you initiated pdf properly in your setup() function? Example:
pdf = createGraphics(width, height, PDF, "test.pdf");
This is before my setup
If I put your implement in my setup it says can convert PGgraphics to graphicsPDF
Simply change
PGraphicsPDF pdf;
toPGraphics pdf;
This is the code, it either gives me the static active error or a missing } or a nullpointerexception.
Okay, I corrected your code - you used too many closing brackets and an else while instead of else if. These errors have nothing to do with your initial question, please open another thread if you get any more errors.
It works so that I can choose every 'combo', but after I used every 'combo' once. Then I can't go back to the former it stopt at the last combo.
Nobody an idea of how I can go further with this project technically.
First of all, one button stroke isn't a combo, I wrote the Combo class with combinations of keys in mind. For this kind of "combo" a simple switch() block would suffice.
I don't understand where exactly your problem is, do you want to reset the screen after every combo, because everything else seems to work as expected - the Combos are executable in any combination.
Looking up the switch() reference!
And want I want is that I can always go back to an other combo, because at the moment when I pressed al 5combo's once. It stays at the last one.
Replace:
With this (like shown in my last example):
it looks like things have gotten a bit off track. The question, in the way it's worded, seems to be asking about modal interface design. If you want to read a very wordy wikipedia article on the topic check out the Mode article
An example of a simple mode might be caps lock: normally you're in normal mode, but then you hit caps lock, and now YOU'RE IN ALL CAPS MODE, even though you're just hitting the same buttons.
The question did say "any action is influenced by the former or latter action", but unfortunately, without the ability to predict the future, it's hard to say what latter actions will happen ;)
Here's an example of how to write a modal program. In this program, we start out in circle mode: when the user clicks on the canvas, we draw a circle. If the user hits space bar while in circle mode, we transition to square mode. While in square mode, if the user clicks on the canvas, we draw a square. If they hit space bar, we transition to circle mode.
The swithc() is it, I think. You could make switch()'s with numerous cases!? correct?
Well I mean like a modulo when you give 0 and then follows a 4 you get the lines to behave divide in lengt. When you give 0 and then follows a 2 you get a multiply of the line length?
Anybody wants to help me with this or has an idea of how he would do it?
For the switch/case it's possible but cumbersome when there are 9x9x9 possibilities.
Isn't their a way to work with an automated random option?
Dear Layzfat,
maybe you should write longer posts and explain more what you want.
Your posts now are very short. Or is it because english is not your first language?
Anyway, I don't quite get what you want.
The guys helped you a lot and made a huge program with Combo for you.
Assuming that a combination of keys leads to a given result.
Now you suddenly ignore the Combo approach and ask for random.
Well, with random, you don't have a given result but end with a random result.
So why do you ignore what others wrote and made for you? This is not very polite.
Please be more specific about what you want to achieve. What do you want to achieve?
Thanks.
Greetings, Chrisir
anyway
I made a new version which collects 3 keys in an array.
If it has all 3 keys it evaluates. Then you can start all over.
To do the evaluation, it stitches together all 3 keys into one number
e.g. you enter 9, 8 and 7 you get the number 987.
At the moment, only 987 and 986 is evaluated.
For all other inputs it goes for random.
So you don't need to write down all 999 cases but need to write down only some...
(Please enter only values between 1 and 9)
of course
of course you can evaluate in other ways
e.g. multiply the first number with 10 and use as y-value for the 1st line
stitch together the 2nd two numbers and use this plus the 1st y-value as an y-value for the 2nd line
and stitch together number 1 and 3 use this as a color for the line.....
Does this help?
Greetings, Chrisir
Man that's exactly it!
I'm going to implement the drawings I have, when it's finished I'll post it here.
Thanks!
you're welcome!