Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / chat code - problems

Author
Message
freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 6th Feb 2003 02:38
hi,

Im busy with a chat 'window' for in my game

Here's the code:



There are two problems:

- In the beginning, the three lines of introduction text aren't right positioned, until you place your first line in the chat
- When you have typed some text, and you press enter after that, the question should only re-appear when you press return again...
koolaid
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Cyberspace
Posted: 6th Feb 2003 08:28
i wish i could help you on that but im still learning myself i appreciate your advice on thise problems

trager
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location: United Kingdom
Posted: 6th Feb 2003 11:32
you haven't set the cursour position for the welcome text yet you do with with the chat code is this the problem?

and secondly you need a flag to disable the "what do you want to say" message when you press return after a message

flag = 0
if returnkey =1 and flag =0
flag = 1

... message code ...

else
if returnkey = 1 and flag = 1 then flag =0
end if

something like that, hope it helps.

freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 6th Feb 2003 12:57
thanks for the replies!

for the returnkey thing, I just had to insert another wait 100, because otherwise, if you press your return key some milliseconds too long, returnkey() will still be 1 at the next time he does my main loop

about the welcome text: this is positioned within the function... I still don't know what was the error, but now I soved it on an other way: I just used the center text command, instead of manually programming that manually (there should have been some error in this which only occured for the welcome text I guess)

trager
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location: United Kingdom
Posted: 6th Feb 2003 13:12
not sure thats such a robust solution as if you hold the reutrn key it will execute the chat procedure.

You may want to test the length of the string message$ just after
input "What do you want to say?",message$

if the length is 0 reposition the cursour and wait for input, this should be slightly tidyer.

trager
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location: United Kingdom
Posted: 6th Feb 2003 13:16
Unless ofcourse if you want to disable your chat window with the same key which activates then you way want to include some kind of timer test but I wouldnt advise using wait 100 in a game as this would make the game stop.

Instead test the time between return key presses if the time is less than 100 or 200 then ignore the keypress.

Hope this helps

Jixer
21
Years of Service
User Offline
Joined: 4th Feb 2003
Location:
Posted: 6th Feb 2003 17:01
How do you test the time between return key presses? I have similar problems using keyboard interface in a flying game I'm making and some of the keys that toggle effects will turn on then off real quick. Any help would be appreciated.

trager
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location: United Kingdom
Posted: 6th Feb 2003 17:19
Use, store and compare the timer() function. the time is stored in milliseconds.

freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 6th Feb 2003 18:20
using the timer is indeed a better idea

its no problem that the main loop stops, but the computer players won't be able to say anything when you are typing...

Killer Sponge
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location: United Kingdom
Posted: 7th Feb 2003 14:42
Ive created a small chat program myself, I'll get the code nxt time im at my computer and post it in here for you to have a look at.

freak
21
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 8th Feb 2003 01:39
ok, I'm very curious to see how you did it

Login to post a reply

Server time is: 2024-05-25 04:16:43
Your offset time is: 2024-05-25 04:16:43