Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / sticking the clock to a sprite

Author
Message
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Sep 2003 15:00
Can anyone show me how to stick the 'GET Time$()' command to a Sprite command and keep it up dated so as to show the seconds, all I get is one time and that it.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 10th Sep 2003 16:59
yes! at the start of the code do......

set text opaque

in the main loop before the sync do.......

the_time$=time$()
set current bitmap 1
text 0,0,the_time$+"**"
get image 1,0,0,textwidth,textheight
set current bitmap 0
sprite 1,xpos,ypos,1
sync

should work fine, you need to get the time every loop and write that to the bitmap you get the sprite image from so that it changes EVERY LOOP or at least every <sync rate> loops (once per second), (not tried this but will work) cheers.

Mentor.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Sep 2003 20:04
Nice to know. How do you calculate the text height and width?

Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 10th Sep 2003 20:51
are you using DB pro?
if so i'm afraid using GET IMAGE every loop is gonn make your game go real slow.
ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 10th Sep 2003 22:29
1) put the logic to update the image in a function.

2) user a timer to update the time every second, not every frame.
intSecondTimer = timer()
do
if timer() - intSecondTimer > 1000
UpdateSecondsImage()
intSecondTimer = timer()
loop

3) use the following to get text height and width:
strName$ = "ChipOne"
intTextWidth = TEXT WIDTH(strName$)
intTextHeight = TEXT HEIGHT(strName$)


cheers

-= i only do what my rice krispies tell me to do =-
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 10th Sep 2003 22:45
Stevie Vee - there are commands, text width(s$) and text height(s$)

If your mansion house needs haunting, just call Rentaghost!
ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 10th Sep 2003 22:59
hey! didn't i just say that?

hehehe

-= i only do what my rice krispies tell me to do =-
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Sep 2003 23:07
Thanks ChipOne and Spooky. That's another problem solved for me. Story line headaches are a thing of the past!

HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Sep 2003 02:06
Thanks to all of the above, and you've ask question I has not even thought of, will help a grat deal, the function ideal sounds just what i'am looking for.

cheers to all
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Sep 2003 02:10
Who nicked me E it was there I Know it was!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Sep 2003 03:21
opps put it in the wrong thread had another one going but it got spamed.

have put the above ideal togther,how every when I run it not using the function part, just put the grab sprite bit in a loop it runs but only puts up the time once. If i use the function Ideal I get lots of errors that as of yet I do not know what they are trying to tell me. any help on the code.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th Sep 2003 14:46 Edited at: 11th Sep 2003 14:48
if timer()+intsecondtimer>1000

should be

if timer()>(intsecondtimer+1000)

the code as it is tries to check if the time plus the oldtime was greater than 1000 (it will be), so it gets called every loop, then when you call updatesecondsimage you need to pass it the_time$ since the function will not see the time, like this

updatesecondsimage(the_time$)

and the function definition needs to be told it will be getting the time with

function updatesecondsimage(the_time$)

and to get the bitmap to work you replace this

load bitmap "foliage.bmp",1

with

create bitmap 1,200,20

and it should work (not tried all this though ), cheers.

Mentor.

ps: you don`t need to sync inside the function since you sync at the end of the loop anyway, that would halve the speed of the code.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 12th Sep 2003 13:14
Finshed Code is now in the Code Snippet section.

Login to post a reply

Server time is: 2024-11-25 06:43:26
Your offset time is: 2024-11-25 06:43:26