TGC Codebase Backup



Pause example by Anonymous Coder

9th Jan 2008 17:39
Summary

A program that will show how to make a pausing thing...it pauses.



Description

A thing that shows you how to make an effective pause function for a program/game.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    
`Dark Basic
`Pause Game
`By @dam





`THIS SETS UP THE EXAMPLE


`variables
rotx#=0
roty#=0
rotz#=0
posy#=0
direction#=1

`make objects
make object cube 1, 1

`make camera
make camera 1

`make light
make light 1
do
    position light 1, 3, 0, 4
    position camera 1, 0, 0, 5
    rotx#=rotx#+1
    roty#=roty#+0
    rotz#=rotz#+2
    if posy#>20
        direction# = 0
        posy#=posy#-.1
    endif
    if posy#<-20
        direction# = 1
        posy#=posy#+.1
    endif
    if direction# = 1 then posy#=posy#+.5
    if direction# = 0 then posy#=posy#-.5
    position object 1, 0, posy#, 0
    rotate object 1, rotx#, roty#, rotz#
    point camera 1, 0, posy#, 0
    
    
`IF THE ENTER KEY IS PRESSED THEN SKIP TO PAUSE
    if returnkey()=1 then goto _pause
    
    
`PLACE WHERE YOU GO AFTER UNPAUSED
    _unpause:
    sync
loop





`THIS IS WHERE IT PAUSES!


_pause:
`WAIT UNTIL THE USER LETS GO OF THE ENTER KEY
do
    cls
    print "Game Is Paused"
    if returnkey()=0 then exit
loop
`GAME IS PAUSED

`TO UNPAUSE YOU MUST PRESS THE ENTER KEY AGAIN
do
    cls
    print "Game Is Paused"
    if returnkey()=1 then exit
loop

do
    if returnkey()=0 then goto _unpause
loop