![]() |
|
if somebody press Esc he go to another function |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
In your first example, the program would halt at "val = readkey();", until a key is pressed. The other one would not. Not the same.
|
Richard Phipps
Member #1,632
November 2001
![]() |
It is not the same Piccolo. |
Michael Faerber
Member #4,800
July 2004
![]() |
Man, I think I've never seen so many crazy people on a thread before! -- |
LennyLen
Member #5,313
December 2004
![]() |
Quote: Man, I think I've never seen so many crazy people on a thread before! Hey! I mean, who... that is... oh, never mind.
|
a b
Member #8,092
December 2006
|
1. so should I change readkey() to keypressed() ? 3. This: should be:
|
Evert
Member #794
November 2000
![]() |
Quote: 1. so should I change readkey() to keypressed() ?
No! Quote:
3. This: Yes. Sortof. You should only call readkey() once, not twice at that point. Read the keypressed() manual entry. Quote: thanks ">>8" I can use "key+key" yes ?? I don't understand what you mean. |
LennyLen
Member #5,313
December 2004
![]() |
You didn't answer question 2, Evert.
|
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Quote: Somebody told that I shouldn't to call out in function function . I read that is good idea ..... so I don't know - should I change that more call function should be in main() ?? I don't even know what that means. I'm actually starting to think that a b is, in fact, THE MOST SOPHISTICATED TROLL EVER!
|
Kauhiz
Member #4,798
July 2004
|
Yeah, like I said, we're getting Punk'd and this guy is having a blast --- |
a b
Member #8,092
December 2006
|
1.Kaukiz told: 2. I read manual but it is in english so I don't understand everything - if I want that program stop untill somebody press any key then I must use keypressed() yes ? 3. thanks ">>8" I can use for example "ctr+shift" (keyboard shortcuts) yes ?? PS. Jonatan Hedborg I don't like Sweden |
Evert
Member #794
November 2000
![]() |
Quote: if I want that program stop untill somebody press any key then I must use keypressed() yes ?
No. val=0; if (keypressed()) val=readkey(); does not. Quote: thanks ">>8" I can use for example "ctr+shift" (keyboard shortcuts) yes ?? No! TFM said:
if ((val & 0xff) == 3) /* ctrl+letter */ if (val == (KEY_X << 8)) /* alt+letter */ EDIT: For shortcuts, check out the key_shifts variable as well. |
Kauhiz
Member #4,798
July 2004
|
Quote:
1.Kaukiz told: I assume you mean what I said, and you just simply CAN NOT SPELL! You apparently missed the next part of that statement, which is the more important one. You can call functions after each other, of course. You shouldn't just call the menu function when someone presses a key. There's a HUGE difference there. Quote: 2. I read manual but it is in english so I don't understand everything - if I want that program stop untill somebody press any key then I must use keypressed() yes ? Nope, the exact opposite. If you can't understand a part of the manual, copy the part here and ask. Quote:
int k = readkey()>>8; That's wrong, you should only call readkey() once. If you knew basic C++, you'd understand why. Quote:
PS. Jonatan Hedborg I don't like Germany WTF? --- |
a b
Member #8,092
December 2006
|
readkey()>>8 I know bite shift in only theoretical side, I never use it. Bite shift faster some actions. And here what is faster ? Read key is faster ? |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Quote:
PS. Jonatan Hedborg I don't like Sweden that was random, even for you. For the record: I don't like you.
|
Kauhiz
Member #4,798
July 2004
|
Quote: Bite shift faster some actions. And here what is faster ? Read key is faster ? What the HELL!!? Read the goddamn manual!? It doesn't make anything faster, it gets the goddamn scancode for you! Please, please, please tell me you're only joking here! --- |
Richard Phipps
Member #1,632
November 2001
![]() |
It's now 140 posts (with this one) to try to resolve this question.. |
a b
Member #8,092
December 2006
|
but why in "k = readkey()>>8;" is "8" ?? why bite shift in right is "8" ?? |
Evert
Member #794
November 2000
![]() |
Instead of us answering that, you should try to answer the following questions: How many bits are there in one byte (on a PC)? |
Richard Phipps
Member #1,632
November 2001
![]() |
Because >> 8 is one byte and readkey() returns a word (2 bytes): Quote:
int readkey(); The low byte of the return value contains the ASCII code of the key, and the high byte the scancode.
I.e. xxxxxxxx | xxxxxxxx (8 bits | 8 bits) |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Do you even try to improve your English? People say "bit", you still use "bite". Kauhiz nickname is visible most of the time - is your H-key broke? My god...
|
piccolo
Member #3,163
January 2003
![]() |
[off topic] from what i understood the problem was that the game went back to the menu when esc was pressed in the started game,and you want it to end the game. when esc was pressed before the mods to the code, a break was issued. This break ends the current loop. when the current loop is ended you are put back to the spot in your code where you entered that loop. That spot is the menu loop. wow |
Kauhiz
Member #4,798
July 2004
|
But you're still discarding the return value of readkey() which is wrong. Quote: Let's just stop this thread right here. We're probably making a record here. Almost 150 posts already to solve a trivial problem (which has already been solved many times over)! I think it'll be fun to see how long this thread will go --- |
piccolo
Member #3,163
January 2003
![]() |
i just wanted to get the main problem fixed. He has been informed that there are some other design errors in his code. After reviewing his code, i saw that those errors do not harm the game in a drastic way. So these errors can be corrected in a later design faze.(now that he knows of them) wow |
Kauhiz
Member #4,798
July 2004
|
Quote: (now that he knows of them) We could have a whole nother debate on this point... --- |
a b
Member #8,092
December 2006
|
thanks piccolo for your help I also will change in code to: But: |
|
|