My friend and I are working on this program that has basic menus, pictures, etc. I recently tried implementing a feature that has that float effect, like the menu changes if the mouse floats over it. But the problem is, it's not doing anything!
Here's the code, w/ pics attached:
`BARC - Beginner's Automatic Response Compiler
`Setup
gosub Setup
gosub load_pictures
`Clear the screen to be ready for use
cls
`Define float
float$ = ""
`Main Loop
do
`Refresh the Screen
sync
`Display the menus
gosub show_menu
`Check Float
gosub float
`Draw Floats
gosub draw_float
`Make sure that if it's the main menu, the state is normal
if menu$ = "main_menu"
state$ = "normal"
endif
`Show Avatar
gosub show_barc
`Check input
if mouseclick() = 1
gosub check_input
endif
if mouseclick() = 2
menu$ = "main_menu"
state$ = "normal"
cls
endif
loop
`Subs
setup:
`Basic Setup
`set refreshing
sync on:sync rate 60
`Set colors
ink 0,rgb(255,255,255)
`set menu state
menu$ = "main_menu"
`set barc state
state$ = "normal"
return
load_pictures:
`Load the pics for use
`Normal Face
load image "Pics\barcface1.jpg",1
`Happy
load image "Pics\barcface2.jpg",2
`Sad
load image "Pics\barcface3.jpg",3
`Thinking
load image "Pics\barcface4.jpg",4
`Main Menu
load image "Pics\barcmenu1.jpg",5
`MainMenu Float Basic
load image "Pics\barcmenu11.jpg",51
`MainMenu Float Fun
load image "Pics\barcmenu12.jpg",52
`MainMenu Float Help
load image "Pics\barcmenu13.jpg",53
`MainMenu Float Exit
load image "Pics\barcmenu14.jpg",54
`Basic Functions
load image "Pics\barcmenu2.jpg",6
`Basic Float Calc
load image "Pics\barcmenu21.jpg",61
`Basic Float Questions
load image "Pics\barcmenu22.jpg",62
`Basic Float History
load image "Pics\barcmenu23.jpg",63
`Basic Float Credits
load image "Pics\barcmenu24.jpg",64
`Calculator
load image "Pics\barcmenu3.jpg",7
`Calc Float x
load image "Pics\barcmenu31.jpg",71
`Calc Float /
load image "Pics\barcmenu32.jpg",72
`Calc Float +
load image "Pics\barcmenu33.jpg",73
`Calc float -
load image "Pics\barcmenu34.jpg",74
`Questions
load image "Pics\barcmenu4.jpg",8
`Questions Float About BARC
load image "Pics\barcmenu41.jpg",81
`Questions Float About User
load image "Pics\barcmenu42.jpg",82
`Fun
load image "Pics\barcmenu5.jpg",9
`Fun Float NumGuess
load image "Pics\barcmenu51.jpg",91
`Fun Float Paint
load image "Pics\barcmenu52.jpg",92
`Fun Float Write
load image "Pics\barcmenu53.jpg",93
return
float:
`Narrow Down
select menu$
case "main_menu"
if mousex() > 0 and mousex() < 160 and mousey() > 0 and mousey() < 20
float$ = "main_1"
endif
if mousex() > 160 and mousex() < 320 and mousey() > 0 and mousey() < 20
float$ = "main_2"
endif
if mousex() > 320 and mousex() < 480 and mousey() > 0 and mousey() < 20
float$ = "main_3"
endif
if mousex() > 480 and mousex() < 640 and mousey() > 0 and mousey() < 20
float$ = "main_4"
endif
endcase
case "basic_functions"
if mousex() > 0 and mousex() < 160 and mousey() > 20 and mousey() < 40
float$ = "basic_1"
endif
if mousex() > 160 and mousex() < 320 and mousey() > 20 and mousey() < 40
float$ = "basic_2"
endif
if mousex() > 320 and mousex() < 480 and mousey() > 20 and mousey() < 40
float$ = "basic_3"
endif
if mousex() > 480 and mousex() < 640 and mousey() > 20 and mousey() < 40
float$ = "basic_4"
endif
endcase
case "calculator"
if mousex() > 0 and mousex() < 160 and mousey() > 40 and mousey() < 60
float$ = "calc_1"
endif
if mousex() > 160 and mousex() < 320 and mousey() > 40 and mousey() < 60
float$ = "calc_2"
endif
if mousex() > 320 and mousex() < 480 and mousey() > 40 and mousey() < 60
float$ = "calc_3"
endif
if mousex() > 480 and mousex() < 640 and mousey() > 40 and mousey() < 60
float$ = "calc_4"
endif
endcase
case "questions"
if mousex() > 0 and mousex() < 320 and mousey() > 40 and mousey() < 60
float$ = "quest_1"
endif
if mousex() > 320 and mousex() < 640 and mousey() > 40 and mousey() < 60
float$ = "quest_2"
endif
endcase
case "fun"
if mousex() > 0 and mousex() < 160 and mousey() > 20 and mousey() < 40
float$ = "fun_1"
endif
if mousex() > 160 and mousex() < 320 and mousey() > 20 and mousey() < 40
float$ = "fun_2"
endif
if mousex() > 320 and mousex() < 480 and mousey() > 20 and mousey() < 40
float$ = "fun_3"
endif
endcase
endselect
draw_float:
`Draw Floats
select float$
case "main_1"
cls
paste image 51,0,0
endcase
case "main_2"
cls
paste image 52,0,0
endcase
case "main_3"
cls
paste image 53,0,0
endcase
case "main_4"
cls
paste image 54,0,0
endcase
case "basic_1"
cls
paste image 61,0,0
endcase
case "basic_2"
cls
paste image 62,0,0
endcase
case "basic_3"
cls
cls
paste image 63,0,0
endcase
case "basic_4"
cls
paste image 64,0,0
endcase
case "calc_1"
cls
paste image 71,0,0
endcase
case "calc_2"
cls
paste image 72,0,0
endcase
case "calc_3"
cls
paste image 73,0,0
endcase
case "calc_4"
cls
paste image 74,0,0
endcase
case "quest_1"
cls
paste image 81,0,0
endcase
case "quest_2"
cls
paste image 82,0,0
endcase
case "fun_1"
cls
paste image 91,0,0
endcase
case "fun_2"
cls
paste image 92,0,0
endcase
case "fun_3"
cls
paste image 93,0,0
endcase
endselect
show_menu:
`Shows the correct menu
select menu$
case "main_menu"
paste image 5,0,0
endcase
case "basic_functions"
paste image 6,0,0
endcase
case "calculator"
paste image 7,0,0
endcase
case "questions"
paste image 8,0,0
endcase
case "fun"
paste image 9,0,0
endcase
endselect
return
show_barc:
`Shows the avvy
select state$
case "normal"
paste image 1,0,50
endcase
case "happy"
paste image 2,0,50
endcase
case "sad"
paste image 3,0,50
endcase
case "thinking"
paste image 4,0,50
endcase
endselect
return
check_input:
`Checks user input
if mousex() > 0 and mousex() < 160 and mousey() > 0 and mousey() <20
state$ = "normal"
menu$ = "basic_functions"
endif
if mousex() > 160 and mousex() < 320 and mousey() > 0 and mousey() < 20
menu$ = "fun"
state$ = "happy"
endif
if mousex() > 320 and mousex() < 480 and mousey() > 0 and mousey() < 20
state$ = "thinking"
gosub help_menu
endif
if mousex() > 480 and mousex() < 640 and mousey() > 0 and mousey() < 20
paste image 3,0,50
wait key
end
endif
if menu$ = "basic_functions"
if mousex() > 0 and mousex() < 160 and mousey() > 20 and mousey() < 40
menu$ = "calculator"
endif
endif
if menu$ = "calculator"
if mousex() > 0 and mousex() < 160 and mousey() > 40 and mousey() < 60
gosub times
endif
endif
if menu$ = "calculator"
if mousex() > 160 and mousex() < 320 and mousey() > 40 and mousey() < 60
gosub divide
endif
endif
if menu$ = "calculator"
if mousex() > 320 and mousex() < 480 and mousey() > 40 and mousey() < 60
gosub add
endif
endif
if menu$ = "calculator"
if mousex() > 480 and mousex() < 640 and mousey() > 40 and mousey() < 60
gosub minus
endif
endif
if menu$ = "basic_functions"
if mousex() > 160 and mousex() < 320 and mousey() > 20 and mousey() < 40
state$ = "thinking"
menu$ = "questions"
endif
endif
if menu$ = "questions"
if mousex() > 0 and mousex() < 320 and mousey() > 40 and mousey() < 60
gosub about_barc
endif
endif
if menu$ = "questions"
if mousex() > 320 and mousex() < 640 and mousey() > 40 and mousey() < 60
gosub about_user
endif
endif
if menu$ = "basic_functions"
if mousex() > 320 and mousex() < 480 and mousey() > 20 and mousey() < 40
gosub history
endif
endif
if menu$ = "basic_functions"
if mousex() > 480 and mousex() < 640 and mousey() > 20 and mousey() < 40
gosub credits
endif
endif
if menu$ = "fun"
if mousex() > 0 and mousex() < 160 and mousey() > 20 and mousey() < 40
gosub guess_game
endif
endif
if menu$ = "fun"
if mousex() > 160 and mousex() < 320 and mousey() > 20 and mousey() < 40
gosub paint
endif
endif
if menu$ = "fun"
if mousex() > 320 and mousex() < 480 and mousey() > 20 and mousey() < 40
gosub write_barc
endif
endif
if mousex() > 479 and mousex() < 640 and mousey() > 460 and mousey() < 480
gosub options
endif
return
options:
`options menu
cls
set cursor 5, 5
print "Resolution : 640 x 480"
set cursor 5, 25
print "Press any key to return"
wait key
cls
return
paint:
cls
text 480, 20, "Red"
text 480, 80, "White"
text 480, 140, "Eraser (black)"
color = rgb(255,255,255)
do
if mouseclick() = 1
if mousex() < 460
ink color,0
circle mousex(),mousey(),3
else
if mousey() < 35 and mousey() > 20
posy = 20
else
if mousey() < 95 and mousey() > 80
posy = 80
else
if mousey() < 155 and mousey() > 140
posy = 140
endif
endif
endif
endif
endif
if posy = 20
color = rgb(255,0,0)
endif
if posy = 80
color = rgb(255,255,255)
endif
if posy = 140
color = 0
endif
loop
return
help_menu:
cls
Print "BARC is a simple AI system that requires answers"
Print "to questions it poses in order to continue on to"
Print "other options, menus, and activities found within"
Print "it. Press any key to see a list of commands used "
Print "to navigate through BARC:"
Print
print
wait key
Print "Left Click buttons to open other menus"
Print
Print "Right Click to go back to the previous menu"
Print
Print "When asked a question, type your answer with"
Print "The keyboard; your answer will show up on screen"
Print "next to the question"
Print
Print "The system will not exit until you press a key"
Print "after clicking exit"
Print "That's all you need to know to use BARC! Have fun!"
Print
Print "Press any key to go back to the main menu..."
wait key
cls
return
write_barc:
cls
print "So, you would like to compose a letter to send to me, eh?"
print "I'm sure I will greatly enjoy it when I can read it tomorrow (and only tomorrow)"
print
print "Press any key to continue..."
wait key
date$=get date$()
temp$=""
for n=1 to len(date$)
if mid$(date$,n)="/"
temp$=temp$+"-"
else
temp$=temp$+mid$(date$,n)
endif
next n
date$ = temp$
open to write 1, date$+"_letter.txt"
input "What is the title of your letter?", title$
write string 1, title$
input "Who is the sender?", sender$
write string 1, sender$
input "What is the body text?", text$
write string 1, text$
input "What is the signature?", sig$
write string 1, sig$
print "Press any key to continue..."
wait key
print
print "Sending..."
wait 2000
close file 1
print "Sent!"
print
print "Now remember that this can only be opened TOMORROW"
print "Press any key to return to the menu..."
wait key
cls
return
credits:
cls
center text 320, 5, "CREDITS"
center text 320, 30, "Bill Derouin: Main Coding, Misc. Graphics"
center text 320, 50, "Gray Alston: Coding, Main Graphics"
center text 320, 70, "Special thanks to all on the DarkBASIC forum for their great advice!"
Center text 320, 130, "Press any key to go back to the main menu..."
wait key
cls
return
history:
cls
Print "I began as a simple idea in the minds of Gray Alston"
Print "and Bill Derouin. It all started when their teacher gave"
Print "them an assignment for the SMATH expo, which is a science"
Print "fair. They decided to do their project under the Computer"
Print "category. They had recently purchased a programming system"
Print "called DarkBASIC, and wanted to do their project by using"
Print "DarkBASIC so they could get to know the system and do a"
Print "Project that nobody else was doing. They worked on me for"
Print "almost 4 months. Finally, at the beginning of February,"
Print "2009, I was complete. And that pretty much sums up how"
Print "I came into existence."
Print
Print "Press any key to go back to the main menu..."
wait key
cls
return
about_user:
cls
print "So, I take it that you would like me to know more about you, yes?"
print "In this section, you will be able to give me information about you,"
print "and I will remember it."
print
print "Press any key to continue..."
wait key
print
if file exist("about_user.txt")
delete file "about_user.txt"
endif
open to write 1, "about_user.txt"
input "What is your name?", name$
write string 1, name$
input "What is your favorite color?", color$
write string 1, color$
input "What is your favorite food?", food$
write string 1, food$
input "Where are you from?", from$
write string 1, from$
input "Where do you live now?", live$
write string 1, live$
print
print "Thanks for that info!"
print
print "Press any key to return to the main menu..."
wait key
close file 1
cls
return
About_BARC:
cls
Print "My name is Beginner's Automated Response Compiler, or"
Print "BARC. I am a simple AI, or Artificial Intelligence. I"
Print "take responses that my users give me, analyze them, and"
Print "create an answer for them. I was created in a programming"
Print "system called DarkBASIC, which allows people to create AI's"
Print "like me! As you navigate throughout my multiple menus, keep"
Print "in mind that I was written by beginners, and that there"
Print "are many more AI's out there that are vastly more complex"
Print "and advanced than me. So, have fun!"
Print
Print "Press any key to return to the main menu..."
wait key
cls
return
times:
cls
input "First number to multiply? (_ x ...) ", firstnum#
input "Second number to multiply? (";firstnum#;" x _) ", secondnum#
print firstnum#;" x ";secondnum#;" = ";firstnum#*secondnum#
print "Press any key to return to the main menu..."
menu$ = "main_menu"
wait key
cls
return
divide:
cls
input "First number to divide? (_ ÷ ...) ",firstnum#
input "Second number to divide? (";firstnum#;" ÷ _)",secondnum#
print firstnum#;" ÷ ";secondnum#;" = ";firstnum#/secondnum#
print "Press any key to return to the main menu..."
menu$ = "main_menu"
wait key
cls
return
add:
cls
input "First number to add? (_ + ...) ",firstnum#
input "Second number to add? (";firstnum#;" + _)",secondnum#
print firstnum#;" + ";secondnum#;" = ";firstnum#+secondnum#
print "Press any key to return to the main menu..."
menu$ = "main_menu"
wait key
cls
return
minus:
cls
input "First number to subtract? (_ - ...) ",firstnum#
input "Second number to subtract? (";firstnum#;" - _)",secondnum#
print firstnum#;" - ";secondnum#;" = ";firstnum#-secondnum#
print "Press any key to return to the main menu..."
menu$ = "main_menu"
wait key
cls
return
guess_game:
randomize timer()
cls
guess = 0
print "I am going to pick a random number between 1 and 1000."
print "You will have to guess it, and i will count your turns!"
num = rnd(1000)
twelves = 0
repeat
inc guess
input "Guess? ", guessnum
if guessnum > num
print "Go lower"
endif
if guessnum < num
print "Go higher"
endif
if guess > 12
cls
inc twelves
guess = 1
endif
until guessnum = num
twelves = twelves*12
guess = guess+twelves
print "Good job!"
print "You got it in ";guess;" turns."
print "Press any key to return to the main menu..."
wait key
cls
return
~QJ