TGC Codebase Backup



a simple menu by Anonymous Coder

18th Nov 2005 11:02
Summary

a simple menu using sprites and images. non royalty, but would like an email with any upgrades you make.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    remstart
This program will make a simple menu using sprites.
please feel free to inprove it, but i would like a copy of the scorce code.
here you go....
remend

rem the background here
disable escapekey
backdrop on
color backdrop rgb(0, 0, 0)
load image "black.bmp", 1
load object "H-SWAT-Idle.x", 14
position object 14, 0, -1, 0
load image "swat.dds", 15
rem replace box with your button
box 0,0,50,50
box 0,0,50,50
box 0,0,50,50

_main_menu:
gosub _sprite_control
rem this makes the box into image
load image "button 1.bmp",2
load image "button 2.bmp",3
load image "button 3.bmp",4
cls
rem makes image into sprite
sprite 2,100,100,2
sprite 3,100,200,3
sprite 4,100,300,4
rem main loop
show sprite 2; show sprite 3; show sprite 4

wait 100
do
rem chechks collision on top button and the "none selected" msg$ message
  sprite 1,mousex(),mousey(),1
  if sprite hit(1,2) then msg$ = "New Game" else msg$ = " "
if msg$ = "New Game" and mouseclick()=1 then gosub _new_game

rem collision and message for the middle box

 if sprite hit(1,3) then msg$ = "Load Game"
if msg$ = "Load Game" and mouseclick()=1 then gosub _load_game

rem collision and message for the lower box

if sprite hit(1,4) then msg$ = "Exit"
if msg$ = "Exit" and mouseclick()=1 then gosub _exit_game

rem prints out what you have selected and/not clicked on

  text 0,0,msg$

  rem loops (you need this)

loop

_load_game:
wait 100
gosub _sprite_control

box 0,0,50,50
box 0,0,50,50
box 0,0,50,50
rem this makes the box into image
load image "button 4.bmp", 5
load image "button 5.bmp", 6
load image "button 6.bmp", 7
cls
rem makes image into sprite
sprite 5,100,100,5
sprite 6,100,200,6
sprite 7,100,300,7
show sprite 5; show sprite 6; show sprite 7
rem main loop
do
rem chechks collision on top button and the "none selected" msg$ message
  sprite 1,mousex(),mousey(),1
  if sprite hit(1,5) then msg$ = "Save1" else msg$ = " "
if msg$ = "Save1" and mouseclick()=1 then text 10,10,"clicked on menu 1"

rem collision and message for the middle box

 if sprite hit(1,6) then msg$ = "Save2"
if msg$ = "Save2" and mouseclick()=1 then text 10,10,"clicked on menu 2"

rem collision and message for the lower box

if sprite hit(1,7) then msg$ = "Back"
if msg$ = "Back" and mouseclick()=1 then goto _main_menu

rem prints out what you have selected and/not clicked on

  text 0,0,msg$

rem loops (you need this)

loop

_new_game:
wait 100
gosub _sprite_control

box 0,0,50,50
box 0,0,50,50
rem this makes the box into image
load image "button 7.bmp", 8
load image "button 8.bmp", 9
cls
rem makes image into sprite
sprite 8,100,100,8
sprite 9,100,200,9
show sprite 8; show sprite 9
rem main loop
do
rem chechks collision on top button and the "none selected" msg$ message
  sprite 1,mousex(),mousey(),1
  if sprite hit(1,8) then msg$ = "Yes" else msg$ = " "
if msg$ = "Yes" and mouseclick()=1 then gosub _main_menu

rem collision and message for the lower box

if sprite hit(1,9) then msg$ = "No"
if msg$ = "No" and mouseclick()=1 then goto _main_menu

rem prints out what you have selected and/not clicked on

  text 0,0,msg$

  rem loops (you need this)

loop

_exit_game:
wait 100
gosub _sprite_control

box 0,0,50,50
box 0,0,50,50
rem this makes the box into image
load image "button 7.bmp", 10
load image "button 8.bmp", 11
cls
rem makes image into sprite
sprite 10,100,100,10
sprite 11,100,200,11
show sprite 10; show sprite 11
rem main loop
do
rem chechks collision on top button and the "none selected" msg$ message
  sprite 1,mousex(),mousey(),1
  if sprite hit(1,10) then msg$ = "Yes" else msg$ = "Exit?"
if msg$ = "Yes" and mouseclick()=1 then exit prompt "Thanks for trying my menu program", "From Alexander Mathieson" ;end

rem collision and message for the lower box

if sprite hit(1,11) then msg$ = "No"
if msg$ = "No" and mouseclick()=1 then goto _main_menu

rem prints out what you have selected and/not clicked on

  text 0,0,msg$

  rem loops (you need this)

loop

_sprite_control:

if sprite exist (1) then delete sprite 1
if sprite exist (2) then delete sprite 2
if sprite exist (3) then delete sprite 3
if sprite exist (4) then delete sprite 4
if sprite exist (5) then delete sprite 5
if sprite exist (6) then delete sprite 6
if sprite exist (7) then delete sprite 7
if sprite exist (8) then delete sprite 8
if sprite exist (9) then delete sprite 9
if sprite exist (10) then delete sprite 10
if sprite exist (11) then delete sprite 11
return