QB / QB64 Discussion Forum     RULES     Other Subforums, Links and Downloads    Index of Threads

 

 Return to Index  

TIME-MAN (time management game program)

December 17 2007 at 4:55 AM
Paraglider1  (Login Paraglider1)


Response to Paraglider1

 
SCREEN 12
CLS
GOSUB speed
spd = s * 50
RANDOMIZE TIMER
GOSUB intro
GOSUB workplace

FOR gamelength = 1 TO 3000
GOSUB player
IF y < 5 OR y > 389 THEN GOSUB unlatch
IF x < 1 OR x > 509 THEN GOSUB unlatch
GOSUB circ1: GOSUB circ2: GOSUB circ3: GOSUB circ4: GOSUB circ5
CIRCLE (x, y), 5, 14: CIRCLE (x, y), 7, 14: REM draws player
FOR pace = 1 TO spd: NEXT: REM controls speed of play
GOSUB waste
GOSUB prscore
NEXT

GOSUB analysis
SYSTEM

REM workplace sub draws the playing area

workplace:
GOSUB time
LINE (50, 20)-(600, 450), 4, BF
VIEW (70, 40)-(580, 430), 1, 12
GOSUB time
LOCATE 28, 10: PRINT "trivial"
LOCATE 28, 29: PRINT "useful"
LOCATE 28, 48: PRINT "important"
LOCATE 28, 68: PRINT "vital"
GOSUB time: GOSUB home
CIRCLE (x, y), 5, 14: CIRCLE (x, y), 7, 14
GOSUB time: RETURN

REM circ subs draw circles (jobs) and check player's position
REM second last line in each circ sub accounts for different behaviour

circ1:
CIRCLE (x1, y1), rad1, 1
IF y1 < 1 THEN GOSUB lose1
z = (x - x1) * (x - x1) + (y - y1) * (y - y1) - 300
a = a2 + a3 + a4 + a5
IF a1 = 1 OR z < rad1 * rad1 AND a = 0 THEN GOSUB latch1
y1 = y1 - 1
IF a1 = 1 AND rad1 < .1 THEN GOSUB bonus: GOSUB make1
IF a1 = 1 THEN y1 = y1 + 1
CIRCLE (x1, y1), rad1, 15
RETURN

circ2:
CIRCLE (x2, y2), rad2, 1
IF y2 < 1 THEN GOSUB lose2
z = (x - x2) * (x - x2) + (y - y2) * (y - y2) - 300
a = a1 + a3 + a4 + a5
IF a2 = 1 OR z < rad2 * rad2 AND a = 0 THEN GOSUB latch2
y2 = y2 - 1
IF a2 = 1 AND rad2 < .1 THEN GOSUB bonus: GOSUB make2
IF x2 > 15 AND a2 = 1 THEN x2 = x2 - 1
CIRCLE (x2, y2), rad2, 15
RETURN

circ3:
CIRCLE (x3, y3), rad3, 1
IF y3 < 1 THEN GOSUB lose3
z = (x - x3) * (x - x3) + (y - y3) * (y - y3) - 300
a = a1 + a2 + a4 + a5
IF a3 = 1 OR z < rad3 * rad3 AND a = 0 THEN GOSUB latch3
y3 = y3 - 1
IF a3 = 1 AND rad3 < .1 THEN GOSUB bonus: GOSUB make3
IF y3 < 250 THEN y3 = y3 - 1
CIRCLE (x3, y3), rad3, 15
RETURN

circ4:
CIRCLE (x4, y4), rad4, 1
IF y4 < 1 THEN GOSUB lose4
z = (x - x4) * (x - x4) + (y - y4) * (y - y4) - 300
a = a1 + a2 + a3 + a5
IF a4 = 1 OR z < rad4 * rad4 AND a = 0 THEN GOSUB latch4
y4 = y4 - 1
IF a4 = 1 AND rad4 < .1 THEN GOSUB bonus: GOSUB make4
IF a > 0 AND rad4 < 25 AND y4 < 300 THEN rad4 = rad4 + 1
CIRCLE (x4, y4), rad4, 15
RETURN

circ5:
CIRCLE (x5, y5), rad5, 1
IF y5 < 1 THEN GOSUB lose5
z = (x - x5) * (x - x5) + (y - y5) * (y - y5) - 300
a = a1 + a2 + a3 + a4
IF a5 = 1 OR z < rad5 * rad5 AND a = 0 THEN GOSUB latch5
y5 = y5 - 1
IF a5 = 1 AND rad5 < .1 THEN GOSUB bonus: GOSUB make5
IF a > 0 AND x5 < 490 THEN x5 = x5 + 3
CIRCLE (x5, y5), rad5, 15
RETURN

REM lose subs reduce score when unfinished job reaches crisis line

lose1: lose = lose + (x1 * rad1): SOUND 180, 1: GOSUB make1: RETURN
lose2: lose = lose + (x2 * rad2): SOUND 180, 1: GOSUB make2: RETURN
lose3: lose = lose + (x3 * rad3): SOUND 180, 1: GOSUB make3: RETURN
lose4: lose = lose + (x4 * rad4): SOUND 180, 1: GOSUB make4: RETURN
lose5: lose = lose + (x5 * rad5): SOUND 180, 1: GOSUB make5: RETURN

REM waste sub reduces score for time spent doing nothing and takes note

waste: w = 1 - a1 - a2 - a3 - a4 - a5: waste = waste + 50 * w
work = work + 1 - w: loaf = loaf + w: RETURN

REM make subs generate new circle centres. make 1 and 2 are unweighted.
REM make 3,4,5 are weighted toward lower x (less important).

make1: x1 = INT(20 + RND * 490): y1 = INT(50 + RND * 500)
rad1 = INT(5 + RND * 20): RETURN
make2: x2 = INT(20 + RND * 490): y2 = INT(50 + RND * 500)
rad2 = INT(5 + RND * 20): RETURN
make3: x3 = INT(20 + RND RND 490): y3 = INT(50 + RND * 500)
rad3 = INT(5 + RND * 20): RETURN
make4: x4 = INT(20 + RND RND 490): y4 = INT(50 + RND * 500)
rad4 = INT(5 + RND * 20): RETURN
make5: x5 = INT(20 + RND RND 490): y5 = INT(50 + RND * 500)
rad5 = INT(5 + RND * 20): RETURN

REM latch subs carry the player in the centre of the circle

latch1: GOSUB rubout: a1 = 1: x = x1: y = y1: rad1 = rad1 * .95: GOSUB win1: RETURN
latch2: GOSUB rubout: a2 = 1: x = x2: y = y2: rad2 = rad2 * .95: GOSUB win2: RETURN
latch3: GOSUB rubout: a3 = 1: x = x3: y = y3: rad3 = rad3 * .95: GOSUB win3: RETURN
latch4: GOSUB rubout: a4 = 1: x = x4: y = y4: rad4 = rad4 * .95: GOSUB win4: RETURN
latch5: GOSUB rubout: a5 = 1: x = x5: y = y5: rad5 = rad5 * .95: GOSUB win5: RETURN

REM win subs add to score when player is in a circle (working on a job)

win1: win = win + (x1 * rad1 / 10): RETURN
win2: win = win + (x2 * rad2 / 10): RETURN
win3: win = win + (x3 * rad3 / 10): RETURN
win4: win = win + (x4 * rad4 / 10): RETURN
win5: win = win + (x5 * rad5 / 10): RETURN

REM bonus sub rewards completed tasks and unlatches

bonus: bonus = bonus + 1000 + x * x / 10
SOUND 3000, 1: GOSUB unlatch: RETURN

REM unlatch sub resets latches and sends player to home

unlatch:
a = 0: a1 = 0: a2 = 0: a3 = 0: a4 = 0: a5 = 0: z = 0: dir$ = ""
GOSUB rubout: GOSUB home: RETURN

home: x = 300: y = 200: RETURN

REM player sub looks for key presses

player:
kbd$ = INKEY$
IF NOT kbd$ = "" THEN dir$ = kbd$
SELECT CASE dir$
CASE CHR$(0) + "H": GOSUB up
CASE CHR$(0) + "P": GOSUB down
CASE CHR$(0) + "K": GOSUB left
CASE CHR$(0) + "M": GOSUB right
CASE CHR$(32): GOSUB unlatch
END SELECT
RETURN

up: GOSUB rubout: y = y - 10: RETURN
down: GOSUB rubout: y = y + 10: RETURN
left: GOSUB rubout: x = x - 10: RETURN
right: GOSUB rubout: x = x + 10: RETURN

REM: rubout sub erases the player's old position

rubout: CIRCLE (x, y), 5, 1: CIRCLE (x, y), 7, 1: RETURN

REM prscore sub prints the aggregate score

prscore:
score% = INT((win + bonus - lose - waste) / 1000)
LOCATE (3), (2): PRINT score%: RETURN

REM analysis sub discusses the player's performance

analysis:
GOSUB time
CLS 2: LINE (0, 0)-(510, 390), 1, BF: GOSUB time
work% = work * 100 / (work + loaf)
loaf% = loaf * 100 / (work + loaf)
win% = INT(win / 1000): lose% = INT(lose / 1000)
waste% = INT(waste / 1000): bonus% = INT(bonus / 1000)
LINE (30, 30)-(450, 250), 2, BF
LINE (40, 40)-(440, 240), 0, BF
GOSUB time: LOCATE 7, 17
PRINT "Your final score was"; score%; "points"
LOCATE 9, 17: GOSUB time
PRINT "You scored"; win% + bonus%; "points for work done"
LOCATE 10, 17: GOSUB time
PRINT "including"; bonus%; "bonus points for completed jobs."
LOCATE 12, 17: GOSUB time
PRINT "You lost"; lose%; "points for unfinished work."
LOCATE 13, 17: GOSUB time
PRINT "and lost"; waste%; "points for time spent between jobs."
LOCATE 15, 17: GOSUB time
PRINT "You spent"; work%; "% of your time working"
LOCATE 16, 17: GOSUB time
PRINT "and"; loaf%; "% of your time between jobs."
GOSUB time: LINE (130, 265)-(490, 370), 2, BF
LINE (140, 275)-(480, 360), 0, BF
LOCATE 21, 30: GOSUB time
PRINT "A Paraglider Program"
LOCATE 22, 30: GOSUB time
PRINT "From the Paranormal Hotel"
LOCATE 23, 30: GOSUB time
PRINT "Somewhere in Dubai"
LOCATE 24, 30: GOSUB time
PRINT "paranormal-hotel.blogspot.com"
GOSUB time: GOSUB time: LINE (5, 5)-(490, 250), 1, BF
GOSUB time: GOSUB time: RETURN

REM intro sub explains the game to the player

intro:
CLS : GOSUB time
PRINT : PRINT : PRINT
PRINT "Time Matters illustrates a central idea of Time Management."
PRINT : PRINT : PRINT : GOSUB time
PRINT "It was designed by Paraglider"
PRINT "The Paranormal Hotel, Dubai"
PRINT "paranormal-hotel.blogspot.com": PRINT
GOSUB time: GOSUB time: GOSUB time: CLS : PRINT
PRINT "When we have several tasks to perform we have to take decisions."
PRINT "For each task we ask `How urgent is it?' and `How important is it?'"
PRINT : GOSUB time
PRINT "In this game tasks are represented by circles."
PRINT "The bigger the circle, the bigger the task."
PRINT : GOSUB time
PRINT "You, the player, must select which tasks to perform."
PRINT : GOSUB time
PRINT "The more important tasks appear on the right of the screen."
GOSUB time
PRINT "The less important tasks appear on the left of the screen."
PRINT : GOSUB time
PRINT "As tasks become more urgent they float upwards on the screen."
GOSUB time
PRINT "There is a crisis line at the top of the screen.": PRINT : GOSUB time
PRINT "You lose points (money?) if unfinished tasks hit the crisis line."
GOSUB time
PRINT "You gain points for all the time you spend working on a task."
GOSUB time
PRINT "If you finish a task bonus points are awarded."
GOSUB time:
PRINT "More important tasks carry more points. (They would, wouldn't they?)"
PRINT : GOSUB time
PRINT "As you work on a task you will see it getting smaller!"
PRINT : PRINT : GOSUB time
PRINT "To move around the screen you use the arrow keys."
PRINT : GOSUB time
PRINT "To escape from a task (to do something more important!) press spacebar."
GOSUB time: PRINT : GOSUB time
PRINT "Good luck!"
PRINT : GOSUB time
INPUT "Press <RETURN> to start the game > ", R$
CLS : RETURN

speed:
REM This routine measures system speed as an integer s
LOCATE 20, 15: PRINT "Program is measuring your system speed. Please wait."
StartTime = TIMER
WHILE TimePast < 2
TimePast = TIMER - StartTime
FOR n = 1 TO 1000: NEXT
s = s + 1
WEND: RETURN

time: FOR t = 1 TO 2000 * s: NEXT: RETURN

 
 Respond to this message   
 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement