15 lines of SIMPLE code - you can help! :) VERY VERY simple TimeBomb

Hi,

I cant work out why the cube isn’t changing colour as the time ticks down. :frowning:
Why isn’t it updating in ‘real’ time? If I Esc & rePlay it updates the colour.

I have tried searching the web for answers.

Any help is MUCHO MUCHO appreciated! :smiley:

Attachments

timebomb2.blend (443 KB)

of course …try this


import time
import bge


logicblocks=bge.logic.getCurrentController()
boxy=logicblocks.owner
print("what substract ? ->" , time.clock())
x=time.clock()
x=int(x)
y=10-x
print(y)


boxy.color=(x/10,0,0,0)


if y<0:
    boxy.endObject()


also , you have to enable the option [object color] [V] in the panel of the material (to change color)


import time
import bge


logicblocks=bge.logic.getCurrentController()
boxy=logicblocks.owner
if not "timer" in boxy:
    boxy["timer"] = time.clock() + 1.0
    
x =  boxy["timer"]-time.clock()




boxy.color=(x+x,x,x,x)


if x<0:
    boxy.endObject()
    
    
    

that is cool, but check this out :slight_smile:
with this you can do that… with no python :slight_smile: and anything else ever :slight_smile:

Attachments


CodeItAll.blend (522 KB)