yeah, shame about the lack of entries.
It would still be good to continue the challenges and eventually add them all together into a progressive challenge course for noobs locked at the top of the forum.
anyway, here's my entry source.
Rem Project: newcomer challenge 2
Rem Created: Monday, June 20, 2011
Rem ***** Main Source File *****
sync on: sync rate 60:randomize timer()
set display mode 1024,768,32
set window on :disable escapekey
set display mode screen width(),screen height(),screen depth()
load sound "media\wave.wav",1
//====================================================================================================
// declare variables
global dim left(5)
global dim top(5)
global dim right(5)
global dim bottom(5)
global dim textx(5)
global dim texty(5)
global dim text$(5)
global dim r_g_b(5,12)
global dim visible(5)
global x#
global y#
global top
global bottom
global button
global t1
global t2
global text$
global time
top = 40
bottom = 80
//====================================================================================================
//set all button visible variables to 1
reset()
//====================================================================================================
//randomize button colors
for a = 1 to 5
for b = 1 to 12
r_g_b(a,b) = rnd(255)
next b
next a
//====================================================================================================
//setup button lables
for a = 1 to 5
text$(a) = "option " + str$(a)
next a
//====================================================================================================
//initial drawing of boxes and gathering data for collision purposes
box_dimentions()
draw_boxes()
x# = right(5)
y# = bottom(5)
//====================================================================================================
// create background image
create bitmap 1,screen width(),screen height()
get image 1,0,0,screen width(),screen height()
delete bitmap 1
set current bitmap 0
//====================================================================================================
//main loop
do
paste image 1,0,0
draw_boxes()
drawtext()
keypress()
if button = 5 then surprise()
sync
loop
//====================================================================================================
//functions
function box_dimentions()
for a = 1 to 5
left(a) = screen width()/2-80
right(a) = screen width()/2+80
top(a) = top
bottom(a) = bottom
top = top + 60
bottom = bottom + 60
next a
top = 40
bottom = 80
endfunction
function draw_boxes()
for a = 1 to 5
if visible(a) = 1
box left(a),top(a),right(a),bottom(a),rgb(r_g_b(a,1),r_g_b(a,2),r_g_b(a,3)),rgb(r_g_b(a,4),r_g_b(a,5),r_g_b(a,6)),rgb(r_g_b(a,7),r_g_b(a,8),r_g_b(a,9)),rgb(r_g_b(a,10),r_g_b(a,11),r_g_b(a,12))
endif
next a
endfunction
function drawtext()
for a = 1 to 5
if visible(a) = 1
textx(a) = left(a)+((right(a) - left(a))/2)
texty(a) = top(a)+((bottom(a) - top(a))/2)
endif
next a
for a = 1 to 5
if visible(a) = 1
center text textx(a),texty(a),text$(a)
endif
next a
endfunction
function keypress()
for a = 2 to 6
if KEYSTATE(a) = 1
button = a-1
if visible(a-1) = 1 and down = 0 then play sound 1
down = 1
endif
if keystate(a) = 0 then down = 0
next a
if mouseclick() = 1
for a = 1 to 4
if visible(a) = 1
if mousex() > left(a) and mousex() < right(a) and mousey() > top(a) and mousey() < bottom(a)
button = a
if visible(a) = 1 then play sound 1
endif
endif
next a
if mousex() > left(5) and mousex() < right(5) and mousey() > top(5) and mousey() < bottom(5)
rem button = 5
endif
endif
if mousex() > left(5) and mousex() < right(5) and mousey() > top(5) and mousey() < bottom(5)
repeat
repeat
x# = rnd(screen width())
y# = rnd(screen height())
until (x# < left(4) + 200 or x# > right(4) + 200) and y# > bottom(4) + 100
until x# > 200 and x# < screen width()-200 and y# > 200 and y# < screen height()-200
endif
if top(5) < bottom(4) and x# > right(4) and y# < bottom(4)
repeat
bottom(5) = bottom(5) + buttonspeed
top(5) = top(5) + buttonspeed
until top(5) > bottom(4)
repeat
left(5) = left(5) + buttonspeed
right(5) = right(5) + buttonspeed
until left(5) > right(4)
endif
if top(5) < bottom(4) and x# < left(4) and y# < bottom(4)
repeat
bottom(5) = bottom(5) + buttonspeed
top(5) = top(5) + buttonspeed
until top(5) > bottom(4)
repeat
left(5) = left(5) - buttonspeed
right(5) = right(5) - buttonspeed
until right(5) < left(4)
endif
buttonmove()
button$ = "button pressed was "+str$(button)
if button = 4 and mouseclick() = 0 and keystate(5) = 0 then reset()
if button = 5 then surprise()
visible(button) = 0
color backdrop rgb(0,0,0)
text 0,texty(button),button$
endfunction
//====================================================================================================
function reset()
for a = 1 to 5
visible(a) = 1
next a
box_dimentions()
x# = right(5)
y# = bottom(5)
button = 0
endfunction
function surprise()
x# = 512,
y# = 384
for a = 1 to 4
visible(a) = 0
next a
visible(5) = 1
repeat
move = left(5)
buttonmove()
move2 = left(5)
paste image 1,0,0
draw_boxes()
drawtext()
until move = move2
paste image 1,0,0
draw_boxes()
drawtext()
t1 = timer()/1000
if t1 >t2 then time = time + 1
t2 = timer()/1000
if time < 5 then text$ = "Excuse me!!!"
if time > 4 and time < 8 then text$ = "I want to have a word with you!!!"
if time > 7 and time < 11 then text$ = "Don't you think it's a little bit cheeky..."
if time > 10 and time < 14 then text$ = "...using the keyboard to select me?"
if time > 13 and time < 17 then text$ = "Does it bother you that you can't catch me?"
if time > 16 and time < 20 then text$ = "whats the big idea anyway?"
if time > 19 and time < 23 then text$ = "hey! there's a box on the screen!"
if time > 22 and time < 26 then text$ = "I'm gonna click on it!!!"
if time > 25 and time < 30 then text$ = "That mouse cursor is pointy!!!"
if time > 29 and time < 34 then text$ = "You are a mean and demented person!"
if time > 33 and time < 36 then text$ = "...and i'm taking away your mouse cursor!"
if time > 35 and time < 37 then hide mouse
if time > 36 and time < 40 then text$ = "how you like those apples!!!"
if time > 39 and time < 45 then text$ = "Now go away! the game is over!"
if time > 44 and time < 61 then text$ = ""
if time > 60 and time < 65 then text$ = "I'm in no mood to entertain you..."
if time > 64 and time < 70 then text$ = ""
if time > 75 and time < 80 then text$ = "If I give you back your mouse cursor will you go away?!!!"
if time > 79 and time < 85 then text$ = "..."
if time > 85 and time < 90 then show mouse
if time > 89 and time < 95 then text$ = "now use it and get lost!"
if time > 94 and time < 99 then text$ = "here let me help you..."
if time > 99 then end
center text left(5)+((right(5) - left(5))/2), top(5) - 20,text$
endfunction
function buttonmove()
buttonspeed = 70
if x# > right(5)
left(5) = left(5) + buttonspeed
right(5) = right(5) + buttonspeed
endif
if x# < right(5)
left(5) = left(5) - buttonspeed
right(5) = right(5) - buttonspeed
endif
if y# > bottom(5)
bottom(5) = bottom(5) + buttonspeed
top(5) = top(5) + buttonspeed
endif
if y# < bottom(5)
bottom(5) = bottom(5) - buttonspeed
top(5) = top(5) - buttonspeed
endif
endfunction
I know a lot of the functions really should have been done with subroutines, but I was just getting into playing with functions and wanted to use them.
edit: oh yeah, no subroutines allowed, that's why no subroutines. lol, its been so long since I made it, I looked at it again and wondered why I didn't sub it as there was no return data. /edit
I'd also like to say that the skills i've learned taking on these challenges have found their way into my other projects.
very handy stuff.
thanks again man
kezzla
Sometimes I like to use words out of contents