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.

DarkBASIC Professional Discussion / How can we play multiple animation (Video) in a Program?

Author
Message
Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 8th Aug 2017 05:00
I insert multiple video, play image to image, but the result was 1 video display on both object but both audio is play. Very strange.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Aug 2017 17:49 Edited at: 10th Aug 2017 18:04
Show us your code please - or a simple version of it showing the problem.

Edit: The following snippet works fine for me using two simple video files from the old Civilization 2 game.

Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 11th Aug 2017 04:06
I am making a 3D world game, which I can walk in the 3D environment yet the the video is appear on two different objects.


template=1023 : load animation "1.mpg",3
template=1024 : load animation "9.mpg",1

width = animation width(3)
height = animation height(3)
make object plain 4, width, height
xrotate object 4,180-45
play animation to image 3,1023,0,0, width, height
TEXTURE OBJECT 4,5
make object blockobj,1023,1023
set object collision off blockobj
position object blockobj,x*200,150,(10-z)*200
coly=300 : gosub _setblockcollision6
inc blockobj
return

width = animation width(1)
height = animation height(1)
make object plain 2, width, height
xrotate object 2,180-45
play animation to image 1,1023,0,0, width, height
TEXTURE OBJECT 2,5
make object blockobj,1023,1023
set object collision off blockobj
position object blockobj,x*200,150,(10-z)*200
coly=300 : gosub _setblockcollision6
inc blockobj
return
Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 11th Aug 2017 04:12
@Green Gandalf

Your coding is working, but it is in 2D plane. How about insert to 3D object? I kind of mess about with 3D object number and video number.
Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 11th Aug 2017 04:35
Sorry @Green Gandalf, after I get organize everything then the video play separately. Thank to your simply code that open my mind.

template=1023 : load animation "1.mpg",1
template=1024 : load animation "9.mpg",2


width = animation width(1)
height = animation height(1)
make object plain 3, width, height
xrotate object 3,180-45
play animation to image 1,1023,0,0, width, height
TEXTURE OBJECT 3,1
make object blockobj,1023,1023
set object collision off blockobj
position object blockobj,x*200,150,(10-z)*200
coly=300 : gosub _setblockcollision6
inc blockobj
return

width2 = animation width(2)
height2 = animation height(2)
make object plain 4, width, height
xrotate object 4,180-45
play animation to image 2,1024,0,0, width2, height2
TEXTURE OBJECT 4,2
make object blockobj,1024,1024
set object collision off blockobj
position object blockobj,x*200,150,(10-z)*200
coly=300 : gosub _setblockcollision6
inc blockobj
return
Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 11th Aug 2017 04:37
@Green Gandalf, but can we start the video after 30 seconds after we run the program?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Aug 2017 13:17
Glad you got it sorted - and thanks for letting us know.

I don't see why not. You just need to use a timer to keep track of time. The built-in function timer() will probably be sufficient for this. The main things to remember are:

1. remember that timer() reports milliseconds so you will need to wait an interval of 30000 before starting the video;

2. store the start time near the start of your program, or near the start of the relevant section of code, something like this (you'll also need to note the intended status of the video in another variable as suggested)



3. then later in a loop somewhere you'll need to check the timer function again, something like this:



You will probably have a different loop in mind, e.g. repeat/until or while/endwhile, and you can use them in the same way.

Hope this helps.
Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 17th Aug 2017 03:39
@Green Gandalf, I try on my program, but is too difficult, I havn't know the logic behind it.
How about try in this sample coding? where support I need to add the timer?

Rem Project: 3DVideo
Rem Created: 10/08/2002 07:03:30
rem Tested for: U6.0

rem Init
sync on : sync rate 30 : hide mouse

rem Switch display mode if available
if check display mode(1024,768,32)=1 then set display mode 1024,768,32

rem Set default screen
color backdrop rgb(0,32,32)
set text font "Verdana"
ink rgb(0,255,0),0
set text to bold
set text size 20

rem Load animation
load animation "media\9.mpg",1
load animation "7clicks.wmv",2

rem Direct animation to texture
play animation to image 1,1,0,0,320,240
play animation to image 2,2,0,0,680,200
stop animation 1

rem Create 3D projection
make object box 3,320,240,10
texture object 3,1
make object box 4,320,240,10
texture object 4,2

rem Setup camera
position camera 0,0,-700
rotate camera 0,0,0

rem Load sound
load sound "type.wav",1 : set sound volume 1,80 : set sound speed 1,44000
load sound "type.wav",2 : set sound volume 2,80 : set sound speed 2,44000

rem Text data
dim htext$(5)

rem Main loop
begin=1
while mouseclick()=0

rem Begin animation and narration
if begin=1
begin=0
restore
stop animation 1
loop animation 1
narstage=0 : pause=0 : text$=""
for h=1 to 5 : htext$(h)="" : next h
time=timer()
endif

rem Teletype
seconds=timer()-time
inc pause
if pause>=0
pause=0
if narstage=0
read triggersec
read leaper
narstage=1
endif
if narstage=1
if seconds>=triggersec then narstage=2
endif
if narstage=2
read nar$
if nar$="*" then end
narstage=3
nari=1
endif
if narstage=3
for r=1 to leaper
if nari<=len(nar$)
a$=mid$(nar$,nari)
text$=text$+upper$(a$)
if sound playing(1)=0 then play sound 1
if sound playing(2)=0 then play sound 2
inc nari
endif
next r
if nari>len(nar$)
for h=5 to 2 step -1
htext$(h)=htext$(h-1)
next h
htext$(1)=text$
narstage=0
text$=""
endif
endif
endif
basey=screen height()-40
for h=1 to 5
text 32,basey-(h*16),htext$(h)
next h
text 32,basey,text$

rem Update screen
sync

rem End loop
endwhile

rem Narration:
data 1500,1,"Let me show you how to create your very own"
data 1500,1,"computer program in seven clicks."
data 8500,2,"This is nothing original as we have done this"
data 8500,1,"type of software before."
data 12250,1,"What is original is that I can do this in seven"
data 12250,1,"clicks and it's a programming language!"
data 18750,2,"And by the way clicks to do include keyboard"
data 20000,1,"presses - subclause 1(one)."
data 25000,2,"First thing we do is load the software."
data 30500,2,"That was two clicks."
data 32750,1,"The third click is here and the forth click"
data 32750,2,"is here."
data 38000,1,"Now we type out a name."
data 43000,1,"The fifth click is here."
data 47500,1,"The sixth click is there, where we type out"
data 47500,1,"a very simple program."
data 55000,1,"And the seventh and final click is the click"
data 55000,1,"to compile and run the program."
data 61000,1,"Click!"
data 64000,1,"And there you go."
data 65000,2,"Hello world, two lines of code."
data 67500,1,"Very simple."
data 68500,1,"And all done in just seven clicks!"
data 71500,1,""
data 71500,1,"*"

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Aug 2017 16:45
You need to decide where you want the delay to occur and also whether anything else is supposed to be happening during the delay because the two cases would be handled differently.

Your code is hard to read at the moment, i.e. I cannot see, at a glance, where each loop starts and ends. Same with if/endif blocks, etc. Use indentation to make the logic clear - and post your code inside a code block, for example, copy your code from your program to the clipboard, then go to your draft post and do the following:

1. place the cursor at the point in your post where you want the code box to appear
2. click the Code button and choose the Misc Code option to insert a code tag in your message
3. paste the copied code after the code tag
4. finally hit the Code button again to close the box.

You can edit the code in the code box before you finally post it if you like (useful for improving layout or adding extra comments). You can always try posting a simple short snippet first and then edit the post afterwards once you know how it works.

The useful thing about the Code box is that it preserves your layout, for example, extra spaces at the start of a line are kept.
Dispenser Ting
7
Years of Service
User Offline
Joined: 18th May 2016
Location:
Posted: 21st Aug 2017 06:43

Login to post a reply

Server time is: 2024-03-29 10:59:45
Your offset time is: 2024-03-29 10:59:45