Script untuk game labirin

  1. Timer awal

import bge

def main():

cont = bge.logic.getCurrentController()

own = cont.owner

own.text = “Time %4.1f” % (30 – bge.logic.globalDict[‘timer’])

main()

  1. Timer lv 1

import bge

def main():

cont = bge.logic.getCurrentController()

own = cont.owner

own.text = “Time %4.1f” % (200 – bge.logic.globalDict[‘timer’])

main()

  1. Timer lv 2

import bge

def main():

cont = bge.logic.getCurrentController()

own = cont.owner

own.text = “Time %4.1f” % (400 – bge.logic.globalDict[‘timer’]

main()

  1. Update score

import bge

def main():

cont = bge.logic.getCurrentController()

own = cont.owner

def init():

#first time there will not be an ‘init’ property

if not ‘init’ in own:

#create property ‘init’

own[‘init’] = 1

if not ‘score’ in bge.logic.globalDict:

#create propery and set initial value

bge.logic.globalDict[‘score’] = 0

bge.logic.globalDict[‘timer’] = 0

def update():

#update he game score from global dictionary

own[‘score’] = bge.logic.globalDict[‘score’]

bge.logic.globalDict[‘timer’] += 0.0167

own[‘time’] = bge.logic.globalDict[‘timer’]

init()

update()

main()

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s