hi,
Im busy with a chat 'window' for in my game
Here's the code:
set display mode 640,480,16
sync on
sync rate 60
rem fake interface
box 0,0,75,100
box screen width()-75,0,screen width()-1,100
box 76,0,screen width()-76,5
box 76,80,screen width()-76,100
rem intialise
dim chat$(4)
chat_begin_count=0
rem main loop
do
rem chat bar
if returnkey()=1 or inkey$()="t"
wait 100
rem chat dialog
set cursor 100,300
input "What do you want to say?",message$
message$=left$(message$,(((screen width()-200)/7.6)*2))
rem execute chat function
chat(1,message$)
endif
rem beginzin
if chat_begin_count=0
chat_begin_count=1
chat(0,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
chat(0,"-= welcome.to bernardfrancois.com card.game.chat =-")
chat(0,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
endif
sync
loop
wait key
end
rem chat function
function chat(player,message$)
rem clear chat dialog
ink 0,0
box 76,5,screen width()-76,79
box 0,150,screen width()-1,screen height()-1
rem set font
set text font "courier"
if player>0 and player(screen width()-200)
chat$(1)=chat$(2)
chat$(2)=chat$(3)
chat$(3)=left$(message$,((screen width()-200)/7.6))
chat$(4)=left$(right$(message$,((text width(message$)/7.6)-((screen width()-200)/7.6))),((screen width()-200)/7.6))
else
chat$(1)=chat$(2)
chat$(2)=chat$(3)
chat$(3)=chat$(4)
chat$(4)=message$
endif
rem print chat conversation
ink rgb(150,150,150),rgb(0,0,0)
text (screen width()-text width(chat$(1)))/2,12,chat$(1)
ink rgb(180,180,180),rgb(0,0,0)
text (screen width()-text width(chat$(2)))/2,27,chat$(2)
ink rgb(220,220,220),rgb(0,0,0)
text (screen width()-text width(chat$(3)))/2,42,chat$(3)
ink rgb(250,250,250),rgb(0,0,0)
text (screen width()-text width(chat$(4)))/2,57,chat$(4)
endfunction
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...